#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
  int /*<<< orphan*/ member_0;
};
struct sockaddr {
  int dummy;
};
struct TYPE_4__ {
  int fd;
};
struct epoll_event {
  int events;
  TYPE_2__ data;
};
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ sa;
typedef scalar_t__ in_port_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ Debug_SysLog(char *);
int /*<<< orphan*/ Debug_UserLog(char *, int /*<<< orphan*/);
scalar_t__ EAGAIN;
int EPOLLET;
int EPOLLIN;
int EPOLLOUT;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SetNonBlock(int);
scalar_t__ atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int epoll_create(int);
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*/ exit(int);
int /*<<< orphan*/ getchar();
int getpid();
int /*<<< orphan*/ htons(scalar_t__);
int inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int strlen(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  int iRet = 1;
  if (4 != argc) {
    Debug_UserLog("Parameter: ServerIP Message ServerPort", 0);
    return 0;
  }
  in_port_t i16_port = atoi(argv[3]);
  if (0 >= i16_port) {
    Debug_UserLog("port number is wrong", 0);
    return 0;
  }
  int sk = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (-1 == sk) {
    Debug_SysLog("open socket failed!");
    return 0;
  }
  struct sockaddr_in sa = {0};
  sa.sin_family = AF_INET;
  sa.sin_port = htons(i16_port);
  struct sockaddr_in *psa = &sa;
  iRet = inet_pton(AF_INET, argv[1], &psa->sin_addr.s_addr);
  if (0 == iRet) {
    Debug_UserLog("inet_pton failed, invalid address!", 0);
    close(sk);
    return 0;
  } else if (iRet < 0) {
    Debug_SysLog("inet_pton failed");
    close(sk);
    return 0;
  }
  if (connect(sk, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
    Debug_SysLog("connect failed");
    close(sk);
    return 0;
  }
  SetNonBlock(sk);
  int efd;
  efd = epoll_create(10);
  if (efd == -1) {
    perror("epoll_create error!");
    exit(1);
  }
  struct epoll_event event;
  struct epoll_event events[10];
  event.events = EPOLLOUT | EPOLLIN | EPOLLET;
  event.data.fd = sk;
  epoll_ctl(efd, EPOLL_CTL_ADD, sk, &event);
  getchar();
  int loop = 0;
  while (1) {
    ssize_t numBytesRcvd = 0;
    char buffer[512] = {0};
    int n = 0;
    int i = 0;
    if (loop == 1) {
      break;
    }
    n = epoll_wait(efd, events, 10, -1);
    printf("%d\n", n);
    for (i = 0; i < n; i++) {
      if (events[i].events & EPOLLOUT) {
        printf("EPOLLOUT...............\n");
        snprintf(buffer, 512, "i am process %d, just say: %s\n", getpid(),
                 argv[2]);
        int n = strlen(buffer);
        int nsend = 0;
        while (n > 0) {
          nsend = write(events[i].data.fd, buffer + nsend, n);
          if (nsend < 0 && errno != EAGAIN) {
            Debug_SysLog("send failed");
            close(events[i].data.fd);
            return 0;
          }
          n -= nsend;
        }
      }
      if (events[i].events & EPOLLIN) {
        printf("EPOLLIN...............\n");
        memset(buffer, 0, 512);
        int len = strlen(buffer);
        int n = 0;
        int nrecv = 0;
        while (1) {
          nrecv = read(events[i].data.fd, buffer + n, 512 - 1);
          if (nrecv == -1 && errno != EAGAIN) {
            perror("read error!");
          }
          if ((nrecv == -1 && errno == EAGAIN) || nrecv == 0) {
            break;
          }
          n += nrecv;
        }
        loop = 1;
        printf("%s\n", buffer);
      }
    }
  }
  close(sk);
  close(efd);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     12a8 <main+0x48>
lea    0xd6b(%rip),%rdi
xor    %esi,%esi
call   1170 <Debug_UserLog@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1130 <atoi@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jl     12df <main+0x7f>
lea    0xd5b(%rip),%rdi
xor    %esi,%esi
call   1170 <Debug_UserLog@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
mov    0x2cd1(%rip),%rax
mov    (%rax),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
call   1180 <socket@plt>
mov    %eax,-0x24(%rbp)
mov    $0xffffffff,%eax
cmp    -0x24(%rbp),%eax
jne    1328 <main+0xc8>
lea    0xd25(%rip),%rdi
call   1050 <Debug_SysLog@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <memset@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <htons@plt>
mov    %eax,-0x34(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x40(%rbp),%rdx
call   1100 <inet_pton@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    13a2 <main+0x142>
lea    0xcc9(%rip),%rdi
xor    %esi,%esi
call   1170 <Debug_UserLog@plt>
mov    -0x24(%rbp),%edi
call   10b0 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
cmpl   $0x0,-0x14(%rbp)
jge    13cc <main+0x16c>
lea    0xcc0(%rip),%rdi
call   1050 <Debug_SysLog@plt>
mov    -0x24(%rbp),%edi
call   10b0 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
jmp    13d1 <main+0x171>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1160 <connect@plt>
cmp    $0x0,%rax
jge    140c <main+0x1ac>
lea    0xc91(%rip),%rdi
call   1050 <Debug_SysLog@plt>
mov    -0x24(%rbp),%edi
call   10b0 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
mov    -0x24(%rbp),%edi
call   10e0 <SetNonBlock@plt>
mov    $0xa,%edi
call   1140 <epoll_create@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1441 <main+0x1e1>
lea    0xc61(%rip),%rdi
call   1120 <perror@plt>
mov    $0x1,%edi
call   1150 <exit@plt>
mov    0x2b70(%rip),%rax
mov    (%rax),%eax
mov    0x2b8f(%rip),%rcx
or     (%rcx),%eax
mov    0x2b4e(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%edi
mov    0x2b69(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
lea    -0x50(%rbp),%rcx
call   10c0 <epoll_ctl@plt>
mov    $0x0,%al
call   10f0 <getchar@plt>
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
lea    -0x2b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10a0 <memset@plt>
movl   $0x0,-0x2b4(%rbp)
movl   $0x0,-0x2b8(%rbp)
cmpl   $0x1,-0xa4(%rbp)
jne    14d1 <main+0x271>
jmp    17a4 <main+0x544>
mov    -0x44(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1110 <epoll_wait@plt>
mov    %eax,-0x2b4(%rbp)
mov    -0x2b4(%rbp),%esi
lea    0xbaa(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x2b8(%rbp)
mov    -0x2b8(%rbp),%eax
cmp    -0x2b4(%rbp),%eax
jge    179f <main+0x53f>
movslq -0x2b8(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%eax
mov    0x2a83(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     164e <main+0x3ee>
lea    0xb64(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x2b0(%rbp),%rax
mov    %rax,-0x2d8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x2d8(%rbp),%rdi
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
mov    $0x200,%esi
lea    0xb44(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x2b0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2bc(%rbp)
movl   $0x0,-0x2c0(%rbp)
cmpl   $0x0,-0x2bc(%rbp)
jle    1649 <main+0x3e9>
movslq -0x2b8(%rbp),%rax
mov    -0x9c(%rbp,%rax,8),%edi
lea    -0x2b0(%rbp),%rsi
movslq -0x2c0(%rbp),%rax
add    %rax,%rsi
mov    -0x2bc(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x2c0(%rbp)
cmpl   $0x0,-0x2c0(%rbp)
jge    1630 <main+0x3d0>
mov    0x29be(%rip),%rax
mov    (%rax),%rax
mov    0x299c(%rip),%rcx
cmp    (%rcx),%rax
je     1630 <main+0x3d0>
lea    0xad7(%rip),%rdi
call   1050 <Debug_SysLog@plt>
movslq -0x2b8(%rbp),%rax
mov    -0x9c(%rbp,%rax,8),%edi
call   10b0 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    17bb <main+0x55b>
mov    -0x2c0(%rbp),%ecx
mov    -0x2bc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2bc(%rbp)
jmp    15a1 <main+0x341>
jmp    164e <main+0x3ee>
movslq -0x2b8(%rbp),%rax
mov    -0xa0(%rbp,%rax,8),%eax
mov    0x297d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1786 <main+0x526>
lea    0xa7a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x2b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10a0 <memset@plt>
lea    -0x2b0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2c4(%rbp)
movl   $0x0,-0x2c8(%rbp)
movl   $0x0,-0x2cc(%rbp)
movslq -0x2b8(%rbp),%rax
mov    -0x9c(%rbp,%rax,8),%edi
lea    -0x2b0(%rbp),%rsi
movslq -0x2c8(%rbp),%rax
add    %rax,%rsi
mov    $0x1ff,%edx
call   10d0 <read@plt>
mov    %eax,-0x2cc(%rbp)
cmpl   $0xffffffff,-0x2cc(%rbp)
jne    1717 <main+0x4b7>
mov    0x28b8(%rip),%rax
mov    (%rax),%rax
mov    0x2896(%rip),%rcx
cmp    (%rcx),%rax
je     1717 <main+0x4b7>
lea    0x9f5(%rip),%rdi
call   1120 <perror@plt>
cmpl   $0xffffffff,-0x2cc(%rbp)
jne    173e <main+0x4de>
mov    0x2885(%rip),%rax
mov    (%rax),%rax
mov    0x2863(%rip),%rcx
cmp    (%rcx),%rax
je     174b <main+0x4eb>
cmpl   $0x0,-0x2cc(%rbp)
jne    1750 <main+0x4f0>
jmp    1767 <main+0x507>
mov    -0x2cc(%rbp),%eax
add    -0x2c8(%rbp),%eax
mov    %eax,-0x2c8(%rbp)
jmp    16b5 <main+0x455>
movl   $0x1,-0xa4(%rbp)
lea    -0x2b0(%rbp),%rsi
lea    0x960(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    178b <main+0x52b>
mov    -0x2b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2b8(%rbp)
jmp    150e <main+0x2ae>
jmp    148e <main+0x22e>
mov    -0x24(%rbp),%edi
call   10b0 <close@plt>
mov    -0x44(%rbp),%edi
call   10b0 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x298,%rsp
cmp    $0x4,%edi
jne    15cb <main+0x35b>
mov    %rsi,%rbx
mov    0x18(%rsi),%rdi
call   1140 <atoi@plt>
test   %rax,%rax
jle    15d4 <main+0x364>
mov    %rax,%rbp
mov    0x2d3f(%rip),%r14
mov    (%r14),%edi
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
mov    0x2d14(%rip),%rax
mov    (%rax),%edx
call   1190 <socket@plt>
cmp    $0xffffffff,%eax
je     15e6 <main+0x376>
mov    %eax,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
mov    (%r14),%eax
mov    %eax,0x28(%rsp)
mov    %rbp,%rdi
call   1080 <htons@plt>
mov    %eax,0x24(%rsp)
mov    (%r14),%edi
mov    0x8(%rbx),%rsi
lea    0x20(%rsp),%rdx
call   1110 <inet_pton@plt>
test   %eax,%eax
je     15f4 <main+0x384>
js     1623 <main+0x3b3>
lea    0x20(%rsp),%rsi
mov    %r15d,%edi
mov    $0x10,%edx
call   1170 <connect@plt>
test   %rax,%rax
js     162c <main+0x3bc>
mov    %rbx,0x30(%rsp)
mov    %r15d,%edi
call   10f0 <SetNonBlock@plt>
mov    $0xa,%edi
call   1150 <epoll_create@plt>
cmp    $0xffffffff,%eax
je     1656 <main+0x3e6>
mov    %eax,%ebp
mov    0x2c6b(%rip),%rcx
mov    0x2c8c(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2c49(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x18(%rsp)
mov    %r15d,0x1c(%rsp)
mov    0x2c67(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rcx
mov    %ebp,%edi
mov    %r15d,0x10(%rsp)
mov    %r15d,%edx
call   10d0 <epoll_ctl@plt>
xor    %eax,%eax
call   1100 <getchar@plt>
lea    0x90(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   10b0 <memset@plt>
lea    0x40(%rsp),%rsi
lea    0xcf9(%rip),%rbx
mov    0x2bfb(%rip),%r13
mov    0x2bdc(%rip),%r15
mov    %ebp,0x14(%rsp)
mov    %ebp,%edi
mov    $0xa,%edx
mov    $0xffffffff,%ecx
call   1120 <epoll_wait@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
movl   $0x0,0xc(%rsp)
test   %ebp,%ebp
jle    1585 <main+0x315>
mov    %ebp,%eax
mov    %rax,0x38(%rsp)
xor    %r14d,%r14d
movl   $0x0,0xc(%rsp)
jmp    1434 <main+0x1c4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x90(%rsp),%rdi
call   1030 <puts@plt>
movl   $0x1,0xc(%rsp)
add    $0x1,%r14
cmp    0x38(%rsp),%r14
je     1585 <main+0x315>
mov    0x2b7d(%rip),%rax
mov    (%rax),%eax
test   %eax,0x40(%rsp,%r14,8)
je     14e0 <main+0x270>
lea    0xcaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
mov    0x30(%rsp),%rcx
mov    0x10(%rcx),%r8
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
lea    0xc30(%rip),%rdx
mov    %eax,%ecx
call   10a0 <snprintf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    14e0 <main+0x270>
mov    %eax,%r12d
xor    %eax,%eax
jmp    14a5 <main+0x235>
cs nopw 0x0(%rax,%rax,1)
nop
sub    %eax,%r12d
jle    14e0 <main+0x270>
mov    0x44(%rsp,%r14,8),%edi
cltq
lea    (%rsp,%rax,1),%rsi
add    $0x90,%rsi
mov    %r12d,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    14a0 <main+0x230>
mov    0x0(%r13),%rcx
cmp    (%r15),%rcx
je     14a0 <main+0x230>
jmp    160e <main+0x39e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2af9(%rip),%rax
mov    (%rax),%eax
test   %eax,0x40(%rsp,%r14,8)
je     1425 <main+0x1b5>
lea    0xbe7(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10b0 <memset@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
jmp    153a <main+0x2ca>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebp,%ebp
je     1410 <main+0x1a0>
add    %ebp,%ebx
mov    0x44(%rsp,%r14,8),%edi
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x90,%rsi
mov    $0x1ff,%edx
call   10e0 <read@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1530 <main+0x2c0>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
je     1410 <main+0x1a0>
lea    0xb64(%rip),%rdi
call   1130 <perror@plt>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
jne    1538 <main+0x2c8>
jmp    1410 <main+0x1a0>
mov    $0x200,%edx
lea    0x90(%rsp),%rdi
xor    %esi,%esi
call   10b0 <memset@plt>
cmpl   $0x1,0xc(%rsp)
mov    0x14(%rsp),%ebp
lea    0x40(%rsp),%rsi
lea    0xaf9(%rip),%rbx
jne    13c0 <main+0x150>
mov    0x10(%rsp),%edi
call   10c0 <close@plt>
mov    %ebp,%edi
call   10c0 <close@plt>
mov    $0x1,%ebx
jmp    1642 <main+0x3d2>
lea    0xa2e(%rip),%rdi
jmp    15db <main+0x36b>
lea    0xa4c(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1180 <Debug_UserLog@plt>
jmp    1642 <main+0x3d2>
lea    0xa4f(%rip),%rdi
call   1060 <Debug_SysLog@plt>
jmp    1640 <main+0x3d0>
lea    0xa55(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1180 <Debug_UserLog@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
jmp    1642 <main+0x3d2>
mov    %r14d,%ebx
lea    0xab2(%rip),%rdi
call   1060 <Debug_SysLog@plt>
mov    0x44(%rsp,%rbx,8),%edi
jmp    163b <main+0x3cb>
lea    0xa49(%rip),%rdi
jmp    1633 <main+0x3c3>
lea    0xa51(%rip),%rdi
call   1060 <Debug_SysLog@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x298,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa36(%rip),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_3__, i32, i32, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [39 x i8] c"Parameter: ServerIP Message ServerPort\00"
@.str.1 = [21 x i8] c"port number is wrong\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.2 = [20 x i8] c"open socket failed!\00"
@.str.3 = [35 x i8] c"inet_pton failed, invalid address!\00"
@.str.4 = [17 x i8] c"inet_pton failed\00"
@.str.5 = [15 x i8] c"connect failed\00"
@.str.6 = [20 x i8] c"epoll_create error!\00"
@EPOLLOUT = global i32 0
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.8 = [25 x i8] c"EPOLLOUT...............\0A\00"
@.str.9 = [31 x i8] c"i am process %d, just say: %s\0A\00"
@errno = global i64 0
@EAGAIN = global i64 0
@.str.10 = [12 x i8] c"send failed\00"
@.str.11 = [24 x i8] c"EPOLLIN...............\0A\00"
@.str.12 = [12 x i8] c"read error!\00"
@.str.13 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in*
%11 = alloca i32
%12 = alloca %struct.epoll_event
%13 = alloca [10 x %struct.epoll_event]
%14 = alloca i32
%15 = alloca i32
%16 = alloca [512 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%24 = load i32, i32* %4
%25 = icmp ne i32 4, %24
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = call i32 @Debug_UserLog(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 0, i32* %3
br label %241
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i64 @atoi(i8* %31)
store i64 %32, i64* %7
%33 = load i64, i64* %7
%34 = icmp sge i64 0, %33
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = call i32 @Debug_UserLog(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 0, i32* %3
br label %241
37: ; preds = %28
%38 = load i32, i32* @AF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = load i32, i32* @IPPROTO_TCP
%41 = call i32 @socket(i32 %38, i32 %39, i32 %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp eq i32 -1, %42
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %241
46: ; preds = %37
%47 = bitcast %struct.sockaddr_in* %9 to i8*
%48 = load i32, i32* @AF_INET
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %48, i32* %49
%50 = load i64, i64* %7
%51 = call i32 @htons(i64 %50)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %51, i32* %52
store %struct.sockaddr_in* %9, %struct.sockaddr_in** %10
%53 = load i32, i32* @AF_INET
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %57, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 0
%60 = call i32 @inet_pton(i32 %53, i8* %56, i32* %59)
store i32 %60, i32* %6
%61 = load i32, i32* %6
%62 = icmp eq i32 0, %61
br i1 %62, label %63, label %67
63: ; preds = %46
%64 = call i32 @Debug_UserLog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 0)
%65 = load i32, i32* %8
%66 = call i32 @close(i32 %65)
store i32 0, i32* %3
br label %241
67: ; preds = %46
%68 = load i32, i32* %6
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%72 = load i32, i32* %8
%73 = call i32 @close(i32 %72)
store i32 0, i32* %3
br label %241
74: ; preds = %67
br label %75
75: ; preds = %74
%76 = load i32, i32* %8
%77 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%78 = call i64 @connect(i32 %76, %struct.sockaddr* %77, i32 16)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %75
%81 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%82 = load i32, i32* %8
%83 = call i32 @close(i32 %82)
store i32 0, i32* %3
br label %241
84: ; preds = %75
%85 = load i32, i32* %8
%86 = call i32 @SetNonBlock(i32 %85)
%87 = call i32 @epoll_create(i32 10)
store i32 %87, i32* %11
%88 = load i32, i32* %11
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %93
90: ; preds = %84
%91 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %84
%94 = load i32, i32* @EPOLLOUT
%95 = load i32, i32* @EPOLLIN
%96 = or i32 %94, %95
%97 = load i32, i32* @EPOLLET
%98 = or i32 %96, %97
%99 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %12, i32 0, i32 0
store i32 %98, i32* %99
%100 = load i32, i32* %8
%101 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %12, i32 0, i32 1
%102 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %101, i32 0, i32 0
store i32 %100, i32* %102
%103 = load i32, i32* %11
%104 = load i32, i32* @EPOLL_CTL_ADD
%105 = load i32, i32* %8
%106 = call i32 @epoll_ctl(i32 %103, i32 %104, i32 %105, %struct.epoll_event* %12)
%107 = call i32 (...) @getchar()
store i32 0, i32* %14
br label %108
108: ; preds = %93, %235
store i32 0, i32* %15
%109 = bitcast [512 x i8]* %16 to i8*
store i32 0, i32* %17
store i32 0, i32* %18
%110 = load i32, i32* %14
%111 = icmp eq i32 %110, 1
br i1 %111, label %112, label %113
112: ; preds = %108
br label %236
113: ; preds = %108
%114 = load i32, i32* %11
%115 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 0
%116 = call i32 @epoll_wait(i32 %114, %struct.epoll_event* %115, i32 10, i32 -1)
store i32 %116, i32* %17
%117 = load i32, i32* %17
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %117)
store i32 0, i32* %18
br label %119
119: ; preds = %232, %113
%120 = load i32, i32* %18
%121 = load i32, i32* %17
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %235
123: ; preds = %119
%124 = load i32, i32* %18
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 %125
%127 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %126, i32 0, i32 0
%128 = load i32, i32* %127
%129 = load i32, i32* @EPOLLOUT
%130 = and i32 %128, %129
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %178
132: ; preds = %123
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%134 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%135 = call i32 (...) @getpid()
%136 = load i8**, i8*** %5
%137 = getelementptr inbounds i8*, i8** %136, i64 2
%138 = load i8*, i8** %137
%139 = call i32 @snprintf(i8* %134, i32 512, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %135, i8* %138)
%140 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%141 = call i32 @strlen(i8* %140)
store i32 %141, i32* %19
store i32 0, i32* %20
br label %142
142: ; preds = %173, %132
%143 = load i32, i32* %19
%144 = icmp sgt i32 %143, 0
br i1 %144, label %145, label %177
145: ; preds = %142
%146 = load i32, i32* %18
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 %147
%149 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %148, i32 0, i32 1
%150 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %149, i32 0, i32 0
%151 = load i32, i32* %150
%152 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%153 = load i32, i32* %20
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i8, i8* %152, i64 %154
%156 = load i32, i32* %19
%157 = call i32 @write(i32 %151, i8* %155, i32 %156)
store i32 %157, i32* %20
%158 = load i32, i32* %20
%159 = icmp slt i32 %158, 0
br i1 %159, label %160, label %173
160: ; preds = %145
%161 = load i64, i64* @errno
%162 = load i64, i64* @EAGAIN
%163 = icmp ne i64 %161, %162
br i1 %163, label %164, label %173
164: ; preds = %160
%165 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%166 = load i32, i32* %18
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 %167
%169 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %168, i32 0, i32 1
%170 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %169, i32 0, i32 0
%171 = load i32, i32* %170
%172 = call i32 @close(i32 %171)
store i32 0, i32* %3
br label %241
173: ; preds = %160, %145
%174 = load i32, i32* %20
%175 = load i32, i32* %19
%176 = sub nsw i32 %175, %174
store i32 %176, i32* %19
br label %142
177: ; preds = %142
br label %178
178: ; preds = %177, %123
%179 = load i32, i32* %18
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 %180
%182 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %181, i32 0, i32 0
%183 = load i32, i32* %182
%184 = load i32, i32* @EPOLLIN
%185 = and i32 %183, %184
%186 = icmp ne i32 %185, 0
br i1 %186, label %187, label %231
187: ; preds = %178
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%189 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%190 = call i32 @memset(i8* %189, i32 0, i32 512)
%191 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%192 = call i32 @strlen(i8* %191)
store i32 %192, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
br label %193
193: ; preds = %187, %224
%194 = load i32, i32* %18
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %13, i64 0, i64 %195
%197 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %196, i32 0, i32 1
%198 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %197, i32 0, i32 0
%199 = load i32, i32* %198
%200 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%201 = load i32, i32* %22
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds i8, i8* %200, i64 %202
%204 = call i32 @read(i32 %199, i8* %203, i32 511)
store i32 %204, i32* %23
%205 = load i32, i32* %23
%206 = icmp eq i32 %205, -1
br i1 %206, label %207, label %213
207: ; preds = %193
%208 = load i64, i64* @errno
%209 = load i64, i64* @EAGAIN
%210 = icmp ne i64 %208, %209
br i1 %210, label %211, label %213
211: ; preds = %207
%212 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %213
213: ; preds = %211, %207, %193
%214 = load i32, i32* %23
%215 = icmp eq i32 %214, -1
br i1 %215, label %216, label %220
216: ; preds = %213
%217 = load i64, i64* @errno
%218 = load i64, i64* @EAGAIN
%219 = icmp eq i64 %217, %218
br i1 %219, label %223, label %220
220: ; preds = %216, %213
%221 = load i32, i32* %23
%222 = icmp eq i32 %221, 0
br i1 %222, label %223, label %224
223: ; preds = %220, %216
br label %228
224: ; preds = %220
%225 = load i32, i32* %23
%226 = load i32, i32* %22
%227 = add nsw i32 %226, %225
store i32 %227, i32* %22
br label %193
228: ; preds = %223
store i32 1, i32* %14
%229 = getelementptr inbounds [512 x i8], [512 x i8]* %16, i64 0, i64 0
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %229)
br label %231
231: ; preds = %228, %178
br label %232
232: ; preds = %231
%233 = load i32, i32* %18
%234 = add nsw i32 %233, 1
store i32 %234, i32* %18
br label %119
235: ; preds = %119
br label %108
236: ; preds = %112
%237 = load i32, i32* %8
%238 = call i32 @close(i32 %237)
%239 = load i32, i32* %11
%240 = call i32 @close(i32 %239)
store i32 1, i32* %3
br label %241
241: ; preds = %236, %164, %80, %70, %63, %44, %35, %26
%242 = load i32, i32* %3
ret i32 %242
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_3__, i32, i32, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.epoll_event = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [39 x i8] c"Parameter: ServerIP Message ServerPort\00"
@.str.1 = [21 x i8] c"port number is wrong\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.2 = [20 x i8] c"open socket failed!\00"
@.str.3 = [35 x i8] c"inet_pton failed, invalid address!\00"
@.str.4 = [17 x i8] c"inet_pton failed\00"
@.str.5 = [15 x i8] c"connect failed\00"
@.str.6 = [20 x i8] c"epoll_create error!\00"
@EPOLLOUT = global i32 0
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str.7 = [4 x i8] c"%d\0A\00"
@.str.9 = [31 x i8] c"i am process %d, just say: %s\0A\00"
@errno = global i64 0
@EAGAIN = global i64 0
@.str.10 = [12 x i8] c"send failed\00"
@.str.12 = [12 x i8] c"read error!\00"
@str = [23 x i8] c"EPOLLIN...............\00"
@str.14 = [24 x i8] c"EPOLLOUT...............\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.epoll_event
%5 = alloca [10 x %struct.epoll_event]
%6 = alloca [512 x i8]
%7 = icmp eq i32 %0, 4
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @Debug_UserLog(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 0)
br label %162
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i64 @atoi(i8* %12)
%14 = icmp slt i64 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @Debug_UserLog(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %162
17: ; preds = %10
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = load i32, i32* @IPPROTO_TCP
%21 = tail call i32 @socket(i32 %18, i32 %19, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @Debug_SysLog(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %162
25: ; preds = %17
%26 = bitcast %struct.sockaddr_in* %3 to i8*
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %27, i32* %28
%29 = tail call i32 @htons(i64 %13)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %29, i32* %30
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
%35 = call i32 @inet_pton(i32 %31, i8* %33, i32* %34)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %25
%38 = call i32 @Debug_UserLog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 0)
%39 = call i32 @close(i32 %21)
br label %160
40: ; preds = %25
%41 = icmp slt i32 %35, 0
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @close(i32 %21)
br label %160
45: ; preds = %40
%46 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%47 = call i64 @connect(i32 %21, %struct.sockaddr* %46, i32 16)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%51 = call i32 @close(i32 %21)
br label %160
52: ; preds = %45
%53 = call i32 @SetNonBlock(i32 %21)
%54 = call i32 @epoll_create(i32 10)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %52
%60 = bitcast %struct.epoll_event* %4 to i8*
%61 = bitcast [10 x %struct.epoll_event]* %5 to i8*
%62 = load i32, i32* @EPOLLOUT
%63 = load i32, i32* @EPOLLIN
%64 = or i32 %63, %62
%65 = load i32, i32* @EPOLLET
%66 = or i32 %64, %65
%67 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 0
store i32 %21, i32* %68
%69 = load i32, i32* @EPOLL_CTL_ADD
%70 = call i32 @epoll_ctl(i32 %54, i32 %69, i32 %21, %struct.epoll_event* %4)
%71 = call i32 (...) @getchar()
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%73 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 0
%74 = getelementptr inbounds i8*, i8** %1, i64 2
br label %75
75: ; preds = %59, %152
%76 = call i32 @epoll_wait(i32 %54, %struct.epoll_event* %73, i32 10, i32 -1)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %76)
%78 = icmp sgt i32 %76, 0
br i1 %78, label %79, label %152
79: ; preds = %75
%80 = zext i32 %76 to i64
br label %81
81: ; preds = %79, %148
%82 = phi i64 [ 0, %79 ], [ %150, %148 ]
%83 = phi i32 [ 0, %79 ], [ %149, %148 ]
%84 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %82, i32 0
%85 = load i32, i32* %84
%86 = load i32, i32* @EPOLLOUT
%87 = and i32 %86, %85
%88 = icmp eq i32 %87, 0
br i1 %88, label %119, label %89
89: ; preds = %81
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
%91 = call i32 (...) @getpid()
%92 = load i8*, i8** %74
%93 = call i32 @snprintf(i8* %72, i32 512, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %91, i8* %92)
%94 = call i32 @strlen(i8* %72)
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %119
96: ; preds = %89
%97 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %82, i32 1, i32 0
br label %98
98: ; preds = %96, %116
%99 = phi i32 [ 0, %96 ], [ %104, %116 ]
%100 = phi i32 [ %94, %96 ], [ %117, %116 ]
%101 = load i32, i32* %97
%102 = sext i32 %99 to i64
%103 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %102
%104 = call i32 @write(i32 %101, i8* %103, i32 %100)
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %116
106: ; preds = %98
%107 = load i64, i64* @errno
%108 = load i64, i64* @EAGAIN
%109 = icmp eq i64 %107, %108
br i1 %109, label %116, label %110
110: ; preds = %106
%111 = and i64 %82, 4294967295
%112 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %111, i32 1, i32 0
%113 = call i32 @Debug_SysLog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%114 = load i32, i32* %112
%115 = call i32 @close(i32 %114)
br label %158
116: ; preds = %106, %98
%117 = sub nsw i32 %100, %104
%118 = icmp sgt i32 %117, 0
br i1 %118, label %98, label %119
119: ; preds = %116, %89, %81
%120 = load i32, i32* %84
%121 = load i32, i32* @EPOLLIN
%122 = and i32 %121, %120
%123 = icmp eq i32 %122, 0
br i1 %123, label %148, label %124
124: ; preds = %119
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%126 = call i32 @memset(i8* %72, i32 0, i32 512)
%127 = call i32 @strlen(i8* %72)
%128 = getelementptr inbounds [10 x %struct.epoll_event], [10 x %struct.epoll_event]* %5, i64 0, i64 %82, i32 1, i32 0
br label %129
129: ; preds = %144, %124
%130 = phi i32 [ 0, %124 ], [ %145, %144 ]
%131 = load i32, i32* %128
%132 = sext i32 %130 to i64
%133 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %132
%134 = call i32 @read(i32 %131, i8* %133, i32 511)
switch i32 %134, label %144 [
i32 -1, label %135
i32 0, label %146
]
135: ; preds = %129
%136 = load i64, i64* @errno
%137 = load i64, i64* @EAGAIN
%138 = icmp eq i64 %136, %137
br i1 %138, label %146, label %139
139: ; preds = %135
%140 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%141 = load i64, i64* @errno
%142 = load i64, i64* @EAGAIN
%143 = icmp eq i64 %141, %142
br i1 %143, label %146, label %144
144: ; preds = %129, %139
%145 = add nsw i32 %134, %130
br label %129
146: ; preds = %135, %129, %139
%147 = call i32 @puts(i8* %72)
br label %148
148: ; preds = %119, %146
%149 = phi i32 [ 1, %146 ], [ %83, %119 ]
%150 = add nuw nsw i64 %82, 1
%151 = icmp eq i64 %150, %80
br i1 %151, label %152, label %81
152: ; preds = %148, %75
%153 = phi i32 [ 0, %75 ], [ %149, %148 ]
%154 = icmp eq i32 %153, 1
br i1 %154, label %155, label %75
155: ; preds = %152
%156 = call i32 @close(i32 %21)
%157 = call i32 @close(i32 %54)
br label %158
158: ; preds = %110, %155
%159 = phi i32 [ 1, %155 ], [ 0, %110 ]
br label %160
160: ; preds = %158, %49, %42, %37
%161 = phi i32 [ 0, %37 ], [ 0, %42 ], [ 0, %49 ], [ %159, %158 ]
br label %162
162: ; preds = %15, %160, %23, %8
%163 = phi i32 [ 0, %8 ], [ 0, %15 ], [ 0, %23 ], [ %161, %160 ]
ret i32 %163
}