#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() {
  srand(time(NULL));
  int r = rand() % 100;
  int i;
  int status = 0;
  int tries = 1;
  printf("Please make a guess between 0-99. ");
  scanf("%d", &i);
  while (status != 1) {
    while (i < 0 || i > 99) {
      printf("Please only integer guesses between 0-99. Enter new number: ");
      scanf("%d", &i);
    }
    if (i > r) {
      printf("Your guess is too high. Please enter another number: ");
      scanf("%d", &i);
      tries++;
    } else if (i < r) {
      printf("Your guess is too low. Please enter another number: ");
      scanf("%d", &i);
      tries++;
    } else {
      printf("Your guess is correct. Congratulations. It took you %d tries to "
             "guess the random number.\n",
             tries);
      status = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%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    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
je     129a <main+0x14a>
jmp    11bc <main+0x6c>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jl     11d5 <main+0x85>
cmpl   $0x63,-0xc(%rbp)
setg   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11e5 <main+0x95>
jmp    1208 <main+0xb8>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe29(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
jmp    11bc <main+0x6c>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1240 <main+0xf0>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfa(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1295 <main+0x145>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1278 <main+0x128>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1290 <main+0x140>
mov    -0x14(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1295 <main+0x145>
jmp    11ad <main+0x5d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe81(%rip),%r15
lea    0x4(%rsp),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    $0x1,%r14d
lea    0xe67(%rip),%rbx
lea    0xe9d(%rip),%r13
jmp    11e6 <main+0x96>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
add    $0x1,%r14d
mov    0x4(%rsp),%eax
cmp    $0x64,%eax
jb     120e <main+0xbe>
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x63,%eax
ja     11f0 <main+0xa0>
mov    %r13,%rdi
cmp    %r12d,%eax
jg     11d0 <main+0x80>
lea    0xe7c(%rip),%rdi
jl     11d0 <main+0x80>
lea    0xea8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Please make a guess between 0-99. \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"Please only integer guesses between 0-99. Enter new number: \00"
@.str.3 = [54 x i8] c"Your guess is too high. Please enter another number: \00"
@.str.4 = [53 x i8] c"Your guess is too low. Please enter another number: \00"
@.str.5 = [90 x i8] c"Your guess is correct. Congratulations. It took you %d tries to guess the random number.\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
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 100
store i32 %9, i32* %2
store i32 0, i32* %4
store i32 1, i32* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %12
12: ; preds = %49, %0
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %50
15: ; preds = %12
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 99
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %16
27: ; preds = %22
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %49
36: ; preds = %27
%37 = load i32, i32* %3
%38 = load i32, i32* %2
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %48
45: ; preds = %36
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.5, i64 0, i64 0), i32 %46)
store i32 1, i32* %4
br label %48
48: ; preds = %45, %40
br label %49
49: ; preds = %48, %31
br label %12
50: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Please make a guess between 0-99. \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"Please only integer guesses between 0-99. Enter new number: \00"
@.str.3 = [54 x i8] c"Your guess is too high. Please enter another number: \00"
@.str.4 = [53 x i8] c"Your guess is too low. Please enter another number: \00"
@.str.5 = [90 x i8] c"Your guess is correct. Congratulations. It took you %d tries to guess the random number.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = bitcast i32* %1 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %25, %0
%10 = phi i32 [ 1, %0 ], [ %29, %25 ]
%11 = load i32, i32* %1
%12 = icmp ugt i32 %11, 99
br i1 %12, label %13, label %18
13: ; preds = %9, %13
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp ugt i32 %16, 99
br i1 %17, label %13, label %18
18: ; preds = %13, %9
%19 = phi i32 [ %11, %9 ], [ %16, %13 ]
%20 = icmp sgt i32 %19, %5
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = icmp slt i32 %19, %5
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.5, i64 0, i64 0), i32 %10)
ret i32 0
25: ; preds = %21, %18
%26 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), %21 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %26)
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%29 = add nuw nsw i32 %10, 1
br label %9
}