#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*/ addstr(char *);
int /*<<< orphan*/ clrtoeol();
int /*<<< orphan*/ move(int /*<<< orphan*/, int /*<<< orphan*/);
char nmgetch();
int /*<<< orphan*/ refresh();
int yn_ask(char *msg) {
  char ch;
  (void)move(0, 0);
  (void)clrtoeol();
  (void)addstr(msg);
  (void)refresh();
  while ((ch = nmgetch()) != 'y' && ch != 'Y' && ch != 'n' && ch != 'N') {
    if (ch == (('g') & 037) || ch == 033)
      return (-1);
  }
  if (ch == 'y' || ch == 'Y')
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<yn_ask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1070 <move@plt>
mov    $0x0,%al
call   1050 <clrtoeol@plt>
mov    -0x10(%rbp),%rdi
call   1060 <addstr@plt>
mov    $0x0,%al
call   1030 <refresh@plt>
mov    $0x0,%al
call   1040 <nmgetch@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x12(%rbp)
je     11c8 <yn_ask+0x78>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x59,%ecx
mov    %al,-0x12(%rbp)
je     11c8 <yn_ask+0x78>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6e,%ecx
mov    %al,-0x12(%rbp)
je     11c8 <yn_ask+0x78>
movsbl -0x11(%rbp),%eax
cmp    $0x4e,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11d8 <yn_ask+0x88>
jmp    1203 <yn_ask+0xb3>
movsbl -0x11(%rbp),%eax
cmp    $0x7,%eax
je     11f2 <yn_ask+0xa2>
movsbl -0x11(%rbp),%eax
cmp    $0x1b,%eax
jne    11fe <yn_ask+0xae>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <yn_ask+0xe0>
jmp    117c <yn_ask+0x2c>
movsbl -0x11(%rbp),%eax
cmp    $0x79,%eax
je     121d <yn_ask+0xcd>
movsbl -0x11(%rbp),%eax
cmp    $0x59,%eax
jne    1229 <yn_ask+0xd9>
movl   $0x1,-0x4(%rbp)
jmp    1230 <yn_ask+0xe0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yn_ask>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   1070 <move@plt>
xor    %eax,%eax
call   1050 <clrtoeol@plt>
mov    %rbx,%rdi
call   1060 <addstr@plt>
xor    %eax,%eax
call   1030 <refresh@plt>
movabs $0x80100000801,%rbx
nopl   (%rax)
xor    %eax,%eax
call   1040 <nmgetch@plt>
lea    -0x4e(%rax),%ecx
cmp    $0x2b,%cl
ja     1198 <yn_ask+0x48>
movzbl %cl,%ecx
bt     %rcx,%rbx
jb     11a7 <yn_ask+0x57>
cmp    $0x7,%al
je     11a0 <yn_ask+0x50>
cmp    $0x1b,%al
jne    1180 <yn_ask+0x30>
mov    $0xffffffff,%ecx
jmp    11b0 <yn_ask+0x60>
and    $0xdf,%al
xor    %ecx,%ecx
cmp    $0x59,%al
sete   %cl
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @yn_ask(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = call i32 @move(i32 0, i32 0)
%6 = call i32 (...) @clrtoeol()
%7 = load i8*, i8** %3
%8 = call i32 @addstr(i8* %7)
%9 = call i32 (...) @refresh()
br label %10
10: ; preds = %37, %1
%11 = call signext i8 (...) @nmgetch()
store i8 %11, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 121
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 89
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 110
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 78
br label %26
26: ; preds = %22, %18, %14, %10
%27 = phi i1 [ false, %18 ], [ false, %14 ], [ false, %10 ], [ %25, %22 ]
br i1 %27, label %28, label %38
28: ; preds = %26
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 7
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 27
br i1 %35, label %36, label %37
36: ; preds = %32, %28
store i32 -1, i32* %2
br label %48
37: ; preds = %32
br label %10
38: ; preds = %26
%39 = load i8, i8* %4
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 121
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 89
br i1 %45, label %46, label %47
46: ; preds = %42, %38
store i32 1, i32* %2
br label %48
47: ; preds = %42
store i32 0, i32* %2
br label %48
48: ; preds = %47, %46, %36
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
define i32 @yn_ask(i8* %0) {
%2 = tail call i32 @move(i32 0, i32 0)
%3 = tail call i32 (...) @clrtoeol()
%4 = tail call i32 @addstr(i8* %0)
%5 = tail call i32 (...) @refresh()
br label %6
6: ; preds = %6, %1
%7 = tail call signext i8 (...) @nmgetch()
switch i8 %7, label %6 [
i8 121, label %8
i8 110, label %8
i8 89, label %8
i8 78, label %8
i8 27, label %12
i8 7, label %12
]
8: ; preds = %6, %6, %6, %6
%9 = and i8 %7, -33
%10 = icmp eq i8 %9, 89
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %6, %6, %8
%13 = phi i32 [ %11, %8 ], [ -1, %6 ], [ -1, %6 ]
ret i32 %13
}