#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_mask;
  int /*<<< orphan*/ sa_handler;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int NSIG;
int SIGKILL;
int SIGSTOP;
int /*<<< orphan*/ SIG_DFL;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sigaction(int, struct sigaction *, int /*<<< orphan*/ *);
int sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void ClearSignalMask() {
  sigset_t empty_sset;
  if ((sigemptyset(&empty_sset)) == -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"
                    ":"
                    "106"
                    ": ");
    perror("sigemptyset(&empty_sset)");
    exit(EXIT_FAILURE);
  };
  if ((sigprocmask(SIG_SETMASK, &empty_sset, 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"
                    ":"
                    "107"
                    ": ");
    perror("sigprocmask(SIG_SETMASK, &empty_sset, NULL)");
    exit(EXIT_FAILURE);
  };
  for (int i = 1; i < NSIG; ++i) {
    if (i == SIGKILL || i == SIGSTOP) {
      continue;
    }
    struct sigaction sa = {.sa_handler = SIG_DFL};
    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"
                      ":"
                      "115"
                      ": ");
      perror("sigemptyset(&sa.sa_mask)");
      exit(EXIT_FAILURE);
    };
    sigaction(i, &sa, NULL);
  }
}


x86 assembly (clang, -O0):
<ClearSignalMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1060 <sigemptyset@plt>
cmp    $0xffffffff,%eax
jne    11a9 <ClearSignalMask+0x49>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xf07(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    11f7 <ClearSignalMask+0x97>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xede(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xf6f(%rip),%rdi
call   1070 <perror@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%eax
jge    12ab <ClearSignalMask+0x14b>
mov    -0x8(%rbp),%eax
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%eax
je     1234 <ClearSignalMask+0xd4>
mov    -0x8(%rbp),%eax
mov    0x2d8c(%rip),%rcx
cmp    (%rcx),%eax
jne    1239 <ClearSignalMask+0xd9>
jmp    129d <ClearSignalMask+0x13d>
movl   $0x0,-0x10(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <sigemptyset@plt>
cmp    $0xffffffff,%eax
jne    128d <ClearSignalMask+0x12d>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xf11(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xfa2(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <sigaction@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fe <ClearSignalMask+0x9e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClearSignalMask>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xc(%rsp),%rdi
call   1060 <sigemptyset@plt>
cmp    $0xffffffff,%eax
je     1260 <ClearSignalMask+0x100>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     127e <ClearSignalMask+0x11e>
mov    0x2e0a(%rip),%r15
mov    (%r15),%eax
cmp    $0x2,%eax
jl     1251 <ClearSignalMask+0xf1>
mov    0x2e07(%rip),%r12
mov    (%r12),%ecx
mov    0x2df4(%rip),%r13
mov    0x0(%r13),%edx
mov    $0x1,%ebx
mov    0x2df4(%rip),%rbp
lea    0x10(%rsp),%r14
jmp    11fe <ClearSignalMask+0x9e>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <sigaction@plt>
mov    (%r12),%ecx
mov    0x0(%r13),%edx
mov    (%r15),%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jge    1251 <ClearSignalMask+0xf1>
cmp    %ecx,%ebx
je     11f7 <ClearSignalMask+0x97>
cmp    %edx,%ebx
je     11f7 <ClearSignalMask+0x97>
movl   $0x0,0x10(%rsp)
mov    0x0(%rbp),%eax
mov    %eax,0x14(%rsp)
mov    %r14,%rdi
call   1060 <sigemptyset@plt>
cmp    $0xffffffff,%eax
jne    11e0 <ClearSignalMask+0x80>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xf4d(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xfde(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe21(%rip),%rdi
jmp    123e <ClearSignalMask+0xde>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xeb9(%rip),%rdi
jmp    123e <ClearSignalMask+0xde>

LLVM IR (-O0):
%struct.sigaction = type { i32, i32 }
@stderr = global i32 0
@.str = [157 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:106: \00"
@.str.1 = [25 x i8] c"sigemptyset(&empty_sset)\00"
@EXIT_FAILURE = global i32 0
@SIG_SETMASK = global i32 0
@.str.2 = [157 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:107: \00"
@.str.3 = [44 x i8] c"sigprocmask(SIG_SETMASK, &empty_sset, NULL)\00"
@NSIG = global i32 0
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@SIG_DFL = global i32 0
@.str.4 = [157 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:115: \00"
@.str.5 = [25 x i8] c"sigemptyset(&sa.sa_mask)\00"
define void @ClearSignalMask() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sigaction
%4 = call i32 @sigemptyset(i32* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = load i32, i32* @SIG_SETMASK
%14 = call i32 @sigprocmask(i32 %13, i32* %1, i32* null)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %12
store i32 1, i32* %2
br label %23
23: ; preds = %52, %22
%24 = load i32, i32* %2
%25 = load i32, i32* @NSIG
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %55
27: ; preds = %23
%28 = load i32, i32* %2
%29 = load i32, i32* @SIGKILL
%30 = icmp eq i32 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i32, i32* %2
%33 = load i32, i32* @SIGSTOP
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %31, %27
br label %52
36: ; preds = %31
%37 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
store i32 0, i32* %37
%38 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 1
%39 = load i32, i32* @SIG_DFL
store i32 %39, i32* %38
%40 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i32 0, i32 0
%41 = call i32 @sigemptyset(i32* %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %49
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %36
%50 = load i32, i32* %2
%51 = call i32 @sigaction(i32 %50, %struct.sigaction* %3, i32* null)
br label %52
52: ; preds = %49, %35
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %23
55: ; preds = %23
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32 }
@stderr = global i32 0
@.str = [157 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:106: \00"
@.str.1 = [25 x i8] c"sigemptyset(&empty_sset)\00"
@EXIT_FAILURE = global i32 0
@SIG_SETMASK = global i32 0
@.str.2 = [157 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:107: \00"
@.str.3 = [44 x i8] c"sigprocmask(SIG_SETMASK, &empty_sset, NULL)\00"
@NSIG = global i32 0
@SIGKILL = global i32 0
@SIGSTOP = global i32 0
@SIG_DFL = global i32 0
@.str.4 = [157 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:115: \00"
@.str.5 = [25 x i8] c"sigemptyset(&sa.sa_mask)\00"
define void @ClearSignalMask() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = bitcast i32* %1 to i8*
%4 = call i32 @sigemptyset(i32* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = load i32, i32* @SIG_SETMASK
%14 = call i32 @sigprocmask(i32 %13, i32* %1, i32* null)
%15 = icmp eq i32 %14, -1
br i1 %15, label %25, label %16
16: ; preds = %12
%17 = load i32, i32* @NSIG
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = bitcast %struct.sigaction* %2 to i8*
%21 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
%22 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 1
%23 = load i32, i32* @SIGKILL
%24 = load i32, i32* @SIGSTOP
br label %32
25: ; preds = %12
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %55, %16
ret void
32: ; preds = %19, %55
%33 = phi i32 [ %17, %19 ], [ %56, %55 ]
%34 = phi i32 [ %24, %19 ], [ %57, %55 ]
%35 = phi i32 [ %23, %19 ], [ %58, %55 ]
%36 = phi i32 [ 1, %19 ], [ %59, %55 ]
%37 = icmp eq i32 %36, %35
%38 = icmp eq i32 %36, %34
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %55, label %40
40: ; preds = %32
store i32 0, i32* %21
%41 = load i32, i32* @SIG_DFL
store i32 %41, i32* %22
%42 = call i32 @sigemptyset(i32* %21)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %40
%51 = call i32 @sigaction(i32 %36, %struct.sigaction* %2, i32* null)
%52 = load i32, i32* @SIGKILL
%53 = load i32, i32* @SIGSTOP
%54 = load i32, i32* @NSIG
br label %55
55: ; preds = %32, %50
%56 = phi i32 [ %33, %32 ], [ %54, %50 ]
%57 = phi i32 [ %34, %32 ], [ %53, %50 ]
%58 = phi i32 [ %35, %32 ], [ %52, %50 ]
%59 = add nuw nsw i32 %36, 1
%60 = icmp slt i32 %59, %56
br i1 %60, label %32, label %31
}