#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*/ SIG_UNBLOCK;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit_with(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void unblock_signal(int signum) {
  sigset_t signals_to_unblock;
  sigemptyset(&signals_to_unblock);
  sigaddset(&signals_to_unblock, signum);
  if (sigprocmask(SIG_UNBLOCK, &signals_to_unblock, NULL) == -1)
    exit_with("sigprocmask failed", errno, 1);
}


x86 assembly (clang, -O0):
<unblock_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    -0x4(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    1199 <unblock_signal+0x59>
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
mov    $0x1,%edx
call   1050 <exit_with@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unblock_signal>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <sigemptyset@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigaddset@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    118f <unblock_signal+0x4f>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe7b(%rip),%rdi
mov    $0x1,%edx
call   1050 <exit_with@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SIG_UNBLOCK = global i32 0
@.str = [19 x i8] c"sigprocmask failed\00"
@errno = global i32 0
define void @unblock_signal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @sigemptyset(i32* %3)
%5 = load i32, i32* %2
%6 = call i32 @sigaddset(i32* %3, i32 %5)
%7 = load i32, i32* @SIG_UNBLOCK
%8 = call i32 @sigprocmask(i32 %7, i32* %3, i32* null)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @errno
%12 = call i32 @exit_with(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %11, i32 1)
br label %13
13: ; preds = %10, %1
ret void
}

LLVM IR (-O2):
@SIG_UNBLOCK = global i32 0
@.str = [19 x i8] c"sigprocmask failed\00"
@errno = global i32 0
define void @unblock_signal(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @sigemptyset(i32* %2)
%5 = call i32 @sigaddset(i32* %2, i32 %0)
%6 = load i32, i32* @SIG_UNBLOCK
%7 = call i32 @sigprocmask(i32 %6, i32* %2, i32* null)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = call i32 @exit_with(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %10, i32 1)
br label %12
12: ; preds = %9, %1
ret void
}