#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*/ clrscr();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ gotoxy(int, int);
int /*<<< orphan*/ printf(char *);
char tolower(char);
char waitForAnyKey();
void exitYN(void) {
  char pressed;
  gotoxy(9, 8);
  printf("Are you sure you want to exit(Y/N)\n");
  do {
    pressed = waitForAnyKey();
    pressed = tolower(pressed);
  } while (!(pressed == 'y' || pressed == 'n'));
  if (pressed == 'y') {
    clrscr();
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<exitYN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x9,%edi
mov    $0x8,%esi
call   1070 <gotoxy@plt>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <waitForAnyKey@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x2(%rbp)
je     11b8 <exitYN+0x58>
movsbl -0x1(%rbp),%eax
cmp    $0x6e,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    1183 <exitYN+0x23>
movsbl -0x1(%rbp),%eax
cmp    $0x79,%eax
jne    11e3 <exitYN+0x83>
mov    $0x0,%al
call   1030 <clrscr@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exitYN>:
push   %rax
mov    $0x9,%edi
mov    $0x8,%esi
call   1070 <gotoxy@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <waitForAnyKey@plt>
movsbl %al,%edi
call   1060 <tolower@plt>
cmp    $0x6e,%al
je     11a8 <exitYN+0x48>
cmp    $0x79,%al
jne    1180 <exitYN+0x20>
xor    %eax,%eax
call   1030 <clrscr@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Are you sure you want to exit(Y/N)\0A\00"
define void @exitYN() {
%1 = alloca i8
%2 = call i32 @gotoxy(i32 9, i32 8)
%3 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %16, %0
%5 = call signext i8 (...) @waitForAnyKey()
store i8 %5, i8* %1
%6 = load i8, i8* %1
%7 = call signext i8 @tolower(i8 signext %6)
store i8 %7, i8* %1
br label %8
8: ; preds = %4
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 121
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 110
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ true, %8 ], [ %15, %12 ]
%18 = xor i1 %17, true
br i1 %18, label %4, label %19
19: ; preds = %16
%20 = load i8, i8* %1
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 121
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 (...) @clrscr()
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
ret void
}

LLVM IR (-O2):
@str = [35 x i8] c"Are you sure you want to exit(Y/N)\00"
define void @exitYN() {
%1 = tail call i32 @gotoxy(i32 9, i32 8)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %3, %0
%4 = tail call signext i8 (...) @waitForAnyKey()
%5 = tail call signext i8 @tolower(i8 signext %4)
switch i8 %5, label %3 [
i8 121, label %6
i8 110, label %9
]
6: ; preds = %3
%7 = tail call i32 (...) @clrscr()
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %3
ret void
}