#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 /*<<< orphan*/ EINTR;
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ __sig_flush();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ pause();
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ const *,
                       int /*<<< orphan*/ const *);
int sigsuspend(const sigset_t *mask) {
  sigset_t old_mask;
  if (mask == NULL) {
    errno = EINVAL;
    return -1;
  }
  if (sigprocmask(SIG_SETMASK, mask, &old_mask))
    return -1;
  pause();
  if (sigprocmask(SIG_SETMASK, &old_mask, NULL))
    return -1;
  __sig_flush();
  errno = EINTR;
  return -1;
}


x86 assembly (clang, -O0):
<sigsuspend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1165 <sigsuspend+0x35>
mov    0x2e7a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e81(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <sigsuspend+0xb4>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
je     1191 <sigsuspend+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <sigsuspend+0xb4>
mov    $0x0,%al
call   1050 <pause@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
je     11c4 <sigsuspend+0x94>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <sigsuspend+0xb4>
mov    $0x0,%al
call   1040 <__sig_flush@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%ecx
mov    0x2dfd(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigsuspend>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     117f <sigsuspend+0x4f>
mov    %rdi,%rsi
mov    0x2ea4(%rip),%rbx
mov    (%rbx),%edi
lea    0xc(%rsp),%rdx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jne    1191 <sigsuspend+0x61>
xor    %eax,%eax
call   1050 <pause@plt>
mov    (%rbx),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jne    1191 <sigsuspend+0x61>
xor    %eax,%eax
call   1040 <__sig_flush@plt>
mov    0x2e53(%rip),%rax
jmp    1186 <sigsuspend+0x56>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    0x2e49(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
@SIG_SETMASK = global i32 0
@EINTR = 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 %16, label %5
5: ; preds = %1
%6 = load i32, i32* @SIG_SETMASK
%7 = call i64 @sigprocmask(i32 %6, i32* %0, i32* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i32 (...) @pause()
%11 = load i32, i32* @SIG_SETMASK
%12 = call i64 @sigprocmask(i32 %11, i32* %2, i32* null)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = call i32 (...) @__sig_flush()
br label %16
16: ; preds = %1, %14
%17 = phi i32* [ @EINTR, %14 ], [ @EINVAL, %1 ]
%18 = load i32, i32* %17
store i32 %18, i32* @errno
br label %19
19: ; preds = %16, %9, %5
ret i32 -1
}