#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*/ LOG_WARNING;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void siglock(void) {
  sigset_t block;
  sigemptyset(&block);
  sigaddset(&block, SIGCHLD);
  if (sigprocmask(SIG_BLOCK, &block, NULL) < 0) {
    syslog(LOG_WARNING, "siglock failed: %s", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<siglock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
jge    11be <siglock+0x6e>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xe47(%rip),%rsi
call   1050 <syslog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<siglock>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <sigaddset@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %rax,%rax
jns    11b2 <siglock+0x62>
mov    0x2e4e(%rip),%rax
mov    (%rax),%ebx
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe57(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <syslog@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SIGCHLD = global i32 0
@SIG_BLOCK = global i32 0
@LOG_WARNING = global i32 0
@.str = [19 x i8] c"siglock failed: %s\00"
@errno = global i32 0
define void @siglock() {
%1 = alloca i32
%2 = call i32 @sigemptyset(i32* %1)
%3 = load i32, i32* @SIGCHLD
%4 = call i32 @sigaddset(i32* %1, i32 %3)
%5 = load i32, i32* @SIG_BLOCK
%6 = call i64 @sigprocmask(i32 %5, i32* %1, i32* null)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i32, i32* @LOG_WARNING
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @syslog(i32 %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %8, %0
ret void
}

LLVM IR (-O2):
@SIGCHLD = global i32 0
@SIG_BLOCK = global i32 0
@LOG_WARNING = global i32 0
@.str = [19 x i8] c"siglock failed: %s\00"
@errno = global i32 0
define void @siglock() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIGCHLD
%5 = call i32 @sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIG_BLOCK
%7 = call i64 @sigprocmask(i32 %6, i32* %1, i32* null)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32, i32* @LOG_WARNING
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %9, %0
ret void
}