#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(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
void ask_exit() {
  while (1) {
    char ans;
    printf("Exit?(y/n) : ");
    scanf(" %c", &ans);
    if (ans == 'Y' || ans == 'y')
      exit(1);
    else if (ans == 'N' || ans == 'n')
      break;
    else
      printf("Wrong input\n");
  }
}


x86 assembly (clang, -O0):
<ask_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x59,%eax
je     116e <ask_exit+0x3e>
movsbl -0x1(%rbp),%eax
cmp    $0x79,%eax
jne    1178 <ask_exit+0x48>
mov    $0x1,%edi
call   1050 <exit@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x4e,%eax
je     1192 <ask_exit+0x62>
movsbl -0x1(%rbp),%eax
cmp    $0x6e,%eax
jne    1197 <ask_exit+0x67>
jmp    11ad <ask_exit+0x7d>
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <ask_exit+0x78>
jmp    1138 <ask_exit+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_exit>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%r14
lea    0xeb8(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xeb0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0x7(%rsp),%eax
and    $0xdf,%al
cmp    $0x4e,%al
je     119c <ask_exit+0x5c>
cmp    $0x59,%al
je     11a8 <ask_exit+0x68>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1170 <ask_exit+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Exit?(y/n) : \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [13 x i8] c"Wrong input\0A\00"
define void @ask_exit() {
%1 = alloca i8
br label %2
2: ; preds = %0, %26
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 89
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 121
br i1 %11, label %12, label %14
12: ; preds = %8, %2
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %8
%15 = load i8, i8* %1
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 78
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8, i8* %1
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 110
br i1 %21, label %22, label %23
22: ; preds = %18, %14
br label %27
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23
br label %26
26: ; preds = %25
br label %2
27: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Exit?(y/n) : \00"
@.str.1 = [4 x i8] c" %c\00"
@str = [12 x i8] c"Wrong input\00"
define void @ask_exit() {
%1 = alloca i8
br label %2
2: ; preds = %9, %0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = load i8, i8* %1
%6 = and i8 %5, -33
switch i8 %6, label %9 [
i8 89, label %7
i8 78, label %11
]
7: ; preds = %2
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %2
11: ; preds = %2
ret void
}