#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 */

/* Type definitions */
struct pollfd {
  int fd;
  scalar_t__ revents;
  scalar_t__ events;
};

/* Variables and functions */
scalar_t__ EWOULDBLOCK;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ O_NONBLOCK;
scalar_t__ POLLIN;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int init_sock(int);
int /*<<< orphan*/ memset(struct pollfd *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int rv, i, j;
  char buffer[256];
  struct pollfd fds[200];
  int nfds = 1;
  int lsock = init_sock(5555);
  memset(fds, 0, sizeof fds);
  fds[0].fd = lsock;
  fds[0].events = POLLIN;
  int timeout = (3 * 60 * 1000);
  while (1) {
    printf("waiting on poll() ...\n");
    rv = poll(fds, nfds, timeout);
    if (rv < 0) {
      perror("poll() failed");
      break;
    } else if (rv == 0) {
      printf("poll() timed out. End Program.\n");
      break;
    }
    int current_size = nfds;
    int compress_array;
    for (i = 0; i < current_size; ++i) {
      if (fds[i].revents == 0) {
        continue;
      } else if (fds[i].revents != POLLIN) {
        printf("error! revents = %d\n", fds[i].revents);
        goto close_server;
      }
      if (fds[i].fd == lsock) {
        printf("incoming connections detected\n");
        int new_sock = -1;
        do {
          new_sock = accept(lsock, NULL, NULL);
          if (new_sock < 0) {
            if (errno != EWOULDBLOCK) {
              perror("accept() failed");
              goto close_server;
            } else {
              break;
            }
          }
          fcntl(new_sock, F_SETFL, O_NONBLOCK);
          printf("new conn on %d\n", new_sock);
          fds[nfds].fd = new_sock;
          fds[nfds].events = POLLIN;
          ++nfds;
        } while (new_sock != -1);
      } else {
        printf("socket %d is readable\n", fds[i].fd);
        int close_conn = 0;
        while (1) {
          rv = recv(fds[i].fd, buffer, sizeof buffer, 0);
          if (rv < 0) {
            if (errno != EWOULDBLOCK) {
              perror("recv() failed");
              close_conn = 1;
              break;
            } else {
              printf("quit recving\n");
              break;
            }
          } else if (rv == 0) {
            printf("connection closed by remote\n");
            close_conn = 1;
            break;
          }
          int len = rv;
          rv = send(fds[i].fd, buffer, len, 0);
          if (rv < 0) {
            perror("send() failed");
            close_conn = 1;
            break;
          }
        }
        if (close_conn) {
          close(fds[i].fd);
          fds[i].fd = -1;
          compress_array = 1;
        }
      }
    }
    if (compress_array) {
      compress_array = 0;
      for (i = 0; i < nfds; ++i) {
        if (fds[i].fd == -1) {
          for (j = i; j < nfds; ++j) {
            fds[j].fd = fds[j + 1].fd;
          }
          --nfds;
        }
      }
    }
  }
close_server:
  for (i = 0; i < nfds; ++i) {
    if (fds[i].fd >= 0) {
      close(fds[i].fd);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1400,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x13e4(%rbp)
mov    $0x15b3,%edi
call   1040 <init_sock@plt>
mov    %eax,-0x13e8(%rbp)
lea    -0x13e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c0,%edx
call   1080 <memset@plt>
mov    -0x13e8(%rbp),%eax
mov    %eax,-0x13e0(%rbp)
mov    0x2de7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x13d0(%rbp)
movl   $0x2bf20,-0x13ec(%rbp)
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x13e0(%rbp),%rdi
mov    -0x13e4(%rbp),%esi
mov    -0x13ec(%rbp),%edx
call   10a0 <poll@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1251 <main+0xb1>
lea    0xdd0(%rip),%rdi
call   10b0 <perror@plt>
jmp    1680 <main+0x4e0>
cmpl   $0x0,-0x14(%rbp)
jne    126e <main+0xce>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1680 <main+0x4e0>
jmp    1273 <main+0xd3>
mov    -0x13e4(%rbp),%eax
mov    %eax,-0x13f0(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x13f0(%rbp),%eax
jge    15bc <main+0x41c>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpq   $0x0,0x8(%rax)
jne    12b7 <main+0x117>
jmp    15ae <main+0x40e>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    0x2d0c(%rip),%rcx
cmp    (%rcx),%rax
je     1306 <main+0x166>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1685 <main+0x4e5>
jmp    130b <main+0x16b>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0x13e8(%rbp),%eax
jne    142a <main+0x28a>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x13f8(%rbp)
ff ff ff
mov    -0x13e8(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10c0 <accept@plt>
mov    %eax,-0x13f8(%rbp)
cmpl   $0x0,-0x13f8(%rbp)
jge    1398 <main+0x1f8>
mov    0x2c59(%rip),%rax
mov    (%rax),%rax
mov    0x2c47(%rip),%rcx
cmp    (%rcx),%rax
je     1393 <main+0x1f3>
lea    0xcf0(%rip),%rdi
call   10b0 <perror@plt>
jmp    1685 <main+0x4e5>
jmp    1425 <main+0x285>
mov    -0x13f8(%rbp),%edi
mov    0x2c2b(%rip),%rax
mov    (%rax),%esi
mov    0x2c3a(%rip),%rax
mov    (%rax),%edx
call   1050 <fcntl@plt>
mov    -0x13f8(%rbp),%esi
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x13f8(%rbp),%ecx
movslq -0x13e4(%rbp),%rdx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
mov    0x2bf3(%rip),%rax
mov    (%rax),%rcx
movslq -0x13e4(%rbp),%rdx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %rcx,0x10(%rax)
mov    -0x13e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13e4(%rbp)
cmpl   $0xffffffff,-0x13f8(%rbp)
jne    1343 <main+0x1a3>
jmp    15a9 <main+0x409>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%esi
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x13fc(%rbp)
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    14d2 <main+0x332>
mov    0x2b37(%rip),%rax
mov    (%rax),%rax
mov    0x2b25(%rip),%rcx
cmp    (%rcx),%rax
je     14bf <main+0x31f>
lea    0xc05(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x13fc(%rbp)
jmp    155c <main+0x3bc>
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    155c <main+0x3bc>
cmpl   $0x0,-0x14(%rbp)
jne    14f9 <main+0x359>
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x13fc(%rbp)
jmp    155c <main+0x3bc>
jmp    14fe <main+0x35e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1400(%rbp)
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rsi
mov    -0x1400(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1557 <main+0x3b7>
lea    0xba6(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x13fc(%rbp)
jmp    155c <main+0x3bc>
jmp    1456 <main+0x2b6>
cmpl   $0x0,-0x13fc(%rbp)
je     15a4 <main+0x404>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edi
call   1090 <close@plt>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
movl   $0x1,-0x13f4(%rbp)
jmp    15a9 <main+0x409>
jmp    15ae <main+0x40e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1286 <main+0xe6>
cmpl   $0x0,-0x13f4(%rbp)
je     167b <main+0x4db>
movl   $0x0,-0x13f4(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x13e4(%rbp),%eax
jge    1676 <main+0x4d6>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpl   $0xffffffff,(%rax)
jne    1663 <main+0x4c3>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x13e4(%rbp),%eax
jge    1654 <main+0x4b4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
movslq -0x1c(%rbp),%rdx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rdx,%rdx
add    %rdx,%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    160a <main+0x46a>
mov    -0x13e4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x13e4(%rbp)
jmp    1668 <main+0x4c8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    15da <main+0x43a>
jmp    167b <main+0x4db>
jmp    120d <main+0x6d>
jmp    1685 <main+0x4e5>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x13e4(%rbp),%eax
jge    16e2 <main+0x542>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,(%rax)
jl     16cf <main+0x52f>
movslq -0x18(%rbp),%rcx
lea    -0x13e0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edi
call   1090 <close@plt>
jmp    16d4 <main+0x534>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    168c <main+0x4ec>
xor    %eax,%eax
add    $0x1400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x13e8,%rsp
mov    $0x15b3,%edi
call   1040 <init_sock@plt>
mov    %eax,%r14d
lea    0x120(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x12c0,%edx
call   1090 <memset@plt>
mov    %r14d,0x120(%rsp)
mov    0x2dec(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x130(%rsp)
lea    0xe70(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%r13d
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x2bf20,%edx
call   10b0 <poll@plt>
test   %eax,%eax
js     15bd <main+0x40d>
mov    $0x1,%r13d
lea    0x20(%rsp),%rbx
mov    %r14d,0xc(%rsp)
jmp    1264 <main+0xb4>
nopl   (%rax)
lea    0xe2f(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x2bf20,%edx
call   10b0 <poll@plt>
test   %eax,%eax
js     15bd <main+0x40d>
test   %eax,%eax
je     15af <main+0x3ff>
test   %r13d,%r13d
jle    1240 <main+0x90>
mov    %r13d,%r12d
xor    %ecx,%ecx
movl   $0x0,0x8(%rsp)
mov    0x2d5b(%rip),%r15
mov    %r12,0x18(%rsp)
jmp    12c1 <main+0x111>
lea    0xdf9(%rip),%rdi
call   1050 <puts@plt>
mov    0x0(%rbp),%edi
call   10a0 <close@plt>
movl   $0xffffffff,0x0(%rbp)
movl   $0x1,0x8(%rsp)
mov    0x10(%rsp),%rcx
add    $0x1,%rcx
cmp    %r12,%rcx
je     1460 <main+0x2b0>
lea    (%rcx,%rcx,2),%rax
mov    0x128(%rsp,%rax,8),%rsi
test   %rsi,%rsi
je     12b4 <main+0x104>
cmp    (%r15),%rsi
jne    1556 <main+0x3a6>
mov    %rcx,0x10(%rsp)
mov    0x120(%rsp,%rax,8),%esi
cmp    %r14d,%esi
jne    13d0 <main+0x220>
lea    0xdbe(%rip),%rdi
call   1050 <puts@plt>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <accept@plt>
test   %eax,%eax
js     138e <main+0x1de>
mov    %eax,%r15d
movslq %r13d,%rax
lea    (%rax,%rax,2),%rax
lea    0x130(%rsp),%rcx
lea    (%rcx,%rax,8),%rbp
mov    0xc(%rsp),%r12d
mov    0x2cb6(%rip),%r14
lea    0xcfa(%rip),%rbx
nopl   0x0(%rax)
mov    0x2c89(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %r15d,%edi
call   1060 <fcntl@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,-0x10(%rbp)
mov    0x2c74(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x0(%rbp)
mov    %r12d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <accept@plt>
mov    %eax,%r15d
add    $0x18,%rbp
add    $0x1,%r13d
test   %eax,%eax
jns    1340 <main+0x190>
mov    0x2c33(%rip),%rax
mov    (%rax),%rax
mov    0x2c21(%rip),%rcx
cmp    (%rcx),%rax
jne    15c6 <main+0x416>
mov    0x2c31(%rip),%r15
mov    0xc(%rsp),%r14d
lea    0x20(%rsp),%rbx
mov    0x18(%rsp),%r12
jmp    12af <main+0xff>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rsp,%rax,8),%rbp
add    $0x120,%rbp
lea    0xc61(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
js     1428 <main+0x278>
je     128c <main+0xdc>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %eax,%eax
jns    13f0 <main+0x240>
lea    0xc42(%rip),%rdi
jmp    1456 <main+0x2a6>
mov    0x2b99(%rip),%rax
mov    (%rax),%rax
mov    0x2b87(%rip),%rcx
cmp    (%rcx),%rax
jne    144f <main+0x29f>
lea    0xc63(%rip),%rdi
call   1050 <puts@plt>
jmp    12af <main+0xff>
lea    0xc04(%rip),%rdi
call   10c0 <perror@plt>
jmp    1298 <main+0xe8>
cmpl   $0x0,0x8(%rsp)
lea    0x120(%rsp),%r15
je     1240 <main+0x90>
test   %r13d,%r13d
jle    1240 <main+0x90>
xor    %r9d,%r9d
mov    %r15,%r10
xor    %edx,%edx
jmp    14ac <main+0x2fc>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%r13d
add    $0x1,%rdx
movslq %r13d,%rax
add    $0x18,%r10
add    $0x3,%r9b
cmp    %rax,%rdx
jge    1240 <main+0x90>
lea    (%rdx,%rdx,2),%rcx
cmpl   $0xffffffff,0x120(%rsp,%rcx,8)
ff
jne    1494 <main+0x2e4>
movslq %r13d,%rcx
cmp    %rcx,%rdx
jge    1490 <main+0x2e0>
mov    %rdx,%r8
not    %r8
mov    %r13d,%esi
mov    %r13d,%ecx
sub    %edx,%ecx
add    %rsi,%r8
mov    %rdx,%rbp
test   $0x3,%cl
je     1508 <main+0x358>
lea    (%r9,%r13,1),%ecx
movzbl %cl,%ebp
and    $0x3,%ebp
neg    %rbp
xor    %edi,%edi
mov    %r10,%rcx
nopl   (%rax)
mov    0x18(%rcx),%eax
mov    %eax,(%rcx)
add    $0x18,%rcx
add    $0xffffffffffffffff,%rdi
cmp    %rdi,%rbp
jne    14f0 <main+0x340>
mov    %rdx,%rbp
sub    %rdi,%rbp
cmp    $0x3,%r8
jb     1490 <main+0x2e0>
sub    %rbp,%rsi
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
lea    (%rsp,%rax,8),%rdi
add    $0x120,%rdi
nopw   0x0(%rax,%rax,1)
mov    0x18(%rdi),%eax
mov    0x30(%rdi),%ecx
mov    %eax,(%rdi)
mov    %ecx,0x18(%rdi)
mov    0x48(%rdi),%eax
mov    %eax,0x30(%rdi)
mov    0x60(%rdi),%eax
mov    %eax,0x48(%rdi)
add    $0x60,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1530 <main+0x380>
jmp    1490 <main+0x2e0>
lea    0xab1(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r13d,%r13d
jle    159b <main+0x3eb>
mov    %r13d,%eax
shl    $0x3,%rax
lea    (%rax,%rax,2),%rbx
xor    %ebp,%ebp
jmp    1589 <main+0x3d9>
nopl   0x0(%rax,%rax,1)
add    $0x18,%rbp
cmp    %rbp,%rbx
je     159b <main+0x3eb>
mov    0x120(%rsp,%rbp,1),%edi
test   %edi,%edi
js     1580 <main+0x3d0>
call   10a0 <close@plt>
jmp    1580 <main+0x3d0>
xor    %eax,%eax
add    $0x13e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb1d(%rip),%rdi
call   1050 <puts@plt>
jmp    1564 <main+0x3b4>
lea    0xa3c(%rip),%rdi
jmp    15cd <main+0x41d>
lea    0xa56(%rip),%rdi
call   10c0 <perror@plt>
jmp    1564 <main+0x3b4>

LLVM IR (-O0):
%struct.pollfd = type { i32, i64, i64 }
@POLLIN = global i64 0
@.str = [23 x i8] c"waiting on poll() ...\0A\00"
@.str.1 = [14 x i8] c"poll() failed\00"
@.str.2 = [32 x i8] c"poll() timed out. End Program.\0A\00"
@.str.3 = [21 x i8] c"error! revents = %d\0A\00"
@.str.4 = [31 x i8] c"incoming connections detected\0A\00"
@errno = global i64 0
@EWOULDBLOCK = global i64 0
@.str.5 = [16 x i8] c"accept() failed\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.6 = [16 x i8] c"new conn on %d\0A\00"
@.str.7 = [23 x i8] c"socket %d is readable\0A\00"
@.str.8 = [14 x i8] c"recv() failed\00"
@.str.9 = [14 x i8] c"quit recving\0A\00"
@.str.10 = [29 x i8] c"connection closed by remote\0A\00"
@.str.11 = [14 x i8] c"send() failed\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 [256 x i8]
%10 = alloca [200 x %struct.pollfd]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %11
%19 = call i32 @init_sock(i32 5555)
store i32 %19, i32* %12
%20 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 0
%21 = call i32 @memset(%struct.pollfd* %20, i32 0, i32 4800)
%22 = load i32, i32* %12
%23 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 0
%24 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load i64, i64* @POLLIN
%26 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 0
%27 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %26, i32 0, i32 2
store i64 %25, i64* %27
store i32 180000, i32* %13
br label %28
28: ; preds = %2, %227
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%30 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 0
%31 = load i32, i32* %11
%32 = load i32, i32* %13
%33 = call i32 @poll(%struct.pollfd* %30, i32 %31, i32 %32)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %28
%37 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %228
38: ; preds = %28
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %228
43: ; preds = %38
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
store i32 %45, i32* %14
store i32 0, i32* %7
br label %46
46: ; preds = %181, %44
%47 = load i32, i32* %7
%48 = load i32, i32* %14
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %184
50: ; preds = %46
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %52
%54 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %53, i32 0, i32 1
%55 = load i64, i64* %54
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %50
br label %181
58: ; preds = %50
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %60
%62 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %61, i32 0, i32 1
%63 = load i64, i64* %62
%64 = load i64, i64* @POLLIN
%65 = icmp ne i64 %63, %64
br i1 %65, label %66, label %73
66: ; preds = %58
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %68
%70 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %69, i32 0, i32 1
%71 = load i64, i64* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %71)
br label %229
73: ; preds = %58
br label %74
74: ; preds = %73
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %76
%78 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load i32, i32* %12
%81 = icmp eq i32 %79, %80
br i1 %81, label %82, label %119
82: ; preds = %74
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %16
br label %84
84: ; preds = %115, %82
%85 = load i32, i32* %12
%86 = call i32 @accept(i32 %85, i32* null, i32* null)
store i32 %86, i32* %16
%87 = load i32, i32* %16
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %96
89: ; preds = %84
%90 = load i64, i64* @errno
%91 = load i64, i64* @EWOULDBLOCK
%92 = icmp ne i64 %90, %91
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %229
95: ; preds = %89
br label %118
96: ; preds = %84
%97 = load i32, i32* %16
%98 = load i32, i32* @F_SETFL
%99 = load i32, i32* @O_NONBLOCK
%100 = call i32 @fcntl(i32 %97, i32 %98, i32 %99)
%101 = load i32, i32* %16
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %16
%104 = load i32, i32* %11
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %105
%107 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %106, i32 0, i32 0
store i32 %103, i32* %107
%108 = load i64, i64* @POLLIN
%109 = load i32, i32* %11
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %110
%112 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %111, i32 0, i32 2
store i64 %108, i64* %112
%113 = load i32, i32* %11
%114 = add nsw i32 %113, 1
store i32 %114, i32* %11
br label %115
115: ; preds = %96
%116 = load i32, i32* %16
%117 = icmp ne i32 %116, -1
br i1 %117, label %84, label %118
118: ; preds = %115, %95
br label %180
119: ; preds = %74
%120 = load i32, i32* %7
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %121
%123 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %122, i32 0, i32 0
%124 = load i32, i32* %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %124)
store i32 0, i32* %17
br label %126
126: ; preds = %119, %164
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %128
%130 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %129, i32 0, i32 0
%131 = load i32, i32* %130
%132 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%133 = call i32 @recv(i32 %131, i8* %132, i32 256, i32 0)
store i32 %133, i32* %6
%134 = load i32, i32* %6
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %144
136: ; preds = %126
%137 = load i64, i64* @errno
%138 = load i64, i64* @EWOULDBLOCK
%139 = icmp ne i64 %137, %138
br i1 %139, label %140, label %142
140: ; preds = %136
%141 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %17
br label %165
142: ; preds = %136
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %165
144: ; preds = %126
%145 = load i32, i32* %6
%146 = icmp eq i32 %145, 0
br i1 %146, label %147, label %149
147: ; preds = %144
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %17
br label %165
149: ; preds = %144
br label %150
150: ; preds = %149
%151 = load i32, i32* %6
store i32 %151, i32* %18
%152 = load i32, i32* %7
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %153
%155 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %154, i32 0, i32 0
%156 = load i32, i32* %155
%157 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%158 = load i32, i32* %18
%159 = call i32 @send(i32 %156, i8* %157, i32 %158, i32 0)
store i32 %159, i32* %6
%160 = load i32, i32* %6
%161 = icmp slt i32 %160, 0
br i1 %161, label %162, label %164
162: ; preds = %150
%163 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %17
br label %165
164: ; preds = %150
br label %126
165: ; preds = %162, %147, %142, %140
%166 = load i32, i32* %17
%167 = icmp ne i32 %166, 0
br i1 %167, label %168, label %179
168: ; preds = %165
%169 = load i32, i32* %7
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %170
%172 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %171, i32 0, i32 0
%173 = load i32, i32* %172
%174 = call i32 @close(i32 %173)
%175 = load i32, i32* %7
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %176
%178 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %177, i32 0, i32 0
store i32 -1, i32* %178
store i32 1, i32* %15
br label %179
179: ; preds = %168, %165
br label %180
180: ; preds = %179, %118
br label %181
181: ; preds = %180, %57
%182 = load i32, i32* %7
%183 = add nsw i32 %182, 1
store i32 %183, i32* %7
br label %46
184: ; preds = %46
%185 = load i32, i32* %15
%186 = icmp ne i32 %185, 0
br i1 %186, label %187, label %227
187: ; preds = %184
store i32 0, i32* %15
store i32 0, i32* %7
br label %188
188: ; preds = %223, %187
%189 = load i32, i32* %7
%190 = load i32, i32* %11
%191 = icmp slt i32 %189, %190
br i1 %191, label %192, label %226
192: ; preds = %188
%193 = load i32, i32* %7
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %194
%196 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %195, i32 0, i32 0
%197 = load i32, i32* %196
%198 = icmp eq i32 %197, -1
br i1 %198, label %199, label %222
199: ; preds = %192
%200 = load i32, i32* %7
store i32 %200, i32* %8
br label %201
201: ; preds = %216, %199
%202 = load i32, i32* %8
%203 = load i32, i32* %11
%204 = icmp slt i32 %202, %203
br i1 %204, label %205, label %219
205: ; preds = %201
%206 = load i32, i32* %8
%207 = add nsw i32 %206, 1
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %208
%210 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %209, i32 0, i32 0
%211 = load i32, i32* %210
%212 = load i32, i32* %8
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %213
%215 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %214, i32 0, i32 0
store i32 %211, i32* %215
br label %216
216: ; preds = %205
%217 = load i32, i32* %8
%218 = add nsw i32 %217, 1
store i32 %218, i32* %8
br label %201
219: ; preds = %201
%220 = load i32, i32* %11
%221 = add nsw i32 %220, -1
store i32 %221, i32* %11
br label %222
222: ; preds = %219, %192
br label %223
223: ; preds = %222
%224 = load i32, i32* %7
%225 = add nsw i32 %224, 1
store i32 %225, i32* %7
br label %188
226: ; preds = %188
br label %227
227: ; preds = %226, %184
br label %28
228: ; preds = %41, %36
br label %229
229: ; preds = %228, %93, %66
store i32 0, i32* %7
br label %230
230: ; preds = %249, %229
%231 = load i32, i32* %7
%232 = load i32, i32* %11
%233 = icmp slt i32 %231, %232
br i1 %233, label %234, label %252
234: ; preds = %230
%235 = load i32, i32* %7
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %236
%238 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %237, i32 0, i32 0
%239 = load i32, i32* %238
%240 = icmp sge i32 %239, 0
br i1 %240, label %241, label %248
241: ; preds = %234
%242 = load i32, i32* %7
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %10, i64 0, i64 %243
%245 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %244, i32 0, i32 0
%246 = load i32, i32* %245
%247 = call i32 @close(i32 %246)
br label %248
248: ; preds = %241, %234
br label %249
249: ; preds = %248
%250 = load i32, i32* %7
%251 = add nsw i32 %250, 1
store i32 %251, i32* %7
br label %230
252: ; preds = %230
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i64, i64 }
@POLLIN = global i64 0
@.str.1 = [14 x i8] c"poll() failed\00"
@.str.3 = [21 x i8] c"error! revents = %d\0A\00"
@errno = global i64 0
@EWOULDBLOCK = global i64 0
@.str.5 = [16 x i8] c"accept() failed\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.6 = [16 x i8] c"new conn on %d\0A\00"
@.str.7 = [23 x i8] c"socket %d is readable\0A\00"
@.str.8 = [14 x i8] c"recv() failed\00"
@.str.11 = [14 x i8] c"send() failed\00"
@str = [22 x i8] c"waiting on poll() ...\00"
@str.12 = [28 x i8] c"connection closed by remote\00"
@str.13 = [13 x i8] c"quit recving\00"
@str.14 = [30 x i8] c"incoming connections detected\00"
@str.15 = [31 x i8] c"poll() timed out. End Program.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [200 x %struct.pollfd]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast [200 x %struct.pollfd]* %4 to i8*
%7 = tail call i32 @init_sock(i32 5555)
%8 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 0
%9 = call i32 @memset(%struct.pollfd* %8, i32 0, i32 4800)
%10 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 0, i32 0
store i32 %7, i32* %10
%11 = load i64, i64* @POLLIN
%12 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 0, i32 2
store i64 %11, i64* %12
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%14 = call i32 @poll(%struct.pollfd* %8, i32 1, i32 180000)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %163, %2
%17 = phi i32 [ 1, %2 ], [ %164, %163 ]
%18 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %168
19: ; preds = %2, %163
%20 = phi i32 [ %166, %163 ], [ %14, %2 ]
%21 = phi i32 [ %164, %163 ], [ 1, %2 ]
%22 = icmp eq i32 %20, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = icmp sgt i32 %21, 0
br i1 %24, label %25, label %163
25: ; preds = %23
%26 = zext i32 %21 to i64
br label %29
27: ; preds = %19
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
br label %168
29: ; preds = %25, %100
%30 = phi i64 [ 0, %25 ], [ %103, %100 ]
%31 = phi i32 [ 0, %25 ], [ %102, %100 ]
%32 = phi i32 [ %21, %25 ], [ %101, %100 ]
%33 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %30, i32 1
%34 = load i64, i64* %33
%35 = icmp eq i64 %34, 0
br i1 %35, label %100, label %36
36: ; preds = %29
%37 = load i64, i64* @POLLIN
%38 = icmp eq i64 %34, %37
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %34)
br label %168
41: ; preds = %36
%42 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %30, i32 0
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, %7
br i1 %44, label %45, label %73
45: ; preds = %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.14, i64 0, i64 0))
%47 = call i32 @accept(i32 %7, i32* null, i32* null)
%48 = icmp slt i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = sext i32 %32 to i64
br label %58
51: ; preds = %58
%52 = trunc i64 %68 to i32
br label %53
53: ; preds = %51, %45
%54 = phi i32 [ %32, %45 ], [ %52, %51 ]
%55 = load i64, i64* @errno
%56 = load i64, i64* @EWOULDBLOCK
%57 = icmp eq i64 %55, %56
br i1 %57, label %100, label %71
58: ; preds = %49, %58
%59 = phi i64 [ %50, %49 ], [ %68, %58 ]
%60 = phi i32 [ %47, %49 ], [ %69, %58 ]
%61 = load i32, i32* @F_SETFL
%62 = load i32, i32* @O_NONBLOCK
%63 = call i32 @fcntl(i32 %60, i32 %61, i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %60)
%65 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %59, i32 0
store i32 %60, i32* %65
%66 = load i64, i64* @POLLIN
%67 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %59, i32 2
store i64 %66, i64* %67
%68 = add i64 %59, 1
%69 = call i32 @accept(i32 %7, i32* null, i32* null)
%70 = icmp slt i32 %69, 0
br i1 %70, label %51, label %58
71: ; preds = %53
%72 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %168
73: ; preds = %41
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %43)
br label %75
75: ; preds = %89, %73
%76 = load i32, i32* %42
%77 = call i32 @recv(i32 %76, i8* %5, i32 256, i32 0)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %85
79: ; preds = %75
%80 = load i64, i64* @errno
%81 = load i64, i64* @EWOULDBLOCK
%82 = icmp eq i64 %80, %81
br i1 %82, label %95, label %83
83: ; preds = %79
%84 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %97
85: ; preds = %75
%86 = icmp eq i32 %77, 0
br i1 %86, label %87, label %89
87: ; preds = %85
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.12, i64 0, i64 0))
br label %97
89: ; preds = %85
%90 = load i32, i32* %42
%91 = call i32 @send(i32 %90, i8* %5, i32 %77, i32 0)
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %75
93: ; preds = %89
%94 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %97
95: ; preds = %79
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
br label %100
97: ; preds = %93, %87, %83
%98 = load i32, i32* %42
%99 = call i32 @close(i32 %98)
store i32 -1, i32* %42
br label %100
100: ; preds = %95, %53, %97, %29
%101 = phi i32 [ %32, %29 ], [ %32, %97 ], [ %32, %95 ], [ %54, %53 ]
%102 = phi i32 [ %31, %29 ], [ 1, %97 ], [ %31, %95 ], [ %31, %53 ]
%103 = add nuw nsw i64 %30, 1
%104 = icmp eq i64 %103, %26
br i1 %104, label %105, label %29
105: ; preds = %100
%106 = icmp ne i32 %102, 0
%107 = icmp sgt i32 %101, 0
%108 = select i1 %106, i1 %107, i1 false
br i1 %108, label %109, label %163
109: ; preds = %105, %158
%110 = phi i64 [ %160, %158 ], [ 0, %105 ]
%111 = phi i32 [ %159, %158 ], [ %101, %105 ]
%112 = xor i64 %110, -1
%113 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %110, i32 0
%114 = load i32, i32* %113
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %158
116: ; preds = %109
%117 = sext i32 %111 to i64
%118 = icmp slt i64 %110, %117
br i1 %118, label %119, label %156
119: ; preds = %116
%120 = zext i32 %111 to i64
%121 = sub nsw i64 %120, %110
%122 = add nsw i64 %112, %120
%123 = and i64 %121, 3
%124 = icmp eq i64 %123, 0
br i1 %124, label %134, label %125
125: ; preds = %119, %125
%126 = phi i64 [ %128, %125 ], [ %110, %119 ]
%127 = phi i64 [ %132, %125 ], [ 0, %119 ]
%128 = add nuw nsw i64 %126, 1
%129 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %128, i32 0
%130 = load i32, i32* %129
%131 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %126, i32 0
store i32 %130, i32* %131
%132 = add i64 %127, 1
%133 = icmp eq i64 %132, %123
br i1 %133, label %134, label %125
134: ; preds = %125, %119
%135 = phi i64 [ %110, %119 ], [ %128, %125 ]
%136 = icmp ult i64 %122, 3
br i1 %136, label %156, label %137
137: ; preds = %134, %137
%138 = phi i64 [ %151, %137 ], [ %135, %134 ]
%139 = add nuw nsw i64 %138, 1
%140 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %139, i32 0
%141 = load i32, i32* %140
%142 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %138, i32 0
store i32 %141, i32* %142
%143 = add nuw nsw i64 %138, 2
%144 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %143, i32 0
%145 = load i32, i32* %144
%146 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %139, i32 0
store i32 %145, i32* %146
%147 = add nuw nsw i64 %138, 3
%148 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %147, i32 0
%149 = load i32, i32* %148
%150 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %143, i32 0
store i32 %149, i32* %150
%151 = add nuw nsw i64 %138, 4
%152 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %151, i32 0
%153 = load i32, i32* %152
%154 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %147, i32 0
store i32 %153, i32* %154
%155 = icmp eq i64 %151, %120
br i1 %155, label %156, label %137
156: ; preds = %134, %137, %116
%157 = add nsw i32 %111, -1
br label %158
158: ; preds = %109, %156
%159 = phi i32 [ %157, %156 ], [ %111, %109 ]
%160 = add nuw nsw i64 %110, 1
%161 = sext i32 %159 to i64
%162 = icmp slt i64 %160, %161
br i1 %162, label %109, label %163
163: ; preds = %158, %23, %105
%164 = phi i32 [ %101, %105 ], [ %21, %23 ], [ %159, %158 ]
%165 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%166 = call i32 @poll(%struct.pollfd* %8, i32 %164, i32 180000)
%167 = icmp slt i32 %166, 0
br i1 %167, label %16, label %19
168: ; preds = %71, %39, %16, %27
%169 = phi i32 [ %17, %16 ], [ %21, %27 ], [ %54, %71 ], [ %32, %39 ]
%170 = icmp sgt i32 %169, 0
br i1 %170, label %171, label %183
171: ; preds = %168
%172 = zext i32 %169 to i64
br label %173
173: ; preds = %171, %180
%174 = phi i64 [ 0, %171 ], [ %181, %180 ]
%175 = getelementptr inbounds [200 x %struct.pollfd], [200 x %struct.pollfd]* %4, i64 0, i64 %174, i32 0
%176 = load i32, i32* %175
%177 = icmp sgt i32 %176, -1
br i1 %177, label %178, label %180
178: ; preds = %173
%179 = call i32 @close(i32 %176)
br label %180
180: ; preds = %173, %178
%181 = add nuw nsw i64 %174, 1
%182 = icmp eq i64 %181, %172
br i1 %182, label %183, label %173
183: ; preds = %180, %168
ret i32 0
}