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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
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)
movb   $0x79,-0x1e(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x79,%eax
jne    12ba <main+0x17a>
movl   $0x1,-0x24(%rbp)
movl   $0x64,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     1259 <main+0x119>
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0x1d(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x79,%eax
jne    1228 <main+0xe8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1254 <main+0x114>
movsbl -0x1d(%rbp),%eax
cmp    $0x6e,%eax
jne    1243 <main+0x103>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    124f <main+0x10f>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
jmp    1254 <main+0x114>
jmp    11c8 <main+0x88>
mov    -0x24(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1e(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x79,%eax
jne    129f <main+0x15f>
movb   $0x79,-0x1e(%rbp)
jmp    12b5 <main+0x175>
movsbl -0x1e(%rbp),%eax
cmp    $0x6e,%eax
jne    12b0 <main+0x170>
movb   $0x6e,-0x1e(%rbp)
jmp    12b5 <main+0x175>
jmp    1187 <main+0x47>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%r15
lea    0xeee(%rip),%r12
lea    0x7(%rsp),%rbx
jmp    11a9 <main+0x69>
nopl   0x0(%rax)
lea    0xeeb(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x79,%bpl
jne    1238 <main+0xf8>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%r13d
mov    $0x64,%r14d
jmp    11e1 <main+0xa1>
nopl   0x0(%rax)
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
cmp    %r13d,%r14d
jl     1170 <main+0x30>
lea    (%r14,%r13,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x6e,%al
je     1230 <main+0xf0>
cmp    $0x79,%al
jne    11d0 <main+0x90>
add    $0x1,%ebp
mov    %ebp,%r13d
jmp    11dc <main+0x9c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
mov    %ebp,%r14d
jmp    11dc <main+0x9c>
lea    0xe85(%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 = [33 x i8] c"Welcome to the High Low game...\0A\00"
@.str.1 = [54 x i8] c"Think of a number between 1 and 100 and press <enter>\00"
@.str.2 = [29 x i8] c"Is it higher than %d? (y/n)\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [12 x i8] c"Type y or n\00"
@.str.5 = [26 x i8] c"\0A>>>>>> The number is %d\0A\00"
@.str.6 = [40 x i8] c"\0ADo you want to continue playing (y/n)?\00"
@.str.7 = [23 x i8] c"Thanks for playing!!!\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
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 100, i32* %7
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = add nsw i32 %14, %15
%17 = sdiv i32 %16, 2
store i32 %17, i32* %8
store i8 121, i8* %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %76, %2
%20 = load i8, i8* %10
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 121
br i1 %22, label %23, label %77
23: ; preds = %19
store i32 1, i32* %11
store i32 100, i32* %12
%24 = load i32, i32* %12
%25 = load i32, i32* %11
%26 = add nsw i32 %24, %25
%27 = sdiv i32 %26, 2
store i32 %27, i32* %13
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%29 = call signext i8 (...) @getchar()
br label %30
30: ; preds = %59, %23
%31 = load i32, i32* %12
%32 = load i32, i32* %11
%33 = icmp sge i32 %31, %32
br i1 %33, label %34, label %60
34: ; preds = %30
%35 = load i32, i32* %12
%36 = load i32, i32* %11
%37 = add nsw i32 %35, %36
%38 = sdiv i32 %37, 2
store i32 %38, i32* %13
%39 = load i32, i32* %13
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%42 = call signext i8 (...) @getchar()
%43 = load i8, i8* %9
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 121
br i1 %45, label %46, label %49
46: ; preds = %34
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %59
49: ; preds = %34
%50 = load i8, i8* %9
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 110
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i32, i32* %13
%55 = sub nsw i32 %54, 1
store i32 %55, i32* %12
br label %58
56: ; preds = %49
%57 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
br label %59
59: ; preds = %58, %46
br label %30
60: ; preds = %30
%61 = load i32, i32* %11
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%64 = call signext i8 (...) @getchar()
store i8 %64, i8* %10
%65 = call signext i8 (...) @getchar()
%66 = load i8, i8* %10
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 121
br i1 %68, label %69, label %70
69: ; preds = %60
store i8 121, i8* %10
br label %76
70: ; preds = %60
%71 = load i8, i8* %10
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 110
br i1 %73, label %74, label %75
74: ; preds = %70
store i8 110, i8* %10
br label %75
75: ; preds = %74, %70
br label %76
76: ; preds = %75, %69
br label %19
77: ; preds = %19
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

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