#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 int c;

/* Variables and functions */
int keyboard_wait_for_key();
int /*<<< orphan*/ mvaddch(int, int, int);
int read_yes_no(int y, int x) {
  char c;
  mvaddch(y, x, ((('_') & 0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
  c = 0;
  do {
    switch (keyboard_wait_for_key()) {
    case 0x15:
      if (c == 0) {
        c = 'Y';
        mvaddch(y, x,
                (((c)&0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
        mvaddch(y, x + 1,
                ((('_') & 0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
      }
      break;
    case 0x31:
      if (c == 0) {
        c = 'N';
        mvaddch(y, x,
                (((c)&0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
        mvaddch(y, x + 1,
                ((('_') & 0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
      }
      break;
    case 0x0e:
      if (c != 0) {
        mvaddch(y, x + 1,
                (((0) & 0xff) | ((((0) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
        mvaddch(y, x,
                ((('_') & 0xff) | ((((7) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
        c = 0;
      }
      break;
    case 0x1c:
      if (c != 0) {
        mvaddch(y, x + 1,
                (((0) & 0xff) | ((((0) & 0x0f) | (((0) & 0x0f) << 4)) << 8)));
        return (c == 'Y') ? 1 : 0;
      }
      break;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<read_yes_no>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
movb   $0x0,-0xd(%rbp)
xor    %eax,%eax
call   1030 <keyboard_wait_for_key@plt>
add    $0xfffffff2,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x23,%eax
ja     1268 <read_yes_no+0x148>
mov    -0x18(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    11ae <read_yes_no+0x8e>
movb   $0x59,-0xd(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsbl -0xd(%rbp),%edx
and    $0xff,%edx
or     $0x700,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
jmp    1268 <read_yes_no+0x148>
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    11f2 <read_yes_no+0xd2>
movb   $0x4e,-0xd(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
movsbl -0xd(%rbp),%edx
and    $0xff,%edx
or     $0x700,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
jmp    1268 <read_yes_no+0x148>
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
je     1228 <read_yes_no+0x108>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
xor    %edx,%edx
call   1040 <mvaddch@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
movb   $0x0,-0xd(%rbp)
jmp    1268 <read_yes_no+0x148>
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
je     1263 <read_yes_no+0x143>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
xor    %edx,%edx
call   1040 <mvaddch@plt>
movsbl -0xd(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x59,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    127c <read_yes_no+0x15c>
jmp    1268 <read_yes_no+0x148>
jmp    126d <read_yes_no+0x14d>
mov    $0x1,%al
test   $0x1,%al
jne    1142 <read_yes_no+0x22>
jmp    127c <read_yes_no+0x15c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_yes_no>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r12d
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
lea    0x1(%r14),%r15d
lea    0xeba(%rip),%rbp
xor    %r13d,%r13d
jmp    115b <read_yes_no+0x3b>
nopl   0x0(%rax,%rax,1)
xor    %r13d,%r13d
test   %bl,%bl
jne    11e8 <read_yes_no+0xc8>
mov    %r13d,%ebx
jmp    1164 <read_yes_no+0x44>
test   %bl,%bl
je     11c0 <read_yes_no+0xa0>
xor    %eax,%eax
call   1030 <keyboard_wait_for_key@plt>
add    $0xfffffff2,%eax
cmp    $0x23,%eax
ja     1164 <read_yes_no+0x44>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
test   %bl,%bl
jne    1164 <read_yes_no+0x44>
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x759,%edx
call   1040 <mvaddch@plt>
mov    $0x59,%r13b
jmp    11d3 <read_yes_no+0xb3>
cs nopw 0x0(%rax,%rax,1)
xor    %r13d,%r13d
test   %bl,%bl
je     115b <read_yes_no+0x3b>
xor    %r13d,%r13d
mov    %r12d,%edi
mov    %r15d,%esi
xor    %edx,%edx
call   1040 <mvaddch@plt>
mov    %r14d,%esi
jmp    11d6 <read_yes_no+0xb6>
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x74e,%edx
call   1040 <mvaddch@plt>
mov    $0x4e,%r13b
mov    %r15d,%esi
mov    %r12d,%edi
mov    $0x75f,%edx
call   1040 <mvaddch@plt>
jmp    115b <read_yes_no+0x3b>
mov    %r12d,%edi
mov    %r15d,%esi
xor    %edx,%edx
call   1040 <mvaddch@plt>
xor    %eax,%eax
cmp    $0x59,%bl
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_yes_no(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = call i32 @mvaddch(i32 %7, i32 %8, i32 1887)
store i8 0, i8* %6
br label %10
10: ; preds = %75, %2
%11 = call i32 (...) @keyboard_wait_for_key()
switch i32 %11, label %74 [
i32 21, label %12
i32 49, label %29
i32 14, label %46
i32 28, label %59
]
12: ; preds = %10
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %12
store i8 89, i8* %6
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = and i32 %20, 255
%22 = or i32 %21, 1792
%23 = call i32 @mvaddch(i32 %17, i32 %18, i32 %22)
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
%27 = call i32 @mvaddch(i32 %24, i32 %26, i32 1887)
br label %28
28: ; preds = %16, %12
br label %74
29: ; preds = %10
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %45
33: ; preds = %29
store i8 78, i8* %6
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = load i8, i8* %6
%37 = sext i8 %36 to i32
%38 = and i32 %37, 255
%39 = or i32 %38, 1792
%40 = call i32 @mvaddch(i32 %34, i32 %35, i32 %39)
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
%44 = call i32 @mvaddch(i32 %41, i32 %43, i32 1887)
br label %45
45: ; preds = %33, %29
br label %74
46: ; preds = %10
%47 = load i8, i8* %6
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = load i32, i32* %4
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
%54 = call i32 @mvaddch(i32 %51, i32 %53, i32 0)
%55 = load i32, i32* %4
%56 = load i32, i32* %5
%57 = call i32 @mvaddch(i32 %55, i32 %56, i32 1887)
store i8 0, i8* %6
br label %58
58: ; preds = %50, %46
br label %74
59: ; preds = %10
%60 = load i8, i8* %6
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %73
63: ; preds = %59
%64 = load i32, i32* %4
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
%67 = call i32 @mvaddch(i32 %64, i32 %66, i32 0)
%68 = load i8, i8* %6
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 89
%71 = zext i1 %70 to i64
%72 = select i1 %70, i32 1, i32 0
store i32 %72, i32* %3
br label %76
73: ; preds = %59
br label %74
74: ; preds = %10, %73, %58, %45, %28
br label %75
75: ; preds = %74
br i1 true, label %10, label %76
76: ; preds = %63, %75
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
define i32 @read_yes_no(i32 %0, i32 %1) {
%3 = tail call i32 @mvaddch(i32 %0, i32 %1, i32 1887)
%4 = add nsw i32 %1, 1
br label %5
5: ; preds = %24, %2
%6 = phi i8 [ 0, %2 ], [ %25, %24 ]
%7 = icmp eq i8 %6, 0
%8 = icmp eq i8 %6, 0
br label %9
9: ; preds = %11, %5
%10 = tail call i32 (...) @keyboard_wait_for_key()
switch i32 %10, label %11 [
i32 21, label %12
i32 49, label %15
i32 14, label %18
i32 28, label %22
]
11: ; preds = %9, %12, %15
br label %9
12: ; preds = %9
br i1 %8, label %13, label %11
13: ; preds = %12
%14 = tail call i32 @mvaddch(i32 %0, i32 %1, i32 1881)
br label %30
15: ; preds = %9
br i1 %7, label %16, label %11
16: ; preds = %15
%17 = tail call i32 @mvaddch(i32 %0, i32 %1, i32 1870)
br label %30
18: ; preds = %9
%19 = icmp eq i8 %6, 0
br i1 %19, label %24, label %20
20: ; preds = %18
%21 = tail call i32 @mvaddch(i32 %0, i32 %4, i32 0)
br label %30
22: ; preds = %9
%23 = icmp eq i8 %6, 0
br i1 %23, label %24, label %26
24: ; preds = %22, %18, %30
%25 = phi i8 [ %32, %30 ], [ 0, %18 ], [ 0, %22 ]
br label %5
26: ; preds = %22
%27 = tail call i32 @mvaddch(i32 %0, i32 %4, i32 0)
%28 = icmp eq i8 %6, 89
%29 = zext i1 %28 to i32
ret i32 %29
30: ; preds = %20, %16, %13
%31 = phi i32 [ %4, %13 ], [ %4, %16 ], [ %1, %20 ]
%32 = phi i8 [ 89, %13 ], [ 78, %16 ], [ 0, %20 ]
%33 = tail call i32 @mvaddch(i32 %0, i32 %31, i32 1887)
br label %24
}