#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*/ SFD_CLOEXEC;
int /*<<< orphan*/ SIGALRM;
int /*<<< orphan*/ SIGCHLD;
int /*<<< orphan*/ SIGWINCH;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int signalfd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int create_signalfd() {
  sigset_t sigset;
  sigemptyset(&sigset);
  sigaddset(&sigset, SIGWINCH);
  sigaddset(&sigset, SIGCHLD);
  sigaddset(&sigset, SIGALRM);
  sigprocmask(SIG_BLOCK, &sigset, NULL);
  return signalfd(-1, &sigset, SFD_CLOEXEC);
}


x86 assembly (clang, -O0):
<create_signalfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1060 <sigaddset@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x4(%rbp),%rsi
call   1040 <signalfd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_signalfd>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <sigaddset@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <sigaddset@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <sigaddset@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
call   1040 <signalfd@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SIGWINCH = global i32 0
@SIGCHLD = global i32 0
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@SFD_CLOEXEC = global i32 0
define i32 @create_signalfd() {
%1 = alloca i32
%2 = call i32 @sigemptyset(i32* %1)
%3 = load i32, i32* @SIGWINCH
%4 = call i32 @sigaddset(i32* %1, i32 %3)
%5 = load i32, i32* @SIGCHLD
%6 = call i32 @sigaddset(i32* %1, i32 %5)
%7 = load i32, i32* @SIGALRM
%8 = call i32 @sigaddset(i32* %1, i32 %7)
%9 = load i32, i32* @SIG_BLOCK
%10 = call i32 @sigprocmask(i32 %9, i32* %1, i32* null)
%11 = load i32, i32* @SFD_CLOEXEC
%12 = call i32 @signalfd(i32 -1, i32* %1, i32 %11)
ret i32 %12
}

LLVM IR (-O2):
@SIGWINCH = global i32 0
@SIGCHLD = global i32 0
@SIGALRM = global i32 0
@SIG_BLOCK = global i32 0
@SFD_CLOEXEC = global i32 0
define i32 @create_signalfd() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIGWINCH
%5 = call i32 @sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIGCHLD
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = load i32, i32* @SIGALRM
%9 = call i32 @sigaddset(i32* %1, i32 %8)
%10 = load i32, i32* @SIG_BLOCK
%11 = call i32 @sigprocmask(i32 %10, i32* %1, i32* null)
%12 = load i32, i32* @SFD_CLOEXEC
%13 = call i32 @signalfd(i32 -1, i32* %1, i32 %12)
ret i32 %13
}