#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  time_t t;
  srand((unsigned)time(&t));
  int value = rand() % 100 + 1;
  int playing = 1;
  int user_guess;
  int tries = 0;
  printf("====================\n");
  while (playing) {
    printf("Enter your guess: ");
    scanf("%d", &user_guess);
    tries++;
    if (user_guess == value) {
      printf("CORRECT! The number was found in %d guess(es).\n", tries);
      printf("====================\n");
      playing = 0;
    } else if (value > user_guess) {
      printf("WRONG! It's higher...\n");
      printf("-----\n");
    } else {
      printf("WRONG! It's lower...\n");
      printf("-----\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     125b <main+0x10b>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1208 <main+0xb8>
mov    -0x18(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1256 <main+0x106>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1235 <main+0xe5>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1251 <main+0x101>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main+0x106>
jmp    11a0 <main+0x50>
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
lea    0x4(%rsp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%r15d
mov    %r15d,%eax
neg    %eax
lea    (%rbx,%rax,1),%r14d
add    $0x1,%r14d
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%eax
mov    $0x1,%ebp
cmp    %r14d,%eax
jne    120f <main+0xaf>
lea    0xe2d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %r15d,%ebx
mov    $0x1,%ebp
lea    0xde2(%rip),%r15
lea    0xdee(%rip),%r12
mov    %rsp,%r13
jmp    1261 <main+0x101>
nopw   0x0(%rax,%rax,1)
call   1030 <puts@plt>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
add    $0x1,%ebp
mov    (%rsp),%eax
cmp    %r14d,%eax
je     11e2 <main+0x82>
lea    0xdde(%rip),%rdi
cmp    %eax,%ebx
jl     1230 <main+0xd0>
lea    0xde8(%rip),%rdi
jmp    1230 <main+0xd0>

LLVM IR (-O0):
@.str = [22 x i8] c"====================\0A\00"
@.str.1 = [19 x i8] c"Enter your guess: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [48 x i8] c"CORRECT! The number was found in %d guess(es).\0A\00"
@.str.4 = [23 x i8] c"WRONG! It's higher...\0A\00"
@.str.5 = [7 x i8] c"-----\0A\00"
@.str.6 = [22 x i8] c"WRONG! It's lower...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i64 @time(i32* %2)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
store i32 1, i32* %4
store i32 0, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %40, %0
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %40
29: ; preds = %17
%30 = load i32, i32* %3
%31 = load i32, i32* %5
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %39
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39, %25
br label %14
41: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Enter your guess: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [48 x i8] c"CORRECT! The number was found in %d guess(es).\0A\00"
@str.7 = [21 x i8] c"WRONG! It's lower...\00"
@str.9 = [22 x i8] c"WRONG! It's higher...\00"
@str.10 = [6 x i8] c"-----\00"
@str.11 = [21 x i8] c"====================\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = call i64 @time(i32* %1)
%5 = trunc i64 %4 to i32
%6 = call i32 @srand(i32 %5)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = add nsw i32 %8, 1
%10 = bitcast i32* %2 to i8*
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, %9
br i1 %15, label %29, label %16
16: ; preds = %0, %16
%17 = phi i32 [ %27, %16 ], [ %14, %0 ]
%18 = phi i32 [ %26, %16 ], [ 1, %0 ]
%19 = icmp slt i32 %8, %17
%20 = select i1 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0)
%21 = select i1 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0)
%22 = call i32 @puts(i8* dereferenceable(1) %20)
%23 = call i32 @puts(i8* dereferenceable(1) %21)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%26 = add nuw nsw i32 %18, 1
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, %9
br i1 %28, label %29, label %16
29: ; preds = %16, %0
%30 = phi i32 [ 1, %0 ], [ %26, %16 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
ret i32 0
}