#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int yes(const char *s) {
  char b[20];
  for (;;) {
    printf("%s? ", s);
    fflush(stdout);
    if (fgets(b, 20, stdin) == NULL)
      exit(0);
    if (b[0] == 'y')
      return (1);
    if (b[0] == 'n')
      return (0);
    printf("Answer `yes' or `no'.\n");
  }
}


x86 assembly (clang, -O0):
<yes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1194 <yes+0x54>
xor    %edi,%edi
call   1060 <exit@plt>
movsbl -0x30(%rbp),%eax
cmp    $0x79,%eax
jne    11ad <yes+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <yes+0x99>
movsbl -0x30(%rbp),%eax
cmp    $0x6e,%eax
jne    11c6 <yes+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <yes+0x99>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114c <yes+0xc>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e5f(%rip),%r13
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
mov    0x2e5f(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x14,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ef <yes+0x9f>
lea    0xe60(%rip),%r14
lea    0xe54(%rip),%r15
mov    %rsp,%r12
nop
movzbl (%rsp),%eax
cmp    $0x6e,%al
je     11f6 <yes+0xa6>
cmp    $0x79,%al
je     11fa <yes+0xaa>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    $0x14,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b0 <yes+0x60>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
jmp    11ff <yes+0xaf>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s? \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [23 x i8] c"Answer `yes' or `no'.\0A\00"
define i32 @yes(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [20 x i8]
store i8* %0, i8** %3
br label %5
5: ; preds = %28, %1
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %10, i32 20, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %5
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 121
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 1, i32* %2
br label %30
22: ; preds = %16
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 110
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %2
br label %30
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %5
30: ; preds = %27, %21
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s? \00"
@stdout = global i32 0
@stdin = global i32 0
@str = [22 x i8] c"Answer `yes' or `no'.\00"
define i32 @yes(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %3, i32 20, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %14, %1
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %1, %14
%13 = load i8, i8* %3
switch i8 %13, label %14 [
i8 121, label %22
i8 110, label %23
]
14: ; preds = %12
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = load i32, i32* @stdin
%20 = call i32* @fgets(i8* %3, i32 20, i32 %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %10, label %12
22: ; preds = %12
br label %23
23: ; preds = %12, %22
%24 = phi i32 [ 1, %22 ], [ 0, %12 ]
ret i32 %24
}