#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 getch();
int /*<<< orphan*/ glk_put_char(char);
int /*<<< orphan*/ glk_put_string(char *);
char yesno(void) {
  char n;
  while (1) {
    glk_put_string("[yn] ");
    n = getch();
    glk_put_char(n);
    glk_put_char('\n');
    if ((n == 'Y') || (n == 'y'))
      return ('Y');
    if ((n == 'N') || (n == 'n'))
      return ('N');
  }
  return ('N');
}


x86 assembly (clang, -O0):
<yesno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <glk_put_string@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%edi
call   1030 <glk_put_char@plt>
mov    $0xa,%edi
call   1030 <glk_put_char@plt>
movsbl -0x2(%rbp),%eax
cmp    $0x59,%eax
je     117b <yesno+0x4b>
movsbl -0x2(%rbp),%eax
cmp    $0x79,%eax
jne    1184 <yesno+0x54>
movb   $0x59,-0x1(%rbp)
jmp    11ac <yesno+0x7c>
movsbl -0x2(%rbp),%eax
cmp    $0x4e,%eax
je     119e <yesno+0x6e>
movsbl -0x2(%rbp),%eax
cmp    $0x6e,%eax
jne    11a7 <yesno+0x77>
movb   $0x4e,-0x1(%rbp)
jmp    11ac <yesno+0x7c>
jmp    1138 <yesno+0x8>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yesno>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <glk_put_string@plt>
xor    %eax,%eax
call   1050 <getch@plt>
movsbl %al,%ebp
mov    %ebp,%edi
call   1030 <glk_put_char@plt>
mov    $0xa,%edi
call   1030 <glk_put_char@plt>
and    $0xdf,%bpl
cmp    $0x59,%bpl
je     1173 <yesno+0x43>
cmp    $0x4e,%bpl
jne    1140 <yesno+0x10>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"[yn] \00"
define signext i8 @yesno() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %0, %26
%4 = call i32 @glk_put_string(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call signext i8 (...) @getch()
store i8 %5, i8* %2
%6 = load i8, i8* %2
%7 = call i32 @glk_put_char(i8 signext %6)
%8 = call i32 @glk_put_char(i8 signext 10)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 89
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 121
br i1 %15, label %16, label %17
16: ; preds = %12, %3
store i8 89, i8* %1
br label %27
17: ; preds = %12
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 78
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 110
br i1 %24, label %25, label %26
25: ; preds = %21, %17
store i8 78, i8* %1
br label %27
26: ; preds = %21
br label %3
27: ; preds = %25, %16
%28 = load i8, i8* %1
ret i8 %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"[yn] \00"
define signext i8 @yesno() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @glk_put_string(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call signext i8 (...) @getch()
%4 = tail call i32 @glk_put_char(i8 signext %3)
%5 = tail call i32 @glk_put_char(i8 signext 10)
%6 = and i8 %3, -33
switch i8 %6, label %1 [
i8 89, label %7
i8 78, label %7
]
7: ; preds = %1, %1
ret i8 %6
}