#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 GetInput();
int /*<<< orphan*/ puts(char *);
void BasicSwitchStatement() {
  puts("1 = true");
  puts("2 = false");
  puts("3 = null");
  int condition = GetInput();
  switch (condition) {
  case 1:
    puts("True");
    break;
  case 2:
    puts("False");
    break;
  case 3:
    puts("Null");
    break;
  default:
    puts("Number not in the initial list");
    break;
  }
}


x86 assembly (clang, -O0):
<BasicSwitchStatement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <GetInput@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     118c <BasicSwitchStatement+0x6c>
jmp    116a <BasicSwitchStatement+0x4a>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     119d <BasicSwitchStatement+0x7d>
jmp    117b <BasicSwitchStatement+0x5b>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11ae <BasicSwitchStatement+0x8e>
jmp    11bf <BasicSwitchStatement+0x9f>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
jmp    11cb <BasicSwitchStatement+0xab>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
jmp    11cb <BasicSwitchStatement+0xab>
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
jmp    11cb <BasicSwitchStatement+0xab>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicSwitchStatement>:
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
lea    0xed5(%rip),%rdi
call   1040 <puts@plt>
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <GetInput@plt>
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     116a <BasicSwitchStatement+0x4a>
cltq
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1040 <puts@plt>
lea    0xebb(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"1 = true\00"
@.str.1 = [10 x i8] c"2 = false\00"
@.str.2 = [9 x i8] c"3 = null\00"
@.str.3 = [5 x i8] c"True\00"
@.str.4 = [6 x i8] c"False\00"
@.str.5 = [5 x i8] c"Null\00"
@.str.6 = [31 x i8] c"Number not in the initial list\00"
define void @BasicSwitchStatement() {
%1 = alloca i32
%2 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (...) @GetInput()
store i32 %5, i32* %1
%6 = load i32, i32* %1
switch i32 %6, label %13 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
]
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %15
9: ; preds = %0
%10 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %15
11: ; preds = %0
%12 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %9, %7
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"1 = true\00"
@.str.1 = [10 x i8] c"2 = false\00"
@.str.2 = [9 x i8] c"3 = null\00"
@.str.3 = [5 x i8] c"True\00"
@.str.4 = [6 x i8] c"False\00"
@.str.5 = [5 x i8] c"Null\00"
@.str.6 = [31 x i8] c"Number not in the initial list\00"
@reltable.BasicSwitchStatement = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.BasicSwitchStatement to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.BasicSwitchStatement to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.BasicSwitchStatement to i64)) to i32)]
define void @BasicSwitchStatement() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (...) @GetInput()
%5 = add i32 %4, -1
%6 = icmp ult i32 %5, 3
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.BasicSwitchStatement to i8*), i64 %9)
br label %11
11: ; preds = %0, %7
%12 = phi i8* [ %10, %7 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), %0 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
ret void
}