#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 *);
int main(int argc, const char *argv[]) {
  int a;
  while (1) {
    scanf("%d", &a);
    switch (a) {
    case 0:
      printf("a = 0\n");
      break;
    case 1:
      printf("a = 1\n");
      break;
    case 2:
      printf("a = 2\n");
      break;
    default:
      printf("a is not 0, 1, or 2\n");
      exit(0);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     118b <main+0x5b>
jmp    1169 <main+0x39>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     119c <main+0x6c>
jmp    117a <main+0x4a>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     11ad <main+0x7d>
jmp    11be <main+0x8e>
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <main+0xa1>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <main+0xa1>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <main+0xa1>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    1146 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xee0(%rip),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
cmp    $0x3,%rax
jae    1174 <main+0x44>
movslq (%rbx,%rax,4),%rdi
add    %rbx,%rdi
call   1030 <puts@plt>
jmp    1150 <main+0x20>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [6 x i8] c"a = 2\00"
@str.5 = [6 x i8] c"a = 1\00"
@str.6 = [6 x i8] c"a = 0\00"
@str.7 = [20 x i8] c"a is not 0, 1, or 2\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %12, %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp ult i32 %7, 3
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %5
%13 = sext i32 %7 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %14)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %5
}