#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*/ SIGALRM;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ err_sys(char *);
int errno;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sigismember(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
void pr_mask(const char *str) {
  sigset_t sigset;
  int errno_save;
  errno_save = errno;
  if (sigprocmask(0, NULL, &sigset) < 0)
    err_sys("sigprocmask error");
  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    0x2e6d(%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    117d <pr_mask+0x3d>
lea    0xe88(%rip),%rdi
call   1040 <err_sys@plt>
mov    -0x8(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     11b9 <pr_mask+0x79>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     11e3 <pr_mask+0xa3>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     120d <pr_mask+0xcd>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigismember@plt>
cmp    $0x0,%rax
je     1237 <pr_mask+0xf7>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%ecx
mov    0x2d71(%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    0x2e5e(%rip),%r14
mov    (%r14),%ebp
lea    0xc(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    1184 <pr_mask+0x34>
lea    0xe81(%rip),%rdi
call   1050 <err_sys@plt>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11bb <pr_mask+0x6b>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     11e1 <pr_mask+0x91>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     1207 <pr_mask+0xb7>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1070 <sigismember@plt>
test   %rax,%rax
je     122d <pr_mask+0xdd>
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %ebp,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@errno = global i32 0
@.str = [18 x i8] c"sigprocmask error\00"
@.str.1 = [3 x i8] c"%s\00"
@SIGINT = global i32 0
@.str.2 = [9 x i8] c"SIGINT \00"
@SIGQUIT = global i32 0
@.str.3 = [10 x i8] c"SIGQUIT \00"
@SIGUSR1 = global i32 0
@.str.4 = [10 x i8] c"SIGUSR1 \00"
@SIGALRM = global i32 0
@.str.5 = [10 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 %9
7: ; preds = %1
%8 = call i32 @err_sys(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = load i32, i32* @SIGINT
%12 = call i64 @sigismember(i32* %2, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* @SIGQUIT
%18 = call i64 @sigismember(i32* %2, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i32, i32* @SIGUSR1
%24 = call i64 @sigismember(i32* %2, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i32, i32* @SIGALRM
%30 = call i64 @sigismember(i32* %2, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = call i32 @putchar(i32 10)
store i32 %4, i32* @errno
ret void
}