#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ advance();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ print_center(int /*<<< orphan*/, char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ timeout(int /*<<< orphan*/);
void confirm_exit(void) {
  int ch;
  print_center(0, "Are you sure you want to quit ? (y/n)");
  refresh();
  timeout(0);
  while ((ch = getch()) != 'n') {
    if (ch == 'y')
      exit(EXIT_SUCCESS);
  }
  advance();
}


x86 assembly (clang, -O0):
<confirm_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    0xe8f(%rip),%rsi
call   1040 <print_center@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
xor    %edi,%edi
call   1030 <timeout@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x6e,%eax
je     11b4 <confirm_exit+0x54>
cmpl   $0x79,-0x4(%rbp)
jne    11af <confirm_exit+0x4f>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1184 <confirm_exit+0x24>
mov    $0x0,%al
call   1050 <advance@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confirm_exit>:
push   %rax
lea    0xe98(%rip),%rsi
xor    %edi,%edi
call   1040 <print_center@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
xor    %edi,%edi
call   1030 <timeout@plt>
nopl   (%rax)
xor    %eax,%eax
call   1070 <getch@plt>
cmp    $0x6e,%eax
je     119f <confirm_exit+0x3f>
cmp    $0x79,%eax
jne    1180 <confirm_exit+0x20>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <advance@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Are you sure you want to quit ? (y/n)\00"
@EXIT_SUCCESS = global i32 0
define void @confirm_exit() {
%1 = alloca i32
%2 = call i32 @print_center(i32 0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @refresh()
%4 = call i32 @timeout(i32 0)
br label %5
5: ; preds = %14, %0
%6 = call i32 (...) @getch()
store i32 %6, i32* %1
%7 = icmp ne i32 %6, 110
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 121
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @EXIT_SUCCESS
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %8
br label %5
15: ; preds = %5
%16 = call i32 (...) @advance()
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Are you sure you want to quit ? (y/n)\00"
@EXIT_SUCCESS = global i32 0
define void @confirm_exit() {
%1 = tail call i32 @print_center(i32 0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @refresh()
%3 = tail call i32 @timeout(i32 0)
br label %4
4: ; preds = %4, %0
%5 = tail call i32 (...) @getch()
switch i32 %5, label %4 [
i32 110, label %9
i32 121, label %6
]
6: ; preds = %4
%7 = load i32, i32* @EXIT_SUCCESS
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %4
%10 = tail call i32 (...) @advance()
ret void
}