#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*/ LOG_ERR;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGTSTP;
int /*<<< orphan*/ SIGTTIN;
int /*<<< orphan*/ SIGTTOU;
scalar_t__ SIG_ERR;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ errno;
scalar_t__ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int set_ignored_signals(void) {
  if (signal(SIGTSTP, SIG_IGN) == SIG_ERR) {
    syslog(LOG_ERR, "failed to set SIGTERM as ignored , code=%d (%s)", errno,
           strerror(errno));
    return 0;
  }
  if (signal(SIGTTOU, SIG_IGN) == SIG_ERR) {
    syslog(LOG_ERR, "failed to set SIGTTOU as ignored , code=%d (%s)", errno,
           strerror(errno));
    return 0;
  }
  if (signal(SIGTTIN, SIG_IGN) == SIG_ERR) {
    syslog(LOG_ERR, "failed to set SIGTTIN as ignored , code=%d (%s)", errno,
           strerror(errno));
    return 0;
  }
  if (signal(SIGHUP, SIG_IGN) == SIG_ERR) {
    syslog(LOG_ERR, "failed to set SIGHUP as ignored , code=%d (%s)", errno,
           strerror(errno));
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<set_ignored_signals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%rax
jne    11a5 <set_ignored_signals+0x75>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    %eax,%ecx
lea    0xe6c(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f3 <set_ignored_signals+0x1c3>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%rax
jne    1212 <set_ignored_signals+0xe2>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xe2f(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f3 <set_ignored_signals+0x1c3>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2d88(%rip),%rcx
cmp    (%rcx),%rax
jne    127f <set_ignored_signals+0x14f>
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xdf2(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f3 <set_ignored_signals+0x1c3>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
call   1030 <signal@plt>
mov    0x2d1b(%rip),%rcx
cmp    (%rcx),%rax
jne    12ec <set_ignored_signals+0x1bc>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xdb5(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f3 <set_ignored_signals+0x1c3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ignored_signals>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    0x2e85(%rip),%rbx
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    0x2e67(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    117c <set_ignored_signals+0x4c>
mov    0x2e42(%rip),%rax
mov    (%rax),%ebx
mov    0x2e49(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1050 <strerror@plt>
lea    0xe89(%rip),%rsi
jmp    122a <set_ignored_signals+0xfa>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
cmp    0x0(%rbp),%rax
jne    11b4 <set_ignored_signals+0x84>
mov    0x2e07(%rip),%rax
mov    (%rax),%ebx
mov    0x2e0e(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1050 <strerror@plt>
lea    0xe7e(%rip),%rsi
jmp    122a <set_ignored_signals+0xfa>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
cmp    0x0(%rbp),%rax
jne    11ec <set_ignored_signals+0xbc>
mov    0x2dcf(%rip),%rax
mov    (%rax),%ebx
mov    0x2dd6(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1050 <strerror@plt>
lea    0xe76(%rip),%rsi
jmp    122a <set_ignored_signals+0xfa>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%esi
call   1030 <signal@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    0x0(%rbp),%rcx
jne    1237 <set_ignored_signals+0x107>
mov    0x2d8f(%rip),%rax
mov    (%rax),%ebx
mov    0x2d96(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1050 <strerror@plt>
lea    0xe66(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
@LOG_ERR = global i32 0
@.str = [48 x i8] c"failed to set SIGTERM as ignored , code=%d (%s)\00"
@errno = global i32 0
@SIGTTOU = global i32 0
@.str.1 = [48 x i8] c"failed to set SIGTTOU as ignored , code=%d (%s)\00"
@SIGTTIN = global i32 0
@.str.2 = [48 x i8] c"failed to set SIGTTIN as ignored , code=%d (%s)\00"
@SIGHUP = global i32 0
@.str.3 = [47 x i8] c"failed to set SIGHUP as ignored , code=%d (%s)\00"
define i32 @set_ignored_signals() {
%1 = alloca i32
%2 = load i32, i32* @SIGTSTP
%3 = load i32, i32* @SIG_IGN
%4 = call i64 @signal(i32 %2, i32 %3)
%5 = load i64, i64* @SIG_ERR
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = load i32, i32* @LOG_ERR
%9 = load i32, i32* @errno
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11)
store i32 0, i32* %1
br label %50
13: ; preds = %0
%14 = load i32, i32* @SIGTTOU
%15 = load i32, i32* @SIG_IGN
%16 = call i64 @signal(i32 %14, i32 %15)
%17 = load i64, i64* @SIG_ERR
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i32, i32* @LOG_ERR
%21 = load i32, i32* @errno
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %23)
store i32 0, i32* %1
br label %50
25: ; preds = %13
%26 = load i32, i32* @SIGTTIN
%27 = load i32, i32* @SIG_IGN
%28 = call i64 @signal(i32 %26, i32 %27)
%29 = load i64, i64* @SIG_ERR
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i32, i32* @LOG_ERR
%33 = load i32, i32* @errno
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 @syslog(i32 %32, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %33, i32 %35)
store i32 0, i32* %1
br label %50
37: ; preds = %25
%38 = load i32, i32* @SIGHUP
%39 = load i32, i32* @SIG_IGN
%40 = call i64 @signal(i32 %38, i32 %39)
%41 = load i64, i64* @SIG_ERR
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = load i32, i32* @LOG_ERR
%45 = load i32, i32* @errno
%46 = load i32, i32* @errno
%47 = call i32 @strerror(i32 %46)
%48 = call i32 @syslog(i32 %44, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %47)
store i32 0, i32* %1
br label %50
49: ; preds = %37
store i32 1, i32* %1
br label %50
50: ; preds = %49, %43, %31, %19, %7
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@SIGTSTP = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
@LOG_ERR = global i32 0
@.str = [48 x i8] c"failed to set SIGTERM as ignored , code=%d (%s)\00"
@errno = global i32 0
@SIGTTOU = global i32 0
@.str.1 = [48 x i8] c"failed to set SIGTTOU as ignored , code=%d (%s)\00"
@SIGTTIN = global i32 0
@.str.2 = [48 x i8] c"failed to set SIGTTIN as ignored , code=%d (%s)\00"
@SIGHUP = global i32 0
@.str.3 = [47 x i8] c"failed to set SIGHUP as ignored , code=%d (%s)\00"
define i32 @set_ignored_signals() {
%1 = load i32, i32* @SIGTSTP
%2 = load i32, i32* @SIG_IGN
%3 = tail call i64 @signal(i32 %1, i32 %2)
%4 = load i64, i64* @SIG_ERR
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @LOG_ERR
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @syslog(i32 %7, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
br label %44
11: ; preds = %0
%12 = load i32, i32* @SIGTTOU
%13 = load i32, i32* @SIG_IGN
%14 = tail call i64 @signal(i32 %12, i32 %13)
%15 = load i64, i64* @SIG_ERR
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i32, i32* @LOG_ERR
%19 = load i32, i32* @errno
%20 = tail call i32 @strerror(i32 %19)
%21 = tail call i32 @syslog(i32 %18, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
br label %44
22: ; preds = %11
%23 = load i32, i32* @SIGTTIN
%24 = load i32, i32* @SIG_IGN
%25 = tail call i64 @signal(i32 %23, i32 %24)
%26 = load i64, i64* @SIG_ERR
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load i32, i32* @LOG_ERR
%30 = load i32, i32* @errno
%31 = tail call i32 @strerror(i32 %30)
%32 = tail call i32 @syslog(i32 %29, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31)
br label %44
33: ; preds = %22
%34 = load i32, i32* @SIGHUP
%35 = load i32, i32* @SIG_IGN
%36 = tail call i64 @signal(i32 %34, i32 %35)
%37 = load i64, i64* @SIG_ERR
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = load i32, i32* @LOG_ERR
%41 = load i32, i32* @errno
%42 = tail call i32 @strerror(i32 %41)
%43 = tail call i32 @syslog(i32 %40, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42)
br label %44
44: ; preds = %33, %39, %28, %17, %6
%45 = phi i32 [ 0, %6 ], [ 0, %17 ], [ 0, %28 ], [ 0, %39 ], [ 1, %33 ]
ret i32 %45
}