#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char);
int /*<<< orphan*/ stdin;
char AskYesOrNo(char *question, char standard) {
  char reply[256];
  do {
    printf("%s (Y=yes, N=no) <%c> ==> ", question, standard);
    fgets(reply, 256, stdin);
    switch (reply[0]) {
    case (char)0:
      reply[0] = standard;
      break;
    case 'y':
    case 'Y':
      reply[0] = 'y';
      break;
    case 'n':
    case 'N':
      reply[0] = 'n';
      break;
    default:
      reply[0] = 0;
    }
  } while (!reply);
  return reply[0];
}


x86 assembly (clang, -O0):
<AskYesOrNo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rsi
movsbl -0x9(%rbp),%edx
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
movsbl -0x110(%rbp),%eax
mov    %eax,-0x114(%rbp)
test   %eax,%eax
je     11cd <AskYesOrNo+0xad>
jmp    117d <AskYesOrNo+0x5d>
mov    -0x114(%rbp),%eax
sub    $0x4e,%eax
je     11e7 <AskYesOrNo+0xc7>
jmp    1191 <AskYesOrNo+0x71>
mov    -0x114(%rbp),%eax
sub    $0x59,%eax
je     11db <AskYesOrNo+0xbb>
jmp    11a5 <AskYesOrNo+0x85>
mov    -0x114(%rbp),%eax
sub    $0x6e,%eax
je     11e7 <AskYesOrNo+0xc7>
jmp    11b9 <AskYesOrNo+0x99>
mov    -0x114(%rbp),%eax
sub    $0x79,%eax
je     11db <AskYesOrNo+0xbb>
jmp    11f3 <AskYesOrNo+0xd3>
mov    -0x9(%rbp),%al
mov    %al,-0x110(%rbp)
jmp    11fa <AskYesOrNo+0xda>
movb   $0x79,-0x110(%rbp)
jmp    11fa <AskYesOrNo+0xda>
movb   $0x6e,-0x110(%rbp)
jmp    11fa <AskYesOrNo+0xda>
movb   $0x0,-0x110(%rbp)
jmp    11ff <AskYesOrNo+0xdf>
lea    -0x110(%rbp),%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1135 <AskYesOrNo+0x15>
movsbl -0x110(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AskYesOrNo>:
push   %rbx
sub    $0x100,%rsp
mov    %esi,%ebx
mov    %rdi,%rsi
lea    0xecc(%rip),%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
movsbl (%rsp),%eax
cmp    $0x58,%eax
jle    116d <AskYesOrNo+0x4d>
cmp    $0x79,%eax
je     1169 <AskYesOrNo+0x49>
cmp    $0x6e,%eax
je     1176 <AskYesOrNo+0x56>
cmp    $0x59,%eax
jne    117a <AskYesOrNo+0x5a>
mov    $0x79,%bl
jmp    117c <AskYesOrNo+0x5c>
test   %eax,%eax
je     117c <AskYesOrNo+0x5c>
cmp    $0x4e,%eax
jne    117a <AskYesOrNo+0x5a>
mov    $0x6e,%bl
jmp    117c <AskYesOrNo+0x5c>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%s (Y=yes, N=no) <%c> ==> \00"
@stdin = global i32 0
define signext i8 @AskYesOrNo(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca [256 x i8]
store i8* %0, i8** %3
store i8 %1, i8* %4
br label %6
6: ; preds = %26, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %4
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %7, i8 signext %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 256, i32 %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %23 [
i32 0, label %16
i32 121, label %19
i32 89, label %19
i32 110, label %21
i32 78, label %21
]
16: ; preds = %6
%17 = load i8, i8* %4
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 %17, i8* %18
br label %25
19: ; preds = %6, %6
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 121, i8* %20
br label %25
21: ; preds = %6, %6
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 110, i8* %22
br label %25
23: ; preds = %6
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 0, i8* %24
br label %25
25: ; preds = %23, %21, %19, %16
br label %26
26: ; preds = %25
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%28 = icmp ne i8* %27, null
%29 = xor i1 %28, true
br i1 %29, label %6, label %30
30: ; preds = %26
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%32 = load i8, i8* %31
ret i8 %32
}

LLVM IR (-O2):
@.str = [27 x i8] c"%s (Y=yes, N=no) <%c> ==> \00"
@stdin = global i32 0
define signext i8 @AskYesOrNo(i8* %0, i8 signext %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i8 signext %1)
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %4, i32 256, i32 %6)
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
switch i32 %9, label %12 [
i32 0, label %13
i32 121, label %10
i32 89, label %10
i32 110, label %11
i32 78, label %11
]
10: ; preds = %2, %2
br label %13
11: ; preds = %2, %2
br label %13
12: ; preds = %2
br label %13
13: ; preds = %2, %12, %11, %10
%14 = phi i8 [ 0, %12 ], [ 110, %11 ], [ 121, %10 ], [ %1, %2 ]
ret i8 %14
}