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

/* Variables and functions */
int /*<<< orphan*/ SIG_IGN;
int __sigaction(int, struct sigaction *, int /*<<< orphan*/ *);
scalar_t__ __sigemptyset(int /*<<< orphan*/ *);
int sigignore(int sig) {
  struct sigaction act;
  act.sa_handler = SIG_IGN;
  if (__sigemptyset(&act.sa_mask) < 0)
    return -1;
  act.sa_flags = 0;
  return __sigaction(sig, &act, NULL);
}


x86 assembly (clang, -O0):
<sigignore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x8,%rdi
call   1030 <__sigemptyset@plt>
cmp    $0x0,%rax
jge    115a <sigignore+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1175 <sigignore+0x55>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <__sigaction@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigignore>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2eba(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <__sigemptyset@plt>
test   %rax,%rax
js     1159 <sigignore+0x39>
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <__sigaction@plt>
jmp    115e <sigignore+0x3e>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { i64, i32, i32 }
@SIG_IGN = global i32 0
define i32 @sigignore(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sigaction
store i32 %0, i32* %3
%5 = load i32, i32* @SIG_IGN
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i32 0, i32 2
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i32 0, i32 1
%8 = call i64 @__sigemptyset(i32* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %15
11: ; preds = %1
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i32 0, i32 0
store i64 0, i64* %12
%13 = load i32, i32* %3
%14 = call i32 @__sigaction(i32 %13, %struct.sigaction* %4, i32* null)
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %10
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
%struct.sigaction = type { i64, i32, i32 }
@SIG_IGN = global i32 0
define i32 @sigignore(i32 %0) {
%2 = alloca %struct.sigaction
%3 = bitcast %struct.sigaction* %2 to i8*
%4 = load i32, i32* @SIG_IGN
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 2
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
%7 = call i64 @__sigemptyset(i32* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
store i64 0, i64* %10
%11 = call i32 @__sigaction(i32 %0, %struct.sigaction* %2, i32* null)
br label %12
12: ; preds = %1, %9
%13 = phi i32 [ %11, %9 ], [ -1, %1 ]
ret i32 %13
}