#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 sigHandler(int sig) {
  char c = '\0';
  signal(sig, SIG_IGN);
  printf("\nCtrl-C pressed!!\n");
  printf("Do you really want to quite [y/n]?\n");
  c = getchar();
  if (c == 'y' || c == 'Y')
    exit(0);
  else
    signal(SIGINT, sigHandler);
}


x86 assembly (clang, -O0):
<sigHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7f(%rip),%rsi
call   1050 <signal@plt>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%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     119a <sigHandler+0x5a>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
jne    11a1 <sigHandler+0x61>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    0x2e37(%rip),%rsi
call   1050 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigHandler>:
push   %rax
mov    0x2e90(%rip),%rsi
call   1050 <signal@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
and    $0xdf,%al
cmp    $0x59,%al
je     1188 <sigHandler+0x48>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    0x2e66(%rip),%rsi
pop    %rax
jmp    1050 <signal@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"\0ACtrl-C pressed!!\0A\00"
@.str.1 = [36 x i8] c"Do you really want to quite [y/n]?\0A\00"
@SIGINT = global i32 0
define void @sigHandler(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %3
%4 = load i32, i32* %2
%5 = call i32 @signal(i32 %4, void (i32)* @SIG_IGN)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, 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 %10, 121
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 %14, 89
br i1 %15, label %16, label %18
16: ; preds = %12, %1
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %12
%19 = load i32, i32* @SIGINT
%20 = call i32 @signal(i32 %19, void (i32)* @sigHandler)
br label %21
21: ; preds = %18
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@str = [18 x i8] c"\0ACtrl-C pressed!!\00"
@str.2 = [35 x i8] c"Do you really want to quite [y/n]?\00"
define void @sigHandler(i32 %0) {
%2 = tail call i32 @signal(i32 %0, void (i32)* @SIG_IGN)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.2, 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 %10
8: ; preds = %1
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %1
%11 = load i32, i32* @SIGINT
%12 = tail call i32 @signal(i32 %11, void (i32)* @sigHandler)
ret void
}