#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 socklen_t;

/* Variables and functions */
int EPOLLERR;
int EPOLLHUP;
int EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int EXIT_SUCCESS;
int NI_MAXHOST;
int NI_MAXSERV;
int /*<<< orphan*/ SOMAXCONN;
int /*<<< orphan*/ abort();
int accept(int, struct sockaddr *, int *);
struct epoll_event *calloc(int, int);
int /*<<< orphan*/ close(int);
int create_and_bind(char *);
int epoll_create(int);
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int epoll_wait(int, struct epoll_event *, int, int);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(struct epoll_event *);
int getpid();
int listen(int, int /*<<< orphan*/);
int make_socket_non_blocking(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  int sfd, s;
  int efd;
  struct epoll_event event;
  struct epoll_event *events;
  sfd = create_and_bind("1234");
  if (sfd == -1)
    abort();
  s = make_socket_non_blocking(sfd);
  if (s == -1)
    abort();
  s = listen(sfd, SOMAXCONN);
  if (s == -1) {
    perror("listen");
    abort();
  }
  efd = epoll_create(64);
  if (efd == -1) {
    perror("epoll_create");
    abort();
  }
  event.data.fd = sfd;
  event.events = EPOLLIN;
  s = epoll_ctl(efd, EPOLL_CTL_ADD, sfd, &event);
  if (s == -1) {
    perror("epoll_ctl");
    abort();
  }
  events = calloc(64, sizeof event);
  int k;
  for (k = 0; k < 10; k++) {
    int pid = fork();
    if (pid == 0) {
      while (1) {
        int n, i;
        n = epoll_wait(efd, events, 64, -1);
        printf("process %d return from epoll_wait!\n", getpid());
        for (i = 0; i < n; i++) {
          if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) ||
              (!(events[i].events & EPOLLIN))) {
            fprintf(stderr, "epoll error\n");
            close(events[i].data.fd);
            continue;
          } else if (sfd == events[i].data.fd) {
            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) {
              printf("process %d accept failed!\n", getpid());
              break;
            }
            printf("process %d accept successed!\n", getpid());
            close(infd);
          }
        }
      }
    }
  }
  int status;
  wait(&status);
  free(events);
  close(sfd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdd3(%rip),%rdi
call   10e0 <create_and_bind@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1246 <main+0x36>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x14(%rbp),%edi
call   1050 <make_socket_non_blocking@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1262 <main+0x52>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x14(%rbp),%edi
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
call   10c0 <listen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1293 <main+0x83>
lea    0xd7e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x40,%edi
call   1110 <epoll_create@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12bd <main+0xad>
lea    0xd5b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   1090 <epoll_ctl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1307 <main+0xf7>
lea    0xd1e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    $0x40,%edi
mov    $0x8,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    14f7 <main+0x2e7>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    14e4 <main+0x2d4>
jmp    1344 <main+0x134>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xcb6(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    14df <main+0x2cf>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2c21(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    13dc <main+0x1cc>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2bec(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    13dc <main+0x1cc>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2c17(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1407 <main+0x1f7>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xc5b(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%edi
call   1080 <close@plt>
jmp    14d1 <main+0x2c1>
mov    -0x14(%rbp),%eax
mov    -0x30(%rbp),%rcx
movslq -0x40(%rbp),%rdx
cmp    0x4(%rcx,%rdx,8),%eax
jne    14c7 <main+0x2b7>
mov    0x2b85(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rax,-0x60(%rbp)
mov    0x2ba1(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x68(%rbp)
movl   $0x4,-0x4c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    1482 <main+0x272>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xbe3(%rip),%rdi
call   1070 <printf@plt>
movl   $0x7,-0x6c(%rbp)
jmp    14a6 <main+0x296>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xbdd(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    -0x6c(%rbp),%eax
test   %eax,%eax
je     14c2 <main+0x2b2>
jmp    14bd <main+0x2ad>
jmp    14df <main+0x2cf>
jmp    14c7 <main+0x2b7>
jmp    14cc <main+0x2bc>
jmp    14d1 <main+0x2c1>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1379 <main+0x169>
jmp    1344 <main+0x134>
jmp    14e9 <main+0x2d9>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1321 <main+0x111>
lea    -0x70(%rbp),%rdi
call   1120 <wait@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    0x2a98(%rip),%rax
mov    (%rax),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xddb(%rip),%rdi
call   10e0 <create_and_bind@plt>
cmp    $0xffffffff,%eax
je     1482 <main+0x272>
mov    %eax,%r13d
mov    %eax,%edi
call   1050 <make_socket_non_blocking@plt>
cmp    $0xffffffff,%eax
je     1482 <main+0x272>
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
je     1489 <main+0x279>
mov    $0x40,%edi
call   1110 <epoll_create@plt>
cmp    $0xffffffff,%eax
je     1492 <main+0x282>
mov    %eax,%ebx
mov    %r13d,0x24(%rsp)
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rcx
mov    %ebx,%edi
mov    %r13d,%edx
call   1090 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     149b <main+0x28b>
mov    $0x40,%edi
mov    $0x8,%esi
call   10a0 <calloc@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1362 <main+0x152>
lea    0x8(%rsp),%rdi
call   1120 <wait@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r13d,%edi
call   1080 <close@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,0x10(%rsp)
mov    0x2c53(%rip),%r15
lea    0xcd3(%rip),%r12
mov    %r13d,0x4(%rsp)
jmp    13a0 <main+0x190>
lea    0xcd2(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
mov    0x18(%rsp),%rsp
mov    0x4(%rsp),%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%edi
mov    %rbp,%rsi
mov    $0x40,%edx
mov    $0xffffffff,%ecx
call   10d0 <epoll_wait@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xc5d(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
test   %ebx,%ebx
jle    13a0 <main+0x190>
mov    %ebx,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%eax
test   %eax,(%r15)
jne    13f5 <main+0x1e5>
mov    0x2bbf(%rip),%rcx
test   %eax,(%rcx)
je     141b <main+0x20b>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
call   10b0 <fprintf@plt>
mov    0x4(%rbp,%r14,8),%edi
call   1080 <close@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    13e0 <main+0x1d0>
jmp    13a0 <main+0x190>
mov    0x2bc6(%rip),%rcx
test   %eax,(%rcx)
je     13f5 <main+0x1e5>
cmp    0x4(%rbp,%r14,8),%r13d
jne    1410 <main+0x200>
mov    %rsp,0x18(%rsp)
movl   $0x4,0x14(%rsp)
mov    %r13d,%edi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1100 <accept@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1060 <getpid@plt>
cmp    $0xffffffff,%r13d
je     137b <main+0x16b>
lea    0xc08(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
mov    %r13d,%edi
call   1080 <close@plt>
mov    0x18(%rsp),%rsp
mov    0x4(%rsp),%r13d
jmp    1410 <main+0x200>
xor    %eax,%eax
call   1040 <abort@plt>
lea    0xb75(%rip),%rdi
jmp    14a2 <main+0x292>
lea    0xb73(%rip),%rdi
jmp    14a2 <main+0x292>
lea    0xb77(%rip),%rdi
call   10f0 <perror@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [5 x i8] c"1234\00"
@SOMAXCONN = global i32 0
@.str.1 = [7 x i8] c"listen\00"
@.str.2 = [13 x i8] c"epoll_create\00"
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [10 x i8] c"epoll_ctl\00"
@.str.4 = [36 x i8] c"process %d return from epoll_wait!\0A\00"
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@stderr = global i32 0
@.str.5 = [13 x i8] c"epoll error\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@.str.6 = [27 x i8] c"process %d accept failed!\0A\00"
@.str.7 = [30 x i8] c"process %d accept successed!\0A\00"
@EXIT_SUCCESS = global i32 0
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 i32
%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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = call i32 @create_and_bind(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %2
%29 = load i32, i32* %6
%30 = call i32 @make_socket_non_blocking(i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 (...) @abort()
unreachable
35: ; preds = %28
%36 = load i32, i32* %6
%37 = load i32, i32* @SOMAXCONN
%38 = call i32 @listen(i32 %36, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %35
%45 = call i32 @epoll_create(i32 64)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 (...) @abort()
unreachable
51: ; preds = %44
%52 = load i32, i32* %6
%53 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 0
store i32 %52, i32* %54
%55 = load i32, i32* @EPOLLIN
%56 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 0
store i32 %55, 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* %9)
store i32 %60, i32* %7
%61 = load i32, i32* %7
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %66
63: ; preds = %51
%64 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 (...) @abort()
unreachable
66: ; preds = %51
%67 = call %struct.epoll_event* @calloc(i32 64, i32 8)
store %struct.epoll_event* %67, %struct.epoll_event** %10
store i32 0, i32* %11
br label %68
68: ; preds = %168, %66
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 10
br i1 %70, label %71, label %171
71: ; preds = %68
%72 = call i32 (...) @fork()
store i32 %72, i32* %12
%73 = load i32, i32* %12
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %167
75: ; preds = %71
br label %76
76: ; preds = %75, %166
%77 = load i32, i32* %8
%78 = load %struct.epoll_event*, %struct.epoll_event** %10
%79 = call i32 @epoll_wait(i32 %77, %struct.epoll_event* %78, i32 64, i32 -1)
store i32 %79, i32* %13
%80 = call i32 (...) @getpid()
%81 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %80)
store i32 0, i32* %14
br label %82
82: ; preds = %163, %76
%83 = load i32, i32* %14
%84 = load i32, i32* %13
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %166
86: ; preds = %82
%87 = load %struct.epoll_event*, %struct.epoll_event** %10
%88 = load i32, i32* %14
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %87, i64 %89
%91 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %90, i32 0, i32 0
%92 = load i32, i32* %91
%93 = load i32, i32* @EPOLLERR
%94 = and i32 %92, %93
%95 = icmp ne i32 %94, 0
br i1 %95, label %116, label %96
96: ; preds = %86
%97 = load %struct.epoll_event*, %struct.epoll_event** %10
%98 = load i32, i32* %14
%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 0
%102 = load i32, i32* %101
%103 = load i32, i32* @EPOLLHUP
%104 = and i32 %102, %103
%105 = icmp ne i32 %104, 0
br i1 %105, label %116, label %106
106: ; preds = %96
%107 = load %struct.epoll_event*, %struct.epoll_event** %10
%108 = load i32, i32* %14
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %107, i64 %109
%111 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = load i32, i32* @EPOLLIN
%114 = and i32 %112, %113
%115 = icmp ne i32 %114, 0
br i1 %115, label %127, label %116
116: ; preds = %106, %96, %86
%117 = load i32, i32* @stderr
%118 = call i32 @fprintf(i32 %117, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%119 = load %struct.epoll_event*, %struct.epoll_event** %10
%120 = load i32, i32* %14
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %119, i64 %121
%123 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %122, i32 0, i32 1
%124 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %123, i32 0, i32 0
%125 = load i32, i32* %124
%126 = call i32 @close(i32 %125)
br label %163
127: ; preds = %106
%128 = load i32, i32* %6
%129 = load %struct.epoll_event*, %struct.epoll_event** %10
%130 = load i32, i32* %14
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %129, i64 %131
%133 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %132, i32 0, i32 1
%134 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %133, i32 0, i32 0
%135 = load i32, i32* %134
%136 = icmp eq i32 %128, %135
br i1 %136, label %137, label %161
137: ; preds = %127
%138 = load i32, i32* @NI_MAXHOST
%139 = zext i32 %138 to i64
%140 = call i8* @llvm.stacksave()
store i8* %140, i8** %18
%141 = alloca i8, i64 %139
store i64 %139, i64* %19
%142 = load i32, i32* @NI_MAXSERV
%143 = zext i32 %142 to i64
%144 = alloca i8, i64 %143
store i64 %143, i64* %20
store i32 4, i32* %16
%145 = load i32, i32* %6
%146 = call i32 @accept(i32 %145, %struct.sockaddr* %15, i32* %16)
store i32 %146, i32* %17
%147 = load i32, i32* %17
%148 = icmp eq i32 %147, -1
br i1 %148, label %149, label %152
149: ; preds = %137
%150 = call i32 (...) @getpid()
%151 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %150)
store i32 7, i32* %21
br label %157
152: ; preds = %137
%153 = call i32 (...) @getpid()
%154 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %153)
%155 = load i32, i32* %17
%156 = call i32 @close(i32 %155)
store i32 0, i32* %21
br label %157
157: ; preds = %152, %149
%158 = load i8*, i8** %18
%159 = load i32, i32* %21
switch i32 %159, label %178 [
i32 0, label %160
i32 7, label %166
]
160: ; preds = %157
br label %161
161: ; preds = %160, %127
br label %162
162: ; preds = %161
br label %163
163: ; preds = %162, %116
%164 = load i32, i32* %14
%165 = add nsw i32 %164, 1
store i32 %165, i32* %14
br label %82
166: ; preds = %157, %82
br label %76
167: ; preds = %71
br label %168
168: ; preds = %167
%169 = load i32, i32* %11
%170 = add nsw i32 %169, 1
store i32 %170, i32* %11
br label %68
171: ; preds = %68
%172 = call i32 @wait(i32* %22)
%173 = load %struct.epoll_event*, %struct.epoll_event** %10
%174 = call i32 @free(%struct.epoll_event* %173)
%175 = load i32, i32* %6
%176 = call i32 @close(i32 %175)
%177 = load i32, i32* @EXIT_SUCCESS
ret i32 %177
178: ; preds = %157
unreachable
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [5 x i8] c"1234\00"
@SOMAXCONN = global i32 0
@.str.1 = [7 x i8] c"listen\00"
@.str.2 = [13 x i8] c"epoll_create\00"
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.3 = [10 x i8] c"epoll_ctl\00"
@.str.4 = [36 x i8] c"process %d return from epoll_wait!\0A\00"
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@stderr = global i32 0
@.str.5 = [13 x i8] c"epoll error\0A\00"
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@.str.6 = [27 x i8] c"process %d accept failed!\0A\00"
@.str.7 = [30 x i8] c"process %d accept successed!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.epoll_event
%4 = alloca %struct.sockaddr
%5 = alloca i32
%6 = alloca i32
%7 = bitcast %struct.epoll_event* %3 to i8*
%8 = tail call i32 @create_and_bind(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %2
%13 = tail call i32 @make_socket_non_blocking(i32 %8)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %12
%18 = load i32, i32* @SOMAXCONN
%19 = tail call i32 @listen(i32 %8, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 (...) @abort()
unreachable
24: ; preds = %17
%25 = tail call i32 @epoll_create(i32 64)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 (...) @abort()
unreachable
30: ; preds = %24
%31 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1, i32 0
store i32 %8, i32* %31
%32 = load i32, i32* @EPOLLIN
%33 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0
store i32 %32, i32* %33
%34 = load i32, i32* @EPOLL_CTL_ADD
%35 = call i32 @epoll_ctl(i32 %25, i32 %34, i32 %8, %struct.epoll_event* %3)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 (...) @abort()
unreachable
40: ; preds = %30
%41 = call %struct.epoll_event* @calloc(i32 64, i32 8)
%42 = call i32 (...) @fork()
%43 = icmp eq i32 %42, 0
br i1 %43, label %77, label %44
44: ; preds = %40
%45 = call i32 (...) @fork()
%46 = icmp eq i32 %45, 0
br i1 %46, label %77, label %47
47: ; preds = %44
%48 = call i32 (...) @fork()
%49 = icmp eq i32 %48, 0
br i1 %49, label %77, label %50
50: ; preds = %47
%51 = call i32 (...) @fork()
%52 = icmp eq i32 %51, 0
br i1 %52, label %77, label %53
53: ; preds = %50
%54 = call i32 (...) @fork()
%55 = icmp eq i32 %54, 0
br i1 %55, label %77, label %56
56: ; preds = %53
%57 = call i32 (...) @fork()
%58 = icmp eq i32 %57, 0
br i1 %58, label %77, label %59
59: ; preds = %56
%60 = call i32 (...) @fork()
%61 = icmp eq i32 %60, 0
br i1 %61, label %77, label %62
62: ; preds = %59
%63 = call i32 (...) @fork()
%64 = icmp eq i32 %63, 0
br i1 %64, label %77, label %65
65: ; preds = %62
%66 = call i32 (...) @fork()
%67 = icmp eq i32 %66, 0
br i1 %67, label %77, label %68
68: ; preds = %65
%69 = call i32 (...) @fork()
%70 = icmp eq i32 %69, 0
br i1 %70, label %77, label %71
71: ; preds = %68
%72 = bitcast i32* %6 to i8*
%73 = call i32 @wait(i32* %6)
%74 = call i32 @free(%struct.epoll_event* %41)
%75 = call i32 @close(i32 %8)
%76 = load i32, i32* @EXIT_SUCCESS
ret i32 %76
77: ; preds = %68, %65, %62, %59, %56, %53, %50, %47, %44, %40
%78 = bitcast %struct.sockaddr* %4 to i8*
%79 = bitcast i32* %5 to i8*
br label %80
80: ; preds = %85, %77
%81 = call i32 @epoll_wait(i32 %25, %struct.epoll_event* %41, i32 64, i32 -1)
%82 = call i32 (...) @getpid()
%83 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %82)
%84 = icmp sgt i32 %81, 0
br i1 %84, label %86, label %85
85: ; preds = %123, %80, %121
br label %80
86: ; preds = %80
%87 = zext i32 %81 to i64
br label %88
88: ; preds = %86, %123
%89 = phi i64 [ 0, %86 ], [ %124, %123 ]
%90 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %41, i64 %89, i32 0
%91 = load i32, i32* %90
%92 = load i32, i32* @EPOLLERR
%93 = and i32 %92, %91
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %103
95: ; preds = %88
%96 = load i32, i32* @EPOLLHUP
%97 = and i32 %96, %91
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %95
%100 = load i32, i32* @EPOLLIN
%101 = and i32 %100, %91
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %109
103: ; preds = %99, %95, %88
%104 = load i32, i32* @stderr
%105 = call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%106 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %41, i64 %89, i32 1, i32 0
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
br label %123
109: ; preds = %99
%110 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %41, i64 %89, i32 1, i32 0
%111 = load i32, i32* %110
%112 = icmp eq i32 %8, %111
br i1 %112, label %113, label %123
113: ; preds = %109
%114 = call i8* @llvm.stacksave()
store i32 4, i32* %5
%115 = call i32 @accept(i32 %8, %struct.sockaddr* %4, i32* %5)
%116 = icmp eq i32 %115, -1
%117 = call i32 (...) @getpid()
br i1 %116, label %121, label %118
118: ; preds = %113
%119 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %117)
%120 = call i32 @close(i32 %115)
br label %123
121: ; preds = %113
%122 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %117)
br label %85
123: ; preds = %118, %109, %103
%124 = add nuw nsw i64 %89, 1
%125 = icmp eq i64 %124, %87
br i1 %125, label %85, label %88
}