#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 /*<<< orphan*/ scanf(char *, int *);
void main() {
  int times = 0;
  int answer;
  int guess = 0;
  scanf("%d", &answer);
  while (answer != guess) {
    times++;
    printf("You:");
    scanf("%d", &guess);
    printf("host:");
    if (guess < answer)
      printf("low.\n");
    else if (answer < guess)
      printf("high.\n");
    else
      printf("You are right, %d time%s you guessed.\n", times,
             times == 1 ? "" : "s");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11f8 <main+0xd8>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a6 <main+0x86>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <main+0xd3>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c5 <main+0xa5>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ee <main+0xce>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%ecx
lea    0xe70(%rip),%rdx
lea    0xe68(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <main+0xd3>
jmp    1146 <main+0x26>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rsp)
lea    0xeb7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     1207 <main+0xd7>
mov    $0x1,%ebx
lea    0xe99(%rip),%r14
lea    0xe8f(%rip),%r15
mov    %rsp,%r12
lea    0xe8d(%rip),%r13
lea    0xebb(%rip),%rbp
jmp    11a4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
add    $0x1,%ebx
cmp    (%rsp),%eax
je     1207 <main+0xd7>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jl     1190 <main+0x60>
jle    11e0 <main+0xb0>
lea    0xe60(%rip),%rdi
jmp    1193 <main+0x63>
nopl   0x0(%rax)
cmp    $0x1,%ebx
lea    0xe4b(%rip),%rdx
lea    0xe43(%rip),%rax
cmove  %rax,%rdx
lea    0xe12(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x68>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"You:\00"
@.str.2 = [6 x i8] c"host:\00"
@.str.3 = [6 x i8] c"low.\0A\00"
@.str.4 = [7 x i8] c"high.\0A\00"
@.str.5 = [39 x i8] c"You are right, %d time%s you guessed.\0A\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"s\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %5
5: ; preds = %34, %0
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %35
9: ; preds = %5
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %34
20: ; preds = %9
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %33
26: ; preds = %20
%27 = load i32, i32* %1
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, 1
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %27, i8* %31)
br label %33
33: ; preds = %26, %24
br label %34
34: ; preds = %33, %18
br label %5
35: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"You:\00"
@.str.2 = [6 x i8] c"host:\00"
@.str.5 = [39 x i8] c"You are right, %d time%s you guessed.\0A\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"s\00"
@str = [6 x i8] c"high.\00"
@str.8 = [5 x i8] c"low.\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %31, label %8
8: ; preds = %0, %27
%9 = phi i32 [ %10, %27 ], [ 0, %0 ]
%10 = add nuw nsw i32 %9, 1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0))
br label %27
19: ; preds = %8
%20 = icmp slt i32 %15, %14
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %27
23: ; preds = %19
%24 = icmp eq i32 %9, 0
%25 = select i1 %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i32 %10, i8* %25)
br label %27
27: ; preds = %21, %23, %17
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %8
31: ; preds = %27, %0
ret void
}