#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  while (1) {
    int a = 0;
    printf("Choose the number: ");
    if (!scanf("%d", &a))
      break;
    switch (a) {
    case 1:
      printf("1\n");
      break;
      break;
    case 2:
      printf("2\n");
      break;
    case 'q':
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%eax
jne    1170 <main+0x40>
jmp    11d4 <main+0xa4>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11a6 <main+0x76>
jmp    1184 <main+0x54>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11b7 <main+0x87>
jmp    1195 <main+0x65>
mov    -0xc(%rbp),%eax
sub    $0x71,%eax
je     11c8 <main+0x98>
jmp    11cf <main+0x9f>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11cf <main+0x9f>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11cf <main+0x9f>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    113f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
test   %eax,%eax
je     11e4 <main+0xa4>
lea    0xe9c(%rip),%r12
lea    0xe7c(%rip),%r14
lea    0xe89(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xe80(%rip),%r13
jmp    11c7 <main+0x87>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
test   %eax,%eax
je     11e4 <main+0xa4>
mov    0xc(%rsp),%eax
mov    %r12,%rdi
cmp    $0x1,%eax
je     11a3 <main+0x63>
cmp    $0x2,%eax
je     11a0 <main+0x60>
cmp    $0x71,%eax
jne    11a8 <main+0x68>
xor    %edi,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Choose the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [3 x i8] c"2\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %16
store i32 0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %3
br label %17
8: ; preds = %3
%9 = load i32, i32* %2
switch i32 %9, label %16 [
i32 1, label %10
i32 2, label %12
i32 113, label %14
]
10: ; preds = %8
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %16
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %16
14: ; preds = %8
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %8, %12, %10
br label %3
17: ; preds = %7
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [20 x i8] c"Choose the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [2 x i8] c"2\00"
@str.4 = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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 = icmp eq i32 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %0, %14
%7 = load i32, i32* %1
switch i32 %7, label %14 [
i32 1, label %11
i32 2, label %8
i32 113, label %9
]
8: ; preds = %6
br label %11
9: ; preds = %6
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %6, %8
%12 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %6 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %6
store i32 0, i32* %1
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %14, %0
ret i32 0
}