#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 sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};
typedef int /*<<< orphan*/ srv_addr;
typedef int /*<<< orphan*/ cli_addr;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EPOLLET;
int EPOLLHUP;
int EPOLLIN;
int EPOLLOUT;
int EPOLLRDHUP;
int /*<<< orphan*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int epoll_create(int);
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ epoll_ctl_add(int, int, int);
int epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ set_sockaddr(struct sockaddr_in *);
int /*<<< orphan*/ setnonblocking(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void server_run() {
  int i;
  int n;
  int epfd;
  int nfds;
  int listen_sock;
  int conn_sock;
  int socklen;
  char buf[(16)];
  struct sockaddr_in srv_addr;
  struct sockaddr_in cli_addr;
  struct epoll_event events[(32)];
  listen_sock = socket(AF_INET, SOCK_STREAM, 0);
  set_sockaddr(&srv_addr);
  bind(listen_sock, (struct sockaddr *)&srv_addr, sizeof(srv_addr));
  setnonblocking(listen_sock);
  listen(listen_sock, (16));
  epfd = epoll_create(1);
  epoll_ctl_add(epfd, listen_sock, EPOLLIN | EPOLLOUT | EPOLLET);
  socklen = sizeof(cli_addr);
  for (;;) {
    nfds = epoll_wait(epfd, events, (32), -1);
    for (i = 0; i < nfds; i++) {
      if (events[i].data.fd == listen_sock) {
        conn_sock = accept(listen_sock, (struct sockaddr *)&cli_addr, &socklen);
        inet_ntop(AF_INET, (char *)&(cli_addr.sin_addr), buf, sizeof(cli_addr));
        printf("[+] connected with %s:%d\n", buf, ntohs(cli_addr.sin_port));
        setnonblocking(conn_sock);
        epoll_ctl_add(epfd, conn_sock,
                      EPOLLIN | EPOLLET | EPOLLRDHUP | EPOLLHUP);
      } else if (events[i].events & EPOLLIN) {
        for (;;) {
          bzero(buf, sizeof(buf));
          n = read(events[i].data.fd, buf, sizeof(buf));
          if (n <= 0) {
            break;
          } else {
            printf("[+] data: %s\n", buf);
            write(events[i].data.fd, buf, strlen(buf));
          }
        }
      } else {
        printf("[+] unexpected\n");
      }
      if (events[i].events & (EPOLLRDHUP | EPOLLHUP)) {
        printf("[+] connection closed\n");
        epoll_ctl(epfd, EPOLL_CTL_DEL, events[i].data.fd, NULL);
        close(events[i].data.fd);
        continue;
      }
    }
  }
}


x86 assembly (clang, -O0):
<server_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x38(%rbp),%rdi
call   10a0 <set_sockaddr@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x8,%edx
call   10f0 <bind@plt>
mov    -0x14(%rbp),%edi
call   1100 <setnonblocking@plt>
mov    -0x14(%rbp),%edi
mov    $0x10,%esi
call   10b0 <listen@plt>
mov    $0x1,%edi
call   1130 <epoll_create@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
mov    0x2d27(%rip),%rax
or     (%rax),%edx
mov    0x2d0e(%rip),%rax
or     (%rax),%edx
call   10c0 <epoll_ctl_add@plt>
movl   $0x8,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0x20,%edx
mov    $0xffffffff,%ecx
call   10e0 <epoll_wait@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    14cc <server_run+0x2ac>
movslq -0x4(%rbp),%rax
mov    -0x13c(%rbp,%rax,8),%eax
cmp    -0x14(%rbp),%eax
jne    138b <server_run+0x16b>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1120 <accept@plt>
mov    %eax,-0x18(%rbp)
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
add    $0x4,%rsi
lea    -0x30(%rbp),%rdx
mov    $0x8,%ecx
call   1030 <inet_ntop@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x40(%rbp),%edi
call   10d0 <ntohs@plt>
mov    -0x148(%rbp),%rsi
mov    %eax,%edx
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
call   1100 <setnonblocking@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    0x2c74(%rip),%rax
mov    (%rax),%edx
mov    0x2c43(%rip),%rax
or     (%rax),%edx
mov    0x2c42(%rip),%rax
or     (%rax),%edx
mov    0x2c29(%rip),%rax
or     (%rax),%edx
call   10c0 <epoll_ctl_add@plt>
jmp    144e <server_run+0x22e>
movslq -0x4(%rbp),%rax
mov    -0x140(%rbp,%rax,8),%eax
mov    0x2c3b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     143b <server_run+0x21b>
jmp    13ad <server_run+0x18d>
lea    -0x30(%rbp),%rdi
mov    $0x10,%esi
call   1110 <bzero@plt>
movslq -0x4(%rbp),%rax
mov    -0x13c(%rbp,%rax,8),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1090 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     13e6 <server_run+0x1c6>
jmp    1436 <server_run+0x216>
lea    -0x30(%rbp),%rsi
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x4(%rbp),%rax
mov    -0x13c(%rbp,%rax,8),%eax
mov    %eax,-0x154(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x154(%rbp),%edi
mov    -0x150(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    13ad <server_run+0x18d>
jmp    1449 <server_run+0x229>
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    144e <server_run+0x22e>
movslq -0x4(%rbp),%rax
mov    -0x140(%rbp,%rax,8),%eax
mov    0x2b58(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2b3f(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     14b9 <server_run+0x299>
lea    0xbbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
mov    0x2b6a(%rip),%rax
mov    (%rax),%esi
movslq -0x4(%rbp),%rax
mov    -0x13c(%rbp,%rax,8),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1080 <epoll_ctl@plt>
movslq -0x4(%rbp),%rax
mov    -0x13c(%rbp,%rax,8),%edi
call   1070 <close@plt>
jmp    14be <server_run+0x29e>
jmp    14be <server_run+0x29e>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    12d3 <server_run+0xb3>
jmp    12b0 <server_run+0x90>

x86 assembly (clang, -O2):
<server_run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r14d
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
call   10b0 <set_sockaddr@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
call   1100 <bind@plt>
mov    %r14d,%edi
call   1110 <setnonblocking@plt>
mov    %r14d,%edi
mov    $0x10,%esi
call   10c0 <listen@plt>
mov    $0x1,%edi
call   1140 <epoll_create@plt>
mov    0x2d38(%rip),%rsi
mov    0x2d19(%rip),%rcx
mov    (%rcx),%edx
or     (%rsi),%edx
mov    0x2cfe(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x4(%rsp)
mov    %eax,%edi
mov    %r14d,%esi
call   10d0 <epoll_ctl_add@plt>
movl   $0x8,0xc(%rsp)
lea    0x20(%rsp),%r15
lea    0xd44(%rip),%r13
mov    %r14d,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x20,%edx
mov    $0xffffffff,%ecx
call   10f0 <epoll_wait@plt>
test   %eax,%eax
jle    12e0 <server_run+0xb0>
mov    %eax,%ebx
xor    %r12d,%r12d
jmp    131e <server_run+0xee>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12
cmp    %rbx,%r12
mov    0x8(%rsp),%r14d
je     12e0 <server_run+0xb0>
mov    0x34(%rsp,%r12,8),%ebp
cmp    %r14d,%ebp
jne    13c0 <server_run+0x190>
mov    %r14d,%edi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1130 <accept@plt>
mov    %eax,%r14d
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0x14(%rsp),%rsi
mov    %r15,%rdx
mov    $0x8,%ecx
call   1030 <inet_ntop@plt>
mov    0x10(%rsp),%edi
call   10e0 <ntohs@plt>
lea    0xc94(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
call   1110 <setnonblocking@plt>
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
mov    0x2c48(%rip),%rax
or     (%rax),%edx
mov    0x2c1f(%rip),%rax
or     (%rax),%edx
mov    0x2c06(%rip),%rax
or     (%rax),%edx
mov    0x4(%rsp),%edi
mov    %r14d,%esi
call   10d0 <epoll_ctl_add@plt>
jmp    1440 <server_run+0x210>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2c11(%rip),%rax
mov    (%rax),%eax
test   %eax,0x30(%rsp,%r12,8)
je     142b <server_run+0x1fb>
mov    %r15,%rdi
mov    $0x10,%esi
call   1120 <bzero@plt>
mov    %ebp,%edi
nop
mov    %r15,%rsi
mov    $0x10,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    1440 <server_run+0x210>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x34(%rsp,%r12,8),%ebp
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %r15,%rdi
mov    $0x10,%esi
call   1120 <bzero@plt>
mov    0x34(%rsp,%r12,8),%edi
jmp    13e0 <server_run+0x1b0>
lea    0xbf6(%rip),%rdi
call   1040 <puts@plt>
nopw   0x0(%rax,%rax,1)
mov    0x2b61(%rip),%rax
mov    (%rax),%eax
mov    0x2b68(%rip),%rcx
or     (%rcx),%eax
test   %eax,0x30(%rsp,%r12,8)
je     1310 <server_run+0xe0>
lea    0xbd3(%rip),%rdi
call   1040 <puts@plt>
mov    0x2b88(%rip),%rax
mov    (%rax),%esi
mov    0x34(%rsp,%r12,8),%edx
mov    0x4(%rsp),%edi
xor    %ecx,%ecx
call   1090 <epoll_ctl@plt>
mov    0x34(%rsp,%r12,8),%edi
call   1080 <close@plt>
jmp    1310 <server_run+0xe0>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@.str = [26 x i8] c"[+] connected with %s:%d\0A\00"
@EPOLLRDHUP = global i32 0
@EPOLLHUP = global i32 0
@.str.1 = [14 x i8] c"[+] data: %s\0A\00"
@EPOLL_CTL_DEL = global i32 0
@str = [15 x i8] c"[+] unexpected\00"
@str.4 = [22 x i8] c"[+] connection closed\00"
define void @server_run() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca [32 x %struct.epoll_event]
%6 = bitcast i32* %1 to i8*
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast [32 x %struct.epoll_event]* %5 to i8*
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_STREAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = call i32 @set_sockaddr(%struct.sockaddr_in* %3)
%15 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%16 = call i32 @bind(i32 %13, %struct.sockaddr* %15, i32 8)
%17 = call i32 @setnonblocking(i32 %13)
%18 = call i32 @listen(i32 %13, i32 16)
%19 = call i32 @epoll_create(i32 1)
%20 = load i32, i32* @EPOLLIN
%21 = load i32, i32* @EPOLLOUT
%22 = or i32 %21, %20
%23 = load i32, i32* @EPOLLET
%24 = or i32 %22, %23
%25 = call i32 @epoll_ctl_add(i32 %19, i32 %13, i32 %24)
store i32 8, i32* %1
%26 = getelementptr inbounds [32 x %struct.epoll_event], [32 x %struct.epoll_event]* %5, i64 0, i64 0
%27 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%29 = bitcast i32* %28 to i8*
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
br label %31
31: ; preds = %34, %0
%32 = call i32 @epoll_wait(i32 %19, %struct.epoll_event* %26, i32 32, i32 -1)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %95, %31
br label %31
35: ; preds = %31
%36 = zext i32 %32 to i64
br label %37
37: ; preds = %35, %95
%38 = phi i64 [ 0, %35 ], [ %96, %95 ]
%39 = getelementptr inbounds [32 x %struct.epoll_event], [32 x %struct.epoll_event]* %5, i64 0, i64 %38
%40 = getelementptr inbounds [32 x %struct.epoll_event], [32 x %struct.epoll_event]* %5, i64 0, i64 %38, i32 1, i32 0
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, %13
br i1 %42, label %43, label %59
43: ; preds = %37
%44 = call i32 @accept(i32 %13, %struct.sockaddr* %27, i32* %1)
%45 = load i32, i32* @AF_INET
%46 = call i32 @inet_ntop(i32 %45, i8* %29, i8* %7, i32 8)
%47 = load i32, i32* %30
%48 = call i32 @ntohs(i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %48)
%50 = call i32 @setnonblocking(i32 %44)
%51 = load i32, i32* @EPOLLIN
%52 = load i32, i32* @EPOLLET
%53 = or i32 %52, %51
%54 = load i32, i32* @EPOLLRDHUP
%55 = or i32 %53, %54
%56 = load i32, i32* @EPOLLHUP
%57 = or i32 %55, %56
%58 = call i32 @epoll_ctl_add(i32 %19, i32 %44, i32 %57)
br label %80
59: ; preds = %37
%60 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %39, i64 0, i32 0
%61 = load i32, i32* %60
%62 = load i32, i32* @EPOLLIN
%63 = and i32 %62, %61
%64 = icmp eq i32 %63, 0
br i1 %64, label %78, label %65
65: ; preds = %59
%66 = call i32 @bzero(i8* %7, i32 16)
%67 = call i32 @read(i32 %41, i8* %7, i32 16)
%68 = icmp slt i32 %67, 1
br i1 %68, label %80, label %69
69: ; preds = %65, %69
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%71 = load i32, i32* %40
%72 = call i32 @strlen(i8* %7)
%73 = call i32 @write(i32 %71, i8* %7, i32 %72)
%74 = call i32 @bzero(i8* %7, i32 16)
%75 = load i32, i32* %40
%76 = call i32 @read(i32 %75, i8* %7, i32 16)
%77 = icmp slt i32 %76, 1
br i1 %77, label %80, label %69
78: ; preds = %59
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %80
80: ; preds = %69, %65, %78, %43
%81 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %39, i64 0, i32 0
%82 = load i32, i32* %81
%83 = load i32, i32* @EPOLLRDHUP
%84 = load i32, i32* @EPOLLHUP
%85 = or i32 %84, %83
%86 = and i32 %85, %82
%87 = icmp eq i32 %86, 0
br i1 %87, label %95, label %88
88: ; preds = %80
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
%90 = load i32, i32* @EPOLL_CTL_DEL
%91 = load i32, i32* %40
%92 = call i32 @epoll_ctl(i32 %19, i32 %90, i32 %91, i32* null)
%93 = load i32, i32* %40
%94 = call i32 @close(i32 %93)
br label %95
95: ; preds = %80, %88
%96 = add nuw nsw i64 %38, 1
%97 = icmp eq i64 %96, %36
br i1 %97, label %34, label %37
}