#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 /*<<< orphan*/ WINDOW;

/* Variables and functions */
int FALSE;
int TRUE;
int /*<<< orphan*/ getyx(int /*<<< orphan*/ *, int, int);
int readchar();
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, char);
int /*<<< orphan*/ waddstr(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int get_bool(void *vp, WINDOW *win) {
  bool *bp = (bool *)vp;
  int oy, ox;
  bool op_bad;
  op_bad = TRUE;
  getyx(win, oy, ox);
  waddstr(win, *bp ? "True" : "False");
  while (op_bad) {
    wmove(win, oy, ox);
    wrefresh(win);
    switch (readchar()) {
    case 't':
    case 'T':
      *bp = TRUE;
      op_bad = FALSE;
      break;
    case 'f':
    case 'F':
      *bp = FALSE;
      op_bad = FALSE;
      break;
    case '\n':
    case '\r':
      op_bad = FALSE;
      break;
    case 27:
      return 1;
    case '-':
      return 2;
    default:
      wmove(win, oy, ox + 10);
      waddstr(win, "(T or F)");
    }
  }
  wmove(win, oy, ox);
  waddstr(win, *bp ? "True" : "False");
  waddch(win, '\n');
  return 0;
}


x86 assembly (clang, -O0):
<get_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1060 <getyx@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
lea    0xe61(%rip),%rsi
lea    0xe55(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1030 <waddstr@plt>
cmpl   $0x0,-0x2c(%rbp)
je     12fa <get_bool+0x19a>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1080 <wmove@plt>
mov    -0x18(%rbp),%rdi
call   1070 <wrefresh@plt>
xor    %eax,%eax
call   1040 <readchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x30(%rbp)
sub    $0xa,%eax
je     12aa <get_bool+0x14a>
jmp    11f3 <get_bool+0x93>
mov    -0x30(%rbp),%eax
sub    $0xd,%eax
je     12aa <get_bool+0x14a>
jmp    1204 <get_bool+0xa4>
mov    -0x30(%rbp),%eax
sub    $0x1b,%eax
je     12bb <get_bool+0x15b>
jmp    1215 <get_bool+0xb5>
mov    -0x30(%rbp),%eax
sub    $0x2d,%eax
je     12c7 <get_bool+0x167>
jmp    1226 <get_bool+0xc6>
mov    -0x30(%rbp),%eax
sub    $0x46,%eax
je     128a <get_bool+0x12a>
jmp    1237 <get_bool+0xd7>
mov    -0x30(%rbp),%eax
sub    $0x54,%eax
je     126a <get_bool+0x10a>
jmp    1248 <get_bool+0xe8>
mov    -0x30(%rbp),%eax
sub    $0x66,%eax
je     128a <get_bool+0x12a>
jmp    1259 <get_bool+0xf9>
mov    -0x30(%rbp),%eax
sub    $0x74,%eax
jne    12d3 <get_bool+0x173>
jmp    126a <get_bool+0x10a>
mov    0x2d77(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    12f5 <get_bool+0x195>
mov    0x2d47(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    12f5 <get_bool+0x195>
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    12f5 <get_bool+0x195>
movl   $0x1,-0x4(%rbp)
jmp    1342 <get_bool+0x1e2>
movl   $0x2,-0x4(%rbp)
jmp    1342 <get_bool+0x1e2>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
add    $0xa,%edx
call   1080 <wmove@plt>
mov    -0x18(%rbp),%rdi
lea    0xd1b(%rip),%rsi
call   1030 <waddstr@plt>
jmp    11b7 <get_bool+0x57>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1080 <wmove@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
lea    0xceb(%rip),%rsi
lea    0xcdf(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1030 <waddstr@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1050 <waddch@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_bool>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e70(%rip),%rax
mov    (%rax),%r13d
mov    %rsi,%rdi
call   1060 <getyx@plt>
cmpl   $0x0,(%r14)
lea    0xf07(%rip),%rax
lea    0xefb(%rip),%r15
mov    %r15,%rsi
cmove  %rax,%rsi
mov    %rbx,%rdi
call   1030 <waddstr@plt>
test   %r13d,%r13d
je     1247 <get_bool+0xe7>
lea    0xe4c(%rip),%r12
mov    0x2e1d(%rip),%rbp
jmp    11d5 <get_bool+0x75>
nopl   (%rax)
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
mov    0x0(%rbp),%r13d
test   %r13d,%r13d
je     1247 <get_bool+0xe7>
mov    %rbx,%rdi
call   1080 <wmove@plt>
mov    %rbx,%rdi
call   1070 <wrefresh@plt>
xor    %eax,%eax
call   1040 <readchar@plt>
cmp    $0x53,%eax
jg     1210 <get_bool+0xb0>
lea    -0xa(%rax),%ecx
cmp    $0x23,%ecx
ja     1221 <get_bool+0xc1>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x74,%eax
je     11c0 <get_bool+0x60>
cmp    $0x66,%eax
je     1226 <get_bool+0xc6>
cmp    $0x54,%eax
je     11c0 <get_bool+0x60>
jmp    122b <get_bool+0xcb>
cmp    $0x46,%eax
jne    122b <get_bool+0xcb>
mov    0x0(%rbp),%eax
jmp    11c9 <get_bool+0x69>
mov    %rbx,%rdi
call   1080 <wmove@plt>
mov    %rbx,%rdi
lea    0xe5e(%rip),%rsi
call   1030 <waddstr@plt>
test   %r13d,%r13d
jne    11d5 <get_bool+0x75>
mov    %rbx,%rdi
call   1080 <wmove@plt>
cmpl   $0x0,(%r14)
lea    0xe3b(%rip),%rax
cmove  %rax,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <waddstr@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <waddch@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    1278 <get_bool+0x118>
mov    $0x2,%eax
jmp    1278 <get_bool+0x118>

LLVM IR (-O0):
@TRUE = global i32 0
@.str = [5 x i8] c"True\00"
@.str.1 = [6 x i8] c"False\00"
@FALSE = global i32 0
@.str.2 = [9 x i8] c"(T or F)\00"
define i32 @get_bool(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %6
%12 = load i32, i32* @TRUE
store i32 %12, i32* %9
%13 = load i32*, i32** %5
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @getyx(i32* %13, i32 %14, i32 %15)
%17 = load i32*, i32** %5
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%23 = call i32 @waddstr(i32* %17, i8* %22)
br label %24
24: ; preds = %55, %2
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %56
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 @wmove(i32* %28, i32 %29, i32 %30)
%32 = load i32*, i32** %5
%33 = call i32 @wrefresh(i32* %32)
%34 = call i32 (...) @readchar()
switch i32 %34, label %47 [
i32 116, label %35
i32 84, label %35
i32 102, label %39
i32 70, label %39
i32 10, label %43
i32 13, label %43
i32 27, label %45
i32 45, label %46
]
35: ; preds = %27, %27
%36 = load i32, i32* @TRUE
%37 = load i32*, i32** %6
store i32 %36, i32* %37
%38 = load i32, i32* @FALSE
store i32 %38, i32* %9
br label %55
39: ; preds = %27, %27
%40 = load i32, i32* @FALSE
%41 = load i32*, i32** %6
store i32 %40, i32* %41
%42 = load i32, i32* @FALSE
store i32 %42, i32* %9
br label %55
43: ; preds = %27, %27
%44 = load i32, i32* @FALSE
store i32 %44, i32* %9
br label %55
45: ; preds = %27
store i32 1, i32* %3
br label %70
46: ; preds = %27
store i32 2, i32* %3
br label %70
47: ; preds = %27
%48 = load i32*, i32** %5
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 10
%52 = call i32 @wmove(i32* %48, i32 %49, i32 %51)
%53 = load i32*, i32** %5
%54 = call i32 @waddstr(i32* %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %47, %43, %39, %35
br label %24
56: ; preds = %24
%57 = load i32*, i32** %5
%58 = load i32, i32* %7
%59 = load i32, i32* %8
%60 = call i32 @wmove(i32* %57, i32 %58, i32 %59)
%61 = load i32*, i32** %5
%62 = load i32*, i32** %6
%63 = load i32, i32* %62
%64 = icmp ne i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%67 = call i32 @waddstr(i32* %61, i8* %66)
%68 = load i32*, i32** %5
%69 = call i32 @waddch(i32* %68, i8 signext 10)
store i32 0, i32* %3
br label %70
70: ; preds = %56, %46, %45
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@TRUE = global i32 0
@.str = [5 x i8] c"True\00"
@.str.1 = [6 x i8] c"False\00"
@FALSE = global i32 0
@.str.2 = [9 x i8] c"(T or F)\00"
define i32 @get_bool(i8* nocapture %0, i32* %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* @TRUE
%5 = tail call i32 @getyx(i32* %1, i32 undef, i32 undef)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%9 = tail call i32 @waddstr(i32* %1, i8* %8)
%10 = icmp eq i32 %4, 0
br i1 %10, label %30, label %11
11: ; preds = %2, %27
%12 = phi i32 [ %28, %27 ], [ %4, %2 ]
%13 = tail call i32 @wmove(i32* %1, i32 undef, i32 undef)
%14 = tail call i32 @wrefresh(i32* %1)
%15 = tail call i32 (...) @readchar()
switch i32 %15, label %24 [
i32 116, label %16
i32 84, label %16
i32 102, label %19
i32 70, label %19
i32 10, label %22
i32 13, label %22
i32 27, label %37
i32 45, label %38
]
16: ; preds = %11, %11
%17 = load i32, i32* @TRUE
store i32 %17, i32* %3
%18 = load i32, i32* @FALSE
br label %27
19: ; preds = %11, %11
%20 = load i32, i32* @FALSE
store i32 %20, i32* %3
%21 = load i32, i32* @FALSE
br label %27
22: ; preds = %11, %11
%23 = load i32, i32* @FALSE
br label %27
24: ; preds = %11
%25 = tail call i32 @wmove(i32* %1, i32 undef, i32 undef)
%26 = tail call i32 @waddstr(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %24, %22, %19, %16
%28 = phi i32 [ %12, %24 ], [ %23, %22 ], [ %21, %19 ], [ %18, %16 ]
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %11
30: ; preds = %27, %2
%31 = tail call i32 @wmove(i32* %1, i32 undef, i32 undef)
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%35 = tail call i32 @waddstr(i32* %1, i8* %34)
%36 = tail call i32 @waddch(i32* %1, i8 signext 10)
br label %38
37: ; preds = %11
br label %38
38: ; preds = %11, %37, %30
%39 = phi i32 [ 0, %30 ], [ 1, %37 ], [ 2, %11 ]
ret i32 %39
}