#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;
  printf("Pick an integer from 1 to 100. I will try to guess ");
  printf("it.\nRespond with a y if my guess is right and with");
  printf("\nan n if it is wrong.\n");
  printf("Uh...is your number %d?\n", guess);
  while ((getchar()) != 'y')
    printf("Well, then, is it %d?\n", ++guess);
  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    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0x79,%eax
je     11a0 <main+0x80>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1171 <main+0x51>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
lea    0xf04(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x79,%al
je     11aa <main+0x7a>
mov    $0x2,%ebx
lea    0xefa(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebx
cmp    $0x79,%al
jne    1190 <main+0x60>
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Pick an integer from 1 to 100. I will try to guess \00"
@.str.1 = [51 x i8] c"it.\0ARespond with a y if my guess is right and with\00"
@.str.2 = [23 x i8] c"\0Aan n if it is wrong.\0A\00"
@.str.3 = [25 x i8] c"Uh...is your number %d?\0A\00"
@.str.4 = [23 x i8] c"Well, then, is it %d?\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
store i32 0, i32* %1
store i32 1, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %12, %0
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 121
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %14)
br label %8
16: ; preds = %8
%17 = 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 = [52 x i8] c"Pick an integer from 1 to 100. I will try to guess \00"
@.str.1 = [51 x i8] c"it.\0ARespond with a y if my guess is right and with\00"
@.str.3 = [25 x i8] c"Uh...is your number %d?\0A\00"
@.str.4 = [23 x i8] c"Well, then, is it %d?\0A\00"
@str = [22 x i8] c"\0Aan n if it is wrong.\00"
@str.6 = [22 x i8] c"I knew I could do it!\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 1)
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 121
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %9, %7 ], [ 1, %0 ]
%9 = add nuw nsw i32 %8, 1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 121
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}