#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*/ SIGTERM;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ sigismember(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void handler(int signum) {
  sigset_t mask;
  sigprocmask(SIG_BLOCK, NULL, &mask);
  printf("SIGUSR2: %s\n",
         sigismember(&mask, SIGUSR2) ? "blocked" : "not blocked");
  printf("SIGTERM: %s\n",
         sigismember(&mask, SIGTERM) ? "blocked" : "not blocked");
}


x86 assembly (clang, -O0):
<handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigismember@plt>
mov    %rax,%rcx
lea    0xea0(%rip),%rsi
lea    0xe9d(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigismember@plt>
mov    %rax,%rcx
lea    0xe69(%rip),%rsi
lea    0xe66(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handler>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%r14
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigismember@plt>
test   %rax,%rax
lea    0xea1(%rip),%r15
lea    0xe9e(%rip),%rbx
mov    %rbx,%rsi
cmove  %r15,%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigismember@plt>
test   %rax,%rax
cmove  %r15,%rbx
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SIG_BLOCK = global i32 0
@.str = [13 x i8] c"SIGUSR2: %s\0A\00"
@SIGUSR2 = global i32 0
@.str.1 = [8 x i8] c"blocked\00"
@.str.2 = [12 x i8] c"not blocked\00"
@.str.3 = [13 x i8] c"SIGTERM: %s\0A\00"
@SIGTERM = global i32 0
define void @handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* @SIG_BLOCK
%5 = call i32 @sigprocmask(i32 %4, i32* null, i32* %3)
%6 = load i32, i32* @SIGUSR2
%7 = call i64 @sigismember(i32* %3, i32 %6)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @SIGTERM
%13 = call i64 @sigismember(i32* %3, i32 %12)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@SIG_BLOCK = global i32 0
@.str = [13 x i8] c"SIGUSR2: %s\0A\00"
@SIGUSR2 = global i32 0
@.str.1 = [8 x i8] c"blocked\00"
@.str.2 = [12 x i8] c"not blocked\00"
@.str.3 = [13 x i8] c"SIGTERM: %s\0A\00"
@SIGTERM = global i32 0
define void @handler(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @SIG_BLOCK
%5 = call i32 @sigprocmask(i32 %4, i32* null, i32* %2)
%6 = load i32, i32* @SIGUSR2
%7 = call i64 @sigismember(i32* %2, i32 %6)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @SIGTERM
%12 = call i64 @sigismember(i32* %2, i32 %11)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret void
}