#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*/ sigaddset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigismember(int /*<<< orphan*/ *, int);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int releasesignal(int sig) {
  sigset_t sset, oset;
  sigemptyset(&sset);
  sigaddset(&sset, sig);
  if (sigprocmask(SIG_UNBLOCK, &sset, &oset) < 0)
    return -1;
  else
    return sigismember(&oset, sig);
}


x86 assembly (clang, -O0):
<releasesignal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    118c <releasesignal+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <releasesignal+0x5b>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1050 <sigismember@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<releasesignal>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <sigaddset@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1030 <sigprocmask@plt>
test   %rax,%rax
js     1181 <releasesignal+0x41>
mov    %rsp,%rdi
mov    %ebp,%esi
call   1050 <sigismember@plt>
jmp    1186 <releasesignal+0x46>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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