#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_addr;
};
struct sockaddr {
  int dummy;
};
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ ip;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ acpaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EPOLLERR;
int EPOLLET;
int EPOLLHUP;
int EPOLLIN;
int EPOLLOUT;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int INET_ADDRSTRLEN;
int accept(int, struct sockaddr *, int *);
struct epoll_event *calloc(int, int);
int /*<<< orphan*/ close(int);
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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(struct epoll_event *);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
int listen_socket(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int setnonblocking(int);
int main(int argc, char **argv) {
  int skfd, rskfd;
  int efd;
  int nefd;
  int rlen, slen;
  char ip[INET_ADDRSTRLEN];
  char buf[64];
  socklen_t addrlen;
  struct epoll_event ev, *evp;
  struct sockaddr acpaddr;
  if (argc != 2) {
    printf("Usage: ./epoll_svr [Port number]\n");
    exit(0);
  }
  skfd = listen_socket(argv[1]);
  if (skfd == -1) {
    return -1;
  }
  efd = epoll_create1(0);
  if (efd == -1) {
    close(skfd);
    perror("epoll_create1");
    return -1;
  }
  ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
  ev.data.fd = skfd;
  if (epoll_ctl(efd, EPOLL_CTL_ADD, skfd, &ev) == -1) {
    close(efd);
    close(skfd);
    perror("epoll_ctl_add");
    return -1;
  }
  evp = calloc(10, sizeof(struct epoll_event));
  if (evp == NULL) {
    printf("Calloc Fialed!\n");
    close(efd);
    close(skfd);
    return -1;
  }
  do {
    nefd = epoll_wait(efd, evp, 10, -1);
    if (nefd == -1) {
      perror("epoll_wait");
      close(efd);
      close(skfd);
      return -1;
    }
    for (int n = 0; n != nefd; ++n) {
      if (evp[n].data.fd == skfd) {
        addrlen = sizeof(acpaddr);
        rskfd = accept(skfd, &acpaddr, &addrlen);
        if (rskfd == -1) {
          close(efd);
          close(skfd);
          close(nefd);
          perror("accept");
          return -1;
        }
        struct sockaddr_in *tmp = (struct sockaddr_in *)&acpaddr;
        inet_ntop(AF_INET, &tmp->sin_addr, ip, sizeof(ip));
        printf("Connect with IP %s\n", ip);
        if (setnonblocking(rskfd) == -1) {
          close(efd);
          close(rskfd);
          close(nefd);
          return -1;
        }
        ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
        ev.data.fd = rskfd;
        if (epoll_ctl(efd, EPOLL_CTL_ADD, rskfd, &ev) == -1) {
          perror("epoll_ctl");
          return -1;
        }
      } else {
        if (evp[n].events & EPOLLIN) {
          memset(buf, 0, sizeof(buf));
          rlen = recv(evp[n].data.fd, buf, sizeof(buf) - 1, 0);
          if (rlen == -1) {
            printf("Recv failed!\n");
            close(evp[n].data.fd);
            return -1;
          }
          printf("Recv : %s (%d)\n", buf, rlen);
        }
        if (evp[n].events & EPOLLOUT) {
          slen = send(evp[n].data.fd, "Here is Server", 14, 0);
          if (slen == -1) {
            printf("Send Failed !\n");
            close(evp[n].data.fd);
            return -1;
          }
          printf("Send %d\n", slen);
        }
        if ((evp[n].events & EPOLLERR) == EPOLLERR ||
            (evp[n].events & EPOLLHUP) == EPOLLHUP ||
            ((evp[n].events & EPOLLIN) != EPOLLIN &&
             (evp[n].events & EPOLLOUT) != EPOLLOUT)) {
          printf("Unknown event: %d\n", evp[n].events);
          close(evp[n].data.fd);
          return -1;
        }
      }
    }
  } while (1);
  free(evp);
  close(rskfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xc0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     126e <main+0x6e>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <listen_socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    129e <main+0x9e>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
xor    %edi,%edi
call   1120 <epoll_create1@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12dc <main+0xdc>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xd61(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    0x2cd4(%rip),%rcx
or     (%rcx),%eax
mov    0x2cbb(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x90(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x90(%rbp),%rcx
call   10a0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    135c <main+0x15c>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xcef(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
mov    $0xa,%edi
mov    $0x8,%esi
call   10b0 <calloc@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    13b4 <main+0x1b4>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
jmp    13b9 <main+0x1b9>
mov    -0x1c(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1411 <main+0x211>
lea    0xc68(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
movl   $0x0,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1809 <main+0x609>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%eax
cmp    -0x14(%rbp),%eax
jne    15a8 <main+0x3a8>
movl   $0x4,-0x84(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0x84(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    14ac <main+0x2ac>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
lea    0xbc8(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
mov    -0xb8(%rbp),%rdx
mov    -0xc0(%rbp),%rax
lea    -0xa0(%rbp),%rcx
mov    %rcx,-0xb0(%rbp)
mov    0x2b19(%rip),%rcx
mov    (%rcx),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xb8(%rbp),%rsi
lea    0xb73(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   10e0 <setnonblocking@plt>
cmp    $0xffffffff,%eax
jne    1533 <main+0x333>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
mov    0x2aa6(%rip),%rax
mov    (%rax),%eax
mov    0x2a7d(%rip),%rcx
or     (%rcx),%eax
mov    0x2a64(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x90(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2a71(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%edx
lea    -0x90(%rbp),%rcx
call   10a0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    15a3 <main+0x3a3>
lea    0xaec(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
jmp    17f0 <main+0x5f0>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2a20(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     165a <main+0x45a>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1080 <memset@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
lea    -0x80(%rbp),%rsi
mov    $0x3f,%edx
xor    %ecx,%ecx
call   1050 <recv@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1645 <main+0x445>
lea    0xa6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
lea    -0x80(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xa39(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x294e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     16fb <main+0x4fb>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
lea    0xa06(%rip),%rsi
mov    $0xe,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    16ea <main+0x4ea>
lea    0x9f5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
mov    -0x28(%rbp),%esi
lea    0x9c6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x28b5(%rip),%rcx
and    (%rcx),%eax
mov    0x28ac(%rip),%rcx
cmp    (%rcx),%eax
je     179f <main+0x59f>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x286c(%rip),%rcx
and    (%rcx),%eax
mov    0x2863(%rip),%rcx
cmp    (%rcx),%eax
je     179f <main+0x59f>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x287b(%rip),%rcx
and    (%rcx),%eax
mov    0x2872(%rip),%rcx
cmp    (%rcx),%eax
je     17eb <main+0x5eb>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2832(%rip),%rcx
and    (%rcx),%eax
mov    0x2829(%rip),%rcx
cmp    (%rcx),%eax
je     17eb <main+0x5eb>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    (%rax,%rcx,8),%esi
lea    0x90c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rax
movslq -0xa8(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    1842 <main+0x642>
jmp    17f0 <main+0x5f0>
jmp    17f5 <main+0x5f5>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    141b <main+0x21b>
jmp    180e <main+0x60e>
mov    $0x1,%al
test   $0x1,%al
jne    13b9 <main+0x1b9>
jmp    181d <main+0x61d>
mov    -0x98(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rax,-0x50(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
cmp    $0x2,%edi
jne    15d3 <main+0x3d3>
mov    0x8(%rsi),%rdi
call   10c0 <listen_socket@plt>
cmp    $0xffffffff,%eax
je     1584 <main+0x384>
mov    %eax,%r13d
xor    %edi,%edi
call   1120 <epoll_create1@plt>
cmp    $0xffffffff,%eax
je     1557 <main+0x357>
mov    %eax,%r15d
mov    0x2d75(%rip),%rcx
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2d33(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    %r13d,-0x34(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rcx
mov    %r15d,%edi
mov    %r13d,%edx
call   10a0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     1568 <main+0x368>
mov    $0xa,%edi
mov    $0x8,%esi
call   10b0 <calloc@plt>
test   %rax,%rax
je     14fe <main+0x2fe>
mov    %rax,%rbx
mov    %r15d,%edi
mov    %rax,%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
cmp    $0xffffffff,%eax
je     1598 <main+0x398>
lea    -0xa0(%rbp),%r14
mov    %r15d,-0x2c(%rbp)
mov    %r13d,-0x3c(%rbp)
jmp    1322 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
cmp    $0xffffffff,%eax
je     1598 <main+0x398>
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     1300 <main+0x100>
mov    -0x30(%rbp),%eax
mov    %rax,-0x58(%rbp)
xor    %r12d,%r12d
jmp    134a <main+0x14a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12
cmp    %r12,-0x58(%rbp)
je     1300 <main+0x100>
cmp    %r13d,0x4(%rbx,%r12,8)
jne    1420 <main+0x220>
mov    %rbx,%r15
mov    %r13d,%edi
mov    %r14,%r13
movl   $0x4,-0x40(%rbp)
lea    -0x60(%rbp),%rbx
mov    %rbx,%rsi
lea    -0x40(%rbp),%rdx
call   1100 <accept@plt>
cmp    $0xffffffff,%eax
je     15a9 <main+0x3a9>
mov    %eax,%r14d
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdx
mov    -0x50(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xc8a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
call   10e0 <setnonblocking@plt>
cmp    $0xffffffff,%eax
je     151c <main+0x31c>
mov    0x2bfa(%rip),%rax
mov    (%rax),%eax
mov    0x2c11(%rip),%rcx
or     (%rcx),%eax
mov    0x2bd8(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    %r14d,-0x34(%rbp)
mov    0x2bf0(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%edi
mov    %r14d,%edx
lea    -0x38(%rbp),%rcx
call   10a0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
mov    %r13,%r14
mov    -0x3c(%rbp),%r13d
mov    %r15,%rbx
jne    1340 <main+0x140>
jmp    15ca <main+0x3ca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r12,%r12,1),%r15
mov    (%rbx,%r12,8),%esi
mov    0x2bb1(%rip),%rax
test   %esi,(%rax)
je     1476 <main+0x276>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1080 <memset@plt>
mov    0x4(%rbx,%r15,4),%edi
mov    %r14,%rsi
mov    $0x3f,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
je     1536 <main+0x336>
lea    0xbe6(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx,%r15,4),%esi
mov    0x2b43(%rip),%rax
test   %esi,(%rax)
je     14b6 <main+0x2b6>
mov    0x4(%rbx,%r15,4),%edi
lea    0xbcf(%rip),%rsi
mov    $0xe,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
je     153f <main+0x33f>
lea    0xbc2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx,%r15,4),%esi
mov    %esi,%eax
not    %eax
mov    0x2b07(%rip),%rcx
test   %eax,(%rcx)
je     14ee <main+0x2ee>
mov    0x2adc(%rip),%rcx
test   %eax,(%rcx)
je     14ee <main+0x2ee>
mov    0x2b09(%rip),%rcx
test   %eax,(%rcx)
je     1340 <main+0x140>
mov    0x2ada(%rip),%rcx
test   %eax,(%rcx)
je     1340 <main+0x140>
lea    0xb7f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    154b <main+0x34b>
lea    0xb9d(%rip),%rdi
call   1050 <puts@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r13d,%edi
call   1090 <close@plt>
jmp    1584 <main+0x384>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
jmp    1584 <main+0x384>
lea    0xb58(%rip),%rdi
jmp    1546 <main+0x346>
lea    0xb41(%rip),%rdi
call   1050 <puts@plt>
mov    0x4(%rbx,%r12,8),%edi
call   1090 <close@plt>
jmp    1584 <main+0x384>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xa9a(%rip),%rdi
jmp    157f <main+0x37f>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r13d,%edi
call   1090 <close@plt>
lea    0xa8f(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa7d(%rip),%rdi
call   10f0 <perror@plt>
jmp    150a <main+0x30a>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
mov    -0x3c(%rbp),%edi
call   1090 <close@plt>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
lea    0xa5f(%rip),%rdi
jmp    157f <main+0x37f>
lea    0xa71(%rip),%rdi
jmp    157f <main+0x37f>
lea    0xad7(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str = [34 x i8] c"Usage: ./epoll_svr [Port number]\0A\00"
@.str.1 = [14 x i8] c"epoll_create1\00"
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.2 = [14 x i8] c"epoll_ctl_add\00"
@.str.3 = [16 x i8] c"Calloc Fialed!\0A\00"
@.str.4 = [11 x i8] c"epoll_wait\00"
@.str.5 = [7 x i8] c"accept\00"
@AF_INET = global i32 0
@.str.6 = [20 x i8] c"Connect with IP %s\0A\00"
@.str.7 = [10 x i8] c"epoll_ctl\00"
@.str.8 = [14 x i8] c"Recv failed!\0A\00"
@.str.9 = [16 x i8] c"Recv : %s (%d)\0A\00"
@.str.10 = [15 x i8] c"Here is Server\00"
@.str.11 = [15 x i8] c"Send Failed !\0A\00"
@.str.12 = [9 x i8] c"Send %d\0A\00"
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@.str.13 = [19 x i8] c"Unknown event: %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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca [64 x i8]
%15 = alloca i32
%16 = alloca %struct.epoll_event
%17 = alloca %struct.epoll_event*
%18 = alloca %struct.sockaddr
%19 = alloca i32
%20 = alloca i32
%21 = alloca %struct.sockaddr_in*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* @INET_ADDRSTRLEN
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %12
%25 = alloca i8, i64 %23
store i64 %23, i64* %13
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 2
br i1 %27, label %28, label %31
28: ; preds = %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @listen_socket(i8* %34)
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %39
38: ; preds = %31
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
39: ; preds = %31
%40 = call i32 @epoll_create1(i32 0)
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i32, i32* %6
%45 = call i32 @close(i32 %44)
%46 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
47: ; preds = %39
%48 = load i32, i32* @EPOLLIN
%49 = load i32, i32* @EPOLLOUT
%50 = or i32 %48, %49
%51 = load i32, i32* @EPOLLET
%52 = or i32 %50, %51
%53 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %16, i32 0, i32 0
store i32 %52, i32* %53
%54 = load i32, i32* %6
%55 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %16, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i32 %54, i32* %56
%57 = load i32, i32* %8
%58 = load i32, i32* @EPOLL_CTL_ADD
%59 = load i32, i32* %6
%60 = call i32 @epoll_ctl(i32 %57, i32 %58, i32 %59, %struct.epoll_event* %16)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %68
62: ; preds = %47
%63 = load i32, i32* %8
%64 = call i32 @close(i32 %63)
%65 = load i32, i32* %6
%66 = call i32 @close(i32 %65)
%67 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
68: ; preds = %47
%69 = call %struct.epoll_event* @calloc(i32 10, i32 8)
store %struct.epoll_event* %69, %struct.epoll_event** %17
%70 = load %struct.epoll_event*, %struct.epoll_event** %17
%71 = icmp eq %struct.epoll_event* %70, null
br i1 %71, label %72, label %78
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%74 = load i32, i32* %8
%75 = call i32 @close(i32 %74)
%76 = load i32, i32* %6
%77 = call i32 @close(i32 %76)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
78: ; preds = %68
br label %79
79: ; preds = %293, %78
%80 = load i32, i32* %8
%81 = load %struct.epoll_event*, %struct.epoll_event** %17
%82 = call i32 @epoll_wait(i32 %80, %struct.epoll_event* %81, i32 10, i32 -1)
store i32 %82, i32* %9
%83 = load i32, i32* %9
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %91
85: ; preds = %79
%86 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%87 = load i32, i32* %8
%88 = call i32 @close(i32 %87)
%89 = load i32, i32* %6
%90 = call i32 @close(i32 %89)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
91: ; preds = %79
store i32 0, i32* %20
br label %92
92: ; preds = %289, %91
%93 = load i32, i32* %20
%94 = load i32, i32* %9
%95 = icmp ne i32 %93, %94
br i1 %95, label %96, label %292
96: ; preds = %92
%97 = load %struct.epoll_event*, %struct.epoll_event** %17
%98 = load i32, i32* %20
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %97, i64 %99
%101 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %100, i32 0, i32 1
%102 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %101, i32 0, i32 0
%103 = load i32, i32* %102
%104 = load i32, i32* %6
%105 = icmp eq i32 %103, %104
br i1 %105, label %106, label %155
106: ; preds = %96
store i32 4, i32* %15
%107 = load i32, i32* %6
%108 = call i32 @accept(i32 %107, %struct.sockaddr* %18, i32* %15)
store i32 %108, i32* %7
%109 = load i32, i32* %7
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %119
111: ; preds = %106
%112 = load i32, i32* %8
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* %6
%115 = call i32 @close(i32 %114)
%116 = load i32, i32* %9
%117 = call i32 @close(i32 %116)
%118 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
119: ; preds = %106
%120 = bitcast %struct.sockaddr* %18 to %struct.sockaddr_in*
store %struct.sockaddr_in* %120, %struct.sockaddr_in** %21
%121 = load i32, i32* @AF_INET
%122 = load %struct.sockaddr_in*, %struct.sockaddr_in** %21
%123 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %122, i32 0, i32 0
%124 = trunc i64 %23 to i32
%125 = call i32 @inet_ntop(i32 %121, i32* %123, i8* %25, i32 %124)
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%127 = load i32, i32* %7
%128 = call i32 @setnonblocking(i32 %127)
%129 = icmp eq i32 %128, -1
br i1 %129, label %130, label %137
130: ; preds = %119
%131 = load i32, i32* %8
%132 = call i32 @close(i32 %131)
%133 = load i32, i32* %7
%134 = call i32 @close(i32 %133)
%135 = load i32, i32* %9
%136 = call i32 @close(i32 %135)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
137: ; preds = %119
%138 = load i32, i32* @EPOLLIN
%139 = load i32, i32* @EPOLLOUT
%140 = or i32 %138, %139
%141 = load i32, i32* @EPOLLET
%142 = or i32 %140, %141
%143 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %16, i32 0, i32 0
store i32 %142, i32* %143
%144 = load i32, i32* %7
%145 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %16, i32 0, i32 1
%146 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %145, i32 0, i32 0
store i32 %144, i32* %146
%147 = load i32, i32* %8
%148 = load i32, i32* @EPOLL_CTL_ADD
%149 = load i32, i32* %7
%150 = call i32 @epoll_ctl(i32 %147, i32 %148, i32 %149, %struct.epoll_event* %16)
%151 = icmp eq i32 %150, -1
br i1 %151, label %152, label %154
152: ; preds = %137
%153 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
154: ; preds = %137
br label %288
155: ; preds = %96
%156 = load %struct.epoll_event*, %struct.epoll_event** %17
%157 = load i32, i32* %20
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %156, i64 %158
%160 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %159, i32 0, i32 0
%161 = load i32, i32* %160
%162 = load i32, i32* @EPOLLIN
%163 = and i32 %161, %162
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %193
165: ; preds = %155
%166 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%167 = call i32 @memset(i8* %166, i32 0, i32 64)
%168 = load %struct.epoll_event*, %struct.epoll_event** %17
%169 = load i32, i32* %20
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %168, i64 %170
%172 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %171, i32 0, i32 1
%173 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %172, i32 0, i32 0
%174 = load i32, i32* %173
%175 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%176 = call i32 @recv(i32 %174, i8* %175, i32 63, i32 0)
store i32 %176, i32* %10
%177 = load i32, i32* %10
%178 = icmp eq i32 %177, -1
br i1 %178, label %179, label %189
179: ; preds = %165
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%181 = load %struct.epoll_event*, %struct.epoll_event** %17
%182 = load i32, i32* %20
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %181, i64 %183
%185 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %184, i32 0, i32 1
%186 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %185, i32 0, i32 0
%187 = load i32, i32* %186
%188 = call i32 @close(i32 %187)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
189: ; preds = %165
%190 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%191 = load i32, i32* %10
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %190, i32 %191)
br label %193
193: ; preds = %189, %155
%194 = load %struct.epoll_event*, %struct.epoll_event** %17
%195 = load i32, i32* %20
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %194, i64 %196
%198 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %197, i32 0, i32 0
%199 = load i32, i32* %198
%200 = load i32, i32* @EPOLLOUT
%201 = and i32 %199, %200
%202 = icmp ne i32 %201, 0
br i1 %202, label %203, label %227
203: ; preds = %193
%204 = load %struct.epoll_event*, %struct.epoll_event** %17
%205 = load i32, i32* %20
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %204, i64 %206
%208 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %207, i32 0, i32 1
%209 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %208, i32 0, i32 0
%210 = load i32, i32* %209
%211 = call i32 @send(i32 %210, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 14, i32 0)
store i32 %211, i32* %11
%212 = load i32, i32* %11
%213 = icmp eq i32 %212, -1
br i1 %213, label %214, label %224
214: ; preds = %203
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%216 = load %struct.epoll_event*, %struct.epoll_event** %17
%217 = load i32, i32* %20
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %216, i64 %218
%220 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %219, i32 0, i32 1
%221 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %220, i32 0, i32 0
%222 = load i32, i32* %221
%223 = call i32 @close(i32 %222)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
224: ; preds = %203
%225 = load i32, i32* %11
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %225)
br label %227
227: ; preds = %224, %193
%228 = load %struct.epoll_event*, %struct.epoll_event** %17
%229 = load i32, i32* %20
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %228, i64 %230
%232 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %231, i32 0, i32 0
%233 = load i32, i32* %232
%234 = load i32, i32* @EPOLLERR
%235 = and i32 %233, %234
%236 = load i32, i32* @EPOLLERR
%237 = icmp eq i32 %235, %236
br i1 %237, label %271, label %238
238: ; preds = %227
%239 = load %struct.epoll_event*, %struct.epoll_event** %17
%240 = load i32, i32* %20
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %239, i64 %241
%243 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %242, i32 0, i32 0
%244 = load i32, i32* %243
%245 = load i32, i32* @EPOLLHUP
%246 = and i32 %244, %245
%247 = load i32, i32* @EPOLLHUP
%248 = icmp eq i32 %246, %247
br i1 %248, label %271, label %249
249: ; preds = %238
%250 = load %struct.epoll_event*, %struct.epoll_event** %17
%251 = load i32, i32* %20
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %250, i64 %252
%254 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %253, i32 0, i32 0
%255 = load i32, i32* %254
%256 = load i32, i32* @EPOLLIN
%257 = and i32 %255, %256
%258 = load i32, i32* @EPOLLIN
%259 = icmp ne i32 %257, %258
br i1 %259, label %260, label %287
260: ; preds = %249
%261 = load %struct.epoll_event*, %struct.epoll_event** %17
%262 = load i32, i32* %20
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %261, i64 %263
%265 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %264, i32 0, i32 0
%266 = load i32, i32* %265
%267 = load i32, i32* @EPOLLOUT
%268 = and i32 %266, %267
%269 = load i32, i32* @EPOLLOUT
%270 = icmp ne i32 %268, %269
br i1 %270, label %271, label %287
271: ; preds = %260, %238, %227
%272 = load %struct.epoll_event*, %struct.epoll_event** %17
%273 = load i32, i32* %20
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %272, i64 %274
%276 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %275, i32 0, i32 0
%277 = load i32, i32* %276
%278 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %277)
%279 = load %struct.epoll_event*, %struct.epoll_event** %17
%280 = load i32, i32* %20
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %279, i64 %281
%283 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %282, i32 0, i32 1
%284 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %283, i32 0, i32 0
%285 = load i32, i32* %284
%286 = call i32 @close(i32 %285)
store i32 -1, i32* %3
store i32 1, i32* %19
br label %299
287: ; preds = %260, %249
br label %288
288: ; preds = %287, %154
br label %289
289: ; preds = %288
%290 = load i32, i32* %20
%291 = add nsw i32 %290, 1
store i32 %291, i32* %20
br label %92
292: ; preds = %92
br label %293
293: ; preds = %292
br i1 true, label %79, label %294
294: ; preds = %293
%295 = load %struct.epoll_event*, %struct.epoll_event** %17
%296 = call i32 @free(%struct.epoll_event* %295)
%297 = load i32, i32* %7
%298 = call i32 @close(i32 %297)
store i32 0, i32* %3
store i32 1, i32* %19
br label %299
299: ; preds = %294, %271, %214, %179, %152, %130, %111, %85, %72, %62, %43, %38
%300 = load i8*, i8** %12
%301 = load i32, i32* %3
ret i32 %301
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str.1 = [14 x i8] c"epoll_create1\00"
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.2 = [14 x i8] c"epoll_ctl_add\00"
@.str.4 = [11 x i8] c"epoll_wait\00"
@.str.5 = [7 x i8] c"accept\00"
@AF_INET = global i32 0
@.str.6 = [20 x i8] c"Connect with IP %s\0A\00"
@.str.7 = [10 x i8] c"epoll_ctl\00"
@.str.9 = [16 x i8] c"Recv : %s (%d)\0A\00"
@.str.10 = [15 x i8] c"Here is Server\00"
@.str.12 = [9 x i8] c"Send %d\0A\00"
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@.str.13 = [19 x i8] c"Unknown event: %d\0A\00"
@str = [14 x i8] c"Send Failed !\00"
@str.14 = [13 x i8] c"Recv failed!\00"
@str.15 = [15 x i8] c"Calloc Fialed!\00"
@str.16 = [33 x i8] c"Usage: ./epoll_svr [Port number]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = alloca %struct.epoll_event
%6 = alloca %struct.sockaddr
%7 = load i32, i32* @INET_ADDRSTRLEN
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = bitcast i32* %4 to i8*
%12 = bitcast %struct.epoll_event* %5 to i8*
%13 = bitcast %struct.sockaddr* %6 to i8*
%14 = icmp eq i32 %0, 2
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @listen_socket(i8* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %160, label %23
23: ; preds = %18
%24 = tail call i32 @epoll_create1(i32 0)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = tail call i32 @close(i32 %21)
%28 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %160
29: ; preds = %23
%30 = load i32, i32* @EPOLLIN
%31 = load i32, i32* @EPOLLOUT
%32 = or i32 %31, %30
%33 = load i32, i32* @EPOLLET
%34 = or i32 %32, %33
%35 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i64 0, i32 0
store i32 %34, i32* %35
%36 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i64 0, i32 1, i32 0
store i32 %21, i32* %36
%37 = load i32, i32* @EPOLL_CTL_ADD
%38 = call i32 @epoll_ctl(i32 %24, i32 %37, i32 %21, %struct.epoll_event* %5)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %44
40: ; preds = %29
%41 = call i32 @close(i32 %24)
%42 = call i32 @close(i32 %21)
%43 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %160
44: ; preds = %29
%45 = call %struct.epoll_event* @calloc(i32 10, i32 8)
%46 = icmp eq %struct.epoll_event* %45, null
br i1 %46, label %52, label %47
47: ; preds = %44
%48 = call i32 @epoll_wait(i32 %24, %struct.epoll_event* %45, i32 10, i32 -1)
%49 = icmp eq i32 %48, -1
br i1 %49, label %64, label %50
50: ; preds = %47
%51 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %6, i64 0, i32 0
br label %59
52: ; preds = %44
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%54 = call i32 @close(i32 %24)
%55 = call i32 @close(i32 %21)
br label %160
56: ; preds = %157, %59
%57 = call i32 @epoll_wait(i32 %24, %struct.epoll_event* %45, i32 10, i32 -1)
%58 = icmp eq i32 %57, -1
br i1 %58, label %64, label %59
59: ; preds = %50, %56
%60 = phi i32 [ %48, %50 ], [ %57, %56 ]
%61 = icmp eq i32 %60, 0
br i1 %61, label %56, label %62
62: ; preds = %59
%63 = zext i32 %60 to i64
br label %68
64: ; preds = %56, %47
%65 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 @close(i32 %24)
%67 = call i32 @close(i32 %21)
br label %160
68: ; preds = %62, %157
%69 = phi i64 [ 0, %62 ], [ %158, %157 ]
%70 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %45, i64 %69, i32 1, i32 0
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, %21
br i1 %72, label %73, label %102
73: ; preds = %68
store i32 4, i32* %4
%74 = call i32 @accept(i32 %21, %struct.sockaddr* %6, i32* %4)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %81
76: ; preds = %73
%77 = call i32 @close(i32 %24)
%78 = call i32 @close(i32 %21)
%79 = call i32 @close(i32 %60)
%80 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %160
81: ; preds = %73
%82 = load i32, i32* @AF_INET
%83 = call i32 @inet_ntop(i32 %82, i32* %51, i8* %9, i32 %7)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %9)
%85 = call i32 @setnonblocking(i32 %74)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %91
87: ; preds = %81
%88 = call i32 @close(i32 %24)
%89 = call i32 @close(i32 %74)
%90 = call i32 @close(i32 %60)
br label %160
91: ; preds = %81
%92 = load i32, i32* @EPOLLIN
%93 = load i32, i32* @EPOLLOUT
%94 = or i32 %93, %92
%95 = load i32, i32* @EPOLLET
%96 = or i32 %94, %95
store i32 %96, i32* %35
store i32 %74, i32* %36
%97 = load i32, i32* @EPOLL_CTL_ADD
%98 = call i32 @epoll_ctl(i32 %24, i32 %97, i32 %74, %struct.epoll_event* %5)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %157
100: ; preds = %91
%101 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %160
102: ; preds = %68
%103 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %45, i64 %69, i32 0
%104 = load i32, i32* %103
%105 = load i32, i32* @EPOLLIN
%106 = and i32 %105, %104
%107 = icmp eq i32 %106, 0
br i1 %107, label %120, label %108
108: ; preds = %102
%109 = call i32 @memset(i8* %10, i32 0, i32 64)
%110 = load i32, i32* %70
%111 = call i32 @recv(i32 %110, i8* %10, i32 63, i32 0)
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %117
113: ; preds = %108
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0))
%115 = load i32, i32* %70
%116 = call i32 @close(i32 %115)
br label %160
117: ; preds = %108
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %10, i32 %111)
%119 = load i32, i32* %103
br label %120
120: ; preds = %117, %102
%121 = phi i32 [ %119, %117 ], [ %104, %102 ]
%122 = load i32, i32* @EPOLLOUT
%123 = and i32 %122, %121
%124 = icmp eq i32 %123, 0
br i1 %124, label %136, label %125
125: ; preds = %120
%126 = load i32, i32* %70
%127 = call i32 @send(i32 %126, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 14, i32 0)
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %133
129: ; preds = %125
%130 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%131 = load i32, i32* %70
%132 = call i32 @close(i32 %131)
br label %160
133: ; preds = %125
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %127)
%135 = load i32, i32* %103
br label %136
136: ; preds = %133, %120
%137 = phi i32 [ %135, %133 ], [ %121, %120 ]
%138 = load i32, i32* @EPOLLERR
%139 = and i32 %138, %137
%140 = icmp eq i32 %139, %138
br i1 %140, label %153, label %141
141: ; preds = %136
%142 = load i32, i32* @EPOLLHUP
%143 = and i32 %142, %137
%144 = icmp eq i32 %143, %142
br i1 %144, label %153, label %145
145: ; preds = %141
%146 = load i32, i32* @EPOLLIN
%147 = and i32 %146, %137
%148 = icmp eq i32 %147, %146
br i1 %148, label %157, label %149
149: ; preds = %145
%150 = load i32, i32* @EPOLLOUT
%151 = and i32 %150, %137
%152 = icmp eq i32 %151, %150
br i1 %152, label %157, label %153
153: ; preds = %149, %141, %136
%154 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %137)
%155 = load i32, i32* %70
%156 = call i32 @close(i32 %155)
br label %160
157: ; preds = %91, %149, %145
%158 = add nuw nsw i64 %69, 1
%159 = icmp eq i64 %158, %63
br i1 %159, label %56, label %68
160: ; preds = %87, %100, %76, %113, %129, %153, %18, %64, %52, %40, %26
ret i32 -1
}