iarith_divrem_s.c (471B)
1 /* iarith: 32-bit SIGNED divide and remainder. 2 * 3 * volatile operands force a real `sdiv w` and the `msub w` that aarch64 uses 4 * to compute the remainder (rem = a - (a/b)*b). Operands chosen so neither 5 * -O0 nor -O1 can fold and no signed overflow / div-by-zero occurs. 6 * 7 * 1000 / 23 = 43 (43*23 = 989) 8 * 1000 % 23 = 11 9 * 43 - 11 + 10 = 42. */ 10 int test_main(void) { 11 volatile int a = 1000, b = 23; 12 int q = a / b; 13 int r = a % b; 14 return q - r + 10; 15 }