#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*/ const sigset_t;

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ __set_errno(int);
int errno;
int /*<<< orphan*/ pause();
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ const *,
                       int /*<<< orphan*/ const *);
int __sigsuspend(const sigset_t *set) {
  sigset_t oset;
  int save;
  if (set == NULL) {
    __set_errno(EINVAL);
    return -1;
  }
  if (sigprocmask(SIG_SETMASK, set, &oset) < 0)
    return -1;
  (void)pause();
  save = errno;
  if (sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL) < 0)
    return -1;
  __set_errno(save);
  return -1;
}


x86 assembly (clang, -O0):
<__sigsuspend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1161 <__sigsuspend+0x31>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <__sigsuspend+0xab>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sigprocmask@plt>
cmp    $0x0,%rax
jge    118d <__sigsuspend+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <__sigsuspend+0xab>
mov    $0x0,%al
call   1050 <pause@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <sigprocmask@plt>
cmp    $0x0,%rax
jge    11cc <__sigsuspend+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11db <__sigsuspend+0xab>
mov    -0x18(%rbp),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sigsuspend>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     117a <__sigsuspend+0x4a>
mov    %rdi,%rsi
mov    0x2ea6(%rip),%rbx
mov    (%rbx),%edi
lea    0x4(%rsp),%rdx
call   1040 <sigprocmask@plt>
test   %rax,%rax
js     1188 <__sigsuspend+0x58>
xor    %eax,%eax
call   1050 <pause@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
call   1040 <sigprocmask@plt>
test   %rax,%rax
js     1188 <__sigsuspend+0x58>
mov    %ebp,%edi
jmp    1183 <__sigsuspend+0x53>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@SIG_SETMASK = global i32 0
@errno = global i32 0
define i32 @__sigsuspend(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @EINVAL
%10 = call i32 @__set_errno(i32 %9)
store i32 -1, i32* %2
br label %27
11: ; preds = %1
%12 = load i32, i32* @SIG_SETMASK
%13 = load i32*, i32** %3
%14 = call i64 @sigprocmask(i32 %12, i32* %13, i32* %4)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %2
br label %27
17: ; preds = %11
%18 = call i32 (...) @pause()
%19 = load i32, i32* @errno
store i32 %19, i32* %5
%20 = load i32, i32* @SIG_SETMASK
%21 = call i64 @sigprocmask(i32 %20, i32* %4, i32* null)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 -1, i32* %2
br label %27
24: ; preds = %17
%25 = load i32, i32* %5
%26 = call i32 @__set_errno(i32 %25)
store i32 -1, i32* %2
br label %27
27: ; preds = %24, %23, %16, %8
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@EINVAL = global i32 0
@SIG_SETMASK = global i32 0
@errno = global i32 0
define i32 @__sigsuspend(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i32* %0, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @EINVAL
%7 = tail call i32 @__set_errno(i32 %6)
br label %20
8: ; preds = %1
%9 = load i32, i32* @SIG_SETMASK
%10 = call i64 @sigprocmask(i32 %9, i32* %0, i32* %2)
%11 = icmp slt i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = call i32 (...) @pause()
%14 = load i32, i32* @errno
%15 = load i32, i32* @SIG_SETMASK
%16 = call i64 @sigprocmask(i32 %15, i32* %2, i32* null)
%17 = icmp slt i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = call i32 @__set_errno(i32 %14)
br label %20
20: ; preds = %12, %8, %18, %5
ret i32 -1
}