#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_handler;
};

/* Variables and functions */
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(struct sigaction *, int /*<<< orphan*/, int);
int /*<<< orphan*/ proxyLog(char *, int /*<<< orphan*/);
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     int /*<<< orphan*/ *);
void setupSignals() {
  struct sigaction newAction;
  memset(&newAction, 0, sizeof(struct sigaction));
  newAction.sa_handler = SIG_IGN;
  if (sigaction(SIGPIPE, &newAction, NULL) < 0) {
    proxyLog("sigaction error errno = %d", errno);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<setupSignals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jge    11a3 <setupSignals+0x63>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe6c(%rip),%rdi
call   1050 <proxyLog@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setupSignals>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
js     1184 <setupSignals+0x44>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe6c(%rip),%rdi
call   1050 <proxyLog@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { i32 }
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [27 x i8] c"sigaction error errno = %d\00"
@errno = global i32 0
define void @setupSignals() {
%1 = alloca %struct.sigaction
%2 = call i32 @memset(%struct.sigaction* %1, i32 0, i32 4)
%3 = load i32, i32* @SIG_IGN
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i32 0, i32 0
store i32 %3, i32* %4
%5 = load i32, i32* @SIGPIPE
%6 = call i64 @sigaction(i32 %5, %struct.sigaction* %1, i32* null)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @errno
%10 = call i32 @proxyLog(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i32 }
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [27 x i8] c"sigaction error errno = %d\00"
@errno = global i32 0
define void @setupSignals() {
%1 = alloca %struct.sigaction
%2 = bitcast %struct.sigaction* %1 to i8*
%3 = call i32 @memset(%struct.sigaction* %1, i32 0, i32 4)
%4 = load i32, i32* @SIG_IGN
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i32 %4, i32* %5
%6 = load i32, i32* @SIGPIPE
%7 = call i64 @sigaction(i32 %6, %struct.sigaction* %1, i32* null)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @errno
%11 = call i32 @proxyLog(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
ret void
}