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

/* Variables and functions */
int SIGBUS;
int SIGSEGV;
int SIGVTALRM;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ sigismember(int /*<<< orphan*/ *, int);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void CheckMask() {
  sigset_t mask;
  int sig;
  if (sigprocmask(SIG_SETMASK, 0, &mask) == -1) {
    fprintf(stderr, "Unable to get mask\n");
    exit(1);
  }
  for (sig = 1; sig < 32; sig++) {
    if (sigismember(&mask, sig)) {
      printf("Signal %d blocked\n", sig);
      if (sig != SIGSEGV && sig != SIGVTALRM && sig != SIGBUS) {
        fprintf(stderr, "Signal %d unexpectedly blocked\n", sig);
        exit(1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<CheckMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    -0x4(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    1196 <CheckMask+0x46>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    123e <CheckMask+0xee>
mov    -0x8(%rbp),%esi
lea    -0x4(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     122b <CheckMask+0xdb>
mov    -0x8(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%eax
je     1226 <CheckMask+0xd6>
mov    -0x8(%rbp),%eax
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%eax
je     1226 <CheckMask+0xd6>
mov    -0x8(%rbp),%eax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%eax
je     1226 <CheckMask+0xd6>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    122b <CheckMask+0xdb>
jmp    1230 <CheckMask+0xe0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <CheckMask+0x4d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckMask>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     1214 <CheckMask+0xc4>
mov    $0x1,%ebx
lea    0x4(%rsp),%r14
lea    0xe8a(%rip),%r15
mov    0x2e4f(%rip),%r12
mov    0x2e28(%rip),%r13
mov    0x2e51(%rip),%rbp
jmp    11b8 <CheckMask+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x20,%ebx
je     1205 <CheckMask+0xb5>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigismember@plt>
test   %rax,%rax
je     11b0 <CheckMask+0x60>
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
cmp    (%r12),%ebx
je     11b0 <CheckMask+0x60>
cmp    0x0(%r13),%ebx
je     11b0 <CheckMask+0x60>
cmp    0x0(%rbp),%ebx
je     11b0 <CheckMask+0x60>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SIG_SETMASK = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Unable to get mask\0A\00"
@.str.1 = [19 x i8] c"Signal %d blocked\0A\00"
@SIGSEGV = global i32 0
@SIGVTALRM = global i32 0
@SIGBUS = global i32 0
@.str.2 = [32 x i8] c"Signal %d unexpectedly blocked\0A\00"
define void @CheckMask() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @SIG_SETMASK
%4 = call i32 @sigprocmask(i32 %3, i32 0, i32* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
store i32 1, i32* %2
br label %11
11: ; preds = %39, %10
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 32
br i1 %13, label %14, label %42
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i64 @sigismember(i32* %1, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %38
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
%22 = load i32, i32* @SIGSEGV
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %18
%25 = load i32, i32* %2
%26 = load i32, i32* @SIGVTALRM
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %2
%30 = load i32, i32* @SIGBUS
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = load i32, i32* %2
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %28, %24, %18
br label %38
38: ; preds = %37, %14
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %11
42: ; preds = %11
ret void
}

LLVM IR (-O2):
@SIG_SETMASK = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Unable to get mask\0A\00"
@.str.1 = [19 x i8] c"Signal %d blocked\0A\00"
@SIGSEGV = global i32 0
@SIGVTALRM = global i32 0
@SIGBUS = global i32 0
@.str.2 = [32 x i8] c"Signal %d unexpectedly blocked\0A\00"
define void @CheckMask() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @SIG_SETMASK
%4 = call i32 @sigprocmask(i32 %3, i32 0, i32* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0, %28
%11 = phi i32 [ %29, %28 ], [ 1, %0 ]
%12 = call i64 @sigismember(i32* %1, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %28, label %14
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%16 = load i32, i32* @SIGSEGV
%17 = icmp eq i32 %11, %16
%18 = load i32, i32* @SIGVTALRM
%19 = icmp eq i32 %11, %18
%20 = select i1 %17, i1 true, i1 %19
%21 = load i32, i32* @SIGBUS
%22 = icmp eq i32 %11, %21
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %28, label %24
24: ; preds = %14
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %10, %14
%29 = add nuw nsw i32 %11, 1
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %10
31: ; preds = %28
ret void
}