#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(void) {
  int guess = 1;
  int response;
  printf("Pick an integer from 1 to 100. I will try to guess it.\n");
  printf("Response with a y if my guess is right and with n if it is wrong.\n");
  printf("Uh...is your number %d?\n", guess);
  while ((response = getchar()) != 'y') {
    if (response == 'n')
      printf("Well, then, is it %d?\n", ++guess);
    else
      printf("Sorry, I understand only y or n.\n");
    while (getchar() != '\n')
      continue;
  }
  printf("I knew I could do it!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x79,%eax
je     11cf <main+0xaf>
cmpl   $0x6e,-0xc(%rbp)
jne    119f <main+0x7f>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ad <main+0x8d>
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <main+0x92>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11ca <main+0xaa>
jmp    11b2 <main+0x92>
jmp    1163 <main+0x43>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%r14
lea    0xf4c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x6e,%al
je     11a0 <main+0x70>
cmp    $0x79,%al
je     11bd <main+0x8d>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11b0 <main+0x80>
nopl   0x0(%rax)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
nop
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <main+0x80>
jmp    1180 <main+0x50>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Pick an integer from 1 to 100. I will try to guess it.\0A\00"
@.str.1 = [67 x i8] c"Response with a y if my guess is right and with n if it is wrong.\0A\00"
@.str.2 = [25 x i8] c"Uh...is your number %d?\0A\00"
@.str.3 = [23 x i8] c"Well, then, is it %d?\0A\00"
@.str.4 = [34 x i8] c"Sorry, I understand only y or n.\0A\00"
@.str.5 = [23 x i8] c"I knew I could do it!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %27, %0
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
store i32 %10, i32* %3
%11 = icmp ne i32 %10, 121
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 110
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
br label %22
22: ; preds = %26, %21
%23 = call signext i8 (...) @getchar()
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %27
26: ; preds = %22
br label %22
27: ; preds = %22
br label %8
28: ; preds = %8
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [25 x i8] c"Uh...is your number %d?\0A\00"
@.str.3 = [23 x i8] c"Well, then, is it %d?\0A\00"
@str = [55 x i8] c"Pick an integer from 1 to 100. I will try to guess it.\00"
@str.6 = [66 x i8] c"Response with a y if my guess is right and with n if it is wrong.\00"
@str.7 = [22 x i8] c"I knew I could do it!\00"
@str.8 = [33 x i8] c"Sorry, I understand only y or n.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.6, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %4
4: ; preds = %14, %0
%5 = phi i32 [ 1, %0 ], [ %13, %14 ]
%6 = tail call signext i8 (...) @getchar()
switch i8 %6, label %10 [
i8 121, label %17
i8 110, label %7
]
7: ; preds = %4
%8 = add nsw i32 %5, 1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %12
10: ; preds = %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ %8, %7 ], [ %5, %10 ]
br label %14
14: ; preds = %14, %12
%15 = tail call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %4, label %14
17: ; preds = %4
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}