#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;
scalar_t__ sigaddset(int /*<<< orphan*/ *, int);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int signals_unblock(int signo) {
  sigset_t mask;
  if (sigemptyset(&mask) || sigaddset(&mask, signo) ||
      sigprocmask(SIG_UNBLOCK, &mask, NULL)) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<signals_unblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0x0,%rax
jne    1184 <signals_unblock+0x54>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1050 <sigaddset@plt>
cmp    $0x0,%rax
jne    1184 <signals_unblock+0x54>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
je     1190 <signals_unblock+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1197 <signals_unblock+0x67>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signals_unblock>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1174 <signals_unblock+0x44>
lea    0x4(%rsp),%rdi
mov    %ebp,%esi
call   1050 <sigaddset@plt>
test   %rax,%rax
jne    1174 <signals_unblock+0x44>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SIG_UNBLOCK = global i32 0
define i32 @signals_unblock(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = call i64 @sigemptyset(i32* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i64 @sigaddset(i32* %4, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i32, i32* @SIG_UNBLOCK
%13 = call i64 @sigprocmask(i32 %12, i32* %4, i32* null)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %7, %1
store i32 0, i32* %2
br label %17
16: ; preds = %11
store i32 1, i32* %2
br label %17
17: ; preds = %16, %15
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@SIG_UNBLOCK = global i32 0
define i32 @signals_unblock(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i64 @sigemptyset(i32* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = call i64 @sigaddset(i32* %2, i32 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* @SIG_UNBLOCK
%11 = call i64 @sigprocmask(i32 %10, i32* %2, i32* null)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %9, %1, %6
%15 = phi i32 [ 0, %6 ], [ 0, %1 ], [ %13, %9 ]
ret i32 %15
}