| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
extern int memcmp (const void *, const void *, __SIZE_TYPE__); |
| 5 |
|
| 6 |
void *x (void *pdst, const void *psrc, unsigned int pn) |
| 7 |
{ |
| 8 |
register void *return_dst = pdst; |
| 9 |
register unsigned char *dst = pdst; |
| 10 |
register unsigned const char *src = psrc; |
| 11 |
register int n __asm__ ("ebx") = pn; |
| 12 |
|
| 13 |
if (src < dst && dst < src + n) |
| 14 |
{ |
| 15 |
src += n; |
| 16 |
dst += n; |
| 17 |
while (n--) |
| 18 |
*--dst = *--src; |
| 19 |
return return_dst; |
| 20 |
} |
| 21 |
|
| 22 |
while (n >= 16) n--; |
| 23 |
|
| 24 |
return return_dst; |
| 25 |
} |
| 26 |
extern void abort (); |
| 27 |
extern void exit (int); |
| 28 |
char xx[30] = "abc"; |
| 29 |
int main (void) |
| 30 |
{ |
| 31 |
char yy[30] = "aab"; |
| 32 |
|
| 33 |
if (x (xx + 1, xx, 2) != xx + 1 || memcmp (xx, yy, sizeof (yy)) != 0) |
| 34 |
abort (); |
| 35 |
exit (0); |
| 36 |
} |