#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;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
void setSignalBehavior(int restoreFlag) {
  if (restoreFlag) {
    signal(SIGINT, SIG_DFL);
    signal(SIGTERM, SIG_DFL);
    signal(SIGQUIT, SIG_DFL);
    signal(SIGTSTP, SIG_DFL);
  } else {
    signal(SIGINT, SIG_IGN);
    signal(SIGTERM, SIG_IGN);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGTSTP, SIG_IGN);
  }
}


x86 assembly (clang, -O0):
<setSignalBehavior>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1186 <setSignalBehavior+0x76>
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
jmp    11e2 <setSignalBehavior+0xd2>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setSignalBehavior>:
push   %rbx
mov    %edi,%eax
mov    0x2ece(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
jne    1129 <setSignalBehavior+0x19>
mov    0x2ea1(%rip),%rbx
jmp    1130 <setSignalBehavior+0x20>
mov    0x2e88(%rip),%rbx
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
pop    %rbx
jmp    1030 <signal@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@SIG_DFL = global i32 0
@SIGTERM = global i32 0
@SIGQUIT = global i32 0
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
define void @setSignalBehavior(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = load i32, i32* @SIGINT
%7 = load i32, i32* @SIG_DFL
%8 = call i32 @signal(i32 %6, i32 %7)
%9 = load i32, i32* @SIGTERM
%10 = load i32, i32* @SIG_DFL
%11 = call i32 @signal(i32 %9, i32 %10)
%12 = load i32, i32* @SIGQUIT
%13 = load i32, i32* @SIG_DFL
%14 = call i32 @signal(i32 %12, i32 %13)
%15 = load i32, i32* @SIGTSTP
%16 = load i32, i32* @SIG_DFL
%17 = call i32 @signal(i32 %15, i32 %16)
br label %31
18: ; preds = %1
%19 = load i32, i32* @SIGINT
%20 = load i32, i32* @SIG_IGN
%21 = call i32 @signal(i32 %19, i32 %20)
%22 = load i32, i32* @SIGTERM
%23 = load i32, i32* @SIG_IGN
%24 = call i32 @signal(i32 %22, i32 %23)
%25 = load i32, i32* @SIGQUIT
%26 = load i32, i32* @SIG_IGN
%27 = call i32 @signal(i32 %25, i32 %26)
%28 = load i32, i32* @SIGTSTP
%29 = load i32, i32* @SIG_IGN
%30 = call i32 @signal(i32 %28, i32 %29)
br label %31
31: ; preds = %18, %5
ret void
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIG_DFL = global i32 0
@SIGTERM = global i32 0
@SIGQUIT = global i32 0
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
define void @setSignalBehavior(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = load i32, i32* @SIGINT
%4 = select i1 %2, i32* @SIG_IGN, i32* @SIG_DFL
%5 = load i32, i32* %4
%6 = tail call i32 @signal(i32 %3, i32 %5)
%7 = load i32, i32* @SIGTERM
%8 = load i32, i32* %4
%9 = tail call i32 @signal(i32 %7, i32 %8)
%10 = load i32, i32* @SIGQUIT
%11 = load i32, i32* %4
%12 = tail call i32 @signal(i32 %10, i32 %11)
%13 = load i32, i32* @SIGTSTP
%14 = load i32, i32* %4
%15 = tail call i32 @signal(i32 %13, i32 %14)
ret void
}