#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int code;
  printf("Enter the error code number\n");
  printf("Range 1 through 5 : ");
  scanf("%d", &code);
  switch (code) {
  case 1: {
    puts("San Andreas Fault");
    puts("Solution: Move your house.");
    break;
  }
  case 2: {
    puts("Illegal Operation");
    puts("Solution: Find another doctor.");
    break;
  }
  case 3: {
    puts("Bad Filename");
    puts("Solution: Spank the filename and put it to bed without any supper.");
    break;
  }
  case 4: {
    puts("Missing Socket");
    puts("Solution: Look in the dryer.");
    break;
  }
  case 5: {
    puts("Divide by Zero");
    puts("Solution: Mess with the numbers until it works.");
    break;
  }
  default: {
    puts("Error code value out of range");
    puts("Solution: Read the directions next time.");
  }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1221 <main+0xf1>
mov    -0x10(%rbp),%rax
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0x109>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0x109>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0x109>
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0x109>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
jmp    1239 <main+0x109>
lea    0xf3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x103c(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     118a <main+0x5a>
cltq
lea    0x1021(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
lea    0x1027(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1198 <main+0x68>
lea    0xfbe(%rip),%rbx
lea    0xf99(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter the error code number\0A\00"
@.str.1 = [21 x i8] c"Range 1 through 5 : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"San Andreas Fault\00"
@.str.4 = [27 x i8] c"Solution: Move your house.\00"
@.str.5 = [18 x i8] c"Illegal Operation\00"
@.str.6 = [31 x i8] c"Solution: Find another doctor.\00"
@.str.7 = [13 x i8] c"Bad Filename\00"
@.str.8 = [67 x i8] c"Solution: Spank the filename and put it to bed without any supper.\00"
@.str.9 = [15 x i8] c"Missing Socket\00"
@.str.10 = [29 x i8] c"Solution: Look in the dryer.\00"
@.str.11 = [15 x i8] c"Divide by Zero\00"
@.str.12 = [48 x i8] c"Solution: Mess with the numbers until it works.\00"
@.str.13 = [30 x i8] c"Error code value out of range\00"
@.str.14 = [41 x i8] c"Solution: Read the directions next time.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
switch i32 %6, label %22 [
i32 1, label %7
i32 2, label %10
i32 3, label %13
i32 4, label %16
i32 5, label %19
]
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %25
10: ; preds = %0
%11 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
br label %25
13: ; preds = %0
%14 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @puts(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.8, i64 0, i64 0))
br label %25
16: ; preds = %0
%17 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%18 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %25
19: ; preds = %0
%20 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0))
br label %25
22: ; preds = %0
%23 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%24 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0))
br label %25
25: ; preds = %22, %19, %16, %13, %10, %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"Range 1 through 5 : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"San Andreas Fault\00"
@.str.4 = [27 x i8] c"Solution: Move your house.\00"
@.str.5 = [18 x i8] c"Illegal Operation\00"
@.str.6 = [31 x i8] c"Solution: Find another doctor.\00"
@.str.7 = [13 x i8] c"Bad Filename\00"
@.str.8 = [67 x i8] c"Solution: Spank the filename and put it to bed without any supper.\00"
@.str.9 = [15 x i8] c"Missing Socket\00"
@.str.10 = [29 x i8] c"Solution: Look in the dryer.\00"
@.str.11 = [15 x i8] c"Divide by Zero\00"
@.str.12 = [48 x i8] c"Solution: Mess with the numbers until it works.\00"
@.str.13 = [30 x i8] c"Error code value out of range\00"
@.str.14 = [41 x i8] c"Solution: Read the directions next time.\00"
@str = [28 x i8] c"Enter the error code number\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.5 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.7 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32)]
@reltable.main.16 = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.main.16 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.6 to i64), i64 ptrtoint ([5 x i32]* @reltable.main.16 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([67 x i8]* @.str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.main.16 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main.16 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([48 x i8]* @.str.12 to i64), i64 ptrtoint ([5 x i32]* @reltable.main.16 to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -1
%8 = icmp ult i32 %7, 5
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main to i8*), i64 %11)
%13 = sext i32 %7 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main.16 to i8*), i64 %14)
br label %16
16: ; preds = %0, %9
%17 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), %0 ]
%18 = phi i8* [ %15, %9 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0), %0 ]
%19 = call i32 @puts(i8* dereferenceable(1) %17)
%20 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}