#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 TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};

/* Variables and functions */
scalar_t__ EINTR;
int EPOLLET;
int EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_NONBLOCK;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int epoll_create(int);
scalar_t__ epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct epoll_event *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ set_flag(int, int /*<<< orphan*/);
scalar_t__ tcp_main(int);
int tcp_server_socket(int);
int main(int argc, char *argv[]) {
  int listen_fd, client_fd, epoll_fd;
  int i, nready;
  struct epoll_event ev, events[10];
  listen_fd = tcp_server_socket(1234);
  if ((epoll_fd = epoll_create(10)) < 0) {
    perror("epoll_create");
    exit(EXIT_FAILURE);
  }
  memset(&ev, 0, sizeof(struct epoll_event));
  ev.events = EPOLLIN;
  ev.data.fd = listen_fd;
  if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, listen_fd, &ev) < 0) {
    perror("epoll_ctl_add-listen_fd error");
    exit(EXIT_FAILURE);
  }
  for (;;) {
    if ((nready = epoll_wait(epoll_fd, events, 10, -1)) < 0) {
      if (errno == EINTR)
        continue;
      perror("epoll_wait error");
      exit(EXIT_FAILURE);
    }
    for (i = 0; i < nready; i++) {
      if (events[i].data.fd == listen_fd) {
        if ((client_fd = accept(listen_fd, NULL, NULL)) < 0) {
          perror("accept error");
          exit(EXIT_FAILURE);
        }
        ev.events = EPOLLIN | EPOLLET;
        ev.data.fd = client_fd;
        if (set_flag(client_fd, O_NONBLOCK) < 0) {
          perror("set_flag error");
          exit(EXIT_FAILURE);
        }
        if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, client_fd, &ev) < 0) {
          perror("epoll_ctl_add-client_fd error");
          exit(EXIT_FAILURE);
        }
      } else {
        if (tcp_main(events[i].data.fd) == 0) {
          if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, events[i].data.fd, NULL) < 0) {
            perror("epoll_ctl_del error");
            exit(EXIT_FAILURE);
          }
          close(events[i].data.fd);
        }
      }
    }
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4d2,%edi
call   1030 <tcp_server_socket@plt>
mov    %eax,-0x14(%rbp)
mov    $0xa,%edi
call   10b0 <epoll_create@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1206 <main+0x56>
lea    0xe0d(%rip),%rdi
call   1090 <perror@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x30(%rbp),%rcx
call   1070 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    1264 <main+0xb4>
lea    0xdbc(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1269 <main+0xb9>
mov    -0x1c(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1080 <epoll_wait@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12c4 <main+0x114>
mov    0x2d2e(%rip),%rax
mov    (%rax),%rax
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%rax
jne    12aa <main+0xfa>
jmp    1269 <main+0xb9>
lea    0xd7a(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    142b <main+0x27b>
movslq -0x20(%rbp),%rax
mov    -0x7c(%rbp,%rax,8),%eax
cmp    -0x14(%rbp),%eax
jne    13ae <main+0x1fe>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10a0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    131d <main+0x16d>
lea    0xd32(%rip),%rdi
call   1090 <perror@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%eax
mov    0x2c7b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
call   10d0 <set_flag@plt>
cmp    $0x0,%rax
jge    136d <main+0x1bd>
lea    0xcef(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2c59(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
lea    -0x30(%rbp),%rcx
call   1070 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    13a9 <main+0x1f9>
lea    0xcc2(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1418 <main+0x268>
movslq -0x20(%rbp),%rax
mov    -0x7c(%rbp,%rax,8),%edi
call   1040 <tcp_main@plt>
cmp    $0x0,%rax
jne    1413 <main+0x263>
mov    -0x1c(%rbp),%edi
mov    0x2c29(%rip),%rax
mov    (%rax),%esi
movslq -0x20(%rbp),%rax
mov    -0x7c(%rbp,%rax,8),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    1406 <main+0x256>
lea    0xc83(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movslq -0x20(%rbp),%rax
mov    -0x7c(%rbp,%rax,8),%edi
call   1060 <close@plt>
jmp    1418 <main+0x268>
jmp    141d <main+0x26d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12cb <main+0x11b>
jmp    1269 <main+0xb9>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    $0x4d2,%edi
call   1030 <tcp_server_socket@plt>
mov    %eax,%ebx
mov    $0xa,%edi
call   10b0 <epoll_create@plt>
test   %eax,%eax
jns    11e4 <main+0x34>
lea    0xe21(%rip),%rdi
jmp    1349 <main+0x199>
mov    %eax,%r12d
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %ebx,0xc(%rsp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %ebx,%edx
mov    %rbp,%rcx
call   1070 <epoll_ctl@plt>
test   %rax,%rax
jns    1233 <main+0x83>
lea    0xddf(%rip),%rdi
jmp    1349 <main+0x199>
lea    0x8(%rsp),%r15
jmp    125a <main+0xaa>
nopw   0x0(%rax,%rax,1)
mov    0x2d79(%rip),%rax
mov    (%rax),%rax
mov    0x2d5f(%rip),%rcx
cmp    (%rcx),%rax
jne    135c <main+0x1ac>
mov    %r12d,%edi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1080 <epoll_wait@plt>
test   %eax,%eax
js     1240 <main+0x90>
je     125a <main+0xaa>
mov    %eax,%r13d
xor    %r14d,%r14d
jmp    1293 <main+0xe3>
nop
call   1040 <tcp_main@plt>
test   %rax,%rax
je     12f9 <main+0x149>
add    $0x1,%r14
cmp    %r14,%r13
je     125a <main+0xaa>
mov    0x14(%rsp,%r14,8),%edi
cmp    %ebx,%edi
jne    1280 <main+0xd0>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <accept@plt>
test   %eax,%eax
js     1327 <main+0x177>
mov    %eax,%ebp
mov    0x2cf4(%rip),%rax
mov    (%rax),%eax
mov    0x2d1b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    %ebp,0xc(%rsp)
mov    0x2d12(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   10d0 <set_flag@plt>
test   %rax,%rax
js     1330 <main+0x180>
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %ebp,%edx
mov    %r15,%rcx
call   1070 <epoll_ctl@plt>
test   %rax,%rax
jns    128a <main+0xda>
jmp    1339 <main+0x189>
lea    (%r14,%r14,1),%rbp
mov    0x2cf4(%rip),%rax
mov    (%rax),%esi
mov    0x14(%rsp,%rbp,4),%edx
mov    %r12d,%edi
xor    %ecx,%ecx
call   1070 <epoll_ctl@plt>
test   %rax,%rax
js     1342 <main+0x192>
mov    0x14(%rsp,%rbp,4),%edi
call   1060 <close@plt>
jmp    128a <main+0xda>
lea    0xd0e(%rip),%rdi
jmp    1349 <main+0x199>
lea    0xd12(%rip),%rdi
jmp    1349 <main+0x199>
lea    0xd18(%rip),%rdi
jmp    1349 <main+0x199>
lea    0xd2d(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xcc8(%rip),%rdi
jmp    1349 <main+0x199>

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [13 x i8] c"epoll_create\00"
@EXIT_FAILURE = global i32 0
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.1 = [30 x i8] c"epoll_ctl_add-listen_fd error\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [17 x i8] c"epoll_wait error\00"
@.str.3 = [13 x i8] c"accept error\00"
@EPOLLET = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [15 x i8] c"set_flag error\00"
@.str.5 = [30 x i8] c"epoll_ctl_add-client_fd error\00"
@EPOLL_CTL_DEL = global i32 0
@.str.6 = [20 x i8] c"epoll_ctl_del error\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.epoll_event
%12 = alloca [10 x %struct.epoll_event]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 @tcp_server_socket(i32 1234)
store i32 %13, i32* %6
%14 = call i32 @epoll_create(i32 10)
store i32 %14, i32* %8
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = call i32 @memset(%struct.epoll_event* %11, i32 0, i32 8)
%22 = load i32, i32* @EPOLLIN
%23 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %11, i32 0, i32 0
store i32 %22, i32* %23
%24 = load i32, i32* %6
%25 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %11, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
store i32 %24, i32* %26
%27 = load i32, i32* %8
%28 = load i32, i32* @EPOLL_CTL_ADD
%29 = load i32, i32* %6
%30 = call i64 @epoll_ctl(i32 %27, i32 %28, i32 %29, %struct.epoll_event* %11)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %20
%33 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %20
br label %37
37: ; preds = %137, %46, %36
%38 = load i32, i32* %8
%39 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %12, i64 0, i64 0
%40 = call i32 @epoll_wait(i32 %38, %struct.epoll_event* %39, i32 10, i32 -1)
store i32 %40, i32* %10
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i64, i64* @errno
%44 = load i64, i64* @EINTR
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %47
46: ; preds = %42
br label %37
47: ; preds = %42
%48 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %37
store i32 0, i32* %9
br label %52
52: ; preds = %134, %51
%53 = load i32, i32* %9
%54 = load i32, i32* %10
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %137
56: ; preds = %52
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %12, i64 0, i64 %58
%60 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %59, i32 0, i32 1
%61 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = load i32, i32* %6
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %100
65: ; preds = %56
%66 = load i32, i32* %6
%67 = call i32 @accept(i32 %66, i32* null, i32* null)
store i32 %67, i32* %7
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %65
%74 = load i32, i32* @EPOLLIN
%75 = load i32, i32* @EPOLLET
%76 = or i32 %74, %75
%77 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %11, i32 0, i32 0
store i32 %76, i32* %77
%78 = load i32, i32* %7
%79 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %11, i32 0, i32 1
%80 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %79, i32 0, i32 0
store i32 %78, i32* %80
%81 = load i32, i32* %7
%82 = load i32, i32* @O_NONBLOCK
%83 = call i64 @set_flag(i32 %81, i32 %82)
%84 = icmp slt i64 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %73
%86 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %73
%90 = load i32, i32* %8
%91 = load i32, i32* @EPOLL_CTL_ADD
%92 = load i32, i32* %7
%93 = call i64 @epoll_ctl(i32 %90, i32 %91, i32 %92, %struct.epoll_event* %11)
%94 = icmp slt i64 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %89
%96 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %89
br label %133
100: ; preds = %56
%101 = load i32, i32* %9
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %12, i64 0, i64 %102
%104 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %103, i32 0, i32 1
%105 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %104, i32 0, i32 0
%106 = load i32, i32* %105
%107 = call i64 @tcp_main(i32 %106)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %132
109: ; preds = %100
%110 = load i32, i32* %8
%111 = load i32, i32* @EPOLL_CTL_DEL
%112 = load i32, i32* %9
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %12, i64 0, i64 %113
%115 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %114, i32 0, i32 1
%116 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %115, i32 0, i32 0
%117 = load i32, i32* %116
%118 = call i64 @epoll_ctl(i32 %110, i32 %111, i32 %117, %struct.epoll_event* null)
%119 = icmp slt i64 %118, 0
br i1 %119, label %120, label %124
120: ; preds = %109
%121 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%122 = load i32, i32* @EXIT_FAILURE
%123 = call i32 @exit(i32 %122)
unreachable
124: ; preds = %109
%125 = load i32, i32* %9
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %12, i64 0, i64 %126
%128 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %127, i32 0, i32 1
%129 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %128, i32 0, i32 0
%130 = load i32, i32* %129
%131 = call i32 @close(i32 %130)
br label %132
132: ; preds = %124, %100
br label %133
133: ; preds = %132, %99
br label %134
134: ; preds = %133
%135 = load i32, i32* %9
%136 = add nsw i32 %135, 1
store i32 %136, i32* %9
br label %52
137: ; preds = %52
br label %37
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [13 x i8] c"epoll_create\00"
@EXIT_FAILURE = global i32 0
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.1 = [30 x i8] c"epoll_ctl_add-listen_fd error\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [17 x i8] c"epoll_wait error\00"
@.str.3 = [13 x i8] c"accept error\00"
@EPOLLET = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [15 x i8] c"set_flag error\00"
@.str.5 = [30 x i8] c"epoll_ctl_add-client_fd error\00"
@EPOLL_CTL_DEL = global i32 0
@.str.6 = [20 x i8] c"epoll_ctl_del error\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.epoll_event
%4 = alloca [10 x %struct.epoll_event]
%5 = bitcast %struct.epoll_event* %3 to i8*
%6 = bitcast [10 x %struct.epoll_event]* %4 to i8*
%7 = tail call i32 @tcp_server_socket(i32 1234)
%8 = tail call i32 @epoll_create(i32 10)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = call i32 @memset(%struct.epoll_event* %3, i32 0, i32 8)
%16 = load i32, i32* @EPOLLIN
%17 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0
store i32 %16, i32* %17
%18 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1, i32 0
store i32 %7, i32* %18
%19 = load i32, i32* @EPOLL_CTL_ADD
%20 = call i64 @epoll_ctl(i32 %8, i32 %19, i32 %7, %struct.epoll_event* %3)
%21 = icmp slt i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %14
%23 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %4, i64 0, i64 0
br label %28
24: ; preds = %14
%25 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %33, %22
%29 = call i32 @epoll_wait(i32 %8, %struct.epoll_event* %23, i32 10, i32 -1)
%30 = icmp slt i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %28
%32 = icmp eq i32 %29, 0
br i1 %32, label %33, label %34
33: ; preds = %90, %31, %36
br label %28
34: ; preds = %31
%35 = zext i32 %29 to i64
br label %44
36: ; preds = %28
%37 = load i64, i64* @errno
%38 = load i64, i64* @EINTR
%39 = icmp eq i64 %37, %38
br i1 %39, label %33, label %40
40: ; preds = %36
%41 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %34, %90
%45 = phi i64 [ 0, %34 ], [ %91, %90 ]
%46 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %4, i64 0, i64 %45, i32 1, i32 0
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, %7
br i1 %48, label %49, label %75
49: ; preds = %44
%50 = call i32 @accept(i32 %7, i32* null, i32* null)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %49
%57 = load i32, i32* @EPOLLIN
%58 = load i32, i32* @EPOLLET
%59 = or i32 %58, %57
store i32 %59, i32* %17
store i32 %50, i32* %18
%60 = load i32, i32* @O_NONBLOCK
%61 = call i64 @set_flag(i32 %50, i32 %60)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %56
%64 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %56
%68 = load i32, i32* @EPOLL_CTL_ADD
%69 = call i64 @epoll_ctl(i32 %8, i32 %68, i32 %50, %struct.epoll_event* %3)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %90
71: ; preds = %67
%72 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %44
%76 = call i64 @tcp_main(i32 %47)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %90
78: ; preds = %75
%79 = load i32, i32* @EPOLL_CTL_DEL
%80 = load i32, i32* %46
%81 = call i64 @epoll_ctl(i32 %8, i32 %79, i32 %80, %struct.epoll_event* null)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %87
83: ; preds = %78
%84 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %78
%88 = load i32, i32* %46
%89 = call i32 @close(i32 %88)
br label %90
90: ; preds = %67, %87, %75
%91 = add nuw nsw i64 %45, 1
%92 = icmp eq i64 %91, %35
br i1 %92, label %33, label %44
}