#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 {
  int /*<<< orphan*/ sa_flags;
  int /*<<< orphan*/ sa_mask;
  int /*<<< orphan*/ sa_handler;
};

/* Variables and functions */
int /*<<< orphan*/ SA_RESTART;
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGTTIN;
int /*<<< orphan*/ SIGTTOU;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ SIG_DFL;
int sigaction(int /*<<< orphan*/, struct sigaction *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int reset_sighandling() {
  struct sigaction sa;
  sa.sa_handler = SIG_DFL;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_RESTART;
  if (sigaction((SIGINT), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGPIPE), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGALRM), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGTTIN), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGTTOU), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGQUIT), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGTERM), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGUSR1), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGUSR2), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGHUP), (&sa), (NULL)) == -1)
    return 1;
  ;
  if (sigaction((SIGCHLD), (&sa), (NULL)) == -1)
    return 1;
  ;
  return 0;
}


x86 assembly (clang, -O0):
<reset_sighandling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1178 <reset_sighandling+0x58>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11a3 <reset_sighandling+0x83>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11ce <reset_sighandling+0xae>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11f9 <reset_sighandling+0xd9>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1224 <reset_sighandling+0x104>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    124f <reset_sighandling+0x12f>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    127a <reset_sighandling+0x15a>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    12a5 <reset_sighandling+0x185>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    12d0 <reset_sighandling+0x1b0>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    12fb <reset_sighandling+0x1db>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1326 <reset_sighandling+0x206>
movl   $0x1,-0x4(%rbp)
jmp    132d <reset_sighandling+0x20d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_sighandling>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
mov    $0x1,%ebx
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     126c <reset_sighandling+0x14c>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i32, i32 }
@SIG_DFL = global i32 0
@SA_RESTART = global i32 0
@SIGINT = global i32 0
@SIGPIPE = global i32 0
@SIGALRM = global i32 0
@SIGTTIN = global i32 0
@SIGTTOU = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGHUP = global i32 0
@SIGCHLD = global i32 0
define i32 @reset_sighandling() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = load i32, i32* @SIG_DFL
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 2
store i32 %3, i32* %4
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 1
%6 = call i32 @sigemptyset(i32* %5)
%7 = load i32, i32* @SA_RESTART
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* @SIGINT
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %2, i32* null)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 1, i32* %1
br label %64
13: ; preds = %0
%14 = load i32, i32* @SIGPIPE
%15 = call i32 @sigaction(i32 %14, %struct.sigaction* %2, i32* null)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 1, i32* %1
br label %64
18: ; preds = %13
%19 = load i32, i32* @SIGALRM
%20 = call i32 @sigaction(i32 %19, %struct.sigaction* %2, i32* null)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %1
br label %64
23: ; preds = %18
%24 = load i32, i32* @SIGTTIN
%25 = call i32 @sigaction(i32 %24, %struct.sigaction* %2, i32* null)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %1
br label %64
28: ; preds = %23
%29 = load i32, i32* @SIGTTOU
%30 = call i32 @sigaction(i32 %29, %struct.sigaction* %2, i32* null)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 1, i32* %1
br label %64
33: ; preds = %28
%34 = load i32, i32* @SIGQUIT
%35 = call i32 @sigaction(i32 %34, %struct.sigaction* %2, i32* null)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %1
br label %64
38: ; preds = %33
%39 = load i32, i32* @SIGTERM
%40 = call i32 @sigaction(i32 %39, %struct.sigaction* %2, i32* null)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 1, i32* %1
br label %64
43: ; preds = %38
%44 = load i32, i32* @SIGUSR1
%45 = call i32 @sigaction(i32 %44, %struct.sigaction* %2, i32* null)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 1, i32* %1
br label %64
48: ; preds = %43
%49 = load i32, i32* @SIGUSR2
%50 = call i32 @sigaction(i32 %49, %struct.sigaction* %2, i32* null)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %53
52: ; preds = %48
store i32 1, i32* %1
br label %64
53: ; preds = %48
%54 = load i32, i32* @SIGHUP
%55 = call i32 @sigaction(i32 %54, %struct.sigaction* %2, i32* null)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %58
57: ; preds = %53
store i32 1, i32* %1
br label %64
58: ; preds = %53
%59 = load i32, i32* @SIGCHLD
%60 = call i32 @sigaction(i32 %59, %struct.sigaction* %2, i32* null)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 1, i32* %1
br label %64
63: ; preds = %58
store i32 0, i32* %1
br label %64
64: ; preds = %63, %62, %57, %52, %47, %42, %37, %32, %27, %22, %17, %12
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32, i32 }
@SIG_DFL = global i32 0
@SA_RESTART = global i32 0
@SIGINT = global i32 0
@SIGPIPE = global i32 0
@SIGALRM = global i32 0
@SIGTTIN = global i32 0
@SIGTTOU = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
@SIGHUP = global i32 0
@SIGCHLD = global i32 0
define i32 @reset_sighandling() {
%1 = alloca %struct.sigaction
%2 = bitcast %struct.sigaction* %1 to i8*
%3 = load i32, i32* @SIG_DFL
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 2
store i32 %3, i32* %4
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 1
%6 = call i32 @sigemptyset(i32* %5)
%7 = load i32, i32* @SA_RESTART
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i32 %7, i32* %8
%9 = load i32, i32* @SIGINT
%10 = call i32 @sigaction(i32 %9, %struct.sigaction* %1, i32* null)
%11 = icmp eq i32 %10, -1
br i1 %11, label %53, label %12
12: ; preds = %0
%13 = load i32, i32* @SIGPIPE
%14 = call i32 @sigaction(i32 %13, %struct.sigaction* %1, i32* null)
%15 = icmp eq i32 %14, -1
br i1 %15, label %53, label %16
16: ; preds = %12
%17 = load i32, i32* @SIGALRM
%18 = call i32 @sigaction(i32 %17, %struct.sigaction* %1, i32* null)
%19 = icmp eq i32 %18, -1
br i1 %19, label %53, label %20
20: ; preds = %16
%21 = load i32, i32* @SIGTTIN
%22 = call i32 @sigaction(i32 %21, %struct.sigaction* %1, i32* null)
%23 = icmp eq i32 %22, -1
br i1 %23, label %53, label %24
24: ; preds = %20
%25 = load i32, i32* @SIGTTOU
%26 = call i32 @sigaction(i32 %25, %struct.sigaction* %1, i32* null)
%27 = icmp eq i32 %26, -1
br i1 %27, label %53, label %28
28: ; preds = %24
%29 = load i32, i32* @SIGQUIT
%30 = call i32 @sigaction(i32 %29, %struct.sigaction* %1, i32* null)
%31 = icmp eq i32 %30, -1
br i1 %31, label %53, label %32
32: ; preds = %28
%33 = load i32, i32* @SIGTERM
%34 = call i32 @sigaction(i32 %33, %struct.sigaction* %1, i32* null)
%35 = icmp eq i32 %34, -1
br i1 %35, label %53, label %36
36: ; preds = %32
%37 = load i32, i32* @SIGUSR1
%38 = call i32 @sigaction(i32 %37, %struct.sigaction* %1, i32* null)
%39 = icmp eq i32 %38, -1
br i1 %39, label %53, label %40
40: ; preds = %36
%41 = load i32, i32* @SIGUSR2
%42 = call i32 @sigaction(i32 %41, %struct.sigaction* %1, i32* null)
%43 = icmp eq i32 %42, -1
br i1 %43, label %53, label %44
44: ; preds = %40
%45 = load i32, i32* @SIGHUP
%46 = call i32 @sigaction(i32 %45, %struct.sigaction* %1, i32* null)
%47 = icmp eq i32 %46, -1
br i1 %47, label %53, label %48
48: ; preds = %44
%49 = load i32, i32* @SIGCHLD
%50 = call i32 @sigaction(i32 %49, %struct.sigaction* %1, i32* null)
%51 = icmp eq i32 %50, -1
%52 = zext i1 %51 to i32
br label %53
53: ; preds = %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %0
%54 = phi i32 [ 1, %0 ], [ 1, %12 ], [ 1, %16 ], [ 1, %20 ], [ 1, %24 ], [ 1, %28 ], [ 1, %32 ], [ 1, %36 ], [ 1, %40 ], [ 1, %44 ], [ %52, %48 ]
ret i32 %54
}