#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;
typedef int /*<<< orphan*/ sig_or_mask;
typedef int /*<<< orphan*/ set;

/* Variables and functions */
int NSIG;
scalar_t__ __sigaddset(int /*<<< orphan*/ *, int);
scalar_t__ sigdelset(int /*<<< orphan*/ *, int);
scalar_t__ sigemptyset(int /*<<< orphan*/ *);
int sigmask(int);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int sigsuspend(int /*<<< orphan*/ *);
int __sigpause(int sig_or_mask, int is_sig) {
  sigset_t set;
  int sig;
  if (is_sig != 0) {
    if (sigprocmask(0, NULL, &set) < 0 || sigdelset(&set, sig_or_mask) < 0)
      return -1;
  } else {
    if (sigemptyset(&set) < 0)
      return -1;
    if (sizeof(sig_or_mask) == sizeof(set))
      *(int *)&set = sig_or_mask;
    else if (sizeof(unsigned long int) == sizeof(set))
      *(unsigned long int *)&set = (unsigned int)sig_or_mask;
    else
      for (sig = 1; sig < NSIG; ++sig)
        if ((sig_or_mask & sigmask(sig)) && __sigaddset(&set, sig) < 0)
          return -1;
  }
  return sigsuspend(&set);
}


x86 assembly (clang, -O0):
<__sigpause>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1198 <__sigpause+0x58>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jl     1187 <__sigpause+0x47>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1060 <sigdelset@plt>
cmp    $0x0,%rax
jge    1193 <__sigpause+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <__sigpause+0x89>
jmp    11bd <__sigpause+0x7d>
lea    -0x10(%rbp),%rdi
call   1040 <sigemptyset@plt>
cmp    $0x0,%rax
jge    11b7 <__sigpause+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <__sigpause+0x89>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <sigsuspend@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sigpause>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   %esi,%esi
je     1174 <__sigpause+0x34>
lea    0x4(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <sigprocmask@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
js     119a <__sigpause+0x5a>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1060 <sigdelset@plt>
test   %rax,%rax
jns    1187 <__sigpause+0x47>
jmp    119a <__sigpause+0x5a>
lea    0x4(%rsp),%rdi
call   1040 <sigemptyset@plt>
test   %rax,%rax
js     1195 <__sigpause+0x55>
mov    %ebx,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1050 <sigsuspend@plt>
mov    %eax,%ebp
jmp    119a <__sigpause+0x5a>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@NSIG = global i32 0
define i32 @__sigpause(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %1, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = call i64 @sigprocmask(i32 0, i32* null, i32* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = call i64 @sigdelset(i32* %3, i32 %0)
%11 = icmp slt i64 %10, 0
br i1 %11, label %18, label %16
12: ; preds = %2
%13 = call i64 @sigemptyset(i32* %3)
%14 = icmp slt i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
store i32 %0, i32* %3
br label %16
16: ; preds = %9, %15
%17 = call i32 @sigsuspend(i32* %3)
br label %18
18: ; preds = %12, %6, %9, %16
%19 = phi i32 [ %17, %16 ], [ -1, %9 ], [ -1, %6 ], [ -1, %12 ]
ret i32 %19
}