modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/usad-run.c (about) 1 extern void abort (); 2 extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__const__)); 3 4 static int 5 foo (unsigned char *w, int i, unsigned char *x, int j) 6 { 7 int tot = 0; 8 for (int a = 0; a < 16; a++) 9 { 10 for (int b = 0; b < 16; b++) 11 tot += abs (w[b] - x[b]); 12 w += i; 13 x += j; 14 } 15 return tot; 16 } 17 18 void 19 bar (unsigned char *w, unsigned char *x, int i, int *result) 20 { 21 *result = foo (w, 16, x, i); 22 } 23 24 int 25 main (void) 26 { 27 unsigned char m[256]; 28 unsigned char n[256]; 29 int sum, i; 30 31 for (i = 0; i < 256; ++i) 32 if (i % 2 == 0) 33 { 34 m[i] = (i % 8) * 2 + 1; 35 n[i] = -(i % 8); 36 } 37 else 38 { 39 m[i] = -((i % 8) * 2 + 2); 40 n[i] = -((i % 8) >> 1); 41 } 42 43 bar (m, n, 16, &sum); 44 45 if (sum != 32384) 46 abort (); 47 48 return 0; 49 }