#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 */
struct gopherusconfig {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ draw_statusbar(char *, struct gopherusconfig *);
int ui_getkey();
int ask_quit_confirmation(struct gopherusconfig *cfg) {
  int keypress;
  char msg[] = "!YOU ARE ABOUT TO QUIT. PRESS ESC TO CONFIRM, OR ANY OTHER KEY "
               "TO ABORT.";
  draw_statusbar(msg, cfg);
  do {
    keypress = ui_getkey();
  } while (keypress == 0x00);
  return ((keypress == 0x1B) || (keypress == 0xFF));
}


x86 assembly (clang, -O0):
<ask_quit_confirmation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x49,%edx
call   1040 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <draw_statusbar@plt>
mov    $0x0,%al
call   1050 <ui_getkey@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     115e <ask_quit_confirmation+0x2e>
mov    $0x1,%al
cmpl   $0x1b,-0xc(%rbp)
mov    %al,-0x61(%rbp)
je     118e <ask_quit_confirmation+0x5e>
cmpl   $0xff,-0xc(%rbp)
sete   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_quit_confirmation>:
sub    $0x58,%rsp
mov    %rdi,%rsi
movups 0xf0b(%rip),%xmm0
movups %xmm0,0x39(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <draw_statusbar@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <ui_getkey@plt>
test   %eax,%eax
je     1170 <ask_quit_confirmation+0x50>
cmp    $0x1b,%eax
sete   %cl
cmp    $0xff,%eax
sete   %al
or     %cl,%al
movzbl %al,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
%struct.gopherusconfig = type { i32 }
@__const.ask_quit_confirmation.msg = [73 x i8] c"!YOU ARE ABOUT TO QUIT. PRESS ESC TO CONFIRM, OR ANY OTHER KEY TO ABORT.\00"
define i32 @ask_quit_confirmation(%struct.gopherusconfig* %0) {
%2 = alloca %struct.gopherusconfig*
%3 = alloca i32
%4 = alloca [73 x i8]
store %struct.gopherusconfig* %0, %struct.gopherusconfig** %2
%5 = bitcast [73 x i8]* %4 to i8*
%6 = getelementptr inbounds [73 x i8], [73 x i8]* %4, i64 0, i64 0
%7 = load %struct.gopherusconfig*, %struct.gopherusconfig** %2
%8 = call i32 @draw_statusbar(i8* %6, %struct.gopherusconfig* %7)
br label %9
9: ; preds = %11, %1
%10 = call i32 (...) @ui_getkey()
store i32 %10, i32* %3
br label %11
11: ; preds = %9
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %9, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 27
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 255
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ true, %14 ], [ %19, %17 ]
%22 = zext i1 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.gopherusconfig = type { i32 }
@__const.ask_quit_confirmation.msg = [73 x i8] c"!YOU ARE ABOUT TO QUIT. PRESS ESC TO CONFIRM, OR ANY OTHER KEY TO ABORT.\00"
define i32 @ask_quit_confirmation(%struct.gopherusconfig* %0) {
%2 = alloca [73 x i8]
%3 = getelementptr inbounds [73 x i8], [73 x i8]* %2, i64 0, i64 0
%4 = call i32 @draw_statusbar(i8* %3, %struct.gopherusconfig* %0)
br label %5
5: ; preds = %5, %1
%6 = call i32 (...) @ui_getkey()
%7 = icmp eq i32 %6, 0
br i1 %7, label %5, label %8
8: ; preds = %5
%9 = icmp eq i32 %6, 27
%10 = icmp eq i32 %6, 255
%11 = or i1 %9, %10
%12 = zext i1 %11 to i32
ret i32 %12
}