#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 */
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int yes_no(char *question_str) {
  ssize_t bytes_read;
  char *answer;
  size_t size;
  size = 0;
  answer = NULL;
  while (1) {
    printf("%s (y/n): ", question_str);
    bytes_read = getline(&answer, &size, stdin);
    if (bytes_read < 0)
      return -1;
    if (answer[0] == 'y')
      return 0;
    if (answer[0] == 'n')
      return 1;
  }
  free(answer);
}


x86 assembly (clang, -O0):
<yes_no>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <getline@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    117d <yes_no+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <yes_no+0x9a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
jne    1199 <yes_no+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11ba <yes_no+0x9a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    11b5 <yes_no+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11ba <yes_no+0x9a>
jmp    113c <yes_no+0x1c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yes_no>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xeb8(%rip),%r14
mov    0x2e99(%rip),%r13
mov    %rsp,%r15
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <getline@plt>
test   %rax,%rax
js     1195 <yes_no+0x75>
mov    (%rsp),%rax
movzbl (%rax),%eax
cmp    $0x79,%al
je     119c <yes_no+0x7c>
cmp    $0x6e,%al
jne    1160 <yes_no+0x40>
mov    $0x1,%eax
jmp    119e <yes_no+0x7e>
mov    $0xffffffff,%eax
jmp    119e <yes_no+0x7e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s (y/n): \00"
@stdin = global i32 0
define i32 @yes_no(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %6
store i8* null, i8** %5
br label %7
7: ; preds = %1, %29
%8 = load i8*, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stdin
%11 = call i64 @getline(i8** %5, i64* %6, i32 %10)
store i64 %11, i64* %4
%12 = load i64, i64* %4
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 -1, i32* %2
br label %30
15: ; preds = %7
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, 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 = %15
store i32 0, i32* %2
br label %30
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 110
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %2
br label %30
29: ; preds = %22
br label %7
30: ; preds = %28, %21, %14
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s (y/n): \00"
@stdin = global i32 0
define i32 @yes_no(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = bitcast i8** %2 to i8*
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
store i8* null, i8** %2
br label %6
6: ; preds = %11, %1
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = load i32, i32* @stdin
%9 = call i64 @getline(i8** %2, i64* %3, i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
switch i8 %13, label %6 [
i8 121, label %14
i8 110, label %16
]
14: ; preds = %6, %11
%15 = phi i32 [ 0, %11 ], [ -1, %6 ]
br label %16
16: ; preds = %11, %14
%17 = phi i32 [ %15, %14 ], [ 1, %11 ]
ret i32 %17
}