#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*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
scalar_t__ SIG_ERR;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ signal(int /*<<< orphan*/, void (*)(int));
int /*<<< orphan*/ stderr;
main() {
  int *y;
  void my_int_handler(int);
  void my_quit_handler(int);
  if (signal(SIGINT, my_int_handler) == SIG_ERR) {
    fprintf(stderr, "signal handler registration failed\n");
    exit(1);
  }
  if (signal(SIGQUIT, my_quit_handler) == SIG_ERR) {
    fprintf(stderr, "signal handler registration failed\n");
    exit(1);
  }
  while (1)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rsi
call   1030 <signal@plt>
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
jne    1183 <main+0x53>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    0x2e5d(%rip),%rsi
call   1030 <signal@plt>
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%rax
jne    11c7 <main+0x97>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11cc <main+0x9c>
jmp    11cc <main+0x9c>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
mov    0x2e77(%rip),%rsi
call   1030 <signal@plt>
mov    0x2e73(%rip),%rbx
cmp    (%rbx),%rax
je     1172 <main+0x42>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    0x2e8e(%rip),%rsi
call   1030 <signal@plt>
cmp    (%rbx),%rax
je     1172 <main+0x42>
nopl   0x0(%rax)
jmp    1170 <main+0x40>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [36 x i8] c"signal handler registration failed\0A\00"
@SIGQUIT = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = load i32, i32* @SIGINT
%4 = call i64 @signal(i32 %3, void (i32)* @my_int_handler)
%5 = load i64, i64* @SIG_ERR
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i32, i32* @SIGQUIT
%13 = call i64 @signal(i32 %12, void (i32)* @my_quit_handler)
%14 = load i64, i64* @SIG_ERR
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %11
br label %21
21: ; preds = %20, %21
br label %21
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIG_ERR = global i64 0
@stderr = global i32 0
@.str = [36 x i8] c"signal handler registration failed\0A\00"
@SIGQUIT = global i32 0
define i32 @main() {
%1 = load i32, i32* @SIGINT
%2 = tail call i64 @signal(i32 %1, void (i32)* @my_int_handler)
%3 = load i64, i64* @SIG_ERR
%4 = icmp eq i64 %2, %3
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i32, i32* @SIGQUIT
%11 = tail call i64 @signal(i32 %10, void (i32)* @my_quit_handler)
%12 = load i64, i64* @SIG_ERR
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9, %18
br label %18
}