#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 /*<<< orphan*/ A_NORMAL;
int /*<<< orphan*/ A_REVERSE;
int FALSE;
#define KEY_LEFT 129
#define KEY_RIGHT 128
int TRUE;
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ del_dialog(int /*<<< orphan*/ *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ keypad(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ mvwchgat(int /*<<< orphan*/ *, int, int, int,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/ *);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *);
int /*<<< orphan*/ *new_dialog(int, int, char *);
int wgetch(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int req_confirm(char *text) {
  int height = 8, width = 32;
  WINDOW *dialog_win = new_dialog(height, width, text);
  getmaxyx(dialog_win, height, width);
  keypad(dialog_win, TRUE);
  curs_set(0);
  int no_row = height / 2, no_col = width - 4;
  mvwprintw(dialog_win, no_row, no_col, "No");
  int yes_row = height / 2, yes_col = 2;
  mvwprintw(dialog_win, yes_row, yes_col, "Yes");
  int ch, confirm = FALSE;
  do {
    mvwchgat(dialog_win, no_row, no_col, 2, confirm ? A_NORMAL : A_REVERSE, 0,
             NULL);
    mvwchgat(dialog_win, yes_row, yes_col, 3, confirm ? A_REVERSE : A_NORMAL, 0,
             NULL);
    wrefresh(dialog_win);
    switch (ch = wgetch(dialog_win)) {
    case 'y':
      return TRUE;
      break;
    case 'n':
      return FALSE;
      break;
    case KEY_LEFT:
      confirm = TRUE;
      break;
    case KEY_RIGHT:
      confirm = FALSE;
      break;
    case 27:
      del_dialog(dialog_win);
      endwin();
      exit(0);
      break;
    default:
      break;
    }
  } while (ch != 10);
  del_dialog(dialog_win);
  curs_set(1);
  return confirm;
}


x86 assembly (clang, -O0):
<req_confirm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movl   $0x20,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <new_dialog@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1070 <getmaxyx@plt>
mov    -0x20(%rbp),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
xor    %edi,%edi
call   10d0 <curs_set@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xdd3(%rip),%rcx
call   10a0 <mvwprintw@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xdab(%rip),%rcx
call   10a0 <mvwprintw@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1298 <req_confirm+0xe8>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    12a4 <req_confirm+0xf4>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%esi
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%r8d
mov    $0x2,%ecx
xor    %r9d,%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
call   1030 <mvwchgat@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     12f8 <req_confirm+0x148>
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
jmp    1304 <req_confirm+0x154>
mov    0x2ce9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%edx
mov    -0x54(%rbp),%esi
mov    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%r8d
mov    %rsp,%rax
movq   $0x0,(%rax)
mov    $0x3,%ecx
xor    %r9d,%r9d
call   1030 <mvwchgat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    -0x20(%rbp),%rdi
call   1090 <wgetch@plt>
mov    %eax,-0x34(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x68(%rbp)
sub    $0x1b,%eax
je     13dd <req_confirm+0x22d>
jmp    1351 <req_confirm+0x1a1>
mov    -0x68(%rbp),%eax
sub    $0x6e,%eax
je     13aa <req_confirm+0x1fa>
jmp    1362 <req_confirm+0x1b2>
mov    -0x68(%rbp),%eax
sub    $0x79,%eax
je     1399 <req_confirm+0x1e9>
jmp    1373 <req_confirm+0x1c3>
mov    -0x68(%rbp),%eax
sub    $0x80,%eax
je     13cc <req_confirm+0x21c>
jmp    1386 <req_confirm+0x1d6>
mov    -0x68(%rbp),%eax
sub    $0x81,%eax
je     13bb <req_confirm+0x20b>
jmp    13f4 <req_confirm+0x244>
mov    0x2c40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1421 <req_confirm+0x271>
mov    0x2c17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1421 <req_confirm+0x271>
mov    0x2c1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    13f9 <req_confirm+0x249>
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    13f9 <req_confirm+0x249>
mov    -0x20(%rbp),%rdi
call   10b0 <del_dialog@plt>
mov    $0x0,%al
call   1080 <endwin@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    13f9 <req_confirm+0x249>
jmp    13fe <req_confirm+0x24e>
cmpl   $0xa,-0x34(%rbp)
jne    1269 <req_confirm+0xb9>
mov    -0x20(%rbp),%rdi
call   10b0 <del_dialog@plt>
mov    $0x1,%edi
call   10d0 <curs_set@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<req_confirm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rdx
mov    $0x8,%edi
mov    $0x20,%esi
call   1060 <new_dialog@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x8,%esi
mov    $0x20,%edx
call   1070 <getmaxyx@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <keypad@plt>
xor    %edi,%edi
call   10d0 <curs_set@plt>
lea    0xe4f(%rip),%rcx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1c,%edx
call   10a0 <mvwprintw@plt>
lea    0xe39(%rip),%rcx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   10a0 <mvwprintw@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%ebp
mov    0x2dac(%rip),%r12
mov    0x2d8d(%rip),%r15
lea    0xdb6(%rip),%r14
jmp    1262 <req_confirm+0xb2>
nopl   0x0(%rax)
mov    0x2d89(%rip),%rcx
mov    (%rcx),%ebp
cmp    $0xa,%eax
je     1309 <req_confirm+0x159>
test   %ebp,%ebp
mov    %r12,%rax
cmove  %r15,%rax
mov    (%rax),%r8d
mov    %r15,%r13
cmove  %r12,%r13
movq   $0x0,(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1c,%edx
mov    $0x2,%ecx
xor    %r9d,%r9d
call   1030 <mvwchgat@plt>
mov    0x0(%r13),%r8d
movq   $0x0,(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
xor    %r9d,%r9d
call   1030 <mvwchgat@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    %rbx,%rdi
call   1090 <wgetch@plt>
lea    -0x6e(%rax),%ecx
cmp    $0x13,%ecx
ja     12ea <req_confirm+0x13a>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    0x2ce3(%rip),%rcx
jmp    1257 <req_confirm+0xa7>
cmp    $0x1b,%eax
jne    1259 <req_confirm+0xa9>
mov    %rbx,%rdi
call   10b0 <del_dialog@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    %rbx,%rdi
call   10b0 <del_dialog@plt>
mov    $0x1,%edi
call   10d0 <curs_set@plt>
jmp    132f <req_confirm+0x17f>
mov    0x2ca4(%rip),%rax
jmp    132d <req_confirm+0x17d>
mov    0x2cb3(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TRUE = global i32 0
@.str = [3 x i8] c"No\00"
@.str.1 = [4 x i8] c"Yes\00"
@FALSE = global i32 0
@A_NORMAL = global i32 0
@A_REVERSE = global i32 0
define i32 @req_confirm(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %3
store i32 8, i32* %4
store i32 32, i32* %5
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = load i8*, i8** %3
%16 = call i32* @new_dialog(i32 %13, i32 %14, i8* %15)
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @getmaxyx(i32* %17, i32 %18, i32 %19)
%21 = load i32*, i32** %6
%22 = load i32, i32* @TRUE
%23 = call i32 @keypad(i32* %21, i32 %22)
%24 = call i32 @curs_set(i32 0)
%25 = load i32, i32* %4
%26 = sdiv i32 %25, 2
store i32 %26, i32* %7
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 4
store i32 %28, i32* %8
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @mvwprintw(i32* %29, i32 %30, i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* %4
%34 = sdiv i32 %33, 2
store i32 %34, i32* %9
store i32 2, i32* %10
%35 = load i32*, i32** %6
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = call i32 @mvwprintw(i32* %35, i32 %36, i32 %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @FALSE
store i32 %39, i32* %12
br label %40
40: ; preds = %84, %1
%41 = load i32*, i32** %6
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %12
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = load i32, i32* @A_NORMAL
br label %50
48: ; preds = %40
%49 = load i32, i32* @A_REVERSE
br label %50
50: ; preds = %48, %46
%51 = phi i32 [ %47, %46 ], [ %49, %48 ]
%52 = call i32 @mvwchgat(i32* %41, i32 %42, i32 %43, i32 2, i32 %51, i32 0, i32* null)
%53 = load i32*, i32** %6
%54 = load i32, i32* %9
%55 = load i32, i32* %10
%56 = load i32, i32* %12
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %50
%59 = load i32, i32* @A_REVERSE
br label %62
60: ; preds = %50
%61 = load i32, i32* @A_NORMAL
br label %62
62: ; preds = %60, %58
%63 = phi i32 [ %59, %58 ], [ %61, %60 ]
%64 = call i32 @mvwchgat(i32* %53, i32 %54, i32 %55, i32 3, i32 %63, i32 0, i32* null)
%65 = load i32*, i32** %6
%66 = call i32 @wrefresh(i32* %65)
%67 = load i32*, i32** %6
%68 = call i32 @wgetch(i32* %67)
store i32 %68, i32* %11
switch i32 %68, label %82 [
i32 121, label %69
i32 110, label %71
i32 129, label %73
i32 128, label %75
i32 27, label %77
]
69: ; preds = %62
%70 = load i32, i32* @TRUE
store i32 %70, i32* %2
br label %92
71: ; preds = %62
%72 = load i32, i32* @FALSE
store i32 %72, i32* %2
br label %92
73: ; preds = %62
%74 = load i32, i32* @TRUE
store i32 %74, i32* %12
br label %83
75: ; preds = %62
%76 = load i32, i32* @FALSE
store i32 %76, i32* %12
br label %83
77: ; preds = %62
%78 = load i32*, i32** %6
%79 = call i32 @del_dialog(i32* %78)
%80 = call i32 (...) @endwin()
%81 = call i32 @exit(i32 0)
unreachable
82: ; preds = %62
br label %83
83: ; preds = %82, %75, %73
br label %84
84: ; preds = %83
%85 = load i32, i32* %11
%86 = icmp ne i32 %85, 10
br i1 %86, label %40, label %87
87: ; preds = %84
%88 = load i32*, i32** %6
%89 = call i32 @del_dialog(i32* %88)
%90 = call i32 @curs_set(i32 1)
%91 = load i32, i32* %12
store i32 %91, i32* %2
br label %92
92: ; preds = %87, %71, %69
%93 = load i32, i32* %2
ret i32 %93
}

LLVM IR (-O2):
@TRUE = global i32 0
@.str = [3 x i8] c"No\00"
@.str.1 = [4 x i8] c"Yes\00"
@FALSE = global i32 0
@A_NORMAL = global i32 0
@A_REVERSE = global i32 0
define i32 @req_confirm(i8* %0) {
%2 = tail call i32* @new_dialog(i32 8, i32 32, i8* %0)
%3 = tail call i32 @getmaxyx(i32* %2, i32 8, i32 32)
%4 = load i32, i32* @TRUE
%5 = tail call i32 @keypad(i32* %2, i32 %4)
%6 = tail call i32 @curs_set(i32 0)
%7 = tail call i32 @mvwprintw(i32* %2, i32 4, i32 28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @mvwprintw(i32* %2, i32 4, i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @FALSE
br label %10
10: ; preds = %35, %1
%11 = phi i32 [ %9, %1 ], [ %36, %35 ]
%12 = icmp eq i32 %11, 0
%13 = load i32, i32* @A_NORMAL
%14 = load i32, i32* @A_REVERSE
%15 = select i1 %12, i32 %14, i32 %13
%16 = tail call i32 @mvwchgat(i32* %2, i32 4, i32 28, i32 2, i32 %15, i32 0, i32* null)
%17 = load i32, i32* @A_REVERSE
%18 = load i32, i32* @A_NORMAL
%19 = select i1 %12, i32 %18, i32 %17
%20 = tail call i32 @mvwchgat(i32* %2, i32 4, i32 2, i32 3, i32 %19, i32 0, i32* null)
%21 = tail call i32 @wrefresh(i32* %2)
%22 = tail call i32 @wgetch(i32* %2)
switch i32 %22, label %35 [
i32 121, label %23
i32 110, label %25
i32 129, label %27
i32 128, label %29
i32 27, label %31
]
23: ; preds = %10
%24 = load i32, i32* @TRUE
br label %41
25: ; preds = %10
%26 = load i32, i32* @FALSE
br label %41
27: ; preds = %10
%28 = load i32, i32* @TRUE
br label %35
29: ; preds = %10
%30 = load i32, i32* @FALSE
br label %35
31: ; preds = %10
%32 = tail call i32 @del_dialog(i32* %2)
%33 = tail call i32 (...) @endwin()
%34 = tail call i32 @exit(i32 0)
unreachable
35: ; preds = %27, %29, %10
%36 = phi i32 [ %11, %10 ], [ %30, %29 ], [ %28, %27 ]
%37 = icmp eq i32 %22, 10
br i1 %37, label %38, label %10
38: ; preds = %35
%39 = tail call i32 @del_dialog(i32* %2)
%40 = tail call i32 @curs_set(i32 1)
br label %41
41: ; preds = %38, %25, %23
%42 = phi i32 [ %36, %38 ], [ %26, %25 ], [ %24, %23 ]
ret i32 %42
}