#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*/ printf(char *, int);
int sigismember(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void printSignalMask() {
  sigset_t maskSet;
  int maskBits;
  sigprocmask(0, NULL, &maskSet);
  int i;
  for (i = 32; i > 0; i--)
    maskBits = (maskBits << 1) | sigismember(&maskSet, i);
  printf("signal mask: 0x%08x\n", maskBits);
}


x86 assembly (clang, -O0):
<printSignalMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x4(%rbp),%rdx
call   1030 <sigprocmask@plt>
movl   $0x20,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1185 <printSignalMask+0x55>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
lea    -0x4(%rbp),%rdi
call   1050 <sigismember@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    114e <printSignalMask+0x1e>
mov    -0x8(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSignalMask>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%r14
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
mov    $0x21,%ebp
xchg   %ax,%ax
add    $0xffffffff,%ebp
mov    %eax,%ebx
add    %eax,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <sigismember@plt>
or     %ebx,%eax
cmp    $0x1,%ebp
ja     1150 <printSignalMask+0x20>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"signal mask: 0x%08x\0A\00"
define void @printSignalMask() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @sigprocmask(i32 0, i32* null, i32* %1)
store i32 32, i32* %3
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %2
%10 = shl i32 %9, 1
%11 = load i32, i32* %3
%12 = call i32 @sigismember(i32* %1, i32 %11)
%13 = or i32 %10, %12
store i32 %13, i32* %2
br label %14
14: ; preds = %8
%15 = load i32, i32* %3
%16 = add nsw i32 %15, -1
store i32 %16, i32* %3
br label %5
17: ; preds = %5
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"signal mask: 0x%08x\0A\00"
define void @printSignalMask() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigprocmask(i32 0, i32* null, i32* %1)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 32, %0 ], [ %10, %4 ]
%6 = phi i32 [ undef, %0 ], [ %9, %4 ]
%7 = shl i32 %6, 1
%8 = call i32 @sigismember(i32* %1, i32 %5)
%9 = or i32 %8, %7
%10 = add nsw i32 %5, -1
%11 = icmp ugt i32 %5, 1
br i1 %11, label %4, label %12
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
ret void
}