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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int sigaction(int, struct sigaction *, int /*<<< orphan*/ *);
int sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void HandleSignal(int sig, void (*handler)(int)) {
  struct sigaction sa = {.sa_handler = handler};
  if ((sigemptyset(&sa.sa_mask)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/"
                    "master/src/main/tools/process-tools.c"
                    ":"
                    "86"
                    ": ");
    perror("sigemptyset(&sa.sa_mask)");
    exit(EXIT_FAILURE);
  };
  if ((sigaction(sig, &sa, NULL)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/"
                    "master/src/main/tools/process-tools.c"
                    ":"
                    "87"
                    ": ");
    perror("sigaction(sig, &sa, NULL)");
    exit(EXIT_FAILURE);
  };
}


x86 assembly (clang, -O0):
<HandleSignal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1050 <sigemptyset@plt>
cmp    $0xffffffff,%eax
jne    11b3 <HandleSignal+0x63>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xefc(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11fb <HandleSignal+0xab>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xed9(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xf69(%rip),%rdi
call   1060 <perror@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HandleSignal>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %rsi,(%rsp)
lea    0x8(%rsp),%rdi
movl   $0x0,0x8(%rsp)
call   1050 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     1189 <HandleSignal+0x39>
mov    %rsp,%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
je     11a7 <HandleSignal+0x57>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xef7(%rip),%rdi
jmp    11c3 <HandleSignal+0x73>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xefe(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xf8e(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i32 }
@stderr = global i32 0
@.str = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:86: \00"
@.str.1 = [25 x i8] c"sigemptyset(&sa.sa_mask)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:87: \00"
@.str.3 = [26 x i8] c"sigaction(sig, &sa, NULL)\00"
define void @HandleSignal(i32 %0, void (i32)* %1) {
%3 = alloca i32
%4 = alloca void (i32)*
%5 = alloca %struct.sigaction
store i32 %0, i32* %3
store void (i32)* %1, void (i32)** %4
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 0
%7 = load void (i32)*, void (i32)** %4
store void (i32)* %7, void (i32)** %6
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 1
store i32 0, i32* %8
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %5, i32 0, i32 1
%10 = call i32 @sigemptyset(i32* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i32, i32* %3
%20 = call i32 @sigaction(i32 %19, %struct.sigaction* %5, i32* null)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i32 }
@stderr = global i32 0
@.str = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:86: \00"
@.str.1 = [25 x i8] c"sigemptyset(&sa.sa_mask)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:87: \00"
@.str.3 = [26 x i8] c"sigaction(sig, &sa, NULL)\00"
define void @HandleSignal(i32 %0, void (i32)* %1) {
%3 = alloca %struct.sigaction
%4 = bitcast %struct.sigaction* %3 to i8*
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 0
store void (i32)* %1, void (i32)** %5
%6 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 1
store i32 0, i32* %6
%7 = call i32 @sigemptyset(i32* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i32 @sigaction(i32 %0, %struct.sigaction* %3, i32* null)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
ret void
}