#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*/ fflush(int /*<<< orphan*/);
int makeGuess(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sleep(double);
int /*<<< orphan*/ stdout;
char tolower(char);
int main() {
  int low_bound = 1;
  int high_bound = 100;
  int guessed = 0;
  int guess = 0;
  char answer;
  while (!guessed) {
    guess = makeGuess(low_bound, high_bound);
    printf("Is your number Higher(h), Lower(l) or Equal(e) to %d? ", guess);
    fflush(stdout);
    scanf(" %c", &answer);
    answer = tolower(answer);
    if (answer == 'e') {
      guessed = 1;
    } else if (answer == 'l') {
      high_bound = guess - 1;
    } else if (answer == 'h') {
      low_bound = guess + 1;
    } else {
      printf("Sorry, I didn't understand that, please enter h, l or e\n");
    }
    sleep(0.5);
  }
  printf("YOUR NUMBER WAS %d!\n", guess);
  printf("MACHINES WIN!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a1 <main+0x41>
jmp    1263 <main+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <makeGuess@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xe6a(%rip),%rdi
lea    -0x15(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x15(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x65,%eax
jne    1203 <main+0xa3>
movl   $0x1,-0x10(%rbp)
jmp    1251 <main+0xf1>
movsbl -0x15(%rbp),%eax
cmp    $0x6c,%eax
jne    121e <main+0xbe>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    124c <main+0xec>
movsbl -0x15(%rbp),%eax
cmp    $0x68,%eax
jne    1239 <main+0xd9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1247 <main+0xe7>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124c <main+0xec>
jmp    1251 <main+0xf1>
movsd  0xda7(%rip),%xmm0
call   1080 <sleep@plt>
jmp    118b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
mov    $0x1,%ebp
mov    $0x64,%r13d
mov    0x2e53(%rip),%r14
lea    0xeab(%rip),%r15
lea    0x7(%rsp),%r12
jmp    11b3 <main+0x43>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
mov    %ebx,%r13d
movsd  0xe52(%rip),%xmm0
call   1090 <sleep@plt>
mov    %ebp,%edi
mov    %r13d,%esi
call   1070 <makeGuess@plt>
mov    %eax,%ebx
lea    0xe42(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edi
call   1060 <fflush@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
movsbl 0x7(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0x7(%rsp)
cmp    $0x68,%al
je     1210 <main+0xa0>
cmp    $0x6c,%al
je     11a0 <main+0x30>
cmp    $0x65,%al
je     1217 <main+0xa7>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
jmp    11a6 <main+0x36>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%ebp
jmp    11a6 <main+0x36>
movsd  0xde1(%rip),%xmm0
call   1090 <sleep@plt>
lea    0xe18(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1d(%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

LLVM IR (-O0):
@.str = [55 x i8] c"Is your number Higher(h), Lower(l) or Equal(e) to %d? \00"
@stdout = global i32 0
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [57 x i8] c"Sorry, I didn't understand that, please enter h, l or e\0A\00"
@.str.3 = [21 x i8] c"YOUR NUMBER WAS %d!\0A\00"
@.str.4 = [15 x i8] c"MACHINES WIN!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
store i32 1, i32* %2
store i32 100, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %44, %0
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %46
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @makeGuess(i32 %12, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%20 = load i8, i8* %6
%21 = call signext i8 @tolower(i8 signext %20)
store i8 %21, i8* %6
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 101
br i1 %24, label %25, label %26
25: ; preds = %11
store i32 1, i32* %4
br label %44
26: ; preds = %11
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 108
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %3
br label %43
33: ; preds = %26
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 104
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %42
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
br label %43
43: ; preds = %42, %30
br label %44
44: ; preds = %43, %25
%45 = call i32 @sleep(double 5.000000e-01)
br label %7
46: ; preds = %7
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"Is your number Higher(h), Lower(l) or Equal(e) to %d? \00"
@stdout = global i32 0
@.str.1 = [4 x i8] c" %c\00"
@.str.3 = [21 x i8] c"YOUR NUMBER WAS %d!\0A\00"
@str = [14 x i8] c"MACHINES WIN!\00"
@str.5 = [56 x i8] c"Sorry, I didn't understand that, please enter h, l or e\00"
define i32 @main() {
%1 = alloca i8
br label %2
2: ; preds = %18, %0
%3 = phi i32 [ 100, %0 ], [ %20, %18 ]
%4 = phi i32 [ 1, %0 ], [ %19, %18 ]
%5 = call i32 @makeGuess(i32 %4, i32 %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = load i8, i8* %1
%11 = call signext i8 @tolower(i8 signext %10)
store i8 %11, i8* %1
switch i8 %11, label %16 [
i8 101, label %22
i8 108, label %12
i8 104, label %14
]
12: ; preds = %2
%13 = add nsw i32 %5, -1
br label %18
14: ; preds = %2
%15 = add nsw i32 %5, 1
br label %18
16: ; preds = %2
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.5, i64 0, i64 0))
br label %18
18: ; preds = %12, %16, %14
%19 = phi i32 [ %4, %12 ], [ %15, %14 ], [ %4, %16 ]
%20 = phi i32 [ %13, %12 ], [ %3, %14 ], [ %3, %16 ]
%21 = call i32 @sleep(double 5.000000e-01)
br label %2
22: ; preds = %2
%23 = call i32 @sleep(double 5.000000e-01)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}