#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 */
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ exit_cleanup();
int /*<<< orphan*/ perror(char *);
scalar_t__ pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sigemptyset(int /*<<< orphan*/ *);
void init_signal(void) {
  sigset_t siglist;
  if (sigemptyset(&siglist) == -1) {
    perror("Unable to initialize signal list");
    exit_cleanup();
  }
  if (sigaddset(&siglist, SIGALRM) == -1) {
    perror("Unable to add SIGALRM signal to signal list");
    exit_cleanup();
  }
  if (sigaddset(&siglist, SIGINT) == -1) {
    perror("Unable to add SIGINT signal to signal list");
    exit_cleanup();
  }
  if (pthread_sigmask(SIG_BLOCK, &siglist, NULL) != 0) {
    perror("Unable to change signal mask");
    exit_cleanup();
  }
}


x86 assembly (clang, -O0):
<init_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1030 <sigemptyset@plt>
cmp    $0xffffffff,%eax
jne    117d <init_signal+0x2d>
lea    0xe8f(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1060 <exit_cleanup@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1070 <sigaddset@plt>
cmp    $0xffffffff,%eax
jne    11ab <init_signal+0x5b>
lea    0xe82(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1060 <exit_cleanup@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1070 <sigaddset@plt>
cmp    $0xffffffff,%eax
jne    11d9 <init_signal+0x89>
lea    0xe80(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1060 <exit_cleanup@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <pthread_sigmask@plt>
cmp    $0x0,%rax
je     120c <init_signal+0xbc>
lea    0xe78(%rip),%rdi
call   1050 <perror@plt>
mov    $0x0,%al
call   1060 <exit_cleanup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_signal>:
push   %rax
lea    0x4(%rsp),%rdi
call   1030 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     11ac <init_signal+0x5c>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdi
call   1070 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11c1 <init_signal+0x71>
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdi
call   1070 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11d6 <init_signal+0x86>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1040 <pthread_sigmask@plt>
test   %rax,%rax
jne    11eb <init_signal+0x9b>
pop    %rax
ret
lea    0xe4d(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1060 <exit_cleanup@plt>
jmp    1160 <init_signal+0x10>
lea    0xe59(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1060 <exit_cleanup@plt>
jmp    1178 <init_signal+0x28>
lea    0xe70(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1060 <exit_cleanup@plt>
jmp    1190 <init_signal+0x40>
lea    0xe86(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
call   1060 <exit_cleanup@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Unable to initialize signal list\00"
@SIGALRM = global i32 0
@.str.1 = [44 x i8] c"Unable to add SIGALRM signal to signal list\00"
@SIGINT = global i32 0
@.str.2 = [43 x i8] c"Unable to add SIGINT signal to signal list\00"
@SIG_BLOCK = global i32 0
@.str.3 = [29 x i8] c"Unable to change signal mask\00"
define void @init_signal() {
%1 = alloca i32
%2 = call i32 @sigemptyset(i32* %1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @exit_cleanup()
br label %7
7: ; preds = %4, %0
%8 = load i32, i32* @SIGALRM
%9 = call i32 @sigaddset(i32* %1, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @exit_cleanup()
br label %14
14: ; preds = %11, %7
%15 = load i32, i32* @SIGINT
%16 = call i32 @sigaddset(i32* %1, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @exit_cleanup()
br label %21
21: ; preds = %18, %14
%22 = load i32, i32* @SIG_BLOCK
%23 = call i64 @pthread_sigmask(i32 %22, i32* %1, i32* null)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (...) @exit_cleanup()
br label %28
28: ; preds = %25, %21
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Unable to initialize signal list\00"
@SIGALRM = global i32 0
@.str.1 = [44 x i8] c"Unable to add SIGALRM signal to signal list\00"
@SIGINT = global i32 0
@.str.2 = [43 x i8] c"Unable to add SIGINT signal to signal list\00"
@SIG_BLOCK = global i32 0
@.str.3 = [29 x i8] c"Unable to change signal mask\00"
define void @init_signal() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @exit_cleanup()
br label %8
8: ; preds = %5, %0
%9 = load i32, i32* @SIGALRM
%10 = call i32 @sigaddset(i32* %1, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @exit_cleanup()
br label %15
15: ; preds = %12, %8
%16 = load i32, i32* @SIGINT
%17 = call i32 @sigaddset(i32* %1, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (...) @exit_cleanup()
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* @SIG_BLOCK
%24 = call i64 @pthread_sigmask(i32 %23, i32* %1, i32* null)
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (...) @exit_cleanup()
br label %29
29: ; preds = %26, %22
ret void
}