#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 get_single_quiet(char *);
int /*<<< orphan*/ my_printf(char *, ...);
int yesno(int def) {
  int i;
  if (def < 0)
    i = get_single_quiet("YN");
  else {
    my_printf("(%s) ", def ? "Yes" : "No");
    i = get_single_quiet(" \nYN");
    if (i == '\n' || i == ' ')
      i = def ? 'Y' : 'N';
  }
  if (i == 'Y') {
    my_printf("Yes\n");
    return (1);
  }
  my_printf("No\n");
  return (0);
}


x86 assembly (clang, -O0):
<yesno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1149 <yesno+0x29>
lea    0xed3(%rip),%rdi
call   1040 <get_single_quiet@plt>
mov    %eax,-0xc(%rbp)
jmp    11ad <yesno+0x8d>
mov    -0x8(%rbp),%ecx
lea    0xeb7(%rip),%rsi
lea    0xeac(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <my_printf@plt>
lea    0xe97(%rip),%rdi
call   1040 <get_single_quiet@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
je     1192 <yesno+0x72>
cmpl   $0x20,-0xc(%rbp)
jne    11a8 <yesno+0x88>
mov    -0x8(%rbp),%edx
mov    $0x4e,%eax
mov    $0x59,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    11ad <yesno+0x8d>
cmpl   $0x59,-0xc(%rbp)
jne    11d1 <yesno+0xb1>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <my_printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <yesno+0xc6>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <my_printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yesno>:
push   %rbx
test   %edi,%edi
js     116f <yesno+0x4f>
mov    %edi,%ebx
lea    0xedc(%rip),%rax
lea    0xed1(%rip),%rsi
cmove  %rax,%rsi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <my_printf@plt>
lea    0xebf(%rip),%rdi
call   1040 <get_single_quiet@plt>
cmp    $0x20,%eax
je     115d <yesno+0x3d>
cmp    $0xa,%eax
jne    117b <yesno+0x5b>
test   %ebx,%ebx
je     1180 <yesno+0x60>
mov    $0x1,%ebx
lea    0xea5(%rip),%rdi
jmp    1189 <yesno+0x69>
lea    0xe99(%rip),%rdi
call   1040 <get_single_quiet@plt>
cmp    $0x59,%eax
je     1161 <yesno+0x41>
xor    %ebx,%ebx
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <my_printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"YN\00"
@.str.1 = [6 x i8] c"(%s) \00"
@.str.2 = [4 x i8] c"Yes\00"
@.str.3 = [3 x i8] c"No\00"
@.str.4 = [5 x i8] c" \0AYN\00"
@.str.5 = [5 x i8] c"Yes\0A\00"
@.str.6 = [4 x i8] c"No\0A\00"
define i32 @yesno(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @get_single_quiet(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %4
br label %27
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @get_single_quiet(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 10
br i1 %17, label %21, label %18
18: ; preds = %9
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %26
21: ; preds = %18, %9
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 89, i32 78
store i32 %25, i32* %4
br label %26
26: ; preds = %21, %18
br label %27
27: ; preds = %26, %7
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 89
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %2
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"YN\00"
@.str.1 = [6 x i8] c"(%s) \00"
@.str.2 = [4 x i8] c"Yes\00"
@.str.3 = [3 x i8] c"No\00"
@.str.4 = [5 x i8] c" \0AYN\00"
@.str.5 = [5 x i8] c"Yes\0A\00"
@.str.6 = [4 x i8] c"No\0A\00"
define i32 @yesno(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @get_single_quiet(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = icmp eq i32 %0, 0
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 (i8*, ...) @my_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = tail call i32 @get_single_quiet(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
switch i32 %9, label %11 [
i32 32, label %10
i32 10, label %10
]
10: ; preds = %5, %5
br i1 %6, label %14, label %15
11: ; preds = %5, %3
%12 = phi i32 [ %4, %3 ], [ %9, %5 ]
%13 = icmp eq i32 %12, 89
br i1 %13, label %15, label %14
14: ; preds = %10, %11
br label %15
15: ; preds = %11, %10, %14
%16 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %11 ]
%17 = phi i32 [ 0, %14 ], [ 1, %10 ], [ 1, %11 ]
%18 = tail call i32 (i8*, ...) @my_printf(i8* %16)
ret i32 %17
}