#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 {
  int dummy;
};
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};
typedef int ssize_t;
typedef int socklen_t;
typedef int /*<<< orphan*/ sbuf;
typedef int /*<<< orphan*/ in_addr;
typedef int /*<<< orphan*/ hbuf;
typedef int /*<<< orphan*/ event;

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ ECONNRESET;
int EPOLLERR;
int EPOLLHUP;
int EPOLLIN;
int EPOLLOUT;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ EPOLL_CTL_MOD;
scalar_t__ EWOULDBLOCK;
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ SOMAXCONN;
int accept(int, struct sockaddr *, int *);
struct epoll_event *calloc(int, int);
int /*<<< orphan*/ close(int);
int create_and_bind(char *);
int epoll_create1(int /*<<< orphan*/);
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(struct epoll_event *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int getnameinfo(struct sockaddr *, int, char *, int, char *, int, int);
int listen(int, int /*<<< orphan*/);
int make_socket_non_blocking(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sfd, s;
  int efd;
  struct epoll_event event;
  struct epoll_event *events;
  char *response = "HTTP/1.1 200 OK\r\n"
                   "Server: Tengine\r\n"
                   "Date: Tue, 10 Dec 2013 08:14:13 GMT\r\n"
                   "Content-Type: text/html; charset=utf-8\r\n"
                   "Connection: close\r\n"
                   "Vary: Cookie\r\n\r\n"
                   "<!doctype html><html "
                   "lang=\"en\"><head><title>hello</title></"
                   "head><body><h1>Hello</h1></body></html>\n";
  int resp_len = strlen(response);
  if (-1 == (sfd = create_and_bind(argv[1])))
    goto error;
  if (-1 == make_socket_non_blocking(sfd))
    goto error;
  if (-1 == listen(sfd, SOMAXCONN))
    goto error;
  if (-1 == (efd = epoll_create1(0)))
    goto error;
  event.data.fd = sfd;
  event.events = EPOLLIN;
  if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, sfd, &event))
    goto error;
  if (NULL == (events = calloc(64, sizeof(event))))
    goto error;
  while (1) {
    int n, i;
    n = epoll_wait(efd, events, 64, -1);
    for (i = 0; i < n; ++i) {
      if (events[i].events & EPOLLERR || events[i].events & EPOLLHUP) {
        fprintf(stderr, "epoll error\n");
        close(events[i].data.fd);
        continue;
      } else if (sfd == events[i].data.fd) {
        while (1) {
          struct sockaddr in_addr;
          socklen_t in_len;
          int infd;
          char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
          in_len = sizeof(in_addr);
          infd = accept(sfd, &in_addr, &in_len);
          if (infd == -1) {
            if (errno == EAGAIN || errno == EWOULDBLOCK)
              break;
            else {
              perror("accept");
              break;
            }
          }
          s = getnameinfo(&in_addr, in_len, hbuf, sizeof(hbuf), sbuf,
                          sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
          if (0 == s) {
            printf("Accepted connection on fd %d (host=%s, port=%s)\n", infd,
                   hbuf, sbuf);
          } else
            perror("**** getnameinfo");
          if (-1 == make_socket_non_blocking(infd))
            goto error;
          event.data.fd = infd;
          event.events = EPOLLIN;
          if (-1 == epoll_ctl(efd, EPOLL_CTL_ADD, infd, &event))
            goto error;
          break;
        }
        continue;
      } else if (events[i].events & EPOLLIN) {
        int recv_error = 0;
        printf("conn %d vvvvvv\n", events[i].data.fd);
        ssize_t bytes_read;
        do {
          char buff[1024];
          bytes_read = recv(events[i].data.fd, buff, 1024, 0);
          if (-1 == bytes_read) {
            perror("recv");
            recv_error = 1;
            break;
          }
          fwrite(buff, 1, bytes_read, stdout);
        } while (bytes_read == 1024);
        if (recv_error) {
          if (errno == ECONNRESET)
            close(events[i].data.fd);
          else
            fprintf(stderr, "WTF? lineno=%d", 118);
        } else {
          event.data.fd = events[i].data.fd;
          event.events = EPOLLOUT;
          if (-1 == epoll_ctl(efd, EPOLL_CTL_MOD, event.data.fd, &event)) {
            perror("epoll_ctl MOD");
            goto error;
          }
        }
        printf("conn %d ^^^^^^\n", events[i].data.fd);
      } else if (events[i].events & EPOLLOUT) {
        send(events[i].data.fd, response, resp_len, 0);
        close(events[i].data.fd);
      } else {
        fprintf(stderr, "fd %d: WTF...\n", events[i].data.fd);
      }
    }
  }
  close(sfd);
  close(efd);
  free(events);
  return 0;
error:
  if (sfd > -1)
    close(sfd);
  if (efd > -1)
    close(efd);
  if (NULL != events)
    free(events);
  fprintf(stderr, "error occured\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdc0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <create_and_bind@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1274 <main+0x54>
jmp    17f5 <main+0x5d5>
mov    -0x14(%rbp),%edi
call   1050 <make_socket_non_blocking@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1290 <main+0x70>
jmp    17f5 <main+0x5d5>
mov    -0x14(%rbp),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
call   10e0 <listen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12b5 <main+0x95>
jmp    17f5 <main+0x5d5>
xor    %edi,%edi
call   1140 <epoll_create1@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12d3 <main+0xb3>
jmp    17f5 <main+0x5d5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2ce9(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   10b0 <epoll_ctl@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1311 <main+0xf1>
jmp    17f5 <main+0x5d5>
mov    $0x40,%edi
mov    $0x8,%esi
call   10c0 <calloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1337 <main+0x117>
jmp    17f5 <main+0x5d5>
jmp    133c <main+0x11c>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10f0 <epoll_wait@plt>
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    17f0 <main+0x5d0>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2c26(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    13a2 <main+0x182>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2bd1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13cf <main+0x1af>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
jmp    17e2 <main+0x5c2>
mov    -0x14(%rbp),%eax
mov    -0x30(%rbp),%rcx
movslq -0x44(%rbp),%rdx
cmp    0x4(%rcx,%rdx,8),%eax
jne    15dc <main+0x3bc>
jmp    13e9 <main+0x1c9>
mov    0x2b80(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x4a0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x498(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
mov    0x2baa(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x490(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x488(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
movl   $0x4,-0x4c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1120 <accept@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    14ca <main+0x2aa>
mov    0x2b0f(%rip),%rax
mov    (%rax),%rax
mov    0x2ad5(%rip),%rcx
cmp    (%rcx),%rax
je     14a6 <main+0x286>
mov    0x2af5(%rip),%rax
mov    (%rax),%rax
mov    0x2ae3(%rip),%rcx
cmp    (%rcx),%rax
jne    14b2 <main+0x292>
movl   $0x9,-0x6c(%rbp)
jmp    15bf <main+0x39f>
lea    0xc4a(%rip),%rdi
call   1110 <perror@plt>
movl   $0x9,-0x6c(%rbp)
jmp    15bf <main+0x39f>
mov    -0x488(%rbp),%r8
mov    -0x498(%rbp),%rdx
mov    -0x490(%rbp),%rax
mov    -0x4a0(%rbp),%rcx
mov    -0x4c(%rbp),%esi
mov    %eax,%r9d
mov    0x2aa5(%rip),%rax
mov    (%rax),%eax
mov    0x2aec(%rip),%rdi
or     (%rdi),%eax
lea    -0x48(%rbp),%rdi
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   10a0 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jne    1544 <main+0x324>
mov    -0x488(%rbp),%rcx
mov    -0x498(%rbp),%rdx
mov    -0x50(%rbp),%esi
lea    0xbd2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1550 <main+0x330>
lea    0xbf0(%rip),%rdi
call   1110 <perror@plt>
mov    -0x50(%rbp),%edi
call   1050 <make_socket_non_blocking@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1573 <main+0x353>
movl   $0x2,-0x6c(%rbp)
jmp    15bf <main+0x39f>
mov    -0x50(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2a60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2a49(%rip),%rax
mov    (%rax),%esi
mov    -0x50(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   10b0 <epoll_ctl@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    15b8 <main+0x398>
movl   $0x2,-0x6c(%rbp)
jmp    15bf <main+0x39f>
movl   $0x9,-0x6c(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    -0x6c(%rbp),%eax
sub    $0x2,%eax
je     17f5 <main+0x5d5>
jmp    15d7 <main+0x3b7>
jmp    17e2 <main+0x5c2>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x29f2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     175e <main+0x53e>
movl   $0x0,-0x70(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%esi
lea    0xb39(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
lea    -0x480(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x74(%rbp)
mov    $0xffffffff,%eax
cmp    -0x74(%rbp),%eax
jne    1662 <main+0x442>
lea    0xb0b(%rip),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x70(%rbp)
jmp    168c <main+0x46c>
lea    -0x480(%rbp),%rdi
mov    -0x74(%rbp),%edx
mov    0x2905(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1130 <fwrite@plt>
cmpl   $0x400,-0x74(%rbp)
je     161a <main+0x3fa>
cmpl   $0x0,-0x70(%rbp)
je     16e7 <main+0x4c7>
mov    0x28eb(%rip),%rax
mov    (%rax),%rax
mov    0x2919(%rip),%rcx
cmp    (%rcx),%rax
jne    16c6 <main+0x4a6>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
jmp    16e2 <main+0x4c2>
mov    0x28e3(%rip),%rax
mov    (%rax),%edi
lea    0xa8b(%rip),%rsi
mov    $0x76,%edx
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    173f <main+0x51f>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%eax
mov    %eax,-0x24(%rbp)
mov    0x2893(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x28ac(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   10b0 <epoll_ctl@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    173a <main+0x51a>
lea    0xa40(%rip),%rdi
call   1110 <perror@plt>
jmp    17f5 <main+0x5d5>
jmp    173f <main+0x51f>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%esi
lea    0xa2c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    17d3 <main+0x5b3>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2820(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     17ab <main+0x58b>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1090 <close@plt>
jmp    17ce <main+0x5ae>
mov    0x27fe(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edx
lea    0x9c7(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    17d3 <main+0x5b3>
jmp    17d8 <main+0x5b8>
jmp    17dd <main+0x5bd>
jmp    17e2 <main+0x5c2>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    135c <main+0x13c>
jmp    133c <main+0x11c>
cmpl   $0xffffffff,-0x14(%rbp)
jle    1807 <main+0x5e7>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jle    1819 <main+0x5f9>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
je     182e <main+0x60e>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x277b(%rip),%rax
mov    (%rax),%edi
lea    0x95f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%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    $0x448,%rsp
mov    %rsi,%rbx
lea    0xdc2(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%r12d
mov    0x8(%rbx),%rdi
call   1100 <create_and_bind@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <make_socket_non_blocking@plt>
cmp    $0xffffffff,%eax
je     1631 <main+0x411>
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10e0 <listen@plt>
cmp    $0xffffffff,%eax
je     1631 <main+0x411>
xor    %edi,%edi
call   1140 <epoll_create1@plt>
cmp    $0xffffffff,%eax
je     1633 <main+0x413>
mov    %eax,%r15d
mov    %ebx,-0x34(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rcx
mov    %r15d,%edi
mov    %ebx,%edx
call   10b0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     1639 <main+0x419>
mov    $0x40,%edi
mov    $0x8,%esi
call   10c0 <calloc@plt>
test   %rax,%rax
je     1689 <main+0x469>
mov    %rax,%r14
mov    %r12d,-0x4c(%rbp)
mov    0x2cbe(%rip),%r12
mov    %ebx,-0x30(%rbp)
mov    %r15d,-0x2c(%rbp)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10f0 <epoll_wait@plt>
test   %eax,%eax
jle    12f0 <main+0xd0>
mov    %eax,%eax
mov    %rax,-0x68(%rbp)
xor    %r13d,%r13d
jmp    133a <main+0x11a>
mov    -0x48(%rbp),%rsp
mov    -0x30(%rbp),%ebx
mov    -0x2c(%rbp),%r15d
mov    0x2c7a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    -0x68(%rbp),%r13
je     12f0 <main+0xd0>
mov    (%r14,%r13,8),%eax
test   %eax,(%r12)
jne    134f <main+0x12f>
mov    0x2c1d(%rip),%rcx
test   %eax,(%rcx)
je     1372 <main+0x152>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x4(%r14,%r13,8),%edi
call   1090 <close@plt>
jmp    1330 <main+0x110>
mov    0x4(%r14,%r13,8),%edx
cmp    %edx,%ebx
jne    148f <main+0x26f>
mov    %rsp,-0x48(%rbp)
mov    0x2be6(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
mov    %rax,-0x60(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
mov    %rax,-0x58(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movl   $0x4,-0x3c(%rbp)
mov    %ebx,%edi
lea    -0x470(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1120 <accept@plt>
cmp    $0xffffffff,%eax
je     1550 <main+0x330>
mov    %eax,%ebx
mov    -0x3c(%rbp),%esi
mov    0x2bfb(%rip),%rax
mov    (%rax),%eax
mov    0x2ba2(%rip),%rcx
or     (%rcx),%eax
sub    $0x8,%rsp
lea    -0x470(%rbp),%rdi
mov    %r12,%rdx
mov    -0x60(%rbp),%rcx
mov    %r15,%r8
mov    -0x58(%rbp),%r9
push   %rax
call   10a0 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    15fb <main+0x3db>
lea    0xce0(%rip),%rdi
mov    %ebx,%esi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
mov    -0x2c(%rbp),%r15d
mov    0x2b5c(%rip),%r12
mov    %ebx,%edi
call   1050 <make_socket_non_blocking@plt>
cmp    $0xffffffff,%eax
je     168e <main+0x46e>
mov    %ebx,-0x34(%rbp)
mov    0x2b82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2b6e(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %ebx,%edx
lea    -0x38(%rbp),%rcx
call   10b0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
mov    -0x48(%rbp),%rsp
mov    -0x30(%rbp),%ebx
jne    1330 <main+0x110>
jmp    1639 <main+0x419>
mov    0x2b4a(%rip),%rcx
test   %eax,(%rcx)
je     158b <main+0x36b>
lea    0xca7(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    -0x470(%rbp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x4(%r14,%r13,8),%edi
mov    %r15,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
je     15ca <main+0x3aa>
mov    %eax,%ebx
mov    0x2a92(%rip),%rax
mov    (%rax),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1130 <fwrite@plt>
cmp    $0x400,%ebx
je     14c0 <main+0x2a0>
mov    0x4(%r14,%r13,8),%edx
mov    %edx,-0x34(%rbp)
mov    0x2a82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2a9e(%rip),%rax
mov    (%rax),%esi
mov    -0x2c(%rbp),%r15d
mov    %r15d,%edi
lea    -0x38(%rbp),%rcx
call   10b0 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
mov    -0x30(%rbp),%ebx
je     1697 <main+0x477>
mov    0x4(%r14,%r13,8),%esi
lea    0xc3a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1330 <main+0x110>
mov    0x2a31(%rip),%rax
mov    (%rax),%rax
mov    0x29f7(%rip),%rcx
cmp    (%rcx),%rax
je     1314 <main+0xf4>
mov    0x2a0f(%rip),%rcx
cmp    (%rcx),%rax
je     1314 <main+0xf4>
lea    0xb82(%rip),%rdi
call   1110 <perror@plt>
jmp    1314 <main+0xf4>
mov    0x29fe(%rip),%rcx
test   %eax,(%rcx)
je     15ae <main+0x38e>
mov    %edx,%edi
lea    0xa61(%rip),%rsi
mov    -0x4c(%rbp),%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    1366 <main+0x146>
mov    0x29fb(%rip),%rax
mov    (%rax),%edi
lea    0xbd0(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1330 <main+0x110>
lea    0xb8b(%rip),%rdi
call   1110 <perror@plt>
mov    0x29ab(%rip),%rax
mov    (%rax),%rax
mov    0x29d9(%rip),%rcx
cmp    (%rcx),%rax
mov    -0x30(%rbp),%ebx
jne    160c <main+0x3ec>
mov    0x4(%r14,%r13,8),%edi
call   1090 <close@plt>
jmp    1628 <main+0x408>
lea    0xb39(%rip),%rdi
call   1110 <perror@plt>
jmp    1439 <main+0x219>
mov    0x299d(%rip),%rax
mov    (%rax),%edi
lea    0xb45(%rip),%rsi
mov    $0x76,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    -0x2c(%rbp),%r15d
jmp    1538 <main+0x318>
jmp    1639 <main+0x419>
mov    $0xffffffff,%r15d
test   %ebx,%ebx
js     1644 <main+0x424>
mov    %ebx,%edi
call   1090 <close@plt>
test   %r15d,%r15d
js     1651 <main+0x431>
mov    %r15d,%edi
call   1090 <close@plt>
test   %r14,%r14
je     165e <main+0x43e>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x294b(%rip),%rax
mov    (%rax),%edi
lea    0xb2f(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
jmp    1639 <main+0x419>
mov    -0x48(%rbp),%rsp
mov    -0x30(%rbp),%ebx
jmp    1639 <main+0x419>
lea    0xad2(%rip),%rdi
call   1110 <perror@plt>
jmp    1639 <main+0x419>

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [246 x i8] c"HTTP/1.1 200 OK\0D\0AServer: Tengine\0D\0ADate: Tue, 10 Dec 2013 08:14:13 GMT\0D\0AContent-Type: text/html; charset=utf-8\0D\0AConnection: close\0D\0AVary: Cookie\0D\0A\0D\0A<!doctype html><html lang=\22en\22><head><title>hello</title></head><body><h1>Hello</h1></body></html>\0A\00"
@SOMAXCONN = global i32 0
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@stderr = global i32 0
@.str.1 = [13 x i8] c"epoll error\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@EWOULDBLOCK = global i64 0
@.str.2 = [7 x i8] c"accept\00"
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.3 = [49 x i8] c"Accepted connection on fd %d (host=%s, port=%s)\0A\00"
@.str.4 = [17 x i8] c"**** getnameinfo\00"
@.str.5 = [16 x i8] c"conn %d vvvvvv\0A\00"
@.str.6 = [5 x i8] c"recv\00"
@stdout = global i32 0
@ECONNRESET = global i64 0
@.str.7 = [15 x i8] c"WTF? lineno=%d\00"
@EPOLLOUT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str.8 = [14 x i8] c"epoll_ctl MOD\00"
@.str.9 = [16 x i8] c"conn %d ^^^^^^\0A\00"
@.str.10 = [15 x i8] c"fd %d: WTF...\0A\00"
@.str.11 = [15 x i8] c"error occured\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 %struct.epoll_event
%10 = alloca %struct.epoll_event*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.sockaddr
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str, i64 0, i64 0), i8** %11
%25 = load i8*, i8** %11
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %12
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @create_and_bind(i8* %29)
store i32 %30, i32* %6
%31 = icmp eq i32 -1, %30
br i1 %31, label %32, label %33
32: ; preds = %2
br label %314
33: ; preds = %2
%34 = load i32, i32* %6
%35 = call i32 @make_socket_non_blocking(i32 %34)
%36 = icmp eq i32 -1, %35
br i1 %36, label %37, label %38
37: ; preds = %33
br label %314
38: ; preds = %33
%39 = load i32, i32* %6
%40 = load i32, i32* @SOMAXCONN
%41 = call i32 @listen(i32 %39, i32 %40)
%42 = icmp eq i32 -1, %41
br i1 %42, label %43, label %44
43: ; preds = %38
br label %314
44: ; preds = %38
%45 = call i32 @epoll_create1(i32 0)
store i32 %45, i32* %8
%46 = icmp eq i32 -1, %45
br i1 %46, label %47, label %48
47: ; preds = %44
br label %314
48: ; preds = %44
%49 = load i32, i32* %6
%50 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %50, i32 0, i32 0
store i32 %49, i32* %51
%52 = load i32, i32* @EPOLLIN
%53 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 0
store i32 %52, i32* %53
%54 = load i32, i32* %8
%55 = load i32, i32* @EPOLL_CTL_ADD
%56 = load i32, i32* %6
%57 = call i32 @epoll_ctl(i32 %54, i32 %55, i32 %56, %struct.epoll_event* %9)
%58 = icmp eq i32 -1, %57
br i1 %58, label %59, label %60
59: ; preds = %48
br label %314
60: ; preds = %48
%61 = call %struct.epoll_event* @calloc(i32 64, i32 8)
store %struct.epoll_event* %61, %struct.epoll_event** %10
%62 = icmp eq %struct.epoll_event* null, %61
br i1 %62, label %63, label %64
63: ; preds = %60
br label %314
64: ; preds = %60
br label %65
65: ; preds = %64, %313
%66 = load i32, i32* %8
%67 = load %struct.epoll_event*, %struct.epoll_event** %10
%68 = call i32 @epoll_wait(i32 %66, %struct.epoll_event* %67, i32 64, i32 -1)
store i32 %68, i32* %13
store i32 0, i32* %14
br label %69
69: ; preds = %310, %65
%70 = load i32, i32* %14
%71 = load i32, i32* %13
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %313
73: ; preds = %69
%74 = load %struct.epoll_event*, %struct.epoll_event** %10
%75 = load i32, i32* %14
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %74, i64 %76
%78 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load i32, i32* @EPOLLERR
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
br i1 %82, label %93, label %83
83: ; preds = %73
%84 = load %struct.epoll_event*, %struct.epoll_event** %10
%85 = load i32, i32* %14
%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 = load i32, i32* %88
%90 = load i32, i32* @EPOLLHUP
%91 = and i32 %89, %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %104
93: ; preds = %83, %73
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%96 = load %struct.epoll_event*, %struct.epoll_event** %10
%97 = load i32, i32* %14
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %96, i64 %98
%100 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %99, i32 0, i32 1
%101 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %100, i32 0, i32 0
%102 = load i32, i32* %101
%103 = call i32 @close(i32 %102)
br label %310
104: ; preds = %83
%105 = load i32, i32* %6
%106 = load %struct.epoll_event*, %struct.epoll_event** %10
%107 = load i32, i32* %14
%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 1
%111 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = icmp eq i32 %105, %112
br i1 %113, label %114, label %175
114: ; preds = %104
br label %115
115: ; preds = %114
%116 = load i32, i32* @NI_MAXHOST
%117 = zext i32 %116 to i64
%118 = call i8* @llvm.stacksave()
store i8* %118, i8** %18
%119 = alloca i8, i64 %117
store i64 %117, i64* %19
%120 = load i32, i32* @NI_MAXSERV
%121 = zext i32 %120 to i64
%122 = alloca i8, i64 %121
store i64 %121, i64* %20
store i32 4, i32* %16
%123 = load i32, i32* %6
%124 = call i32 @accept(i32 %123, %struct.sockaddr* %15, i32* %16)
store i32 %124, i32* %17
%125 = load i32, i32* %17
%126 = icmp eq i32 %125, -1
br i1 %126, label %127, label %138
127: ; preds = %115
%128 = load i64, i64* @errno
%129 = load i64, i64* @EAGAIN
%130 = icmp eq i64 %128, %129
br i1 %130, label %135, label %131
131: ; preds = %127
%132 = load i64, i64* @errno
%133 = load i64, i64* @EWOULDBLOCK
%134 = icmp eq i64 %132, %133
br i1 %134, label %135, label %136
135: ; preds = %131, %127
store i32 9, i32* %21
br label %171
136: ; preds = %131
%137 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 9, i32* %21
br label %171
138: ; preds = %115
%139 = load i32, i32* %16
%140 = trunc i64 %117 to i32
%141 = trunc i64 %121 to i32
%142 = load i32, i32* @NI_NUMERICHOST
%143 = load i32, i32* @NI_NUMERICSERV
%144 = or i32 %142, %143
%145 = call i32 @getnameinfo(%struct.sockaddr* %15, i32 %139, i8* %119, i32 %140, i8* %122, i32 %141, i32 %144)
store i32 %145, i32* %7
%146 = load i32, i32* %7
%147 = icmp eq i32 0, %146
br i1 %147, label %148, label %151
148: ; preds = %138
%149 = load i32, i32* %17
%150 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %149, i8* %119, i8* %122)
br label %153
151: ; preds = %138
%152 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %153
153: ; preds = %151, %148
%154 = load i32, i32* %17
%155 = call i32 @make_socket_non_blocking(i32 %154)
%156 = icmp eq i32 -1, %155
br i1 %156, label %157, label %158
157: ; preds = %153
store i32 2, i32* %21
br label %171
158: ; preds = %153
%159 = load i32, i32* %17
%160 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%161 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %160, i32 0, i32 0
store i32 %159, i32* %161
%162 = load i32, i32* @EPOLLIN
%163 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 0
store i32 %162, i32* %163
%164 = load i32, i32* %8
%165 = load i32, i32* @EPOLL_CTL_ADD
%166 = load i32, i32* %17
%167 = call i32 @epoll_ctl(i32 %164, i32 %165, i32 %166, %struct.epoll_event* %9)
%168 = icmp eq i32 -1, %167
br i1 %168, label %169, label %170
169: ; preds = %158
store i32 2, i32* %21
br label %171
170: ; preds = %158
store i32 9, i32* %21
br label %171
171: ; preds = %169, %157, %170, %136, %135
%172 = load i8*, i8** %18
%173 = load i32, i32* %21
switch i32 %173, label %335 [
i32 9, label %174
i32 2, label %314
]
174: ; preds = %171
br label %310
175: ; preds = %104
%176 = load %struct.epoll_event*, %struct.epoll_event** %10
%177 = load i32, i32* %14
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %176, i64 %178
%180 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %179, i32 0, i32 0
%181 = load i32, i32* %180
%182 = load i32, i32* @EPOLLIN
%183 = and i32 %181, %182
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %267
185: ; preds = %175
store i32 0, i32* %22
%186 = load %struct.epoll_event*, %struct.epoll_event** %10
%187 = load i32, i32* %14
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %186, i64 %188
%190 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %189, i32 0, i32 1
%191 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %190, i32 0, i32 0
%192 = load i32, i32* %191
%193 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %192)
br label %194
194: ; preds = %213, %185
%195 = load %struct.epoll_event*, %struct.epoll_event** %10
%196 = load i32, i32* %14
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %195, i64 %197
%199 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %198, i32 0, i32 1
%200 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %199, i32 0, i32 0
%201 = load i32, i32* %200
%202 = getelementptr inbounds [1024 x i8], [1024 x i8]* %24, i64 0, i64 0
%203 = call i32 @recv(i32 %201, i8* %202, i32 1024, i32 0)
store i32 %203, i32* %23
%204 = load i32, i32* %23
%205 = icmp eq i32 -1, %204
br i1 %205, label %206, label %208
206: ; preds = %194
%207 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %22
br label %216
208: ; preds = %194
%209 = getelementptr inbounds [1024 x i8], [1024 x i8]* %24, i64 0, i64 0
%210 = load i32, i32* %23
%211 = load i32, i32* @stdout
%212 = call i32 @fwrite(i8* %209, i32 1, i32 %210, i32 %211)
br label %213
213: ; preds = %208
%214 = load i32, i32* %23
%215 = icmp eq i32 %214, 1024
br i1 %215, label %194, label %216
216: ; preds = %213, %206
%217 = load i32, i32* %22
%218 = icmp ne i32 %217, 0
br i1 %218, label %219, label %236
219: ; preds = %216
%220 = load i64, i64* @errno
%221 = load i64, i64* @ECONNRESET
%222 = icmp eq i64 %220, %221
br i1 %222, label %223, label %232
223: ; preds = %219
%224 = load %struct.epoll_event*, %struct.epoll_event** %10
%225 = load i32, i32* %14
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %224, i64 %226
%228 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %227, i32 0, i32 1
%229 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %228, i32 0, i32 0
%230 = load i32, i32* %229
%231 = call i32 @close(i32 %230)
br label %235
232: ; preds = %219
%233 = load i32, i32* @stderr
%234 = call i32 (i32, i8*, ...) @fprintf(i32 %233, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 118)
br label %235
235: ; preds = %232, %223
br label %258
236: ; preds = %216
%237 = load %struct.epoll_event*, %struct.epoll_event** %10
%238 = load i32, i32* %14
%239 = sext i32 %238 to i64
%240 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %237, i64 %239
%241 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %240, i32 0, i32 1
%242 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %241, i32 0, i32 0
%243 = load i32, i32* %242
%244 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%245 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %244, i32 0, i32 0
store i32 %243, i32* %245
%246 = load i32, i32* @EPOLLOUT
%247 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 0
store i32 %246, i32* %247
%248 = load i32, i32* %8
%249 = load i32, i32* @EPOLL_CTL_MOD
%250 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%251 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %250, i32 0, i32 0
%252 = load i32, i32* %251
%253 = call i32 @epoll_ctl(i32 %248, i32 %249, i32 %252, %struct.epoll_event* %9)
%254 = icmp eq i32 -1, %253
br i1 %254, label %255, label %257
255: ; preds = %236
%256 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %314
257: ; preds = %236
br label %258
258: ; preds = %257, %235
%259 = load %struct.epoll_event*, %struct.epoll_event** %10
%260 = load i32, i32* %14
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %259, i64 %261
%263 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %262, i32 0, i32 1
%264 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %263, i32 0, i32 0
%265 = load i32, i32* %264
%266 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %265)
br label %307
267: ; preds = %175
%268 = load %struct.epoll_event*, %struct.epoll_event** %10
%269 = load i32, i32* %14
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %268, i64 %270
%272 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %271, i32 0, i32 0
%273 = load i32, i32* %272
%274 = load i32, i32* @EPOLLOUT
%275 = and i32 %273, %274
%276 = icmp ne i32 %275, 0
br i1 %276, label %277, label %296
277: ; preds = %267
%278 = load %struct.epoll_event*, %struct.epoll_event** %10
%279 = load i32, i32* %14
%280 = sext i32 %279 to i64
%281 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %278, i64 %280
%282 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %281, i32 0, i32 1
%283 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %282, i32 0, i32 0
%284 = load i32, i32* %283
%285 = load i8*, i8** %11
%286 = load i32, i32* %12
%287 = call i32 @send(i32 %284, i8* %285, i32 %286, i32 0)
%288 = load %struct.epoll_event*, %struct.epoll_event** %10
%289 = load i32, i32* %14
%290 = sext i32 %289 to i64
%291 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %288, i64 %290
%292 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %291, i32 0, i32 1
%293 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %292, i32 0, i32 0
%294 = load i32, i32* %293
%295 = call i32 @close(i32 %294)
br label %306
296: ; preds = %267
%297 = load i32, i32* @stderr
%298 = load %struct.epoll_event*, %struct.epoll_event** %10
%299 = load i32, i32* %14
%300 = sext i32 %299 to i64
%301 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %298, i64 %300
%302 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %301, i32 0, i32 1
%303 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %302, i32 0, i32 0
%304 = load i32, i32* %303
%305 = call i32 (i32, i8*, ...) @fprintf(i32 %297, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %304)
br label %306
306: ; preds = %296, %277
br label %307
307: ; preds = %306, %258
br label %308
308: ; preds = %307
br label %309
309: ; preds = %308
br label %310
310: ; preds = %309, %174, %93
%311 = load i32, i32* %14
%312 = add nsw i32 %311, 1
store i32 %312, i32* %14
br label %69
313: ; preds = %69
br label %65
314: ; preds = %255, %171, %63, %59, %47, %43, %37, %32
%315 = load i32, i32* %6
%316 = icmp sgt i32 %315, -1
br i1 %316, label %317, label %320
317: ; preds = %314
%318 = load i32, i32* %6
%319 = call i32 @close(i32 %318)
br label %320
320: ; preds = %317, %314
%321 = load i32, i32* %8
%322 = icmp sgt i32 %321, -1
br i1 %322, label %323, label %326
323: ; preds = %320
%324 = load i32, i32* %8
%325 = call i32 @close(i32 %324)
br label %326
326: ; preds = %323, %320
%327 = load %struct.epoll_event*, %struct.epoll_event** %10
%328 = icmp ne %struct.epoll_event* null, %327
br i1 %328, label %329, label %332
329: ; preds = %326
%330 = load %struct.epoll_event*, %struct.epoll_event** %10
%331 = call i32 @free(%struct.epoll_event* %330)
br label %332
332: ; preds = %329, %326
%333 = load i32, i32* @stderr
%334 = call i32 (i32, i8*, ...) @fprintf(i32 %333, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
ret i32 1
335: ; preds = %171
unreachable
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [246 x i8] c"HTTP/1.1 200 OK\0D\0AServer: Tengine\0D\0ADate: Tue, 10 Dec 2013 08:14:13 GMT\0D\0AContent-Type: text/html; charset=utf-8\0D\0AConnection: close\0D\0AVary: Cookie\0D\0A\0D\0A<!doctype html><html lang=\22en\22><head><title>hello</title></head><body><h1>Hello</h1></body></html>\0A\00"
@SOMAXCONN = global i32 0
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@stderr = global i32 0
@.str.1 = [13 x i8] c"epoll error\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@EWOULDBLOCK = global i64 0
@.str.2 = [7 x i8] c"accept\00"
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str.3 = [49 x i8] c"Accepted connection on fd %d (host=%s, port=%s)\0A\00"
@.str.4 = [17 x i8] c"**** getnameinfo\00"
@.str.5 = [16 x i8] c"conn %d vvvvvv\0A\00"
@.str.6 = [5 x i8] c"recv\00"
@stdout = global i32 0
@ECONNRESET = global i64 0
@.str.7 = [15 x i8] c"WTF? lineno=%d\00"
@EPOLLOUT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str.8 = [14 x i8] c"epoll_ctl MOD\00"
@.str.9 = [16 x i8] c"conn %d ^^^^^^\0A\00"
@.str.10 = [15 x i8] c"fd %d: WTF...\0A\00"
@.str.11 = [15 x i8] c"error occured\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.epoll_event
%4 = alloca %struct.sockaddr
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = bitcast %struct.epoll_event* %3 to i8*
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @create_and_bind(i8* %10)
%12 = icmp ne i32 %11, -1
tail call void @llvm.assume(i1 %12)
%13 = tail call i32 @make_socket_non_blocking(i32 %11)
%14 = icmp eq i32 %13, -1
br i1 %14, label %153, label %15
15: ; preds = %2
%16 = load i32, i32* @SOMAXCONN
%17 = tail call i32 @listen(i32 %11, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %153, label %19
19: ; preds = %15
%20 = tail call i32 @epoll_create1(i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %153, label %22
22: ; preds = %19
%23 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1, i32 0
store i32 %11, i32* %23
%24 = load i32, i32* @EPOLLIN
%25 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* @EPOLL_CTL_ADD
%27 = call i32 @epoll_ctl(i32 %20, i32 %26, i32 %11, %struct.epoll_event* %3)
%28 = icmp eq i32 %27, -1
br i1 %28, label %153, label %29
29: ; preds = %22
%30 = call %struct.epoll_event* @calloc(i32 64, i32 8)
%31 = icmp eq %struct.epoll_event* %30, null
br i1 %31, label %153, label %32
32: ; preds = %29
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = bitcast %struct.sockaddr* %4 to i8*
%35 = bitcast i32* %5 to i8*
br label %36
36: ; preds = %39, %32
%37 = call i32 @epoll_wait(i32 %20, %struct.epoll_event* %30, i32 64, i32 -1)
%38 = icmp sgt i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %150, %36
br label %36
40: ; preds = %36
%41 = zext i32 %37 to i64
br label %42
42: ; preds = %40, %150
%43 = phi i64 [ 0, %40 ], [ %151, %150 ]
%44 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %30, i64 %43, i32 0
%45 = load i32, i32* %44
%46 = load i32, i32* @EPOLLERR
%47 = and i32 %46, %45
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %42
%50 = load i32, i32* @EPOLLHUP
%51 = and i32 %50, %45
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %49, %42
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%56 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %30, i64 %43, i32 1, i32 0
%57 = load i32, i32* %56
%58 = call i32 @close(i32 %57)
br label %150
59: ; preds = %49
%60 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %30, i64 %43, i32 1, i32 0
%61 = load i32, i32* %60
%62 = icmp eq i32 %11, %61
br i1 %62, label %63, label %103
63: ; preds = %59
%64 = load i32, i32* @NI_MAXHOST
%65 = zext i32 %64 to i64
%66 = call i8* @llvm.stacksave()
%67 = alloca i8, i64 %65
%68 = load i32, i32* @NI_MAXSERV
%69 = zext i32 %68 to i64
%70 = alloca i8, i64 %69
store i32 4, i32* %5
%71 = call i32 @accept(i32 %11, %struct.sockaddr* %4, i32* %5)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %82
73: ; preds = %63
%74 = load i64, i64* @errno
%75 = load i64, i64* @EAGAIN
%76 = icmp eq i64 %74, %75
%77 = load i64, i64* @EWOULDBLOCK
%78 = icmp eq i64 %74, %77
%79 = select i1 %76, i1 true, i1 %78
br i1 %79, label %97, label %80
80: ; preds = %73
%81 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %97
82: ; preds = %63
%83 = load i32, i32* %5
%84 = load i32, i32* @NI_NUMERICHOST
%85 = load i32, i32* @NI_NUMERICSERV
%86 = or i32 %85, %84
%87 = call i32 @getnameinfo(%struct.sockaddr* %4, i32 %83, i8* %67, i32 %64, i8* %70, i32 %68, i32 %86)
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %82
%90 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %71, i8* %67, i8* %70)
br label %93
91: ; preds = %82
%92 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %93
93: ; preds = %91, %89
%94 = call i32 @make_socket_non_blocking(i32 %71)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %93
br label %153
97: ; preds = %80, %73
br label %150
98: ; preds = %93
store i32 %71, i32* %23
%99 = load i32, i32* @EPOLLIN
store i32 %99, i32* %25
%100 = load i32, i32* @EPOLL_CTL_ADD
%101 = call i32 @epoll_ctl(i32 %20, i32 %100, i32 %71, %struct.epoll_event* %3)
%102 = icmp eq i32 %101, -1
br i1 %102, label %153, label %150
103: ; preds = %59
%104 = load i32, i32* @EPOLLIN
%105 = and i32 %104, %45
%106 = icmp eq i32 %105, 0
br i1 %106, label %139, label %107
107: ; preds = %103
%108 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %61)
br label %109
109: ; preds = %113, %107
%110 = load i32, i32* %60
%111 = call i32 @recv(i32 %110, i8* %33, i32 1024, i32 0)
%112 = icmp eq i32 %111, -1
br i1 %112, label %117, label %113
113: ; preds = %109
%114 = load i32, i32* @stdout
%115 = call i32 @fwrite(i8* %33, i32 1, i32 %111, i32 %114)
%116 = icmp eq i32 %111, 1024
br i1 %116, label %109, label %128
117: ; preds = %109
%118 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%119 = load i64, i64* @errno
%120 = load i64, i64* @ECONNRESET
%121 = icmp eq i64 %119, %120
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i32, i32* %60
%124 = call i32 @close(i32 %123)
br label %134
125: ; preds = %117
%126 = load i32, i32* @stderr
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 118)
br label %134
128: ; preds = %113
%129 = load i32, i32* %60
store i32 %129, i32* %23
%130 = load i32, i32* @EPOLLOUT
store i32 %130, i32* %25
%131 = load i32, i32* @EPOLL_CTL_MOD
%132 = call i32 @epoll_ctl(i32 %20, i32 %131, i32 %129, %struct.epoll_event* %3)
%133 = icmp eq i32 %132, -1
br i1 %133, label %137, label %134
134: ; preds = %125, %122, %128
%135 = load i32, i32* %60
%136 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %135)
br label %150
137: ; preds = %128
%138 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %153
139: ; preds = %103
%140 = load i32, i32* @EPOLLOUT
%141 = and i32 %140, %45
%142 = icmp eq i32 %141, 0
br i1 %142, label %147, label %143
143: ; preds = %139
%144 = call i32 @send(i32 %61, i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str, i64 0, i64 0), i32 %8, i32 0)
%145 = load i32, i32* %60
%146 = call i32 @close(i32 %145)
br label %150
147: ; preds = %139
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %61)
br label %150
150: ; preds = %134, %97, %147, %143, %98, %53
%151 = add nuw nsw i64 %43, 1
%152 = icmp eq i64 %151, %41
br i1 %152, label %39, label %42
153: ; preds = %98, %96, %137, %29, %22, %19, %15, %2
%154 = phi %struct.epoll_event* [ undef, %2 ], [ undef, %15 ], [ undef, %19 ], [ undef, %22 ], [ null, %29 ], [ %30, %137 ], [ %30, %96 ], [ %30, %98 ]
%155 = phi i32 [ undef, %2 ], [ undef, %15 ], [ -1, %19 ], [ %20, %22 ], [ %20, %29 ], [ %20, %137 ], [ %20, %96 ], [ %20, %98 ]
%156 = icmp sgt i32 %11, -1
br i1 %156, label %157, label %159
157: ; preds = %153
%158 = call i32 @close(i32 %11)
br label %159
159: ; preds = %157, %153
%160 = icmp sgt i32 %155, -1
br i1 %160, label %161, label %163
161: ; preds = %159
%162 = call i32 @close(i32 %155)
br label %163
163: ; preds = %161, %159
%164 = icmp eq %struct.epoll_event* %154, null
br i1 %164, label %167, label %165
165: ; preds = %163
%166 = call i32 @free(%struct.epoll_event* %154)
br label %167
167: ; preds = %163, %165
%168 = load i32, i32* @stderr
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
ret i32 1
}