aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/06-goto.c
blob: a0f2457d5a82d5d0ca95d01c6b9c9f9504c17798 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* EXPECT:
7 -> 14
-3 -> 0
0 -> 0
2 -> 4
*/
int crz(int x) {
/* x <<= 1; while (x < 0) ++x; return x; */
  goto e;
a:
  return x;
j:
  ++x;
  goto q;
b:
  if (x < 0)
    goto j;
  goto a;
q:
  goto b;
e:
  x <<= 1;
  goto b;
}
void dummy() {
   for (;;) {
      ;
   }
}

int printf(const char *, ...);
int main(int n) {
   n = 7,  printf("%d -> %d\n", n, crz(n));
   n = -3, printf("%d -> %d\n", n, crz(n));
   n = 0,  printf("%d -> %d\n", n, crz(n));
   n = 2,  printf("%d -> %d\n", n, crz(n));
}