#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct TYPE_4__ {
  int fd;
};
struct epoll_event {
  TYPE_2__ data;
  void *events;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serverDetail;
typedef int /*<<< orphan*/ clientDetail;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
void *EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int epoll_create(int);
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ listen(int, int);
struct epoll_event *malloc(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int serverSock, clientSock;
  struct sockaddr_in serverDetail, clientDetail;
  char buf[16];
  socklen_t addrSize;
  int i;
  int strLength;
  struct epoll_event *ep_events;
  struct epoll_event epollEvent;
  int epfd, event_cnt;
  serverSock = socket(PF_INET, SOCK_STREAM, 0);
  memset(&serverDetail, 0, sizeof(serverDetail));
  serverDetail.sin_family = AF_INET;
  serverDetail.sin_addr.s_addr = inet_addr("127.0.0.1");
  serverDetail.sin_port = htons(9000);
  bind(serverSock, (struct sockaddr *)&serverDetail, sizeof(serverDetail));
  listen(serverSock, 5);
  epfd = epoll_create(64);
  ep_events = malloc(sizeof(struct epoll_event) * 64);
  epollEvent.events = EPOLLIN;
  epollEvent.data.fd = serverSock;
  epoll_ctl(epfd, EPOLL_CTL_ADD, serverSock, &epollEvent);
  while (1) {
    event_cnt = epoll_wait(epfd, ep_events, 64, -1);
    if (event_cnt == -1) {
      puts("wait error\n");
      break;
    }
    for (i = 0; i < event_cnt; ++i) {
      if (ep_events[i].data.fd == serverSock) {
        addrSize = sizeof(clientDetail);
        clientSock =
            accept(serverSock, (struct sockaddr *)&clientDetail, &addrSize);
        epollEvent.events = EPOLLIN;
        epollEvent.data.fd = clientSock;
        epoll_ctl(epfd, EPOLL_CTL_ADD, clientSock, &epollEvent);
        printf("conneted client: %d\n", clientSock);
      } else {
        strLength = read(ep_events[i].data.fd, buf, 16);
        if (strLength == 0) {
          epoll_ctl(epfd, EPOLL_CTL_DEL, ep_events[i].data.fd, NULL);
          close(ep_events[i].data.fd);
          printf("disconnect client: %d\n", ep_events[i].data.fd);
        } else {
          write(ep_events[i].data.fd, buf, strLength);
        }
      }
    }
  }
  close(serverSock);
  close(epfd);
  return 0;
}


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    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    0xda8(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2328,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
mov    $0x40,%edi
call   1110 <epoll_create@plt>
mov    %eax,-0x7c(%rbp)
mov    $0x400,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x7c(%rbp),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x78(%rbp),%rcx
call   1090 <epoll_ctl@plt>
mov    -0x7c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10e0 <epoll_wait@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0xffffffff,-0x80(%rbp)
jne    1306 <main+0x106>
lea    0xd0e(%rip),%rdi
call   1030 <puts@plt>
jmp    1451 <main+0x251>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    144c <main+0x24c>
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    138d <main+0x18d>
movl   $0xc,-0x54(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x7c(%rbp),%edi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
lea    -0x78(%rbp),%rcx
call   1090 <epoll_ctl@plt>
mov    -0x18(%rbp),%esi
lea    0xc93(%rip),%rdi
call   1060 <printf@plt>
jmp    1439 <main+0x239>
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <read@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jne    1417 <main+0x217>
mov    -0x7c(%rbp),%edi
mov    0x2c35(%rip),%rax
mov    (%rax),%esi
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1090 <epoll_ctl@plt>
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
call   1080 <close@plt>
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%esi
lea    0xc1e(%rip),%rdi
call   1060 <printf@plt>
jmp    1434 <main+0x234>
mov    -0x68(%rbp),%rax
movslq -0x58(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
mov    -0x5c(%rbp),%edx
call   1040 <write@plt>
jmp    1439 <main+0x239>
jmp    143e <main+0x23e>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    130d <main+0x10d>
jmp    12d2 <main+0xd2>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    -0x7c(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%r14d
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
lea    0xdae(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x24(%rsp)
mov    $0x2328,%edi
call   1050 <htons@plt>
mov    %eax,0x20(%rsp)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   10f0 <bind@plt>
mov    %r14d,%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
mov    $0x40,%edi
call   1110 <epoll_create@plt>
mov    %eax,%ebx
mov    $0x400,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    0x2d32(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %r14d,0x10(%rsp)
mov    0x2d16(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    %r14d,%edx
call   1090 <epoll_ctl@plt>
mov    %ebx,0x8(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10e0 <epoll_wait@plt>
cmp    $0xffffffff,%eax
je     13f4 <main+0x1f4>
lea    0x40(%rsp),%rbx
jmp    131f <main+0x11f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10e0 <epoll_wait@plt>
cmp    $0xffffffff,%eax
je     13f4 <main+0x1f4>
test   %eax,%eax
jle    1300 <main+0x100>
mov    %eax,%r15d
shl    $0x4,%r15
xor    %r12d,%r12d
jmp    1397 <main+0x197>
nop
movl   $0xc,0xc(%rsp)
mov    %r14d,%edi
lea    0x30(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1100 <accept@plt>
mov    %eax,%r13d
mov    0x2c84(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %r13d,0x10(%rsp)
mov    0x2c68(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%edi
mov    %r13d,%edx
lea    0x10(%rsp),%rcx
call   1090 <epoll_ctl@plt>
lea    0xc94(%rip),%rdi
mov    %r13d,%esi
call   1060 <printf@plt>
add    $0x10,%r12
cmp    %r12,%r15
je     1300 <main+0x100>
mov    0x0(%rbp,%r12,1),%edi
cmp    %r14d,%edi
je     1330 <main+0x130>
mov    %rbx,%rsi
mov    $0x10,%edx
call   10a0 <read@plt>
test   %eax,%eax
je     13c3 <main+0x1c3>
mov    0x0(%rbp,%r12,1),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    138a <main+0x18a>
mov    0x2c2e(%rip),%rax
mov    (%rax),%esi
mov    0x0(%rbp,%r12,1),%edx
mov    0x8(%rsp),%edi
xor    %ecx,%ecx
call   1090 <epoll_ctl@plt>
mov    0x0(%rbp,%r12,1),%edi
call   1080 <close@plt>
mov    0x0(%rbp,%r12,1),%esi
lea    0xc39(%rip),%rdi
jmp    1385 <main+0x185>
lea    0xc0f(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { %struct.TYPE_4__, i8* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@EPOLLIN = global i8* null
@EPOLL_CTL_ADD = global i32 0
@.str.1 = [12 x i8] c"wait error\0A\00"
@.str.2 = [21 x i8] c"conneted client: %d\0A\00"
@EPOLL_CTL_DEL = global i32 0
@.str.3 = [23 x i8] c"disconnect client: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca [16 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.epoll_event*
%15 = alloca %struct.epoll_event
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* @PF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = call i32 @socket(i32 %18, i32 %19, i32 0)
store i32 %20, i32* %6
%21 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %22, i32* %23
%24 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 0
store i32 %24, i32* %26
%27 = call i32 @htons(i32 9000)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %27, i32* %28
%29 = load i32, i32* %6
%30 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%31 = call i32 @bind(i32 %29, %struct.sockaddr* %30, i32 12)
%32 = load i32, i32* %6
%33 = call i32 @listen(i32 %32, i32 5)
%34 = call i32 @epoll_create(i32 64)
store i32 %34, i32* %16
%35 = call %struct.epoll_event* @malloc(i32 1024)
store %struct.epoll_event* %35, %struct.epoll_event** %14
%36 = load i8*, i8** @EPOLLIN
%37 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %15, i32 0, i32 1
store i8* %36, i8** %37
%38 = load i32, i32* %6
%39 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %15, i32 0, i32 0
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i32 0, i32 0
store i32 %38, i32* %40
%41 = load i32, i32* %16
%42 = load i32, i32* @EPOLL_CTL_ADD
%43 = load i32, i32* %6
%44 = call i32 @epoll_ctl(i32 %41, i32 %42, i32 %43, %struct.epoll_event* %15)
br label %45
45: ; preds = %2, %138
%46 = load i32, i32* %16
%47 = load %struct.epoll_event*, %struct.epoll_event** %14
%48 = call i32 @epoll_wait(i32 %46, %struct.epoll_event* %47, i32 64, i32 -1)
store i32 %48, i32* %17
%49 = load i32, i32* %17
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %139
53: ; preds = %45
store i32 0, i32* %12
br label %54
54: ; preds = %135, %53
%55 = load i32, i32* %12
%56 = load i32, i32* %17
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %138
58: ; preds = %54
%59 = load %struct.epoll_event*, %struct.epoll_event** %14
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %59, i64 %61
%63 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %62, i32 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %63, i32 0, i32 0
%65 = load i32, i32* %64
%66 = load i32, i32* %6
%67 = icmp eq i32 %65, %66
br i1 %67, label %68, label %83
68: ; preds = %58
store i32 12, i32* %11
%69 = load i32, i32* %6
%70 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%71 = call i32 @accept(i32 %69, %struct.sockaddr* %70, i32* %11)
store i32 %71, i32* %7
%72 = load i8*, i8** @EPOLLIN
%73 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %15, i32 0, i32 1
store i8* %72, i8** %73
%74 = load i32, i32* %7
%75 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %15, i32 0, i32 0
%76 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %75, i32 0, i32 0
store i32 %74, i32* %76
%77 = load i32, i32* %16
%78 = load i32, i32* @EPOLL_CTL_ADD
%79 = load i32, i32* %7
%80 = call i32 @epoll_ctl(i32 %77, i32 %78, i32 %79, %struct.epoll_event* %15)
%81 = load i32, i32* %7
%82 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %81)
br label %134
83: ; preds = %58
%84 = load %struct.epoll_event*, %struct.epoll_event** %14
%85 = load i32, i32* %12
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %84, i64 %86
%88 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %87, i32 0, i32 0
%89 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%92 = call i32 @read(i32 %90, i8* %91, i32 16)
store i32 %92, i32* %13
%93 = load i32, i32* %13
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %122
95: ; preds = %83
%96 = load i32, i32* %16
%97 = load i32, i32* @EPOLL_CTL_DEL
%98 = load %struct.epoll_event*, %struct.epoll_event** %14
%99 = load i32, i32* %12
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %98, i64 %100
%102 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %101, i32 0, i32 0
%103 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %102, i32 0, i32 0
%104 = load i32, i32* %103
%105 = call i32 @epoll_ctl(i32 %96, i32 %97, i32 %104, %struct.epoll_event* null)
%106 = load %struct.epoll_event*, %struct.epoll_event** %14
%107 = load i32, i32* %12
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %106, i64 %108
%110 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %109, i32 0, i32 0
%111 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = load %struct.epoll_event*, %struct.epoll_event** %14
%115 = load i32, i32* %12
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %114, i64 %116
%118 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %117, i32 0, i32 0
%119 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %118, i32 0, i32 0
%120 = load i32, i32* %119
%121 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %120)
br label %133
122: ; preds = %83
%123 = load %struct.epoll_event*, %struct.epoll_event** %14
%124 = load i32, i32* %12
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %123, i64 %125
%127 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %126, i32 0, i32 0
%128 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %127, i32 0, i32 0
%129 = load i32, i32* %128
%130 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%131 = load i32, i32* %13
%132 = call i32 @write(i32 %129, i8* %130, i32 %131)
br label %133
133: ; preds = %122, %95
br label %134
134: ; preds = %133, %68
br label %135
135: ; preds = %134
%136 = load i32, i32* %12
%137 = add nsw i32 %136, 1
store i32 %137, i32* %12
br label %54
138: ; preds = %54
br label %45
139: ; preds = %51
%140 = load i32, i32* %6
%141 = call i32 @close(i32 %140)
%142 = load i32, i32* %16
%143 = call i32 @close(i32 %142)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { %struct.TYPE_4__, i8* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@EPOLLIN = global i8* null
@EPOLL_CTL_ADD = global i32 0
@.str.1 = [12 x i8] c"wait error\0A\00"
@.str.2 = [21 x i8] c"conneted client: %d\0A\00"
@EPOLL_CTL_DEL = global i32 0
@.str.3 = [23 x i8] c"disconnect client: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = alloca %struct.epoll_event
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast %struct.epoll_event* %7 to i8*
%13 = load i32, i32* @PF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %19, i32* %20
%21 = call i32 @htons(i32 9000)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %21, i32* %22
%23 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%24 = call i32 @bind(i32 %15, %struct.sockaddr* %23, i32 12)
%25 = call i32 @listen(i32 %15, i32 5)
%26 = call i32 @epoll_create(i32 64)
%27 = call %struct.epoll_event* @malloc(i32 1024)
%28 = load i8*, i8** @EPOLLIN
%29 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i64 0, i32 1
store i8* %28, i8** %29
%30 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i64 0, i32 0, i32 0
store i32 %15, i32* %30
%31 = load i32, i32* @EPOLL_CTL_ADD
%32 = call i32 @epoll_ctl(i32 %26, i32 %31, i32 %15, %struct.epoll_event* %7)
%33 = call i32 @epoll_wait(i32 %26, %struct.epoll_event* %27, i32 64, i32 -1)
%34 = icmp eq i32 %33, -1
br i1 %34, label %45, label %35
35: ; preds = %2
%36 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %40
37: ; preds = %74, %40
%38 = call i32 @epoll_wait(i32 %26, %struct.epoll_event* %27, i32 64, i32 -1)
%39 = icmp eq i32 %38, -1
br i1 %39, label %45, label %40
40: ; preds = %35, %37
%41 = phi i32 [ %33, %35 ], [ %38, %37 ]
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %37
43: ; preds = %40
%44 = zext i32 %41 to i64
br label %49
45: ; preds = %37, %2
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @close(i32 %15)
%48 = call i32 @close(i32 %26)
ret i32 0
49: ; preds = %43, %74
%50 = phi i64 [ 0, %43 ], [ %75, %74 ]
%51 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %27, i64 %50, i32 0, i32 0
%52 = load i32, i32* %51
%53 = icmp eq i32 %52, %15
br i1 %53, label %54, label %60
54: ; preds = %49
store i32 12, i32* %6
%55 = call i32 @accept(i32 %15, %struct.sockaddr* %36, i32* %6)
%56 = load i8*, i8** @EPOLLIN
store i8* %56, i8** %29
store i32 %55, i32* %30
%57 = load i32, i32* @EPOLL_CTL_ADD
%58 = call i32 @epoll_ctl(i32 %26, i32 %57, i32 %55, %struct.epoll_event* %7)
%59 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %55)
br label %74
60: ; preds = %49
%61 = call i32 @read(i32 %52, i8* %10, i32 16)
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %71
63: ; preds = %60
%64 = load i32, i32* @EPOLL_CTL_DEL
%65 = load i32, i32* %51
%66 = call i32 @epoll_ctl(i32 %26, i32 %64, i32 %65, %struct.epoll_event* null)
%67 = load i32, i32* %51
%68 = call i32 @close(i32 %67)
%69 = load i32, i32* %51
%70 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %69)
br label %74
71: ; preds = %60
%72 = load i32, i32* %51
%73 = call i32 @write(i32 %72, i8* %10, i32 %61)
br label %74
74: ; preds = %54, %71, %63
%75 = add nuw nsw i64 %50, 1
%76 = icmp eq i64 %75, %44
br i1 %76, label %37, label %49
}