aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/goto.c
blob: 0ecbf286911dcf6482a31725120e2cc7a5357f63 (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
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;
}

int printf(const char *, ...);
int main() {
   printf("should print 14: %d\n", crz(7));
   printf("should print 0: %d\n", crz(-3));
   printf("should print 0: %d\n", crz(0));
}