#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i;
  printf("> i = ");
  scanf("%i", &i);
  switch (i) {
  case 1:
    printf("case 1 \n");
    break;
  case 2:
    printf("case 2\n");
  default:
    printf("default case \n");
    break;
  }
  printf("\n");
  if (i == 1)
    goto case1;
  if (i == 2)
    goto case2;
  goto caseDefault;
case1:
  printf("case 1 \n");
  goto end;
case2:
  printf("case 2 \n");
caseDefault:
  printf("default case \n");
  goto end;
end:;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1170 <main+0x50>
jmp    115f <main+0x3f>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1181 <main+0x61>
jmp    118d <main+0x6d>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    1199 <main+0x79>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11b4 <main+0x94>
jmp    11c8 <main+0xa8>
cmpl   $0x2,-0x8(%rbp)
jne    11c3 <main+0xa3>
jmp    11d9 <main+0xb9>
jmp    11e5 <main+0xc5>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
jmp    11f1 <main+0xd1>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xebe(%rip),%rbx
mov    0xc(%rsp),%eax
mov    %rbx,%rdi
cmp    $0x1,%eax
je     118d <main+0x4d>
cmp    $0x2,%eax
jne    1186 <main+0x46>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     11bd <main+0x7d>
cmp    $0x2,%eax
jne    11b6 <main+0x76>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe54(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"> i = \00"
@.str.1 = [3 x i8] c"%i\00"
@str = [7 x i8] c"case 2\00"
@str.8 = [14 x i8] c"default case \00"
@str.9 = [8 x i8] c"case 2 \00"
@str.11 = [8 x i8] c"case 1 \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
switch i32 %5, label %8 [
i32 1, label %9
i32 2, label %6
]
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %0, %6
br label %9
9: ; preds = %0, %8
%10 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0), %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0), %0 ]
%11 = call i32 @puts(i8* dereferenceable(1) %10)
%12 = call i32 @putchar(i32 10)
%13 = load i32, i32* %1
switch i32 %13, label %16 [
i32 1, label %17
i32 2, label %14
]
14: ; preds = %9
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
br label %16
16: ; preds = %9, %14
br label %17
17: ; preds = %9, %16
%18 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0), %16 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0), %9 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}