#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*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int signalfd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main() {
  sigset_t mask;
  int sfd;
  sigemptyset(&mask);
  sigaddset(&mask, SIGINT);
  sigaddset(&mask, SIGQUIT);
  sfd = signalfd(-1, &mask, 0);
  sigaddset(&mask, SIGUSR1);
  sigaddset(&mask, SIGUSR2);
  sfd = signalfd(sfd, &mask, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <sigemptyset@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigaddset@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigaddset@plt>
mov    $0xffffffff,%edi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <signalfd@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigaddset@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <sigaddset@plt>
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <signalfd@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigemptyset@plt>
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
mov    $0xffffffff,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <signalfd@plt>
mov    %eax,%ebp
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <signalfd@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @sigemptyset(i32* %2)
%5 = load i32, i32* @SIGINT
%6 = call i32 @sigaddset(i32* %2, i32 %5)
%7 = load i32, i32* @SIGQUIT
%8 = call i32 @sigaddset(i32* %2, i32 %7)
%9 = call i32 @signalfd(i32 -1, i32* %2, i32 0)
store i32 %9, i32* %3
%10 = load i32, i32* @SIGUSR1
%11 = call i32 @sigaddset(i32* %2, i32 %10)
%12 = load i32, i32* @SIGUSR2
%13 = call i32 @sigaddset(i32* %2, i32 %12)
%14 = load i32, i32* %3
%15 = call i32 @signalfd(i32 %14, i32* %2, i32 0)
store i32 %15, i32* %3
ret i32 0
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGUSR1 = global i32 0
@SIGUSR2 = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIGINT
%5 = call i32 @sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIGQUIT
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = call i32 @signalfd(i32 -1, i32* %1, i32 0)
%9 = load i32, i32* @SIGUSR1
%10 = call i32 @sigaddset(i32* %1, i32 %9)
%11 = load i32, i32* @SIGUSR2
%12 = call i32 @sigaddset(i32* %1, i32 %11)
%13 = call i32 @signalfd(i32 %8, i32* %1, i32 0)
ret i32 0
}