#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 getRandomNum(int);
int /*<<< orphan*/ printf(char *);
void correctAnswer() {
  int response = getRandomNum(12);
  switch (response) {
  case 1:
  case 2:
  case 3:
    printf("Very good!\n");
    break;
  case 4:
  case 5:
  case 6:
    printf("Excellent!\n");
    break;
  case 7:
  case 8:
  case 9:
    printf("Nice Work!\n");
    break;
  case 10:
  case 11:
  case 12:
    printf("Keep up the good work!\n");
    break;
  default:
    printf("Congrats!\n");
  }
}


x86 assembly (clang, -O0):
<correctAnswer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xc,%edi
call   1030 <getRandomNum@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xb,%eax
ja     11a2 <correctAnswer+0x82>
mov    -0x10(%rbp),%rax
lea    0xeab(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <correctAnswer+0x8e>
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <correctAnswer+0x8e>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <correctAnswer+0x8e>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <correctAnswer+0x8e>
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<correctAnswer>:
push   %rax
mov    $0xc,%edi
call   1040 <getRandomNum@plt>
add    $0xffffffff,%eax
cmp    $0xb,%eax
ja     1149 <correctAnswer+0x29>
cltq
lea    0xf08(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xee8(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Very good!\0A\00"
@.str.1 = [12 x i8] c"Excellent!\0A\00"
@.str.2 = [12 x i8] c"Nice Work!\0A\00"
@.str.3 = [24 x i8] c"Keep up the good work!\0A\00"
@.str.4 = [11 x i8] c"Congrats!\0A\00"
define void @correctAnswer() {
%1 = alloca i32
%2 = call i32 @getRandomNum(i32 12)
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %12 [
i32 1, label %4
i32 2, label %4
i32 3, label %4
i32 4, label %6
i32 5, label %6
i32 6, label %6
i32 7, label %8
i32 8, label %8
i32 9, label %8
i32 10, label %10
i32 11, label %10
i32 12, label %10
]
4: ; preds = %0, %0, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %14
6: ; preds = %0, %0, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %14
8: ; preds = %0, %0, %0
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %14
10: ; preds = %0, %0, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@str = [23 x i8] c"Keep up the good work!\00"
@str.5 = [11 x i8] c"Nice Work!\00"
@str.6 = [11 x i8] c"Excellent!\00"
@str.7 = [11 x i8] c"Very good!\00"
@str.8 = [10 x i8] c"Congrats!\00"
@reltable.correctAnswer = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str to i64), i64 ptrtoint ([12 x i32]* @reltable.correctAnswer to i64)) to i32)]
define void @correctAnswer() {
%1 = tail call i32 @getRandomNum(i32 12)
%2 = add i32 %1, -1
%3 = icmp ult i32 %2, 12
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.correctAnswer to i8*), i64 %6)
br label %8
8: ; preds = %0, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0), %0 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret void
}