| 1 |
void foo(int x, int y, int z, int d, int *buf) |
| 2 |
{ |
| 3 |
for(int i = z; i < y-z; ++i) |
| 4 |
for(int j = 0; j < d; ++j) |
| 5 |
/* buf[x(i+1) + j] = buf[x(i+1)-j-1] */ |
| 6 |
buf[i*x+(x-z+j)] = buf[i*x+(x-z-1-j)]; |
| 7 |
} |
| 8 |
|
| 9 |
void bar(int x, int y, int z, int d, int *buf) |
| 10 |
{ |
| 11 |
for(int i = 0; i < d; ++i) |
| 12 |
for(int j = z; j < x-z; ++j) |
| 13 |
/* buf[j+(y+i)*x] = buf[j+(y-1-i)*x] */ |
| 14 |
buf[j+(y-z+i)*x] = buf[j+(y-z-1-i)*x]; |
| 15 |
} |
| 16 |
|
| 17 |
__attribute__((noipa)) |
| 18 |
void baz(int x, int y, int d, int *buf) |
| 19 |
{ |
| 20 |
foo(x, y, 0, d, buf); |
| 21 |
bar(x, y, 0, d, buf); |
| 22 |
} |
| 23 |
|
| 24 |
int main(void) |
| 25 |
{ |
| 26 |
int a[] = { 1, 2, 3 }; |
| 27 |
baz (1, 2, 1, a); |
| 28 |
/* foo does: |
| 29 |
buf[1] = buf[0]; |
| 30 |
buf[2] = buf[1]; |
| 31 |
|
| 32 |
bar does: |
| 33 |
buf[2] = buf[1]; (no-op) |
| 34 |
so we should have { 1, 1, 1 }. */ |
| 35 |
for (int i = 0; i < 3; i++) |
| 36 |
if (a[i] != 1) |
| 37 |
__builtin_abort (); |
| 38 |
} |