#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 */
struct sigaction {
  void (*sa_handler)(int);
  int sa_flags;
  int /*<<< orphan*/ sa_mask;
};

/* Variables and functions */
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
void sighandleall(void (*handler)(int), int flags) {
  struct sigaction act = {.sa_handler = handler, .sa_flags = flags};
  sigfillset(&act.sa_mask);
  if (sigaction(SIGINT, &act, NULL) || sigaction(SIGQUIT, &act, NULL) ||
      sigaction(SIGTERM, &act, NULL) || sigaction(SIGCHLD, &act, NULL) ||
      sigaction(SIGHUP, &act, NULL) || sigaction(SIGUSR1, &act, NULL) ||
      sigaction(SIGUSR2, &act, NULL) || sigaction(SIGPIPE, &act, NULL)) {
    do {
      perror("sigaction");
      exit(1);
    } while (0);
  }
}


x86 assembly (clang, -O0):
<sighandleall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
add    $0xc,%rdi
call   1040 <sigfillset@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jne    1271 <sighandleall+0x131>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
je     128c <sighandleall+0x14c>
jmp    1276 <sighandleall+0x136>
lea    0xd83(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sighandleall>:
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
mov    %esi,0x10(%rsp)
lea    0x14(%rsp),%rdi
movl   $0x0,0x14(%rsp)
call   1040 <sigfillset@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jne    1240 <sighandleall+0x100>
add    $0x18,%rsp
ret
lea    0xdb9(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i32, i32 }
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
@SIGCHLD = global i32 0
@SIGHUP = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGPIPE = global i32 0
@.str = [10 x i8] c"sigaction\00"
define void @sighandleall(void (i32)* %0, i32 %1) {
%3 = alloca void (i32)*
%4 = alloca i32
%5 = alloca %struct.sigaction
store void (i32)* %0, void (i32)** %3
store i32 %1, i32* %4
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 0
%7 = load void (i32)*, void (i32)** %3
store void (i32)* %7, void (i32)** %6
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 1
%9 = load i32, i32* %4
store i32 %9, i32* %8
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 2
store i32 0, i32* %10
%11 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 2
%12 = call i32 @sigfillset(i32* %11)
%13 = load i32, i32* @SIGINT
%14 = call i64 @sigaction(i32 %13, %struct.sigaction* %5, i32* null)
%15 = icmp ne i64 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %2
%17 = load i32, i32* @SIGQUIT
%18 = call i64 @sigaction(i32 %17, %struct.sigaction* %5, i32* null)
%19 = icmp ne i64 %18, 0
br i1 %19, label %44, label %20
20: ; preds = %16
%21 = load i32, i32* @SIGTERM
%22 = call i64 @sigaction(i32 %21, %struct.sigaction* %5, i32* null)
%23 = icmp ne i64 %22, 0
br i1 %23, label %44, label %24
24: ; preds = %20
%25 = load i32, i32* @SIGCHLD
%26 = call i64 @sigaction(i32 %25, %struct.sigaction* %5, i32* null)
%27 = icmp ne i64 %26, 0
br i1 %27, label %44, label %28
28: ; preds = %24
%29 = load i32, i32* @SIGHUP
%30 = call i64 @sigaction(i32 %29, %struct.sigaction* %5, i32* null)
%31 = icmp ne i64 %30, 0
br i1 %31, label %44, label %32
32: ; preds = %28
%33 = load i32, i32* @SIGUSR1
%34 = call i64 @sigaction(i32 %33, %struct.sigaction* %5, i32* null)
%35 = icmp ne i64 %34, 0
br i1 %35, label %44, label %36
36: ; preds = %32
%37 = load i32, i32* @SIGUSR2
%38 = call i64 @sigaction(i32 %37, %struct.sigaction* %5, i32* null)
%39 = icmp ne i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i32, i32* @SIGPIPE
%42 = call i64 @sigaction(i32 %41, %struct.sigaction* %5, i32* null)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40, %36, %32, %28, %24, %20, %16, %2
br label %45
45: ; preds = %44
%46 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; No predecessors!
br label %49
49: ; preds = %48, %40
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i32, i32 }
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
@SIGCHLD = global i32 0
@SIGHUP = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGPIPE = global i32 0
@.str = [10 x i8] c"sigaction\00"
define void @sighandleall(void (i32)* %0, i32 %1) {
%3 = alloca %struct.sigaction
%4 = bitcast %struct.sigaction* %3 to i8*
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 0
store void (i32)* %0, void (i32)** %5
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 1
store i32 %1, i32* %6
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 2
store i32 0, i32* %7
%8 = call i32 @sigfillset(i32* %7)
%9 = load i32, i32* @SIGINT
%10 = call i64 @sigaction(i32 %9, %struct.sigaction* %3, i32* null)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %40
12: ; preds = %2
%13 = load i32, i32* @SIGQUIT
%14 = call i64 @sigaction(i32 %13, %struct.sigaction* %3, i32* null)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %12
%17 = load i32, i32* @SIGTERM
%18 = call i64 @sigaction(i32 %17, %struct.sigaction* %3, i32* null)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i32, i32* @SIGCHLD
%22 = call i64 @sigaction(i32 %21, %struct.sigaction* %3, i32* null)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32, i32* @SIGHUP
%26 = call i64 @sigaction(i32 %25, %struct.sigaction* %3, i32* null)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = load i32, i32* @SIGUSR1
%30 = call i64 @sigaction(i32 %29, %struct.sigaction* %3, i32* null)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32, i32* @SIGUSR2
%34 = call i64 @sigaction(i32 %33, %struct.sigaction* %3, i32* null)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* @SIGPIPE
%38 = call i64 @sigaction(i32 %37, %struct.sigaction* %3, i32* null)
%39 = icmp eq i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %2, %12, %16, %20, %24, %28, %32, %36
%41 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %36
ret void
}