#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int x = 1;
top:
  switch (x) {
  case 0:
    x = 2;
    goto top;
  case 1:
    x = 0;
    goto top;
  case 2:
    x = -1;
    goto top;
  default:
    break;
  }
  printf("x=%d\n", x);
  for (x = 0;; x++)
    if (x == 10)
      goto exit;
exit:
  printf("x=%d\n", x);
  for (x = 0;;) {
    switch (x) {
    case 0:
      x++;
      continue;
    case 1:
      x++;
      continue;
    case 2:
      break;
    }
    break;
  }
  printf("x=%d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     115b <main+0x4b>
jmp    1139 <main+0x29>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     1167 <main+0x57>
jmp    114a <main+0x3a>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1173 <main+0x63>
jmp    117f <main+0x6f>
movl   $0x2,-0x8(%rbp)
jmp    1126 <main+0x16>
movl   $0x0,-0x8(%rbp)
jmp    1126 <main+0x16>
movl   $0xffffffff,-0x8(%rbp)
jmp    1126 <main+0x16>
jmp    1184 <main+0x74>
mov    -0x8(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11a9 <main+0x99>
jmp    11bc <main+0xac>
jmp    11ae <main+0x9e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119a <main+0x8a>
mov    -0x8(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1207 <main+0xf7>
jmp    11e5 <main+0xd5>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1215 <main+0x105>
jmp    11f6 <main+0xe6>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1223 <main+0x113>
jmp    1228 <main+0x118>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <main+0xc2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d2 <main+0xc2>
jmp    1228 <main+0x118>
jmp    122d <main+0x11d>
mov    -0x8(%rbp),%esi
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%esi
mov    $0x1,%eax
test   %esi,%esi
je     1140 <main+0x30>
cmp    $0x1,%esi
jne    1157 <main+0x47>
mov    $0x2,%eax
jmp    1140 <main+0x30>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"x=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %3
3: ; preds = %7, %6, %5, %0
%4 = load i32, i32* %2
switch i32 %4, label %8 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
]
5: ; preds = %3
store i32 2, i32* %2
br label %3
6: ; preds = %3
store i32 0, i32* %2
br label %3
7: ; preds = %3
store i32 -1, i32* %2
br label %3
8: ; preds = %3
br label %9
9: ; preds = %8
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %2
br label %12
12: ; preds = %17, %9
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %12
br label %20
16: ; preds = %12
br label %17
17: ; preds = %16
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %12
20: ; preds = %15
%21 = load i32, i32* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 0, i32* %2
br label %23
23: ; preds = %28, %25, %20
%24 = load i32, i32* %2
switch i32 %24, label %32 [
i32 0, label %25
i32 1, label %28
i32 2, label %31
]
25: ; preds = %23
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %23
28: ; preds = %23
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %23
31: ; preds = %23
br label %32
32: ; preds = %23, %31
br label %33
33: ; preds = %32
%34 = load i32, i32* %2
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"x=%d\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 -1)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 10)
br label %3
3: ; preds = %6, %0
%4 = phi i32 [ 0, %0 ], [ %7, %6 ]
switch i32 %4, label %8 [
i32 0, label %6
i32 1, label %5
]
5: ; preds = %3
br label %6
6: ; preds = %5, %3
%7 = phi i32 [ 2, %5 ], [ 1, %3 ]
br label %3
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
ret i32 0
}