#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 */
scalar_t__ EINTR;
int /*<<< orphan*/ SIGBUS;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGIO;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGURG;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_UNBLOCK;
scalar_t__ errno;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
void transfer_rate_sigmask(int block) {
  static sigset_t sig_set;
  if (block) {
    sigemptyset(&sig_set);
    sigaddset(&sig_set, SIGCHLD);
    sigaddset(&sig_set, SIGINT);
    sigaddset(&sig_set, SIGQUIT);
    sigaddset(&sig_set, SIGURG);
    sigaddset(&sig_set, SIGIO);
    sigaddset(&sig_set, SIGBUS);
    sigaddset(&sig_set, SIGHUP);
    while (sigprocmask(SIG_BLOCK, &sig_set, NULL) < 0) {
      if (errno == EINTR) {
        continue;
      }
      break;
    }
  } else {
    while (sigprocmask(SIG_UNBLOCK, &sig_set, NULL) < 0) {
      if (errno == EINTR) {
        continue;
      }
      break;
    }
  }
  return;
}


x86 assembly (clang, -O0):
<transfer_rate_sigmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1230 <transfer_rate_sigmask+0x100>
lea    0x2ef4(%rip),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
lea    0x2edf(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0x2eca(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
lea    0x2eb5(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
lea    0x2ea0(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%esi
lea    0x2e8b(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    0x2e76(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    0x2e61(%rip),%rdi
call   1050 <sigaddset@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0x2e4c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    122b <transfer_rate_sigmask+0xfb>
mov    0x2da2(%rip),%rax
mov    (%rax),%rax
mov    0x2d80(%rip),%rcx
cmp    (%rcx),%rax
jne    1226 <transfer_rate_sigmask+0xf6>
jmp    11e4 <transfer_rate_sigmask+0xb4>
jmp    122b <transfer_rate_sigmask+0xfb>
jmp    1281 <transfer_rate_sigmask+0x151>
jmp    1235 <transfer_rate_sigmask+0x105>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0x2dfb(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    127c <transfer_rate_sigmask+0x14c>
mov    0x2d51(%rip),%rax
mov    (%rax),%rax
mov    0x2d2f(%rip),%rcx
cmp    (%rcx),%rax
jne    1277 <transfer_rate_sigmask+0x147>
jmp    1235 <transfer_rate_sigmask+0x105>
jmp    127c <transfer_rate_sigmask+0x14c>
jmp    1281 <transfer_rate_sigmask+0x151>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfer_rate_sigmask>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     11fd <transfer_rate_sigmask+0xcd>
lea    0x2ef9(%rip),%r14
mov    %r14,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <sigaddset@plt>
mov    0x2dd3(%rip),%r15
mov    0x2ddc(%rip),%r12
mov    0x2dbd(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    123b <transfer_rate_sigmask+0x10b>
mov    (%r12),%rax
cmp    (%rbx),%rax
je     11e0 <transfer_rate_sigmask+0xb0>
jmp    123b <transfer_rate_sigmask+0x10b>
mov    0x2dd4(%rip),%r14
lea    0x2e35(%rip),%r15
mov    0x2d9e(%rip),%r12
mov    0x2d7f(%rip),%rbx
nopl   0x0(%rax)
mov    (%r14),%edi
mov    %r15,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    123b <transfer_rate_sigmask+0x10b>
mov    (%r12),%rax
cmp    (%rbx),%rax
je     1220 <transfer_rate_sigmask+0xf0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@transfer_rate_sigmask.sig_set = internal global i32 0
@SIGCHLD = global i32 0
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGURG = global i32 0
@SIGIO = global i32 0
@SIGBUS = global i32 0
@SIGHUP = global i32 0
@SIG_BLOCK = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@SIG_UNBLOCK = global i32 0
define void @transfer_rate_sigmask(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %32
5: ; preds = %1
%6 = call i32 @sigemptyset(i32* @transfer_rate_sigmask.sig_set)
%7 = load i32, i32* @SIGCHLD
%8 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %7)
%9 = load i32, i32* @SIGINT
%10 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %9)
%11 = load i32, i32* @SIGQUIT
%12 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %11)
%13 = load i32, i32* @SIGURG
%14 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %13)
%15 = load i32, i32* @SIGIO
%16 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %15)
%17 = load i32, i32* @SIGBUS
%18 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %17)
%19 = load i32, i32* @SIGHUP
%20 = call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %19)
br label %21
21: ; preds = %29, %5
%22 = load i32, i32* @SIG_BLOCK
%23 = call i64 @sigprocmask(i32 %22, i32* @transfer_rate_sigmask.sig_set, i32* null)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i64, i64* @errno
%27 = load i64, i64* @EINTR
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
br label %21
30: ; preds = %25
br label %31
31: ; preds = %30, %21
br label %44
32: ; preds = %1
br label %33
33: ; preds = %41, %32
%34 = load i32, i32* @SIG_UNBLOCK
%35 = call i64 @sigprocmask(i32 %34, i32* @transfer_rate_sigmask.sig_set, i32* null)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = load i64, i64* @errno
%39 = load i64, i64* @EINTR
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %37
br label %33
42: ; preds = %37
br label %43
43: ; preds = %42, %33
br label %44
44: ; preds = %43, %31
ret void
}

LLVM IR (-O2):
@transfer_rate_sigmask.sig_set = internal global i32 0
@SIGCHLD = global i32 0
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGURG = global i32 0
@SIGIO = global i32 0
@SIGBUS = global i32 0
@SIGHUP = global i32 0
@SIG_BLOCK = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@SIG_UNBLOCK = global i32 0
define void @transfer_rate_sigmask(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %27, label %3
3: ; preds = %1
%4 = tail call i32 @sigemptyset(i32* @transfer_rate_sigmask.sig_set)
%5 = load i32, i32* @SIGCHLD
%6 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %5)
%7 = load i32, i32* @SIGINT
%8 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %7)
%9 = load i32, i32* @SIGQUIT
%10 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %9)
%11 = load i32, i32* @SIGURG
%12 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %11)
%13 = load i32, i32* @SIGIO
%14 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %13)
%15 = load i32, i32* @SIGBUS
%16 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %15)
%17 = load i32, i32* @SIGHUP
%18 = tail call i32 @sigaddset(i32* @transfer_rate_sigmask.sig_set, i32 %17)
br label %19
19: ; preds = %23, %3
%20 = load i32, i32* @SIG_BLOCK
%21 = tail call i64 @sigprocmask(i32 %20, i32* @transfer_rate_sigmask.sig_set, i32* null)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %19
%24 = load i64, i64* @errno
%25 = load i64, i64* @EINTR
%26 = icmp eq i64 %24, %25
br i1 %26, label %19, label %35
27: ; preds = %1, %31
%28 = load i32, i32* @SIG_UNBLOCK
%29 = tail call i64 @sigprocmask(i32 %28, i32* @transfer_rate_sigmask.sig_set, i32* null)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i64, i64* @errno
%33 = load i64, i64* @EINTR
%34 = icmp eq i64 %32, %33
br i1 %34, label %27, label %35
35: ; preds = %19, %23, %27, %31
ret void
}