#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*/ SIGCHLD;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ err_log(int, int, char *);
int pthread_sigmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sigemptyset(int /*<<< orphan*/ *);
int _os_start_signal_handler(void) {
  sigset_t set;
  if ((sigemptyset(&set) == -1) || (sigaddset(&set, SIGINT) == -1) ||
      (sigaddset(&set, SIGHUP) == -1) || (sigaddset(&set, SIGCHLD) == -1) ||
      (sigaddset(&set, SIGTERM) == -1) || (sigaddset(&set, SIGPIPE) == -1) ||
      (pthread_sigmask(SIG_BLOCK, &set, NULL) == -1)) {
    err_log(1, 0x00000400, "Error setting signal set\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_os_start_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     1200 <_os_start_signal_handler+0xc0>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <pthread_sigmask@plt>
cmp    $0xffffffff,%eax
jne    1222 <_os_start_signal_handler+0xe2>
mov    $0x1,%edi
mov    $0x400,%esi
lea    0xdef(%rip),%rdx
call   1030 <err_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <_os_start_signal_handler+0xe9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_os_start_signal_handler>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1060 <sigaddset@plt>
cmp    $0xffffffff,%eax
je     11ec <_os_start_signal_handler+0xac>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1050 <pthread_sigmask@plt>
cmp    $0xffffffff,%eax
jne    1207 <_os_start_signal_handler+0xc7>
lea    0xe0d(%rip),%rdx
mov    $0x1,%edi
mov    $0x400,%esi
call   1030 <err_log@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SIGINT = global i32 0
@SIGHUP = global i32 0
@SIGCHLD = global i32 0
@SIGTERM = global i32 0
@SIGPIPE = global i32 0
@SIG_BLOCK = global i32 0
@.str = [26 x i8] c"Error setting signal set\0A\00"
define i32 @_os_start_signal_handler() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @sigemptyset(i32* %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %29, label %5
5: ; preds = %0
%6 = load i32, i32* @SIGINT
%7 = call i32 @sigaddset(i32* %2, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = load i32, i32* @SIGHUP
%11 = call i32 @sigaddset(i32* %2, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %29, label %13
13: ; preds = %9
%14 = load i32, i32* @SIGCHLD
%15 = call i32 @sigaddset(i32* %2, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %29, label %17
17: ; preds = %13
%18 = load i32, i32* @SIGTERM
%19 = call i32 @sigaddset(i32* %2, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i32, i32* @SIGPIPE
%23 = call i32 @sigaddset(i32* %2, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* @SIG_BLOCK
%27 = call i32 @pthread_sigmask(i32 %26, i32* %2, i32* null)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %25, %21, %17, %13, %9, %5, %0
%30 = call i32 @err_log(i32 1, i32 1024, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %32
31: ; preds = %25
store i32 0, i32* %1
br label %32
32: ; preds = %31, %29
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGHUP = global i32 0
@SIGCHLD = global i32 0
@SIGTERM = global i32 0
@SIGPIPE = global i32 0
@SIG_BLOCK = global i32 0
@.str = [26 x i8] c"Error setting signal set\0A\00"
define i32 @_os_start_signal_handler() {
%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 %29, label %5
5: ; preds = %0
%6 = load i32, i32* @SIGINT
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = load i32, i32* @SIGHUP
%11 = call i32 @sigaddset(i32* %1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %29, label %13
13: ; preds = %9
%14 = load i32, i32* @SIGCHLD
%15 = call i32 @sigaddset(i32* %1, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %29, label %17
17: ; preds = %13
%18 = load i32, i32* @SIGTERM
%19 = call i32 @sigaddset(i32* %1, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i32, i32* @SIGPIPE
%23 = call i32 @sigaddset(i32* %1, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i32, i32* @SIG_BLOCK
%27 = call i32 @pthread_sigmask(i32 %26, i32* %1, i32* null)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %25, %21, %17, %13, %9, %5, %0
%30 = call i32 @err_log(i32 1, i32 1024, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %25, %29
%32 = phi i32 [ -1, %29 ], [ 0, %25 ]
ret i32 %32
}