#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_BLOCK;
scalar_t__ sigdelset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ sigset_set_old_mask(int /*<<< orphan*/ *, int);
int sigsuspend(int /*<<< orphan*/ *);
int __sigpause(int sig_or_mask, int is_sig) {
  sigset_t set;
  if (is_sig) {
    sigprocmask(SIG_BLOCK, NULL, &set);
    if (sigdelset(&set, sig_or_mask) < 0)
      return -1;
  } else
    sigset_set_old_mask(&set, sig_or_mask);
  return sigsuspend(&set);
}


x86 assembly (clang, -O0):
<__sigpause>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1195 <__sigpause+0x55>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1060 <sigdelset@plt>
cmp    $0x0,%rax
jge    1190 <__sigpause+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ad <__sigpause+0x6d>
jmp    11a1 <__sigpause+0x61>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1040 <sigset_set_old_mask@plt>
lea    -0x10(%rbp),%rdi
call   1050 <sigsuspend@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sigpause>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
test   %esi,%esi
je     1178 <__sigpause+0x38>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%r14
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <sigdelset@plt>
test   %rax,%rax
jns    1184 <__sigpause+0x44>
mov    $0xffffffff,%eax
jmp    118e <__sigpause+0x4e>
lea    0x4(%rsp),%rdi
mov    %ebx,%esi
call   1040 <sigset_set_old_mask@plt>
lea    0x4(%rsp),%rdi
call   1050 <sigsuspend@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@SIG_BLOCK = 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 %11, label %6
6: ; preds = %2
%7 = load i32, i32* @SIG_BLOCK
%8 = call i32 @sigprocmask(i32 %7, i32* null, i32* %3)
%9 = call i64 @sigdelset(i32* %3, i32 %0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %15, label %13
11: ; preds = %2
%12 = call i32 @sigset_set_old_mask(i32* %3, i32 %0)
br label %13
13: ; preds = %6, %11
%14 = call i32 @sigsuspend(i32* %3)
br label %15
15: ; preds = %6, %13
%16 = phi i32 [ %14, %13 ], [ -1, %6 ]
ret i32 %16
}