ctl_loops_mixed.c (674B)
1 /* A mix of loop forms in one function: a while accumulator feeding a do/while 2 * that drains it, with an if guard between them. Exercises multiple distinct 3 * branch labels and back-edges in a single body so label allocation and the 4 * round-trip of several branches is checked together. volatile bounds keep all 5 * branches real. Net result computed to 42. Exit code 42. */ 6 int test_main(void) { 7 volatile int up = 10, down = 3; 8 int acc = 0; 9 int i = 0; 10 while (i < up) { /* 0+1+..+9 = 45 */ 11 acc += i; 12 i++; 13 } 14 if (acc > 40) { 15 int j = 0; 16 do { /* subtract 3 once: 45 - 3 = 42 */ 17 acc -= down; 18 j++; 19 } while (j < 1); 20 } 21 return acc; 22 }