#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 SIGINT;
void SIG_IGN(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
int /*<<< orphan*/ signal(int, void (*)(int));
int /*<<< orphan*/ stdout;
void int_handler(int sig) {
  signal(sig, SIG_IGN);
  fprintf(stdout, "\nDo you really want to quit? [y/n] ");
  char c = getchar();
  if ('y' == c || 'Y' == c)
    exit(EXIT_SUCCESS);
  else
    signal(SIGINT, int_handler);
  getchar();
}


x86 assembly (clang, -O0):
<int_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e83(%rip),%rsi
call   1040 <signal@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
mov    $0x79,%eax
cmp    %ecx,%eax
je     119b <int_handler+0x5b>
movsbl -0x5(%rbp),%ecx
mov    $0x59,%eax
cmp    %ecx,%eax
jne    11a9 <int_handler+0x69>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    0x2e27(%rip),%rsi
call   1040 <signal@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_handler>:
push   %rax
mov    0x2e90(%rip),%rsi
call   1040 <signal@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <getchar@plt>
and    $0xdf,%al
cmp    $0x59,%al
je     118c <int_handler+0x4c>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rsi
call   1040 <signal@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <getchar@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [36 x i8] c"\0ADo you really want to quit? [y/n] \00"
@EXIT_SUCCESS = global i32 0
@SIGINT = global i32 0
define void @int_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @signal(i32 %4, void (i32)* @SIG_IGN)
%6 = load i32, i32* @stdout
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %3
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 121, %10
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 89, %14
br i1 %15, label %16, label %19
16: ; preds = %12, %1
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %12
%20 = load i32, i32* @SIGINT
%21 = call i32 @signal(i32 %20, void (i32)* @int_handler)
br label %22
22: ; preds = %19
%23 = call signext i8 (...) @getchar()
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [36 x i8] c"\0ADo you really want to quit? [y/n] \00"
@EXIT_SUCCESS = global i32 0
@SIGINT = global i32 0
define void @int_handler(i32 %0) {
%2 = tail call i32 @signal(i32 %0, void (i32)* @SIG_IGN)
%3 = load i32, i32* @stdout
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = tail call signext i8 (...) @getchar()
%6 = and i8 %5, -33
%7 = icmp eq i8 %6, 89
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @EXIT_SUCCESS
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = load i32, i32* @SIGINT
%13 = tail call i32 @signal(i32 %12, void (i32)* @int_handler)
%14 = tail call signext i8 (...) @getchar()
ret void
}