#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 signal_handler(int sig) {
  char c;
  signal(sig, SIG_IGN);
  fprintf(stdout, "\nquit server? [y/N] ");
  c = getchar();
  if (c == 'y' || c == 'Y') {
    exit(EXIT_SUCCESS);
  }
  signal(SIGINT, signal_handler);
}


x86 assembly (clang, -O0):
<signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%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),%eax
cmp    $0x79,%eax
je     1193 <signal_handler+0x53>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
jne    11a1 <signal_handler+0x61>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    0x2e1f(%rip),%rsi
call   1040 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_handler>:
push   %rax
mov    0x2e98(%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     1185 <signal_handler+0x45>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e51(%rip),%rsi
pop    %rax
jmp    1040 <signal@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [21 x i8] c"\0Aquit server? [y/N] \00"
@EXIT_SUCCESS = global i32 0
@SIGINT = global i32 0
define void @signal_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 ([21 x i8], [21 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 %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 %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)* @signal_handler)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [21 x i8] c"\0Aquit server? [y/N] \00"
@EXIT_SUCCESS = global i32 0
@SIGINT = global i32 0
define void @signal_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 ([21 x i8], [21 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)* @signal_handler)
ret void
}