#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 number;
  int randomNum;
  srand(time(NULL));
  printf("Think of your question and enter\n");
  printf("your favorite number: ");
  scanf(" %d", &number);
  randomNum = rand() % 5 - 1;
  switch (randomNum) {
  case (1):
    printf("\nOutcome unclear\n");
    break;
  case (2):
    printf("\nAbsolutely certain\n");
    break;
  case (3):
    printf("\nThe answer is no\n");
    break;
  case (4):
    printf("\nAsk again\n");
    break;
  case (5):
    printf("\nDefinitely not\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
call   1070 <rand@plt>
mov    %eax,%ecx
movslq %ecx,%rax
imul   $0x66666667,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x21,%rdx
add    %eax,%edx
mov    %edx,%eax
lea    (%rax,%rax,4),%eax
not    %eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1240 <main+0xf0>
mov    -0x18(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <main+0xf0>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     11d9 <main+0x79>
cltq
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [23 x i8] c"your favorite number: \00"
@.str.2 = [4 x i8] c" %d\00"
@str = [33 x i8] c"Think of your question and enter\00"
@str.8 = [18 x i8] c"\0AThe answer is no\00"
@str.9 = [20 x i8] c"\0AAbsolutely certain\00"
@str.10 = [17 x i8] c"\0AOutcome unclear\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.10 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str.9 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @str.8 to i64), i64 ptrtoint ([3 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 ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 5
%10 = add nsw i32 %9, -2
%11 = icmp ult i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = sext i32 %10 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %14)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %0, %12
ret i32 0
}