#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 rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int favoriteNumber;
  int choice;
  int random1 = 0;
  int random2 = 0;
  int random3 = 0;
  int random4 = 0;
  int random5 = 0;
  srand(time(NULL));
  printf("Think of a question and enter your favorite number: \n");
  scanf("%d", &favoriteNumber);
  choice = rand() % 5;
  switch (choice) {
  case 0:
    printf("Outcome unclear.\n");
    break;
  case 1:
    printf("Absolutely certain.\n");
    break;
  case 2:
    printf("The answer is no.\n");
    break;
  case 3:
    printf("Ask again.\n");
    break;
  case 4:
    printf("Definitely not.\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x2c(%rbp),%eax
call   1070 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x4,%rax
ja     124f <main+0xff>
mov    -0x28(%rbp),%rax
lea    0xe0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0xff>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0xff>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0xff>
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0xff>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    $0x4,%eax
ja     11b8 <main+0x68>
cltq
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Think of a question and enter your favorite number: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Outcome unclear.\0A\00"
@.str.3 = [21 x i8] c"Absolutely certain.\0A\00"
@.str.4 = [19 x i8] c"The answer is no.\0A\00"
@.str.5 = [12 x i8] c"Ask again.\0A\00"
@.str.6 = [17 x i8] c"Definitely not.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 5
store i32 %14, i32* %3
%15 = load i32, i32* %3
switch i32 %15, label %26 [
i32 0, label %16
i32 1, label %18
i32 2, label %20
i32 3, label %22
i32 4, label %24
]
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %26
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %26
20: ; preds = %0
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %26
22: ; preds = %0
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %26
24: ; preds = %0
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %26
26: ; preds = %0, %24, %22, %20, %18, %16
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [53 x i8] c"Think of a question and enter your favorite number: \00"
@str.7 = [16 x i8] c"Definitely not.\00"
@str.8 = [11 x i8] c"Ask again.\00"
@str.9 = [18 x i8] c"The answer is no.\00"
@str.10 = [20 x i8] c"Absolutely certain.\00"
@str.11 = [17 x i8] c"Outcome unclear.\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.7 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 5
%9 = icmp ult i32 %8, 5
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main to i8*), i64 %12)
%14 = call i32 @puts(i8* dereferenceable(1) %13)
br label %15
15: ; preds = %0, %10
ret i32 0
}