#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct pollfd {
  int member_0;
  int revents;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int EPOLLIN;
int EPOLLOUT;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ POLLIN;
int /*<<< orphan*/ POLLOUT;
int epoll_create1(int /*<<< orphan*/);
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main() {
  fd_set readset, writeset;
  FD_ZERO(&readset);
  FD_ZERO(&writeset);
  FD_SET(0, &readset);
  FD_SET(1, &writeset);
  FD_SET(2, &writeset);
  int maxfdpl = 4;
  int select_ret = select(maxfdpl, &readset, &writeset, NULL, NULL);
  printf("select return %d,isset(%d,%d,%d).\n", select_ret,
         FD_ISSET(0, &readset), FD_ISSET(1, &writeset), FD_ISSET(2, &writeset));
  struct pollfd pollfds[3] = {{0, POLLIN, 0}, {1, POLLOUT, 0}, {2, POLLOUT, 0}};
  int poll_ret = poll(pollfds, 3, -1);
  printf("poll return %d, revents(%d,%d,%d).\n", poll_ret, pollfds[0].revents,
         pollfds[1].revents, pollfds[2].revents);
  int fd = 1;
  int epoll_fd = epoll_create1(0);
  if (epoll_fd < 0) {
    printf("epoll_create() returns %d.\n", epoll_fd);
    return 1;
  }
  struct epoll_event event;
  event.data.fd = fd;
  event.events = EPOLLIN | EPOLLOUT;
  int ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &event);
  if (ret < 0) {
    printf("epoll_ctl() returns %d.\n", ret);
    return 1;
  }
  struct epoll_event events[100];
  int max_events = 100;
  int timeout = -1;
  int nr_events = epoll_wait(epoll_fd, events, max_events, timeout);
  if (nr_events < 0) {
    printf("epoll_wait() returns %d.\n", nr_events);
    return 1;
  }
  int i;
  for (i = 0; i < nr_events; ++i) {
    printf("event=%ld on fd=%d\n", events[i].events, events[i].data.fd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <FD_ZERO@plt>
lea    -0xc(%rbp),%rdi
call   1060 <FD_ZERO@plt>
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    $0x1,%edi
lea    -0xc(%rbp),%rsi
call   10a0 <FD_SET@plt>
mov    $0x2,%edi
lea    -0xc(%rbp),%rsi
call   10a0 <FD_SET@plt>
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1070 <select@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x3ac(%rbp)
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1030 <FD_ISSET@plt>
mov    %eax,-0x3a8(%rbp)
mov    $0x1,%edi
lea    -0xc(%rbp),%rsi
call   1030 <FD_ISSET@plt>
mov    %eax,-0x3a4(%rbp)
mov    $0x2,%edi
lea    -0xc(%rbp),%rsi
call   1030 <FD_ISSET@plt>
mov    -0x3ac(%rbp),%esi
mov    -0x3a8(%rbp),%edx
mov    -0x3a4(%rbp),%ecx
mov    %eax,%r8d
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x1,-0x40(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x2,-0x30(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x3,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x58(%rbp)
xor    %edi,%edi
call   10b0 <epoll_create1@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    1328 <main+0x198>
mov    -0x5c(%rbp),%esi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1448 <main+0x2b8>
mov    -0x58(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    0x2cab(%rip),%rax
mov    (%rax),%eax
mov    0x2c82(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x68(%rbp)
mov    -0x5c(%rbp),%edi
mov    0x2c8b(%rip),%rax
mov    (%rax),%esi
mov    -0x58(%rbp),%edx
lea    -0x68(%rbp),%rcx
call   1050 <epoll_ctl@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1385 <main+0x1f5>
mov    -0x6c(%rbp),%esi
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1448 <main+0x2b8>
movl   $0x64,-0x394(%rbp)
movl   $0xffffffff,-0x398(%rbp)
ff ff ff
mov    -0x5c(%rbp),%edi
lea    -0x390(%rbp),%rsi
mov    -0x394(%rbp),%edx
mov    -0x398(%rbp),%ecx
call   1080 <epoll_wait@plt>
mov    %eax,-0x39c(%rbp)
cmpl   $0x0,-0x39c(%rbp)
jge    13e7 <main+0x257>
mov    -0x39c(%rbp),%esi
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1448 <main+0x2b8>
movl   $0x0,-0x3a0(%rbp)
mov    -0x3a0(%rbp),%eax
cmp    -0x39c(%rbp),%eax
jge    1441 <main+0x2b1>
movslq -0x3a0(%rbp),%rax
mov    -0x390(%rbp,%rax,8),%esi
movslq -0x3a0(%rbp),%rax
mov    -0x38c(%rbp,%rax,8),%edx
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3a0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a0(%rbp)
jmp    13f1 <main+0x261>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x370,%rsp
lea    0x4c(%rsp),%r15
mov    %r15,%rdi
call   1060 <FD_ZERO@plt>
lea    0x48(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <FD_ZERO@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   10a0 <FD_SET@plt>
mov    $0x1,%r14d
mov    $0x1,%edi
mov    %rbx,%rsi
call   10a0 <FD_SET@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   10a0 <FD_SET@plt>
mov    $0x4,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <select@plt>
mov    %eax,%r12d
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <FD_ISSET@plt>
mov    %eax,%r15d
mov    $0x1,%edi
mov    %rbx,%rsi
call   1030 <FD_ISSET@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    %rbx,%rsi
call   1030 <FD_ISSET@plt>
lea    0xdd5(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0x10(%rsp)
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
movq   $0x0,0x18(%rsp)
movl   $0x1,0x20(%rsp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
movq   $0x0,0x28(%rsp)
movl   $0x2,0x30(%rsp)
mov    %eax,0x34(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
mov    $0xffffffff,%edx
call   1090 <poll@plt>
mov    0x14(%rsp),%edx
mov    0x24(%rsp),%ecx
mov    0x34(%rsp),%r8d
lea    0xd6d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <epoll_create1@plt>
mov    %eax,%ebx
test   %eax,%eax
js     135d <main+0x1cd>
mov    0x2d09(%rip),%rax
mov    0x2ce2(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
movl   $0x1,0xc(%rsp)
mov    %ecx,0x8(%rsp)
mov    0x2ce3(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%r14d
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <epoll_ctl@plt>
test   %eax,%eax
js     1368 <main+0x1d8>
lea    0x50(%rsp),%rsi
mov    %ebx,%edi
mov    $0x64,%edx
mov    $0xffffffff,%ecx
call   1080 <epoll_wait@plt>
test   %eax,%eax
js     138b <main+0x1fb>
je     13a3 <main+0x213>
mov    %eax,%ebp
xor    %r14d,%r14d
lea    0xd5c(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x50(%rsp,%rbx,8),%esi
mov    0x54(%rsp,%rbx,8),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1340 <main+0x1b0>
jmp    1378 <main+0x1e8>
lea    0xce3(%rip),%rdi
mov    %ebx,%esi
jmp    1371 <main+0x1e1>
lea    0xcf4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
add    $0x370,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcea(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
jmp    1378 <main+0x1e8>
xor    %r14d,%r14d
jmp    1378 <main+0x1e8>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32, i32 }
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [35 x i8] c"select return %d,isset(%d,%d,%d).\0A\00"
@POLLIN = global i32 0
@POLLOUT = global i32 0
@.str.1 = [36 x i8] c"poll return %d, revents(%d,%d,%d).\0A\00"
@.str.2 = [28 x i8] c"epoll_create() returns %d.\0A\00"
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [25 x i8] c"epoll_ctl() returns %d.\0A\00"
@.str.4 = [26 x i8] c"epoll_wait() returns %d.\0A\00"
@.str.5 = [20 x i8] c"event=%ld on fd=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x %struct.pollfd]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.epoll_event
%11 = alloca i32
%12 = alloca [100 x %struct.epoll_event]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %1
%17 = call i32 @FD_ZERO(i32* %2)
%18 = call i32 @FD_ZERO(i32* %3)
%19 = call i32 @FD_SET(i32 0, i32* %2)
%20 = call i32 @FD_SET(i32 1, i32* %3)
%21 = call i32 @FD_SET(i32 2, i32* %3)
store i32 4, i32* %4
%22 = load i32, i32* %4
%23 = call i32 @select(i32 %22, i32* %2, i32* %3, i32* null, i32* null)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = call i32 @FD_ISSET(i32 0, i32* %2)
%26 = call i32 @FD_ISSET(i32 1, i32* %3)
%27 = call i32 @FD_ISSET(i32 2, i32* %3)
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26, i32 %27)
%29 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %6, i64 0, i64 0
%30 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 0
store i32 0, i32* %30
%31 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 1
%32 = load i32, i32* @POLLIN
store i32 %32, i32* %31
%33 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 2
store i32 0, i32* %33
%34 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 3
store i32 0, i32* %34
%35 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i64 1
%36 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i32 0, i32 0
store i32 1, i32* %36
%37 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i32 0, i32 1
%38 = load i32, i32* @POLLOUT
store i32 %38, i32* %37
%39 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i32 0, i32 2
store i32 0, i32* %39
%40 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i32 0, i32 3
store i32 0, i32* %40
%41 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i64 1
%42 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %41, i32 0, i32 0
store i32 2, i32* %42
%43 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %41, i32 0, i32 1
%44 = load i32, i32* @POLLOUT
store i32 %44, i32* %43
%45 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %41, i32 0, i32 2
store i32 0, i32* %45
%46 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %41, i32 0, i32 3
store i32 0, i32* %46
%47 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %6, i64 0, i64 0
%48 = call i32 @poll(%struct.pollfd* %47, i32 3, i32 -1)
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %6, i64 0, i64 0
%51 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %6, i64 0, i64 1
%54 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %53, i32 0, i32 1
%55 = load i32, i32* %54
%56 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %6, i64 0, i64 2
%57 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %52, i32 %55, i32 %58)
store i32 1, i32* %8
%60 = call i32 @epoll_create1(i32 0)
store i32 %60, i32* %9
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %0
%64 = load i32, i32* %9
%65 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %64)
store i32 1, i32* %1
br label %116
66: ; preds = %0
%67 = load i32, i32* %8
%68 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %10, i32 0, i32 1
%69 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %68, i32 0, i32 0
store i32 %67, i32* %69
%70 = load i32, i32* @EPOLLIN
%71 = load i32, i32* @EPOLLOUT
%72 = or i32 %70, %71
%73 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %10, i32 0, i32 0
store i32 %72, i32* %73
%74 = load i32, i32* %9
%75 = load i32, i32* @EPOLL_CTL_ADD
%76 = load i32, i32* %8
%77 = call i32 @epoll_ctl(i32 %74, i32 %75, i32 %76, %struct.epoll_event* %10)
store i32 %77, i32* %11
%78 = load i32, i32* %11
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %66
%81 = load i32, i32* %11
%82 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %81)
store i32 1, i32* %1
br label %116
83: ; preds = %66
store i32 100, i32* %13
store i32 -1, i32* %14
%84 = load i32, i32* %9
%85 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %12, i64 0, i64 0
%86 = load i32, i32* %13
%87 = load i32, i32* %14
%88 = call i32 @epoll_wait(i32 %84, %struct.epoll_event* %85, i32 %86, i32 %87)
store i32 %88, i32* %15
%89 = load i32, i32* %15
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %83
%92 = load i32, i32* %15
%93 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %92)
store i32 1, i32* %1
br label %116
94: ; preds = %83
store i32 0, i32* %16
br label %95
95: ; preds = %112, %94
%96 = load i32, i32* %16
%97 = load i32, i32* %15
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %115
99: ; preds = %95
%100 = load i32, i32* %16
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %12, i64 0, i64 %101
%103 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %102, i32 0, i32 0
%104 = load i32, i32* %103
%105 = load i32, i32* %16
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %12, i64 0, i64 %106
%108 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %107, i32 0, i32 1
%109 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %108, i32 0, i32 0
%110 = load i32, i32* %109
%111 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %104, i32 %110)
br label %112
112: ; preds = %99
%113 = load i32, i32* %16
%114 = add nsw i32 %113, 1
store i32 %114, i32* %16
br label %95
115: ; preds = %95
store i32 0, i32* %1
br label %116
116: ; preds = %115, %91, %80, %63
%117 = load i32, i32* %1
ret i32 %117
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32, i32 }
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [35 x i8] c"select return %d,isset(%d,%d,%d).\0A\00"
@POLLIN = global i32 0
@POLLOUT = global i32 0
@.str.1 = [36 x i8] c"poll return %d, revents(%d,%d,%d).\0A\00"
@.str.2 = [28 x i8] c"epoll_create() returns %d.\0A\00"
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [25 x i8] c"epoll_ctl() returns %d.\0A\00"
@.str.4 = [26 x i8] c"epoll_wait() returns %d.\0A\00"
@.str.5 = [20 x i8] c"event=%ld on fd=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x %struct.pollfd]
%4 = alloca %struct.epoll_event
%5 = alloca [100 x %struct.epoll_event]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = call i32 @FD_ZERO(i32* %1)
%9 = call i32 @FD_ZERO(i32* %2)
%10 = call i32 @FD_SET(i32 0, i32* %1)
%11 = call i32 @FD_SET(i32 1, i32* %2)
%12 = call i32 @FD_SET(i32 2, i32* %2)
%13 = call i32 @select(i32 4, i32* %1, i32* %2, i32* null, i32* null)
%14 = call i32 @FD_ISSET(i32 0, i32* %1)
%15 = call i32 @FD_ISSET(i32 1, i32* %2)
%16 = call i32 @FD_ISSET(i32 2, i32* %2)
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %16)
%18 = bitcast [3 x %struct.pollfd]* %3 to i8*
%19 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 0
%20 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 0, i32 0
store i32 0, i32* %20
%21 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 0, i32 1
%22 = load i32, i32* @POLLIN
store i32 %22, i32* %21
%23 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 0, i32 2
store i32 0, i32* %23
%24 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 0, i32 3
store i32 0, i32* %24
%25 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 1, i32 0
store i32 1, i32* %25
%26 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 1, i32 1
%27 = load i32, i32* @POLLOUT
store i32 %27, i32* %26
%28 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 1, i32 2
store i32 0, i32* %28
%29 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 1, i32 3
store i32 0, i32* %29
%30 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 2, i32 0
store i32 2, i32* %30
%31 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 2, i32 1
store i32 %27, i32* %31
%32 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 2, i32 2
store i32 0, i32* %32
%33 = getelementptr inbounds [3 x %struct.pollfd], [3 x %struct.pollfd]* %3, i64 0, i64 2, i32 3
store i32 0, i32* %33
%34 = call i32 @poll(%struct.pollfd* %19, i32 3, i32 -1)
%35 = load i32, i32* %21
%36 = load i32, i32* %26
%37 = load i32, i32* %31
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35, i32 %36, i32 %37)
%39 = call i32 @epoll_create1(i32 0)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %0
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %79
43: ; preds = %0
%44 = bitcast %struct.epoll_event* %4 to i8*
%45 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 0
store i32 1, i32* %45
%46 = load i32, i32* @EPOLLIN
%47 = load i32, i32* @EPOLLOUT
%48 = or i32 %47, %46
%49 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %48, i32* %49
%50 = load i32, i32* @EPOLL_CTL_ADD
%51 = call i32 @epoll_ctl(i32 %39, i32 %50, i32 1, %struct.epoll_event* %4)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %43
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %51)
br label %77
55: ; preds = %43
%56 = bitcast [100 x %struct.epoll_event]* %5 to i8*
%57 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %5, i64 0, i64 0
%58 = call i32 @epoll_wait(i32 %39, %struct.epoll_event* %57, i32 100, i32 -1)
%59 = icmp slt i32 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %55
%61 = icmp eq i32 %58, 0
br i1 %61, label %75, label %62
62: ; preds = %60
%63 = zext i32 %58 to i64
br label %66
64: ; preds = %55
%65 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %58)
br label %75
66: ; preds = %62, %66
%67 = phi i64 [ 0, %62 ], [ %73, %66 ]
%68 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %5, i64 0, i64 %67, i32 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds [100 x %struct.epoll_event], [100 x %struct.epoll_event]* %5, i64 0, i64 %67, i32 1, i32 0
%71 = load i32, i32* %70
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %69, i32 %71)
%73 = add nuw nsw i64 %67, 1
%74 = icmp eq i64 %73, %63
br i1 %74, label %75, label %66
75: ; preds = %66, %60, %64
%76 = phi i32 [ 1, %64 ], [ 0, %60 ], [ 0, %66 ]
br label %77
77: ; preds = %75, %53
%78 = phi i32 [ 1, %53 ], [ %76, %75 ]
br label %79
79: ; preds = %77, %41
%80 = phi i32 [ 1, %41 ], [ %78, %77 ]
ret i32 %80
}