#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGUSR1;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sigismember(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void pr_mask(const char *str) {
  sigset_t sigset;
  int errno_save;
  errno_save = errno;
  if (sigprocmask(0, NULL, &sigset) < 0) {
    fprintf(stderr, "sigprocmask error");
    exit(EXIT_FAILURE);
  }
  printf("%s", str);
  if (sigismember(&sigset, SIGINT))
    printf("SIGINT ");
  if (sigismember(&sigset, SIGQUIT))
    printf("SIGQUIT ");
  if (sigismember(&sigset, SIGUSR1))
    printf("SIGUSR1 ");
  if (sigismember(&sigset, SIGALRM))
    printf("SIGALRM ");
  printf("\n");
  errno = errno_save;
}


x86 assembly (clang, -O0):
<pr_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0xc(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    11a4 <pr_mask+0x54>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     11e0 <pr_mask+0x90>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     120a <pr_mask+0xba>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     1234 <pr_mask+0xe4>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     125e <pr_mask+0x10e>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%ecx
mov    0x2d42(%rip),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_mask>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e46(%rip),%r14
mov    (%r14),%ebp
lea    0xc(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <sigprocmask@plt>
test   %rax,%rax
js     124b <pr_mask+0xeb>
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11c3 <pr_mask+0x63>
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11e9 <pr_mask+0x89>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     120f <pr_mask+0xaf>
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     1235 <pr_mask+0xd5>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %ebp,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"sigprocmask error\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@SIGINT = global i32 0
@.str.2 = [8 x i8] c"SIGINT \00"
@SIGQUIT = global i32 0
@.str.3 = [9 x i8] c"SIGQUIT \00"
@SIGUSR1 = global i32 0
@.str.4 = [9 x i8] c"SIGUSR1 \00"
@SIGALRM = global i32 0
@.str.5 = [9 x i8] c"SIGALRM \00"
@.str.6 = [2 x i8] c"\0A\00"
define void @pr_mask(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i32, i32* @errno
store i32 %5, i32* %4
%6 = call i64 @sigprocmask(i32 0, i32* null, i32* %3)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @SIGINT
%17 = call i64 @sigismember(i32* %3, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = load i32, i32* @SIGQUIT
%23 = call i64 @sigismember(i32* %3, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* @SIGUSR1
%29 = call i64 @sigismember(i32* %3, i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = load i32, i32* @SIGALRM
%35 = call i64 @sigismember(i32* %3, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%41 = load i32, i32* %4
store i32 %41, i32* @errno
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"sigprocmask error\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@SIGINT = global i32 0
@.str.2 = [8 x i8] c"SIGINT \00"
@SIGQUIT = global i32 0
@.str.3 = [9 x i8] c"SIGQUIT \00"
@SIGUSR1 = global i32 0
@.str.4 = [9 x i8] c"SIGUSR1 \00"
@SIGALRM = global i32 0
@.str.5 = [9 x i8] c"SIGALRM \00"
define void @pr_mask(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @errno
%5 = call i64 @sigprocmask(i32 0, i32* null, i32* %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = load i32, i32* @SIGINT
%15 = call i64 @sigismember(i32* %2, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = load i32, i32* @SIGQUIT
%21 = call i64 @sigismember(i32* %2, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* @SIGUSR1
%27 = call i64 @sigismember(i32* %2, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = load i32, i32* @SIGALRM
%33 = call i64 @sigismember(i32* %2, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = call i32 @putchar(i32 10)
store i32 %4, i32* @errno
ret void
}