#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 eightball = 0;
  int shake;
  int num;
  int numshake = 1000;
  srand(time(NULL));
  while (numshake > 0) {
    printf("Think of your question and enter your favorite number?\n");
    scanf("%d", &num);
    shake = rand() % 6;
    switch (shake) {
    case 0:
      printf("Maybe when you have cancer\n");
      break;
    case 1:
      printf("Definitely not\n");
      break;
    case 2:
      printf("Absolutely certain\n");
      break;
    case 3:
      printf("Game over, you are dead\n");
      break;
    case 4:
      printf("You will die alone\n");
      break;
    case 5:
      printf("Windows had just recovered from a fatal error\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x3e8,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x0,-0x14(%rbp)
jle    1258 <main+0x108>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rcx
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x5,%rax
ja     1253 <main+0x103>
mov    -0x20(%rbp),%rax
lea    0xe17(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
jmp    1253 <main+0x103>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    117d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe96(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xf50(%rip),%rbx
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x5,%eax
ja     1180 <main+0x30>
cltq
movslq (%rbx,%rax,4),%rdi
add    %rbx,%rdi
call   1030 <puts@plt>
jmp    1180 <main+0x30>

LLVM IR (-O0):
@.str = [56 x i8] c"Think of your question and enter your favorite number?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Maybe when you have cancer\0A\00"
@.str.3 = [16 x i8] c"Definitely not\0A\00"
@.str.4 = [20 x i8] c"Absolutely certain\0A\00"
@.str.5 = [25 x i8] c"Game over, you are dead\0A\00"
@.str.6 = [20 x i8] c"You will die alone\0A\00"
@.str.7 = [47 x i8] c"Windows had just recovered from a fatal error\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1000, i32* %5
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
br label %8
8: ; preds = %29, %0
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 6
store i32 %15, i32* %3
%16 = load i32, i32* %3
switch i32 %16, label %29 [
i32 0, label %17
i32 1, label %19
i32 2, label %21
i32 3, label %23
i32 4, label %25
i32 5, label %27
]
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %29
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %29
21: ; preds = %11
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %29
23: ; preds = %11
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %29
25: ; preds = %11
%26 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %29
27: ; preds = %11
%28 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
br label %29
29: ; preds = %11, %27, %25, %23, %21, %19, %17
br label %8
30: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [55 x i8] c"Think of your question and enter your favorite number?\00"
@str.8 = [46 x i8] c"Windows had just recovered from a fatal error\00"
@str.9 = [19 x i8] c"You will die alone\00"
@str.10 = [24 x i8] c"Game over, you are dead\00"
@str.11 = [19 x i8] c"Absolutely certain\00"
@str.12 = [15 x i8] c"Definitely not\00"
@str.13 = [27 x i8] c"Maybe when you have cancer\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @str.13 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.12 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.11 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([46 x i8]* @str.8 to i64), i64 ptrtoint ([6 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)
br label %5
5: ; preds = %11, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 6
%10 = icmp ult i32 %9, 6
br i1 %10, label %12, label %11
11: ; preds = %5, %12
br label %5
12: ; preds = %5
%13 = sext i32 %9 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %14)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %11
}