mem_array.c (519B)
1 /* mem: a small local int array summed in a counted loop. The element accesses 2 * lower to scaled-register loads (`ldr w, [base, x, lsl #2]`) or post/pre 3 * computed addresses; the loop also exercises the back-edge branch. A volatile 4 * bound defeats unrolling/folding so the loads survive. Exit: 1+2+...+8 = 36, 5 * +6 = 42. */ 6 int test_main(void) { 7 int a[8]; 8 for (int i = 0; i < 8; ++i) a[i] = i + 1; 9 volatile int n = 8; 10 int sum = 0; 11 for (int i = 0; i < n; ++i) sum += a[i]; 12 return sum + 6; /* 36 + 6 */ 13 }