#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("Welcome to the High Low game...\n");
  printf("Think of a number between 1 and 100 and press press <enter>");
  getchar();
  int low = 1;
  int high = 100;
  int mid = (low + high) / 2;
  char answer;
  while (1) {
    printf("Is it higher than %d? (y/n)\n", mid);
    answer = getchar();
    if (answer == 'y') {
      low = mid + 1;
    } else if (answer == 'n') {
      high = mid - 1;
    } else {
      printf("Type y or n\n");
    }
    getchar();
    mid = (low + high) / 2;
    if (high < low) {
      printf("\n");
      printf(">>>>>> The number is %d\n", low);
      printf("\n");
      printf("Do you want to continue playing (y/n)?\n");
      answer = getchar();
      getchar();
      if (answer == 'n') {
        break;
      } else {
        low = 1;
        high = 100;
        mid = (low + high) / 2;
        printf("Think of a number between 1 and 100 and press press <enter>\n");
        getchar();
      }
    }
  }
}


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)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x79,%eax
jne    11ae <main+0x8e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <main+0xbc>
movsbl -0x1d(%rbp),%eax
cmp    $0x6e,%eax
jne    11c9 <main+0xa9>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d7 <main+0xb7>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1297 <main+0x177>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1d(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x6e,%eax
jne    125e <main+0x13e>
jmp    129c <main+0x17c>
movl   $0x1,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
jmp    1297 <main+0x177>
jmp    1178 <main+0x58>
mov    -0x4(%rbp),%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    0xee4(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe94(%rip),%rbx
lea    0xeef(%rip),%r12
lea    0xedc(%rip),%r13
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    $0x32,%r14d
mov    $0x64,%r15d
mov    $0x1,%ebp
jmp    11c5 <main+0x85>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    (%r15,%rbp,1),%eax
mov    %eax,%r14d
shr    $0x1f,%r14d
add    %eax,%r14d
sar    %r14d
cmp    %ebp,%r15d
jl     1200 <main+0xc0>
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x6e,%al
je     11f0 <main+0xb0>
cmp    $0x79,%al
jne    11a0 <main+0x60>
add    $0x1,%r14d
mov    %r14d,%ebp
jmp    11a8 <main+0x68>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%r14d
mov    %r14d,%r15d
jmp    11a8 <main+0x68>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe0c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x6e,%bpl
je     1253 <main+0x113>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Welcome to the High Low game...\0A\00"
@.str.1 = [60 x i8] c"Think of a number between 1 and 100 and press press <enter>\00"
@.str.2 = [29 x i8] c"Is it higher than %d? (y/n)\0A\00"
@.str.3 = [13 x i8] c"Type y or n\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c">>>>>> The number is %d\0A\00"
@.str.6 = [40 x i8] c"Do you want to continue playing (y/n)?\0A\00"
@.str.7 = [61 x i8] c"Think of a number between 1 and 100 and press press <enter>\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 i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%12 = call signext i8 (...) @getchar()
store i32 1, i32* %6
store i32 100, i32* %7
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 2
store i32 %16, i32* %8
br label %17
17: ; preds = %2, %66
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %9
%21 = load i8, i8* %9
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 121
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %37
27: ; preds = %17
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 110
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %7
br label %36
34: ; preds = %27
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
br label %37
37: ; preds = %36, %24
%38 = call signext i8 (...) @getchar()
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = add nsw i32 %39, %40
%42 = sdiv i32 %41, 2
store i32 %42, i32* %8
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %66
46: ; preds = %37
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%52 = call signext i8 (...) @getchar()
store i8 %52, i8* %9
%53 = call signext i8 (...) @getchar()
%54 = load i8, i8* %9
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 110
br i1 %56, label %57, label %58
57: ; preds = %46
br label %67
58: ; preds = %46
store i32 1, i32* %6
store i32 100, i32* %7
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = add nsw i32 %59, %60
%62 = sdiv i32 %61, 2
store i32 %62, i32* %8
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%64 = call signext i8 (...) @getchar()
br label %65
65: ; preds = %58
br label %66
66: ; preds = %65, %37
br label %17
67: ; preds = %57
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str.2 = [29 x i8] c"Is it higher than %d? (y/n)\0A\00"
@.str.5 = [25 x i8] c">>>>>> The number is %d\0A\00"
@str = [32 x i8] c"Welcome to the High Low game...\00"
@str.8 = [12 x i8] c"Type y or n\00"
@str.9 = [39 x i8] c"Do you want to continue playing (y/n)?\00"
@str.10 = [60 x i8] c"Think of a number between 1 and 100 and press press <enter>\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.10, i64 0, i64 0))
br label %5
5: ; preds = %2, %34
%6 = tail call signext i8 (...) @getchar()
br label %7
7: ; preds = %5, %19
%8 = phi i32 [ %20, %19 ], [ 1, %5 ]
%9 = phi i32 [ %21, %19 ], [ 100, %5 ]
%10 = phi i32 [ %24, %19 ], [ 50, %5 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call signext i8 (...) @getchar()
switch i8 %12, label %17 [
i8 121, label %13
i8 110, label %15
]
13: ; preds = %7
%14 = add nsw i32 %10, 1
br label %19
15: ; preds = %7
%16 = add nsw i32 %10, -1
br label %19
17: ; preds = %7
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
br label %19
19: ; preds = %15, %17, %13
%20 = phi i32 [ %14, %13 ], [ %8, %15 ], [ %8, %17 ]
%21 = phi i32 [ %9, %13 ], [ %16, %15 ], [ %9, %17 ]
%22 = tail call signext i8 (...) @getchar()
%23 = add nsw i32 %21, %20
%24 = sdiv i32 %23, 2
%25 = icmp slt i32 %21, %20
br i1 %25, label %26, label %7
26: ; preds = %19
%27 = tail call i32 @putchar(i32 10)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.9, i64 0, i64 0))
%31 = tail call signext i8 (...) @getchar()
%32 = tail call signext i8 (...) @getchar()
%33 = icmp eq i8 %31, 110
br i1 %33, label %36, label %34
34: ; preds = %26
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.10, i64 0, i64 0))
br label %5
36: ; preds = %26
ret i32 0
}