#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 */
typedef int u_short;
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ event;
typedef int /*<<< orphan*/ cliaddr;

/* Variables and functions */
scalar_t__ EAGAIN;
int EPOLLERR;
int EPOLLET;
int EPOLLHUP;
int EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ EPOLL_CTL_DEL;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ accept_request(int);
struct epoll_event *calloc(int, int);
int /*<<< orphan*/ close(int);
int epoll_create1(int /*<<< orphan*/);
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
scalar_t__ errno;
int /*<<< orphan*/ make_socket_non_blocking(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int startup(int *);
int main(void) {
  int server_sock = -1;
  u_short port = 55555;
  int client_sock;
  struct sockaddr_in cliaddr;
  socklen_t cli_len;
  signal(SIGPIPE, SIG_IGN);
  server_sock = startup(&port);
  make_socket_non_blocking(server_sock);
  printf("httpd running on port %d\n", port);
  struct epoll_event event;
  struct epoll_event *events;
  int eventfd = epoll_create1(0);
  event.data.fd = server_sock;
  event.events = EPOLLIN | EPOLLET;
  epoll_ctl(eventfd, EPOLL_CTL_ADD, server_sock, &event);
  events = calloc(1024, sizeof(event));
  int n, i;
  while (1) {
    n = epoll_wait(eventfd, events, 1024, -1);
    for (i = 0; i < n; i++) {
      if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) ||
          (!events[i].events & EPOLLIN)) {
        perror("epoll error");
        close(events[i].data.fd);
        continue;
      } else if (server_sock == events[i].data.fd) {
        while (1) {
          cli_len = sizeof(cliaddr);
          client_sock =
              accept(server_sock, (struct sockaddr *)&cliaddr, &cli_len);
          if (client_sock == -1)
            if (errno == EAGAIN)
              break;
          make_socket_non_blocking(client_sock);
          event.data.fd = client_sock;
          event.events = EPOLLIN | EPOLLET;
          epoll_ctl(eventfd, EPOLL_CTL_ADD, client_sock, &event);
        }
        continue;
      } else {
        accept_request(events[i].data.fd);
        epoll_ctl(eventfd, EPOLL_CTL_DEL, events[i].data.fd, &events[i]);
      }
    }
  }
  close(server_sock);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xd903,-0xc(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
call   1090 <signal@plt>
lea    -0xc(%rbp),%rdi
call   10a0 <startup@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <make_socket_non_blocking@plt>
mov    -0xc(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10e0 <epoll_create1@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    0x2d71(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%edi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   1070 <epoll_ctl@plt>
mov    $0x400,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0x400,%edx
mov    $0xffffffff,%ecx
call   10b0 <epoll_wait@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1413 <main+0x253>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2d1b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    12f5 <main+0x135>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2cde(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    12f5 <main+0x135>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,8)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    0x2cf6(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1317 <main+0x157>
lea    0xd1e(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1060 <close@plt>
jmp    1405 <main+0x245>
mov    -0x8(%rbp),%eax
mov    -0x30(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
cmp    0x4(%rcx,%rdx,8),%eax
jne    13be <main+0x1fe>
jmp    1331 <main+0x171>
movl   $0x4,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1379 <main+0x1b9>
mov    0x2c54(%rip),%rax
mov    (%rax),%rax
mov    0x2c2a(%rip),%rcx
cmp    (%rcx),%rax
jne    1374 <main+0x1b4>
jmp    13b9 <main+0x1f9>
jmp    1379 <main+0x1b9>
mov    -0x10(%rbp),%edi
call   1040 <make_socket_non_blocking@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2c52(%rip),%rax
mov    (%rax),%eax
mov    0x2c11(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%edi
mov    0x2c32(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   1070 <epoll_ctl@plt>
jmp    1331 <main+0x171>
jmp    1405 <main+0x245>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1030 <accept_request@plt>
mov    -0x34(%rbp),%edi
mov    0x2c1f(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edx
mov    -0x30(%rbp),%rcx
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
call   1070 <epoll_ctl@plt>
jmp    1400 <main+0x240>
jmp    1405 <main+0x245>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1287 <main+0xc7>
jmp    1267 <main+0xa7>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movl   $0xd903,0xc(%rsp)
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
call   1090 <signal@plt>
lea    0xc(%rsp),%rdi
call   10a0 <startup@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <make_socket_non_blocking@plt>
mov    0xc(%rsp),%esi
lea    0xdf5(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10e0 <epoll_create1@plt>
mov    %eax,%ebp
mov    0x2dc0(%rip),%rcx
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    %ebx,0x14(%rsp)
mov    %eax,0x10(%rsp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%r14
mov    %ebp,%edi
mov    %ebx,%edx
mov    %r14,%rcx
call   1070 <epoll_ctl@plt>
mov    $0x400,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,%r15
lea    0x40(%rsp),%r12
lea    0x1c(%rsp),%r13
mov    %rax,0x20(%rsp)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x400,%edx
mov    $0xffffffff,%ecx
call   10b0 <epoll_wait@plt>
test   %eax,%eax
jle    1270 <main+0xb0>
mov    %eax,%eax
mov    %rax,0x38(%rsp)
xor    %edx,%edx
jmp    12c5 <main+0x105>
lea    0xd80(%rip),%rdi
call   10c0 <perror@plt>
mov    0x28(%rsp),%rax
mov    0x4(%r15,%rax,8),%edi
call   1060 <close@plt>
xchg   %ax,%ax
mov    0x28(%rsp),%rdx
add    $0x1,%rdx
cmp    0x38(%rsp),%rdx
mov    0x20(%rsp),%r15
je     1270 <main+0xb0>
mov    (%r15,%rdx,8),%eax
mov    0x2cf0(%rip),%rcx
test   %eax,(%rcx)
mov    %rdx,0x28(%rsp)
jne    1293 <main+0xd3>
mov    0x2cc0(%rip),%rcx
test   %eax,(%rcx)
jne    1293 <main+0xd3>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    0x2cee(%rip),%rax
test   %ecx,(%rax)
jne    1293 <main+0xd3>
mov    0x4(%r15,%rdx,8),%edi
cmp    %edi,%ebx
je     1379 <main+0x1b9>
lea    (%r15,%rdx,8),%rax
mov    %rax,0x30(%rsp)
mov    %rdx,%r15
call   1030 <accept_request@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
mov    0x20(%rsp),%rax
mov    0x4(%rax,%r15,8),%edx
mov    %ebp,%edi
mov    0x30(%rsp),%rcx
call   1070 <epoll_ctl@plt>
jmp    12b0 <main+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
call   1040 <make_socket_non_blocking@plt>
mov    %r15d,0x14(%rsp)
mov    0x2c54(%rip),%rax
mov    (%rax),%eax
mov    0x2c83(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x10(%rsp)
mov    0x2c6e(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r15d,%edx
mov    %r14,%rcx
call   1070 <epoll_ctl@plt>
movl   $0x4,0x1c(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   10d0 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1340 <main+0x180>
mov    0x2c13(%rip),%rax
mov    (%rax),%rax
mov    0x2be9(%rip),%rcx
cmp    (%rcx),%rax
jne    1340 <main+0x180>
jmp    12b0 <main+0xf0>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@.str = [26 x i8] c"httpd running on port %d\0A\00"
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@.str.1 = [12 x i8] c"epoll error\00"
@errno = global i64 0
@EAGAIN = global i64 0
@EPOLL_CTL_DEL = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca %struct.epoll_event
%5 = bitcast i32* %1 to i8*
store i32 55555, i32* %1
%6 = bitcast %struct.sockaddr_in* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = load i32, i32* @SIGPIPE
%9 = load i32, i32* @SIG_IGN
%10 = tail call i32 @signal(i32 %8, i32 %9)
%11 = call i32 @startup(i32* %1)
%12 = call i32 @make_socket_non_blocking(i32 %11)
%13 = load i32, i32* %1
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = bitcast %struct.epoll_event* %4 to i8*
%16 = call i32 @epoll_create1(i32 0)
%17 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 0
store i32 %11, i32* %17
%18 = load i32, i32* @EPOLLIN
%19 = load i32, i32* @EPOLLET
%20 = or i32 %19, %18
%21 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %20, i32* %21
%22 = load i32, i32* @EPOLL_CTL_ADD
%23 = call i32 @epoll_ctl(i32 %16, i32 %22, i32 %11, %struct.epoll_event* %4)
%24 = call %struct.epoll_event* @calloc(i32 1024, i32 8)
%25 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %26
26: ; preds = %29, %0
%27 = call i32 @epoll_wait(i32 %16, %struct.epoll_event* %24, i32 1024, i32 -1)
%28 = icmp sgt i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %78, %26
br label %26
30: ; preds = %26
%31 = zext i32 %27 to i64
br label %32
32: ; preds = %30, %78
%33 = phi i64 [ 0, %30 ], [ %79, %78 ]
%34 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %24, i64 %33
%35 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %34, i64 0, i32 0
%36 = load i32, i32* %35
%37 = load i32, i32* @EPOLLERR
%38 = and i32 %37, %36
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %32
%41 = load i32, i32* @EPOLLHUP
%42 = and i32 %41, %36
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = icmp eq i32 %36, 0
%46 = zext i1 %45 to i32
%47 = load i32, i32* @EPOLLIN
%48 = and i32 %47, %46
%49 = icmp eq i32 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %44, %40, %32
%51 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%52 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %24, i64 %33, i32 1, i32 0
%53 = load i32, i32* %52
%54 = call i32 @close(i32 %53)
br label %78
55: ; preds = %44
%56 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %24, i64 %33, i32 1, i32 0
%57 = load i32, i32* %56
%58 = icmp eq i32 %11, %57
br i1 %58, label %59, label %73
59: ; preds = %55, %66
store i32 4, i32* %3
%60 = call i32 @accept(i32 %11, %struct.sockaddr* %25, i32* %3)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i64, i64* @errno
%64 = load i64, i64* @EAGAIN
%65 = icmp eq i64 %63, %64
br i1 %65, label %78, label %66
66: ; preds = %62, %59
%67 = call i32 @make_socket_non_blocking(i32 %60)
store i32 %60, i32* %17
%68 = load i32, i32* @EPOLLIN
%69 = load i32, i32* @EPOLLET
%70 = or i32 %69, %68
store i32 %70, i32* %21
%71 = load i32, i32* @EPOLL_CTL_ADD
%72 = call i32 @epoll_ctl(i32 %16, i32 %71, i32 %60, %struct.epoll_event* %4)
br label %59
73: ; preds = %55
%74 = call i32 @accept_request(i32 %57)
%75 = load i32, i32* @EPOLL_CTL_DEL
%76 = load i32, i32* %56
%77 = call i32 @epoll_ctl(i32 %16, i32 %75, i32 %76, %struct.epoll_event* %34)
br label %78
78: ; preds = %62, %73, %50
%79 = add nuw nsw i64 %33, 1
%80 = icmp eq i64 %79, %31
br i1 %80, label %29, label %32
}