#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 */
struct timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};
struct pollfd {
  int member_0;
  int member_1;
  int /*<<< orphan*/ member_2;
};
struct epoll_event {
  int dummy;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int EPOLL_CTL_ADD;
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ close(int);
int epoll_create(int);
int /*<<< orphan*/ epoll_ctl(int, int, int, struct epoll_event *);
int /*<<< orphan*/ epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ poll(struct pollfd *, int, int);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int main() {
  struct epoll_event ev, events[17];
  struct pollfd pfd = {7, 0x23, 0};
  int fd;
  struct timespec tim = {.tv_sec = 0, .tv_nsec = 200000000};
  sigset_t sigs;
  sigemptyset(&sigs);
  sigaddset(&sigs, SIGUSR2);
  fd = epoll_create(32);
  epoll_create(-1);
  epoll_ctl(fd, EPOLL_CTL_ADD, 13, &ev);
  epoll_ctl(-1, EPOLL_CTL_ADD, 13, &ev);
  epoll_ctl(fd, -1, 13, &ev);
  epoll_ctl(fd, EPOLL_CTL_ADD, -1, &ev);
  epoll_ctl(fd, EPOLL_CTL_ADD, 13, (struct epoll_event *)-1);
  epoll_wait(fd, events, 17, 0);
  epoll_wait(-1, events, 17, 0);
  epoll_wait(fd, (struct epoll_event *)-1, 17, 0);
  epoll_wait(fd, events, -1, 0);
  epoll_wait(-1, events, 17, -1);
  close(fd);
  poll(&pfd, 1, 0);
  poll((struct pollfd *)-1, 1, 0);
  poll(&pfd, -1, 0);
  poll(NULL, 1, -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0x58(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    -0x74(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    -0x74(%rbp),%rdi
call   1090 <sigaddset@plt>
mov    $0x20,%edi
call   1080 <epoll_create@plt>
mov    %eax,-0x64(%rbp)
mov    $0xffffffff,%edi
call   1080 <epoll_create@plt>
mov    -0x64(%rbp),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
mov    $0xd,%edx
lea    -0x8(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
mov    $0xd,%edx
lea    -0x8(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    -0x64(%rbp),%edi
mov    $0xffffffff,%esi
mov    $0xd,%edx
lea    -0x8(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    -0x64(%rbp),%edi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edx
lea    -0x8(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    -0x64(%rbp),%edi
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
mov    $0xd,%edx
mov    $0xffffffffffffffff,%rcx
call   1040 <epoll_ctl@plt>
mov    -0x64(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
lea    -0x50(%rbp),%rsi
mov    $0xffffffff,%edi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    -0x64(%rbp),%edi
mov    $0xffffffffffffffff,%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    -0x64(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0xffffffff,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
lea    -0x50(%rbp),%rsi
mov    $0xffffffff,%ecx
mov    $0x11,%edx
mov    %ecx,%edi
call   1060 <epoll_wait@plt>
mov    -0x64(%rbp),%edi
call   1030 <close@plt>
lea    -0x60(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <poll@plt>
mov    $0xffffffffffffffff,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <poll@plt>
lea    -0x60(%rbp),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <poll@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1070 <poll@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0xe89(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xe76(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sigemptyset@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <sigaddset@plt>
mov    $0x20,%edi
call   1080 <epoll_create@plt>
mov    %eax,%ebx
mov    $0xffffffff,%edi
call   1080 <epoll_create@plt>
mov    0x2e1e(%rip),%r15
mov    (%r15),%esi
lea    0x18(%rsp),%r14
mov    %ebx,%edi
mov    $0xd,%edx
mov    %r14,%rcx
call   1040 <epoll_ctl@plt>
mov    (%r15),%esi
mov    $0xffffffff,%edi
mov    $0xd,%edx
mov    %r14,%rcx
call   1040 <epoll_ctl@plt>
mov    %ebx,%edi
mov    $0xffffffff,%esi
mov    $0xd,%edx
mov    %r14,%rcx
call   1040 <epoll_ctl@plt>
mov    (%r15),%esi
mov    %ebx,%edi
mov    $0xffffffff,%edx
mov    %r14,%rcx
call   1040 <epoll_ctl@plt>
mov    (%r15),%esi
mov    %ebx,%edi
mov    $0xd,%edx
mov    $0xffffffffffffffff,%rcx
call   1040 <epoll_ctl@plt>
lea    0x20(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
mov    $0x11,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xffffffff,%edx
xor    %ecx,%ecx
call   1060 <epoll_wait@plt>
mov    $0xffffffff,%edi
mov    %r14,%rsi
mov    $0x11,%edx
mov    $0xffffffff,%ecx
call   1060 <epoll_wait@plt>
mov    %ebx,%edi
call   1030 <close@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <poll@plt>
mov    $0xffffffffffffffff,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <poll@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <poll@plt>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1070 <poll@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
%struct.timespec = type { i32, i32 }
%struct.epoll_event = type { i32 }
@__const.main.pfd = %struct.pollfd { i32 7, i32 35, i32 0 }
@__const.main.tim = %struct.timespec { i32 200000000, i32 0 }
@SIGUSR2 = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.epoll_event
%3 = alloca [17 x %struct.epoll_event]
%4 = alloca %struct.pollfd
%5 = alloca i32
%6 = alloca %struct.timespec
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast %struct.pollfd* %4 to i8*
%9 = bitcast %struct.timespec* %6 to i8*
%10 = call i32 @sigemptyset(i32* %7)
%11 = load i32, i32* @SIGUSR2
%12 = call i32 @sigaddset(i32* %7, i32 %11)
%13 = call i32 @epoll_create(i32 32)
store i32 %13, i32* %5
%14 = call i32 @epoll_create(i32 -1)
%15 = load i32, i32* %5
%16 = load i32, i32* @EPOLL_CTL_ADD
%17 = call i32 @epoll_ctl(i32 %15, i32 %16, i32 13, %struct.epoll_event* %2)
%18 = load i32, i32* @EPOLL_CTL_ADD
%19 = call i32 @epoll_ctl(i32 -1, i32 %18, i32 13, %struct.epoll_event* %2)
%20 = load i32, i32* %5
%21 = call i32 @epoll_ctl(i32 %20, i32 -1, i32 13, %struct.epoll_event* %2)
%22 = load i32, i32* %5
%23 = load i32, i32* @EPOLL_CTL_ADD
%24 = call i32 @epoll_ctl(i32 %22, i32 %23, i32 -1, %struct.epoll_event* %2)
%25 = load i32, i32* %5
%26 = load i32, i32* @EPOLL_CTL_ADD
%27 = call i32 @epoll_ctl(i32 %25, i32 %26, i32 13, %struct.epoll_event* inttoptr (i64 -1 to %struct.epoll_event*))
%28 = load i32, i32* %5
%29 = getelementptr inbounds [17 x %struct.epoll_event], [17 x %struct.epoll_event]* %3, i64 0, i64 0
%30 = call i32 @epoll_wait(i32 %28, %struct.epoll_event* %29, i32 17, i32 0)
%31 = getelementptr inbounds [17 x %struct.epoll_event], [17 x %struct.epoll_event]* %3, i64 0, i64 0
%32 = call i32 @epoll_wait(i32 -1, %struct.epoll_event* %31, i32 17, i32 0)
%33 = load i32, i32* %5
%34 = call i32 @epoll_wait(i32 %33, %struct.epoll_event* inttoptr (i64 -1 to %struct.epoll_event*), i32 17, i32 0)
%35 = load i32, i32* %5
%36 = getelementptr inbounds [17 x %struct.epoll_event], [17 x %struct.epoll_event]* %3, i64 0, i64 0
%37 = call i32 @epoll_wait(i32 %35, %struct.epoll_event* %36, i32 -1, i32 0)
%38 = getelementptr inbounds [17 x %struct.epoll_event], [17 x %struct.epoll_event]* %3, i64 0, i64 0
%39 = call i32 @epoll_wait(i32 -1, %struct.epoll_event* %38, i32 17, i32 -1)
%40 = load i32, i32* %5
%41 = call i32 @close(i32 %40)
%42 = call i32 @poll(%struct.pollfd* %4, i32 1, i32 0)
%43 = call i32 @poll(%struct.pollfd* inttoptr (i64 -1 to %struct.pollfd*), i32 1, i32 0)
%44 = call i32 @poll(%struct.pollfd* %4, i32 -1, i32 0)
%45 = call i32 @poll(%struct.pollfd* null, i32 1, i32 -1)
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
%struct.epoll_event = type { i32 }
@__const.main.pfd = %struct.pollfd { i32 7, i32 35, i32 0 }
@SIGUSR2 = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @main() {
%1 = alloca %struct.epoll_event
%2 = alloca [17 x %struct.epoll_event]
%3 = alloca %struct.pollfd
%4 = alloca i32
%5 = bitcast %struct.epoll_event* %1 to i8*
%6 = bitcast [17 x %struct.epoll_event]* %2 to i8*
%7 = bitcast %struct.pollfd* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @sigemptyset(i32* %4)
%10 = load i32, i32* @SIGUSR2
%11 = call i32 @sigaddset(i32* %4, i32 %10)
%12 = call i32 @epoll_create(i32 32)
%13 = call i32 @epoll_create(i32 -1)
%14 = load i32, i32* @EPOLL_CTL_ADD
%15 = call i32 @epoll_ctl(i32 %12, i32 %14, i32 13, %struct.epoll_event* %1)
%16 = load i32, i32* @EPOLL_CTL_ADD
%17 = call i32 @epoll_ctl(i32 -1, i32 %16, i32 13, %struct.epoll_event* %1)
%18 = call i32 @epoll_ctl(i32 %12, i32 -1, i32 13, %struct.epoll_event* %1)
%19 = load i32, i32* @EPOLL_CTL_ADD
%20 = call i32 @epoll_ctl(i32 %12, i32 %19, i32 -1, %struct.epoll_event* %1)
%21 = load i32, i32* @EPOLL_CTL_ADD
%22 = call i32 @epoll_ctl(i32 %12, i32 %21, i32 13, %struct.epoll_event* inttoptr (i64 -1 to %struct.epoll_event*))
%23 = getelementptr inbounds [17 x %struct.epoll_event], [17 x %struct.epoll_event]* %2, i64 0, i64 0
%24 = call i32 @epoll_wait(i32 %12, %struct.epoll_event* %23, i32 17, i32 0)
%25 = call i32 @epoll_wait(i32 -1, %struct.epoll_event* %23, i32 17, i32 0)
%26 = call i32 @epoll_wait(i32 %12, %struct.epoll_event* inttoptr (i64 -1 to %struct.epoll_event*), i32 17, i32 0)
%27 = call i32 @epoll_wait(i32 %12, %struct.epoll_event* %23, i32 -1, i32 0)
%28 = call i32 @epoll_wait(i32 -1, %struct.epoll_event* %23, i32 17, i32 -1)
%29 = call i32 @close(i32 %12)
%30 = call i32 @poll(%struct.pollfd* %3, i32 1, i32 0)
%31 = call i32 @poll(%struct.pollfd* inttoptr (i64 -1 to %struct.pollfd*), i32 1, i32 0)
%32 = call i32 @poll(%struct.pollfd* %3, i32 -1, i32 0)
%33 = call i32 @poll(%struct.pollfd* null, i32 1, i32 -1)
ret i32 0
}