#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 argc, char *argv[]) {
  int max_guesses = 3;
  int current_guess = 0;
  int answer = 0;
  int user_guess = 0;
  srand(time(NULL));
  answer = ((rand() % 9) + 1);
  printf("I'm thinking of a number between 1 and 9, can you guess it?\n");
  do {
    if (user_guess != 0) {
      printf("Guess again.\n");
    }
    scanf("%d", &user_guess);
    if (user_guess == answer) {
      printf("You got it! You truly are a being to be reckoned with.\n");
      break;
    } else if (user_guess > answer) {
      printf("My number is lower than that.\n");
    } else if (user_guess < answer) {
      printf("My number is higher than that.\n");
    }
    current_guess++;
  } while (current_guess < max_guesses);
  if (user_guess != answer) {
    printf("\nLooks like I win today, human. Better luck next time!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
je     11c9 <main+0x79>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11f6 <main+0xa6>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
jmp    124a <main+0xfa>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1213 <main+0xc3>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    1230 <main+0xe0>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122b <main+0xdb>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    1230 <main+0xe0>
jmp    1235 <main+0xe5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11b3 <main+0x63>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1262 <main+0x112>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
mov    %eax,%ebx
sub    %ecx,%ebx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe53(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
lea    0xef1(%rip),%r14
cmp    %ebp,%eax
je     126e <main+0x11e>
jle    11d5 <main+0x85>
lea    0xec2(%rip),%rdi
jmp    11e0 <main+0x90>
cmp    %ebx,%eax
jg     11e5 <main+0x95>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     11f8 <main+0xa8>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe01(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
je     126e <main+0x11e>
jle    121c <main+0xcc>
lea    0xe7b(%rip),%rdi
jmp    1227 <main+0xd7>
cmp    %ebx,%eax
jg     122c <main+0xdc>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     123f <main+0xef>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xdba(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
je     126e <main+0x11e>
jle    1263 <main+0x113>
lea    0xe34(%rip),%r14
jmp    126e <main+0x11e>
cmp    %ebx,%eax
jg     1276 <main+0x126>
lea    0xe08(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
cmp    %ebp,0xc(%rsp)
je     1288 <main+0x138>
lea    0xdbc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [61 x i8] c"I'm thinking of a number between 1 and 9, can you guess it?\0A\00"
@.str.1 = [14 x i8] c"Guess again.\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [56 x i8] c"You got it! You truly are a being to be reckoned with.\0A\00"
@.str.4 = [31 x i8] c"My number is lower than that.\0A\00"
@.str.5 = [32 x i8] c"My number is higher than that.\0A\00"
@.str.6 = [56 x i8] c"\0ALooks like I win today, human. Better luck next time!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 9
%14 = add nsw i32 %13, 1
store i32 %14, i32* %8
%15 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %45, %2
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
br label %49
28: ; preds = %21
%29 = load i32, i32* %9
%30 = load i32, i32* %8
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %41
34: ; preds = %28
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40, %32
br label %42
42: ; preds = %41
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %42
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %16, label %49
49: ; preds = %45, %26
%50 = load i32, i32* %9
%51 = load i32, i32* %8
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [60 x i8] c"I'm thinking of a number between 1 and 9, can you guess it?\00"
@str.7 = [55 x i8] c"\0ALooks like I win today, human. Better luck next time!\00"
@str.8 = [31 x i8] c"My number is higher than that.\00"
@str.9 = [30 x i8] c"My number is lower than that.\00"
@str.10 = [55 x i8] c"You got it! You truly are a being to be reckoned with.\00"
@str.11 = [13 x i8] c"Guess again.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 9
%9 = add nsw i32 %8, 1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, %9
br i1 %13, label %50, label %14
14: ; preds = %2
%15 = icmp sgt i32 %12, %9
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = icmp sgt i32 %12, %8
br i1 %17, label %21, label %18
18: ; preds = %16, %14
%19 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0), %16 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %18, %16
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, %9
br i1 %29, label %50, label %30
30: ; preds = %26
%31 = icmp sgt i32 %28, %9
br i1 %31, label %34, label %32
32: ; preds = %30
%33 = icmp sgt i32 %28, %8
br i1 %33, label %37, label %34
34: ; preds = %30, %32
%35 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0), %32 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0), %30 ]
%36 = call i32 @puts(i8* dereferenceable(1) %35)
br label %37
37: ; preds = %34, %32
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, %9
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = icmp sgt i32 %44, %9
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = icmp sgt i32 %44, %8
br i1 %49, label %53, label %50
50: ; preds = %46, %48, %2, %26, %42
%51 = phi i8* [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.10, i64 0, i64 0), %42 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.10, i64 0, i64 0), %26 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.10, i64 0, i64 0), %2 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0), %48 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0), %46 ]
%52 = call i32 @puts(i8* dereferenceable(1) %51)
br label %53
53: ; preds = %50, %48
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, %9
br i1 %55, label %58, label %56
56: ; preds = %53
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.7, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
ret i32 0
}