#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 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) {
        fprintf(stderr, "Signal %d unexpectedly blocked\n", sig);
        exit(1);
      }
    }
  }
}


x86 assembly (clang, -O0):
<CheckMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    -0x4(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    1196 <CheckMask+0x46>
mov    0x2e54(%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    122c <CheckMask+0xdc>
mov    -0x8(%rbp),%esi
lea    -0x4(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     1219 <CheckMask+0xc9>
mov    -0x8(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2e12(%rip),%rcx
cmp    (%rcx),%eax
je     1214 <CheckMask+0xc4>
mov    -0x8(%rbp),%eax
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
je     1214 <CheckMask+0xc4>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1219 <CheckMask+0xc9>
jmp    121e <CheckMask+0xce>
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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     11fe <CheckMask+0xae>
mov    $0x1,%ebx
lea    0xc(%rsp),%r14
lea    0xe88(%rip),%r15
mov    0x2e55(%rip),%r12
mov    0x2e2e(%rip),%r13
jmp    11a8 <CheckMask+0x58>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x20,%ebx
je     11f0 <CheckMask+0xa0>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigismember@plt>
test   %rax,%rax
je     11a0 <CheckMask+0x50>
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
cmp    (%r12),%ebx
je     11a0 <CheckMask+0x50>
cmp    0x0(%r13),%ebx
je     11a0 <CheckMask+0x50>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%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
@.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 = %35, %10
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 32
br i1 %13, label %14, label %38
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 %34
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 %33
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 %33
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i32, i32* %2
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %24, %18
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %11
38: ; 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
@.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, %25
%11 = phi i32 [ %26, %25 ], [ 1, %0 ]
%12 = call i64 @sigismember(i32* %1, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %25, 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
br i1 %20, label %25, label %21
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %10, %14
%26 = add nuw nsw i32 %11, 1
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %10
28: ; preds = %25
ret void
}