#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 TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct pollfd {
  int fd;
  int events;
  int revents;
};
typedef scalar_t__ ssize_t;
typedef int socklen_t;
typedef int /*<<< orphan*/ servAddr;
typedef int /*<<< orphan*/ optval;
typedef int /*<<< orphan*/ cliAddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int POLLERR;
int POLLRDNORM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int SERV_PORT = 6666;
  if (argc > 2)
    printf("param err:\nUsage:\n\t%s port | %s\n\n", argv[0], argv[0]);
  if (argc == 2)
    SERV_PORT = atoi(argv[1]);
  int i, maxi, nready;
  int servSocket, cliSocket;
  ssize_t nbytes;
  char buf[200];
  socklen_t addrLen;
  struct pollfd client[1024];
  struct sockaddr_in cliAddr, servAddr;
  if ((servSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    exit(1);
  }
  int optval = 1;
  if (setsockopt(servSocket, SOL_SOCKET, SO_REUSEADDR, &optval,
                 sizeof(optval)) < 0) {
    perror("setsockopt");
    exit(0);
  }
  bzero(&servAddr, sizeof(servAddr));
  servAddr.sin_family = AF_INET;
  servAddr.sin_port = htons(SERV_PORT);
  servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(servSocket, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
    perror("bind");
    exit(1);
  }
  if (listen(servSocket, 5) < 0) {
    perror("listen err");
    exit(1);
  }
  printf("Listen Port: %d\nListening ...\n", SERV_PORT);
  client[0].fd = servSocket;
  client[0].events = POLLRDNORM;
  for (i = 1; i < 1024; i++)
    client[i].fd = -1;
  maxi = 0;
  for (;;) {
    nready = poll(client, maxi + 1, -1);
    if (nready < 0) {
      printf("poll err");
      exit(1);
    }
    if (client[0].revents & POLLRDNORM) {
      addrLen = sizeof(cliAddr);
      if ((cliSocket =
               accept(servSocket, (struct sockaddr *)&cliAddr, &addrLen)) < 0) {
        printf("accept err");
        exit(1);
      }
      for (i = 1; i < 1024; i++)
        if (client[i].fd < 0) {
          client[i].fd = cliSocket;
          break;
        }
      printf("\nNew client connections client[%d] %s:%d\n", i,
             inet_ntoa(cliAddr.sin_addr), ntohs(cliAddr.sin_port));
      if (i == 1024)
        printf("too many clients");
      client[i].events = POLLRDNORM;
      if (i > maxi)
        maxi = i;
      if (--nready <= 0)
        continue;
    }
    for (i = 1; i <= maxi; i++) {
      if ((cliSocket = client[i].fd) < 0)
        continue;
      if (client[i].revents & (POLLRDNORM | POLLERR)) {
        memset(buf, 0, 200);
        nbytes = recv(cliSocket, buf, 200, 0);
        if (nbytes < 0) {
          printf("recv err");
          continue;
        } else if (nbytes == 0) {
          printf("client[%d] closed connection\n", i);
          close(cliSocket);
          client[i].fd = -1;
        } else {
          printf("\nFrom client[%d]\n", i);
          printf("Recv: %sLength: %d\n\n", buf, (int)nbytes);
        }
        if (--nready <= 0)
          break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1a0a,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1266 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1280 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12bb <main+0x9b>
lea    0xd76(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x1,-0x3134(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
lea    -0x3134(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1309 <main+0xe9>
lea    0xd2c(%rip),%rdi
call   10f0 <perror@plt>
xor    %edi,%edi
call   1130 <exit@plt>
lea    -0x3130(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3128(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x3130(%rbp)
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x312c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x3130(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    137f <main+0x15f>
lea    0xcc4(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    13ac <main+0x18c>
lea    0xc9c(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x3110(%rbp)
mov    0x2c0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x310c(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jge    140f <main+0x1ef>
movslq -0x18(%rbp),%rcx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    13dc <main+0x1bc>
movl   $0x0,-0x1c(%rbp)
lea    -0x3110(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    $0xffffffff,%edx
call   10d0 <poll@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1452 <main+0x232>
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x3108(%rbp),%eax
mov    0x2b79(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     15b6 <main+0x396>
movl   $0xc,-0x104(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x3120(%rbp),%rsi
lea    -0x104(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    14ae <main+0x28e>
lea    0xbcf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jge    150c <main+0x2ec>
movslq -0x18(%rbp),%rcx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,(%rax)
jge    14f9 <main+0x2d9>
mov    -0x28(%rbp),%ecx
movslq -0x18(%rbp),%rdx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
jmp    150c <main+0x2ec>
jmp    14fe <main+0x2de>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14b5 <main+0x295>
mov    -0x18(%rbp),%eax
mov    %eax,-0x3144(%rbp)
mov    -0x311c(%rbp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,-0x3140(%rbp)
mov    -0x3120(%rbp),%edi
call   10c0 <ntohs@plt>
mov    -0x3144(%rbp),%esi
mov    -0x3140(%rbp),%rdx
mov    %eax,%ecx
lea    0xb2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x400,-0x18(%rbp)
jne    156a <main+0x34a>
lea    0xb3e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2a67(%rip),%rax
mov    (%rax),%ecx
movslq -0x18(%rbp),%rdx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    159a <main+0x37a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     15b1 <main+0x391>
jmp    1416 <main+0x1f6>
jmp    15b6 <main+0x396>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     170c <main+0x4ec>
movslq -0x18(%rbp),%rcx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    15ee <main+0x3ce>
jmp    16fe <main+0x4de>
movslq -0x18(%rbp),%rcx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    0x29ce(%rip),%rcx
mov    (%rcx),%ecx
mov    0x29bd(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     16f9 <main+0x4d9>
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1090 <memset@plt>
mov    -0x28(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    $0xc8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jge    166b <main+0x44b>
lea    0xa53(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    16fe <main+0x4de>
cmpq   $0x0,-0x30(%rbp)
jne    16ac <main+0x48c>
mov    -0x18(%rbp),%esi
lea    0xa3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%edi
call   10a0 <close@plt>
movslq -0x18(%rbp),%rcx
lea    -0x3110(%rbp),%rax
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
jmp    16d8 <main+0x4b8>
mov    -0x18(%rbp),%esi
lea    0xa23(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x100(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xa1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    16dd <main+0x4bd>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     16f4 <main+0x4d4>
jmp    170c <main+0x4ec>
jmp    16f9 <main+0x4d9>
jmp    16fe <main+0x4de>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    15bd <main+0x39d>
jmp    1416 <main+0x1f6>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3118,%rsp
cmp    $0x3,%edi
jl     1251 <main+0x31>
mov    (%rsi),%rdx
lea    0xdc0(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1a0a,%ebx
jmp    1266 <main+0x46>
mov    $0x1a0a,%ebx
cmp    $0x2,%edi
jne    1266 <main+0x46>
mov    0x8(%rsi),%rdi
call   1120 <atoi@plt>
mov    %eax,%ebx
mov    0x2d73(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
jns    1290 <main+0x70>
lea    0xd97(%rip),%rdi
jmp    1345 <main+0x125>
mov    %eax,%r15d
movl   $0x1,0x8(%rsp)
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
mov    0x2d05(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jns    12d8 <main+0xb8>
lea    0xd5d(%rip),%rdi
call   10f0 <perror@plt>
xor    %edi,%edi
call   1130 <exit@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %eax,0x20(%rsp)
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x24(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jns    132c <main+0x10c>
lea    0xd0a(%rip),%rdi
jmp    1345 <main+0x125>
mov    %r15d,%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
test   %rax,%rax
jns    1354 <main+0x134>
lea    0xcf4(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xce9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,0x110(%rsp)
mov    0x2c65(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x114(%rsp)
mov    $0x24,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0xffffffff,0xf8(%rsp,%rax,1)
ff ff ff ff
movl   $0xffffffff,0x104(%rsp,%rax,1)
ff ff ff ff
movl   $0xffffffff,0x110(%rsp,%rax,1)
ff ff ff ff
add    $0x24,%rax
cmp    $0x3018,%rax
jne    1390 <main+0x170>
lea    0x110(%rsp),%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   10d0 <poll@plt>
test   %eax,%eax
jns    13e4 <main+0x1c4>
lea    0xc84(%rip),%rdi
jmp    165d <main+0x43d>
mov    %eax,%ebx
lea    0x110(%rsp),%r14
xor    %r12d,%r12d
mov    %r15d,0x4(%rsp)
jmp    142a <main+0x20a>
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%r15d
lea    0x110(%rsp),%r14
mov    0x10(%rsp),%r12
lea    0x1(%r12),%esi
mov    %r14,%rdi
mov    $0xffffffff,%edx
call   10d0 <poll@plt>
mov    %eax,%ebx
test   %eax,%eax
js     13d8 <main+0x1b8>
mov    0x2ba7(%rip),%rax
mov    (%rax),%eax
test   %eax,0x118(%rsp)
je     154d <main+0x32d>
movl   $0xc,0xc(%rsp)
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1110 <accept@plt>
test   %eax,%eax
js     1656 <main+0x436>
mov    $0x1,%ebp
mov    $0x3,%edx
xor    %ecx,%ecx
xchg   %ax,%ax
cmpl   $0x0,0x11c(%rsp,%rcx,1)
js     14ad <main+0x28d>
cmpl   $0x0,0x128(%rsp,%rcx,1)
js     14bc <main+0x29c>
cmpl   $0x0,0x134(%rsp,%rcx,1)
js     14cf <main+0x2af>
add    $0x3,%rbp
add    $0x24,%rcx
add    $0x3,%rdx
cmp    $0x2ff4,%rcx
jne    1470 <main+0x250>
mov    %r12,%r13
mov    $0x400,%ebp
jmp    14e1 <main+0x2c1>
mov    %r12,%r13
add    %rsp,%rcx
add    $0x11c,%rcx
jmp    14df <main+0x2bf>
mov    %r12,%r13
add    $0x1,%rbp
add    %rsp,%rcx
add    $0x128,%rcx
jmp    14df <main+0x2bf>
mov    %r12,%r13
add    %rsp,%rcx
add    $0x134,%rcx
mov    %rdx,%rbp
mov    %eax,(%rcx)
mov    0x34(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r12
mov    0x30(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xb7a(%rip),%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x400,%ebp
jne    1521 <main+0x301>
lea    0xb87(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2ab0(%rip),%rax
mov    (%rax),%eax
mov    %ebp,%ecx
lea    (%rcx,%rcx,2),%rcx
mov    %eax,0x114(%rsp,%rcx,4)
mov    %r13,%r12
cmp    %r12d,%ebp
cmovg  %ebp,%r12d
cmp    $0x2,%ebx
jl     1412 <main+0x1f2>
add    $0xffffffff,%ebx
test   %r12d,%r12d
jle    1412 <main+0x1f2>
mov    %r12,0x10(%rsp)
lea    0x1(%r12),%edx
mov    $0x1,%r15d
lea    0x11c(%rsp),%r12
mov    %rdx,0x18(%rsp)
jmp    159c <main+0x37c>
lea    0xb36(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%ebx
mov    0x18(%rsp),%rdx
add    $0x1,%r15
add    $0xc,%r12
cmp    %r15,%rdx
je     1400 <main+0x1e0>
mov    (%r12),%ebp
test   %ebp,%ebp
js     158b <main+0x36b>
mov    0x2a25(%rip),%rax
mov    (%rax),%eax
mov    0x2a24(%rip),%rcx
or     (%rcx),%eax
test   %eax,0x8(%r12)
je     158b <main+0x36b>
mov    %ebx,%r14d
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1090 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc8,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
js     1575 <main+0x355>
je     1621 <main+0x401>
mov    %rax,%r13
lea    0xae3(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xae4(%rip),%rdi
lea    0x40(%rsp),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x2,%r14d
jge    164b <main+0x42b>
jmp    1400 <main+0x1e0>
lea    0xa93(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
movl   $0xffffffff,(%r12)
ff
cmp    $0x2,%r14d
jl     1400 <main+0x1e0>
mov    %r14d,%ebx
add    $0xffffffff,%ebx
jmp    1586 <main+0x366>
lea    0xa0f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"param err:\0AUsage:\0A\09%s port | %s\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [11 x i8] c"listen err\00"
@.str.5 = [31 x i8] c"Listen Port: %d\0AListening ...\0A\00"
@POLLRDNORM = global i32 0
@.str.6 = [9 x i8] c"poll err\00"
@.str.7 = [11 x i8] c"accept err\00"
@.str.8 = [42 x i8] c"\0ANew client connections client[%d] %s:%d\0A\00"
@.str.9 = [17 x i8] c"too many clients\00"
@POLLERR = global i32 0
@.str.10 = [9 x i8] c"recv err\00"
@.str.11 = [30 x i8] c"client[%d] closed connection\0A\00"
@.str.12 = [18 x i8] c"\0AFrom client[%d]\0A\00"
@.str.13 = [21 x i8] c"Recv: %sLength: %d\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca [200 x i8]
%14 = alloca i32
%15 = alloca [1024 x %struct.pollfd]
%16 = alloca %struct.sockaddr_in
%17 = alloca %struct.sockaddr_in
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 6666, i32* %6
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %29
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %27)
br label %29
29: ; preds = %21, %2
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %6
br label %37
37: ; preds = %32, %29
%38 = load i32, i32* @AF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %10
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
store i32 1, i32* %18
%46 = load i32, i32* %10
%47 = load i32, i32* @SOL_SOCKET
%48 = load i32, i32* @SO_REUSEADDR
%49 = call i64 @setsockopt(i32 %46, i32 %47, i32 %48, i32* %18, i32 4)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @exit(i32 0)
unreachable
54: ; preds = %45
%55 = call i32 @bzero(%struct.sockaddr_in* %17, i32 12)
%56 = load i32, i32* @AF_INET
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 2
store i32 %56, i32* %57
%58 = load i32, i32* %6
%59 = call i32 @htons(i32 %58)
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i32 %59, i32* %60
%61 = load i32, i32* @INADDR_ANY
%62 = call i32 @htonl(i32 %61)
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%64 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %63, i32 0, i32 0
store i32 %62, i32* %64
%65 = load i32, i32* %10
%66 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%67 = call i64 @bind(i32 %65, %struct.sockaddr* %66, i32 12)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %54
%70 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %54
%73 = load i32, i32* %10
%74 = call i64 @listen(i32 %73, i32 5)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %72
%80 = load i32, i32* %6
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %10
%83 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 0
%84 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %83, i32 0, i32 0
store i32 %82, i32* %84
%85 = load i32, i32* @POLLRDNORM
%86 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 0
%87 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %86, i32 0, i32 1
store i32 %85, i32* %87
store i32 1, i32* %7
br label %88
88: ; preds = %96, %79
%89 = load i32, i32* %7
%90 = icmp slt i32 %89, 1024
br i1 %90, label %91, label %99
91: ; preds = %88
%92 = load i32, i32* %7
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %93
%95 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %94, i32 0, i32 0
store i32 -1, i32* %95
br label %96
96: ; preds = %91
%97 = load i32, i32* %7
%98 = add nsw i32 %97, 1
store i32 %98, i32* %7
br label %88
99: ; preds = %88
store i32 0, i32* %8
br label %100
100: ; preds = %241, %175, %99
%101 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 0
%102 = load i32, i32* %8
%103 = add nsw i32 %102, 1
%104 = call i32 @poll(%struct.pollfd* %101, i32 %103, i32 -1)
store i32 %104, i32* %9
%105 = load i32, i32* %9
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %100
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %100
%111 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 0
%112 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %111, i32 0, i32 2
%113 = load i32, i32* %112
%114 = load i32, i32* @POLLRDNORM
%115 = and i32 %113, %114
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %177
117: ; preds = %110
store i32 12, i32* %14
%118 = load i32, i32* %10
%119 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%120 = call i32 @accept(i32 %118, %struct.sockaddr* %119, i32* %14)
store i32 %120, i32* %11
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%124 = call i32 @exit(i32 1)
unreachable
125: ; preds = %117
store i32 1, i32* %7
br label %126
126: ; preds = %143, %125
%127 = load i32, i32* %7
%128 = icmp slt i32 %127, 1024
br i1 %128, label %129, label %146
129: ; preds = %126
%130 = load i32, i32* %7
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %131
%133 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %132, i32 0, i32 0
%134 = load i32, i32* %133
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %142
136: ; preds = %129
%137 = load i32, i32* %11
%138 = load i32, i32* %7
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %139
%141 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %140, i32 0, i32 0
store i32 %137, i32* %141
br label %146
142: ; preds = %129
br label %143
143: ; preds = %142
%144 = load i32, i32* %7
%145 = add nsw i32 %144, 1
store i32 %145, i32* %7
br label %126
146: ; preds = %136, %126
%147 = load i32, i32* %7
%148 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
%149 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %148, i32 0, i32 0
%150 = load i32, i32* %149
%151 = call i8* @inet_ntoa(i32 %150)
%152 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%153 = load i32, i32* %152
%154 = call i32 @ntohs(i32 %153)
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %147, i8* %151, i32 %154)
%156 = load i32, i32* %7
%157 = icmp eq i32 %156, 1024
br i1 %157, label %158, label %160
158: ; preds = %146
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %160
160: ; preds = %158, %146
%161 = load i32, i32* @POLLRDNORM
%162 = load i32, i32* %7
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %163
%165 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %164, i32 0, i32 1
store i32 %161, i32* %165
%166 = load i32, i32* %7
%167 = load i32, i32* %8
%168 = icmp sgt i32 %166, %167
br i1 %168, label %169, label %171
169: ; preds = %160
%170 = load i32, i32* %7
store i32 %170, i32* %8
br label %171
171: ; preds = %169, %160
%172 = load i32, i32* %9
%173 = add nsw i32 %172, -1
store i32 %173, i32* %9
%174 = icmp sle i32 %173, 0
br i1 %174, label %175, label %176
175: ; preds = %171
br label %100
176: ; preds = %171
br label %177
177: ; preds = %176, %110
store i32 1, i32* %7
br label %178
178: ; preds = %238, %177
%179 = load i32, i32* %7
%180 = load i32, i32* %8
%181 = icmp sle i32 %179, %180
br i1 %181, label %182, label %241
182: ; preds = %178
%183 = load i32, i32* %7
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %184
%186 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %185, i32 0, i32 0
%187 = load i32, i32* %186
store i32 %187, i32* %11
%188 = icmp slt i32 %187, 0
br i1 %188, label %189, label %190
189: ; preds = %182
br label %238
190: ; preds = %182
%191 = load i32, i32* %7
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %192
%194 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %193, i32 0, i32 2
%195 = load i32, i32* %194
%196 = load i32, i32* @POLLRDNORM
%197 = load i32, i32* @POLLERR
%198 = or i32 %196, %197
%199 = and i32 %195, %198
%200 = icmp ne i32 %199, 0
br i1 %200, label %201, label %237
201: ; preds = %190
%202 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%203 = call i32 @memset(i8* %202, i32 0, i32 200)
%204 = load i32, i32* %11
%205 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%206 = call i64 @recv(i32 %204, i8* %205, i32 200, i32 0)
store i64 %206, i64* %12
%207 = load i64, i64* %12
%208 = icmp slt i64 %207, 0
br i1 %208, label %209, label %211
209: ; preds = %201
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
br label %238
211: ; preds = %201
%212 = load i64, i64* %12
%213 = icmp eq i64 %212, 0
br i1 %213, label %214, label %223
214: ; preds = %211
%215 = load i32, i32* %7
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %215)
%217 = load i32, i32* %11
%218 = call i32 @close(i32 %217)
%219 = load i32, i32* %7
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %15, i64 0, i64 %220
%222 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %221, i32 0, i32 0
store i32 -1, i32* %222
br label %230
223: ; preds = %211
%224 = load i32, i32* %7
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), i32 %224)
%226 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%227 = load i64, i64* %12
%228 = trunc i64 %227 to i32
%229 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i8* %226, i32 %228)
br label %230
230: ; preds = %223, %214
br label %231
231: ; preds = %230
%232 = load i32, i32* %9
%233 = add nsw i32 %232, -1
store i32 %233, i32* %9
%234 = icmp sle i32 %233, 0
br i1 %234, label %235, label %236
235: ; preds = %231
br label %241
236: ; preds = %231
br label %237
237: ; preds = %236, %190
br label %238
238: ; preds = %237, %209, %189
%239 = load i32, i32* %7
%240 = add nsw i32 %239, 1
store i32 %240, i32* %7
br label %178
241: ; preds = %235, %178
br label %100
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"param err:\0AUsage:\0A\09%s port | %s\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [11 x i8] c"listen err\00"
@.str.5 = [31 x i8] c"Listen Port: %d\0AListening ...\0A\00"
@POLLRDNORM = global i32 0
@.str.6 = [9 x i8] c"poll err\00"
@.str.7 = [11 x i8] c"accept err\00"
@.str.8 = [42 x i8] c"\0ANew client connections client[%d] %s:%d\0A\00"
@.str.9 = [17 x i8] c"too many clients\00"
@POLLERR = global i32 0
@.str.10 = [9 x i8] c"recv err\00"
@.str.11 = [30 x i8] c"client[%d] closed connection\0A\00"
@.str.12 = [18 x i8] c"\0AFrom client[%d]\0A\00"
@.str.13 = [21 x i8] c"Recv: %sLength: %d\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca [1024 x %struct.pollfd]
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = icmp sgt i32 %0, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %11)
br label %19
13: ; preds = %2
%14 = icmp eq i32 %0, 2
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
br label %19
19: ; preds = %10, %15, %13
%20 = phi i32 [ %18, %15 ], [ 6666, %13 ], [ 6666, %10 ]
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%22 = bitcast i32* %4 to i8*
%23 = bitcast [1024 x %struct.pollfd]* %5 to i8*
%24 = bitcast %struct.sockaddr_in* %6 to i8*
%25 = bitcast %struct.sockaddr_in* %7 to i8*
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = tail call i32 @socket(i32 %26, i32 %27, i32 0)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %19
%34 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%35 = load i32, i32* @SOL_SOCKET
%36 = load i32, i32* @SO_REUSEADDR
%37 = call i64 @setsockopt(i32 %28, i32 %35, i32 %36, i32* %8, i32 4)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %33
%43 = call i32 @bzero(%struct.sockaddr_in* %7, i32 12)
%44 = load i32, i32* @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i32 %44, i32* %45
%46 = call i32 @htons(i32 %20)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* @INADDR_ANY
%49 = call i32 @htonl(i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1, i32 0
store i32 %49, i32* %50
%51 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%52 = call i64 @bind(i32 %28, %struct.sockaddr* %51, i32 12)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %42
%55 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %42
%58 = call i64 @listen(i32 %28, i32 5)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %57
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%65 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 0, i32 0
store i32 %28, i32* %65
%66 = load i32, i32* @POLLRDNORM
%67 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 0, i32 1
store i32 %66, i32* %67
br label %77
68: ; preds = %77
%69 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 0
%70 = call i32 @poll(%struct.pollfd* %69, i32 1, i32 -1)
%71 = icmp slt i32 %70, 0
br i1 %71, label %86, label %72
72: ; preds = %68
%73 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 0, i32 2
%74 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
br label %89
77: ; preds = %77, %63
%78 = phi i64 [ 1, %63 ], [ %84, %77 ]
%79 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %78, i32 0
store i32 -1, i32* %79
%80 = add nuw nsw i64 %78, 1
%81 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %80, i32 0
store i32 -1, i32* %81
%82 = add nuw nsw i64 %78, 2
%83 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %82, i32 0
store i32 -1, i32* %83
%84 = add nuw nsw i64 %78, 3
%85 = icmp eq i64 %84, 1024
br i1 %85, label %68, label %77
86: ; preds = %186, %68
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %72, %186
%90 = phi i32 [ %70, %72 ], [ %189, %186 ]
%91 = phi i32 [ 0, %72 ], [ %187, %186 ]
%92 = load i32, i32* %73
%93 = load i32, i32* @POLLRDNORM
%94 = and i32 %93, %92
%95 = icmp eq i32 %94, 0
br i1 %95, label %142, label %96
96: ; preds = %89
store i32 12, i32* %4
%97 = call i32 @accept(i32 %28, %struct.sockaddr* %74, i32* %4)
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %96
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %96, %121
%103 = phi i64 [ %122, %121 ], [ 1, %96 ]
%104 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %103, i32 0
%105 = load i32, i32* %104
%106 = icmp slt i32 %105, 0
br i1 %106, label %107, label %111
107: ; preds = %116, %111, %102
%108 = phi i64 [ %103, %102 ], [ %112, %111 ], [ %117, %116 ]
%109 = phi i32* [ %104, %102 ], [ %113, %111 ], [ %118, %116 ]
%110 = trunc i64 %108 to i32
store i32 %97, i32* %109
br label %124
111: ; preds = %102
%112 = add nuw nsw i64 %103, 1
%113 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %112, i32 0
%114 = load i32, i32* %113
%115 = icmp slt i32 %114, 0
br i1 %115, label %107, label %116
116: ; preds = %111
%117 = add nuw nsw i64 %103, 2
%118 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %117, i32 0
%119 = load i32, i32* %118
%120 = icmp slt i32 %119, 0
br i1 %120, label %107, label %121
121: ; preds = %116
%122 = add nuw nsw i64 %103, 3
%123 = icmp eq i64 %122, 1024
br i1 %123, label %124, label %102
124: ; preds = %121, %107
%125 = phi i32 [ %110, %107 ], [ 1024, %121 ]
%126 = load i32, i32* %75
%127 = call i8* @inet_ntoa(i32 %126)
%128 = load i32, i32* %76
%129 = call i32 @ntohs(i32 %128)
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %125, i8* %127, i32 %129)
%131 = icmp eq i32 %125, 1024
br i1 %131, label %132, label %134
132: ; preds = %124
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %134
134: ; preds = %132, %124
%135 = load i32, i32* @POLLRDNORM
%136 = zext i32 %125 to i64
%137 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %136, i32 1
store i32 %135, i32* %137
%138 = icmp sgt i32 %125, %91
%139 = select i1 %138, i32 %125, i32 %91
%140 = add nsw i32 %90, -1
%141 = icmp slt i32 %90, 2
br i1 %141, label %186, label %142
142: ; preds = %134, %89
%143 = phi i32 [ %139, %134 ], [ %91, %89 ]
%144 = phi i32 [ %140, %134 ], [ %90, %89 ]
%145 = icmp slt i32 %143, 1
br i1 %145, label %186, label %146
146: ; preds = %142
%147 = add nuw i32 %143, 1
%148 = zext i32 %147 to i64
br label %149
149: ; preds = %146, %182
%150 = phi i64 [ 1, %146 ], [ %184, %182 ]
%151 = phi i32 [ %144, %146 ], [ %183, %182 ]
%152 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %150, i32 0
%153 = load i32, i32* %152
%154 = icmp slt i32 %153, 0
br i1 %154, label %182, label %155
155: ; preds = %149
%156 = getelementptr inbounds [1024 x %struct.pollfd], [1024 x %struct.pollfd]* %5, i64 0, i64 %150, i32 2
%157 = load i32, i32* %156
%158 = load i32, i32* @POLLRDNORM
%159 = load i32, i32* @POLLERR
%160 = or i32 %159, %158
%161 = and i32 %160, %157
%162 = icmp eq i32 %161, 0
br i1 %162, label %182, label %163
163: ; preds = %155
%164 = call i32 @memset(i8* %21, i32 0, i32 200)
%165 = call i64 @recv(i32 %153, i8* %21, i32 200, i32 0)
%166 = icmp slt i64 %165, 0
br i1 %166, label %167, label %169
167: ; preds = %163
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
br label %182
169: ; preds = %163
%170 = icmp eq i64 %165, 0
%171 = trunc i64 %150 to i32
br i1 %170, label %172, label %175
172: ; preds = %169
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %171)
%174 = call i32 @close(i32 %153)
store i32 -1, i32* %152
br label %179
175: ; preds = %169
%176 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0), i32 %171)
%177 = trunc i64 %165 to i32
%178 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i8* %21, i32 %177)
br label %179
179: ; preds = %172, %175
%180 = add nsw i32 %151, -1
%181 = icmp slt i32 %151, 2
br i1 %181, label %186, label %182
182: ; preds = %155, %179, %149, %167
%183 = phi i32 [ %151, %149 ], [ %151, %167 ], [ %180, %179 ], [ %151, %155 ]
%184 = add nuw nsw i64 %150, 1
%185 = icmp eq i64 %184, %148
br i1 %185, label %186, label %149
186: ; preds = %179, %182, %142, %134
%187 = phi i32 [ %139, %134 ], [ %143, %142 ], [ %143, %182 ], [ %143, %179 ]
%188 = add nsw i32 %187, 1
%189 = call i32 @poll(%struct.pollfd* %69, i32 %188, i32 -1)
%190 = icmp slt i32 %189, 0
br i1 %190, label %86, label %89
}