#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*/ cbreak();
int /*<<< orphan*/ clrtoeol();
char getch();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ nocbreak();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sleep(int);
int get_confirm() {
  int confirmed = 0;
  char first_char = 'N';
  mvprintw(20, 5, "Are you sure? ");
  clrtoeol();
  refresh();
  cbreak();
  first_char = getch();
  if (first_char == 'Y' || first_char == 'y') {
    confirmed = 1;
  }
  nocbreak();
  if (!confirmed) {
    mvprintw(20, 1, "    Cancelled");
    clrtoeol();
    refresh();
    sleep(1);
  }
  return confirmed;
}


x86 assembly (clang, -O0):
<get_confirm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x4e,-0x5(%rbp)
mov    $0x14,%edi
mov    $0x5,%esi
lea    0xe6c(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1060 <clrtoeol@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
je     11d2 <get_confirm+0x62>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
jne    11d9 <get_confirm+0x69>
movl   $0x1,-0x4(%rbp)
mov    $0x0,%al
call   1070 <nocbreak@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1218 <get_confirm+0xa8>
mov    $0x14,%edi
mov    $0x1,%esi
lea    0xe14(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1060 <clrtoeol@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_confirm>:
push   %rbx
lea    0xe88(%rip),%rdx
mov    $0x14,%edi
mov    $0x5,%esi
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1060 <clrtoeol@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebx
and    $0xdf,%bl
xor    %eax,%eax
call   1070 <nocbreak@plt>
cmp    $0x59,%bl
je     11e2 <get_confirm+0x72>
lea    0xe54(%rip),%rdx
mov    $0x14,%edi
mov    $0x1,%esi
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1060 <clrtoeol@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
cmp    $0x59,%bl
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Are you sure? \00"
@.str.1 = [14 x i8] c" Cancelled\00"
define i32 @get_confirm() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
store i8 78, i8* %2
%3 = call i32 @mvprintw(i32 20, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @clrtoeol()
%5 = call i32 (...) @refresh()
%6 = call i32 (...) @cbreak()
%7 = call signext i8 (...) @getch()
store i8 %7, i8* %2
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 89
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 121
br i1 %14, label %15, label %16
15: ; preds = %11, %0
store i32 1, i32* %1
br label %16
16: ; preds = %15, %11
%17 = call i32 (...) @nocbreak()
%18 = load i32, i32* %1
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = call i32 @mvprintw(i32 20, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @clrtoeol()
%23 = call i32 (...) @refresh()
%24 = call i32 @sleep(i32 1)
br label %25
25: ; preds = %20, %16
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [15 x i8] c"Are you sure? \00"
@.str.1 = [14 x i8] c" Cancelled\00"
define i32 @get_confirm() {
%1 = tail call i32 @mvprintw(i32 20, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @clrtoeol()
%3 = tail call i32 (...) @refresh()
%4 = tail call i32 (...) @cbreak()
%5 = tail call signext i8 (...) @getch()
%6 = and i8 %5, -33
%7 = icmp eq i8 %6, 89
%8 = tail call i32 (...) @nocbreak()
br i1 %7, label %14, label %9
9: ; preds = %0
%10 = tail call i32 @mvprintw(i32 20, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 (...) @clrtoeol()
%12 = tail call i32 (...) @refresh()
%13 = tail call i32 @sleep(i32 1)
br label %14
14: ; preds = %9, %0
%15 = zext i1 %7 to i32
ret i32 %15
}