#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 SIGINT;
void SIG_IGN(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ signal(int, void (*)(int));
void INThandler(int sig) {
  char c;
  signal(sig, SIG_IGN);
  printf("WARNING Ctrl-C detected.\nDo you really want to quit? [y/n] ");
  c = getchar();
  if (c == 'y' || c == 'Y')
    exit(0);
  else
    signal(SIGINT, INThandler);
  getchar();
}


x86 assembly (clang, -O0):
<INThandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rsi
call   1050 <signal@plt>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
je     118a <INThandler+0x4a>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
jne    1191 <INThandler+0x51>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    0x2e2f(%rip),%rsi
call   1050 <signal@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<INThandler>:
push   %rax
mov    0x2e98(%rip),%rsi
call   1050 <signal@plt>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
and    $0xdf,%al
cmp    $0x59,%al
je     1183 <INThandler+0x43>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%rsi
call   1050 <signal@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <getchar@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"WARNING Ctrl-C detected.\0ADo you really want to quit? [y/n] \00"
@SIGINT = global i32 0
define void @INThandler(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 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %3
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 121
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 89
br i1 %14, label %15, label %17
15: ; preds = %11, %1
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %11
%18 = load i32, i32* @SIGINT
%19 = call i32 @signal(i32 %18, void (i32)* @INThandler)
br label %20
20: ; preds = %17
%21 = call signext i8 (...) @getchar()
ret void
}

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