#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 */
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ FD_CLR(int, int /*<<< orphan*/ *);
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ SHUT_WR;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ diesys(char *);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char, int);
int /*<<< orphan*/ memmove(char *, char *, int);
int read(int, char *, int);
scalar_t__ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                  int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int main(int argc, char **argv) {
  static int i, j, *fd, bytes, nfds, maxfd, fds[16][2], len[16], active[2];
  static char buf[16][4096], first = 1, verbose;
  static fd_set fdset[2];
  for (fd = fds[0], argc--, argv++; argc > 1 && nfds < 16;
       nfds++, argc -= 2, argv += 2) {
    if (**argv == 'v') {
      verbose++;
      nfds--;
      argc++;
      argv--;
      continue;
    }
    for (j = 0; j < 2; j++, fd++) {
      if ((*fd = atoi(argv[j])) > maxfd)
        maxfd = *fd;
      if (fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL, 0) | O_NONBLOCK) < 0)
        diesys("fcntl");
      active[j] |= (1 << nfds);
    }
  }
  while (active[0] | active[1]) {
    if (!first)
      if (select(maxfd + 1, &fdset[0], &fdset[1], 0, 0) < 0)
        diesys("select");
    for (first = 0, i = 0, fd = fds[0]; i < nfds; i++) {
      for (j = 0; j < 2; j++, fd++) {
        if (FD_ISSET(*fd, &fdset[j])) {
          if (j == 1 && (bytes = write(*fd, buf[i], len[i])) > 0)
            memmove(buf[i], buf[i] + bytes, len[i] - bytes);
          else
            bytes = read(*fd, buf[i], sizeof(buf[i]));
          if (verbose)
            fprintf(stderr, "iocopy: %d %c %d\n", *fd, j ? '<' : '>', bytes);
          if (bytes < 0)
            diesys(j ? "write" : "read");
          if (j == 0 && bytes == 0)
            active[0] &= ~(1 << i);
          len[i] += (j == 1 ? -bytes : bytes);
        }
        if (j == 1 && !len[i] && !(active[0] & (1 << i)))
          active[1] &= ~(1 << i);
      }
      for (j = 0, fd = fds[i]; j < 2; j++, fd++) {
        if ((j == len[i] > 0) && (active[j] & (1 << i)))
          FD_SET(*fd, &fdset[j]);
        else
          FD_CLR(*fd, &fdset[j]);
        if (!(active[j] & (1 << i)))
          j ? shutdown(*fd, SHUT_WR) : close(*fd);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2ed3(%rip),%rax
mov    %rax,0x2eb4(%rip)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jle    1225 <main+0x55>
cmpl   $0x10,0x2e95(%rip)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1235 <main+0x65>
jmp    13a6 <main+0x1d6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x76,%eax
jne    127f <main+0xaf>
mov    0x12f42(%rip),%al
add    $0x1,%al
mov    %al,0x12f3a(%rip)
mov    0x2e58(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e4f(%rip)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x10(%rbp)
jmp    137d <main+0x1ad>
movl   $0x0,0x2e1b(%rip)
cmpl   $0x2,0x2e14(%rip)
jge    1378 <main+0x1a8>
mov    -0x10(%rbp),%rax
movslq 0x2e03(%rip),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <atoi@plt>
mov    0x2df7(%rip),%rcx
mov    %eax,(%rcx)
cmp    0x2dff(%rip),%eax
jle    12ce <main+0xfe>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2dea(%rip)
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    %eax,%edx
mov    0x2cda(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0x0,%eax
jge    132a <main+0x15a>
lea    0xcdb(%rip),%rdi
call   10b0 <diesys@plt>
mov    0x2d84(%rip),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movslq 0x2d66(%rip),%rcx
lea    0x2e3b(%rip),%rax
or     (%rax,%rcx,4),%edx
lea    0x2e31(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    0x2d4c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d43(%rip)
mov    0x2d40(%rip),%rax
add    $0x4,%rax
mov    %rax,0x2d35(%rip)
jmp    1289 <main+0xb9>
jmp    137d <main+0x1ad>
mov    0x2d31(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d28(%rip)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1209 <main+0x39>
jmp    13ab <main+0x1db>
mov    0x2dcf(%rip),%eax
or     0x2dcd(%rip),%eax
cmp    $0x0,%eax
je     184d <main+0x67d>
cmpb   $0x0,0x2cc1(%rip)
jne    140a <main+0x23a>
mov    0x2ce5(%rip),%edi
add    $0x1,%edi
lea    0x12db7(%rip),%rsi
mov    %rsi,%rdx
add    $0x4,%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   10a0 <select@plt>
cmp    $0x0,%rax
jge    1405 <main+0x235>
lea    0xc06(%rip),%rdi
call   10b0 <diesys@plt>
jmp    140a <main+0x23a>
movb   $0x0,0x2c77(%rip)
movl   $0x0,0x2c85(%rip)
lea    0x2c9e(%rip),%rax
mov    %rax,0x2c7f(%rip)
mov    0x2c71(%rip),%eax
cmp    0x2c7f(%rip),%eax
jge    1848 <main+0x678>
movl   $0x0,0x2c5f(%rip)
cmpl   $0x2,0x2c58(%rip)
jge    16d0 <main+0x500>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
movslq 0x2c42(%rip),%rax
lea    0x12d2b(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1644 <main+0x474>
cmpl   $0x1,0x2c1e(%rip)
jne    1524 <main+0x354>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
movslq 0x2c04(%rip),%rax
lea    0x2ced(%rip),%rsi
shl    $0xc,%rax
add    %rax,%rsi
movslq 0x2bef(%rip),%rcx
lea    0x2c88(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1040 <write@plt>
mov    %eax,0x2bea(%rip)
cmp    $0x0,%eax
jle    1524 <main+0x354>
movslq 0x2bca(%rip),%rax
lea    0x2cb3(%rip),%rdi
shl    $0xc,%rax
add    %rax,%rdi
movslq 0x2bb5(%rip),%rax
lea    0x2c9e(%rip),%rsi
shl    $0xc,%rax
add    %rax,%rsi
movslq 0x2bb0(%rip),%rax
add    %rax,%rsi
movslq 0x2b96(%rip),%rcx
lea    0x2c2f(%rip),%rax
mov    (%rax,%rcx,4),%edx
sub    0x2b96(%rip),%edx
call   10c0 <memmove@plt>
jmp    1552 <main+0x382>
mov    0x2b7d(%rip),%rax
mov    (%rax),%edi
movslq 0x2b6c(%rip),%rax
lea    0x2c55(%rip),%rsi
shl    $0xc,%rax
add    %rax,%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
mov    %eax,0x2b5e(%rip)
cmpb   $0x0,0x12c37(%rip)
je     159d <main+0x3cd>
mov    0x2a6a(%rip),%rax
mov    (%rax),%edi
mov    0x2b39(%rip),%rax
mov    (%rax),%edx
mov    0x2b2d(%rip),%esi
mov    $0x3e,%eax
mov    $0x3c,%ecx
cmp    $0x0,%esi
cmovne %ecx,%eax
mov    0x2b22(%rip),%r8d
lea    0xa78(%rip),%rsi
movsbl %al,%ecx
call   1090 <fprintf@plt>
cmpl   $0x0,0x2b0c(%rip)
jge    15ca <main+0x3fa>
mov    0x2af4(%rip),%ecx
lea    0xa6e(%rip),%rdi
lea    0xa61(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   10b0 <diesys@plt>
cmpl   $0x0,0x2ad3(%rip)
jne    1600 <main+0x430>
cmpl   $0x0,0x2ad2(%rip)
jne    1600 <main+0x430>
mov    0x2ab6(%rip),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    0x2b86(%rip),%eax
mov    %eax,0x2b80(%rip)
cmpl   $0x1,0x2a9d(%rip)
jne    161d <main+0x44d>
xor    %eax,%eax
sub    0x2a9b(%rip),%eax
mov    %eax,-0x20(%rbp)
jmp    1626 <main+0x456>
mov    0x2a8d(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edx
movslq 0x2a70(%rip),%rcx
lea    0x2b09(%rip),%rax
add    (%rax,%rcx,4),%edx
lea    0x2aff(%rip),%rax
mov    %edx,(%rax,%rcx,4)
cmpl   $0x1,0x2a59(%rip)
jne    16a5 <main+0x4d5>
movslq 0x2a48(%rip),%rcx
lea    0x2ae1(%rip),%rax
cmpl   $0x0,(%rax,%rcx,4)
jne    16a5 <main+0x4d5>
mov    0x2b11(%rip),%eax
mov    0x2a2b(%rip),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    16a5 <main+0x4d5>
mov    0x2a11(%rip),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    0x2ae5(%rip),%eax
mov    %eax,0x2adf(%rip)
jmp    16aa <main+0x4da>
mov    0x29f4(%rip),%eax
add    $0x1,%eax
mov    %eax,0x29eb(%rip)
mov    0x29e8(%rip),%rax
add    $0x4,%rax
mov    %rax,0x29dd(%rip)
jmp    1445 <main+0x275>
movl   $0x0,0x29ca(%rip)
movslq 0x29bf(%rip),%rcx
lea    0x29d8(%rip),%rax
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,0x29b2(%rip)
cmpl   $0x2,0x29a7(%rip)
jge    182f <main+0x65f>
mov    0x299b(%rip),%eax
movslq 0x2990(%rip),%rdx
lea    0x2a29(%rip),%rcx
cmpl   $0x0,(%rcx,%rdx,4)
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
jne    177f <main+0x5af>
movslq 0x2971(%rip),%rcx
lea    0x2a46(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    0x295d(%rip),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     177f <main+0x5af>
mov    0x294a(%rip),%rax
mov    (%rax),%edi
movslq 0x293d(%rip),%rax
lea    0x12a26(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   10f0 <FD_SET@plt>
jmp    17a2 <main+0x5d2>
mov    0x2922(%rip),%rax
mov    (%rax),%edi
movslq 0x2915(%rip),%rax
lea    0x129fe(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   10e0 <FD_CLR@plt>
movslq 0x28fb(%rip),%rcx
lea    0x29d0(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    0x28e7(%rip),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    1804 <main+0x634>
cmpl   $0x0,0x28d0(%rip)
je     17f6 <main+0x626>
mov    0x28c7(%rip),%rax
mov    (%rax),%edi
mov    0x27f6(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
jmp    1804 <main+0x634>
mov    0x28ab(%rip),%rax
mov    (%rax),%edi
call   1070 <close@plt>
jmp    1809 <main+0x639>
mov    0x2895(%rip),%eax
add    $0x1,%eax
mov    %eax,0x288c(%rip)
mov    0x2889(%rip),%rax
add    $0x4,%rax
mov    %rax,0x287e(%rip)
jmp    16f6 <main+0x526>
jmp    1834 <main+0x664>
mov    0x2866(%rip),%eax
add    $0x1,%eax
mov    %eax,0x285d(%rip)
jmp    1429 <main+0x259>
jmp    13ab <main+0x1db>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x2ede(%rip),%rax
mov    %rax,0x2ebf(%rip)
cmp    $0x3,%edi
jl     1322 <main+0x152>
mov    0x2ebc(%rip),%eax
cmp    $0xf,%eax
jg     1322 <main+0x152>
mov    %rsi,%r12
mov    %edi,%edx
add    $0x8,%r12
add    $0xffffffff,%edx
lea    0x2eac(%rip),%rbx
mov    0x2da5(%rip),%r14
mov    0x2dc6(%rip),%r15
lea    0x2f57(%rip),%r13
nopl   0x0(%rax)
mov    (%r12),%rdi
cmpb   $0x76,(%rdi)
jne    1260 <main+0x90>
addb   $0x1,0x12f51(%rip)
add    $0xffffffff,%eax
add    $0x1,%edx
add    $0xfffffffffffffff8,%r12
mov    %eax,%ecx
jmp    1304 <main+0x134>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,0x4(%rsp)
movl   $0x0,0x2e36(%rip)
xchg   %ax,%ax
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    %eax,(%rbx)
cmp    0x2e39(%rip),%eax
jle    1287 <main+0xb7>
mov    %ebp,0x2e31(%rip)
mov    0x2d3a(%rip),%rax
mov    (%rax),%ebx
mov    (%r14),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
or     (%r15),%eax
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <fcntl@plt>
test   %eax,%eax
jns    12ba <main+0xea>
lea    0xd4b(%rip),%rdi
call   10b0 <diesys@plt>
mov    0x2df4(%rip),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movslq 0x2dd6(%rip),%rax
or     %edx,0x0(%r13,%rax,4)
lea    0x1(%rax),%edx
mov    0x2dcb(%rip),%rbx
add    $0x4,%rbx
mov    %edx,0x2dbd(%rip)
mov    %rbx,0x2dba(%rip)
test   %rax,%rax
jg     1300 <main+0x130>
mov    0x8(%r12,%rax,8),%rdi
jmp    1270 <main+0xa0>
nopl   (%rax)
mov    0x4(%rsp),%edx
lea    0x1(%rcx),%eax
mov    %eax,0x2da7(%rip)
cmp    $0x4,%edx
jl     1322 <main+0x152>
add    $0xfffffffe,%edx
add    $0x10,%r12
cmp    $0xf,%ecx
jl     1230 <main+0x60>
mov    0x2e5c(%rip),%eax
or     0x2e52(%rip),%eax
je     1693 <main+0x4c3>
lea    0x12e59(%rip),%rbx
lea    0x2dfe(%rip),%rbp
lea    0x2e37(%rip),%r15
mov    0x2c90(%rip),%r14
lea    0x2e39(%rip),%r13
lea    0xcaf(%rip),%r12
jmp    1372 <main+0x1a2>
mov    0x2e1e(%rip),%eax
or     0x2e14(%rip),%eax
je     1693 <main+0x4c3>
cmpb   $0x1,0x12e17(%rip)
jne    13b0 <main+0x1e0>
mov    0x2d37(%rip),%edi
add    $0x1,%edi
mov    %rbx,%rsi
lea    0x12e0a(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <select@plt>
test   %rax,%rax
jns    13b0 <main+0x1e0>
lea    0xc62(%rip),%rdi
call   10b0 <diesys@plt>
nopl   0x0(%rax)
movb   $0x1,0x12dd9(%rip)
movl   $0x0,0x2cdf(%rip)
lea    0x2cf8(%rip),%rax
mov    %rax,0x2cd9(%rip)
cmpl   $0x0,0x2cde(%rip)
jle    1360 <main+0x190>
lea    0x2ce1(%rip),%rax
jmp    1405 <main+0x235>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ecx
mov    %ecx,0x2ca7(%rip)
cmp    0x2cb5(%rip),%ecx
jge    1360 <main+0x190>
movl   $0x0,0x2c95(%rip)
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rax),%edi
movslq %ecx,%rax
lea    (%rbx,%rax,4),%rsi
call   1050 <FD_ISSET@plt>
mov    0x2c70(%rip),%edx
test   %rax,%rax
je     155e <main+0x38e>
cmp    $0x1,%edx
jne    14a0 <main+0x2d0>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
movslq 0x2c4e(%rip),%rsi
mov    0x0(%rbp,%rsi,4),%edx
shl    $0xc,%rsi
add    %r13,%rsi
call   1040 <write@plt>
mov    %eax,0x2c48(%rip)
test   %eax,%eax
jle    14a0 <main+0x2d0>
movslq 0x2c2d(%rip),%rdi
mov    0x0(%rbp,%rdi,4),%edx
shl    $0xc,%rdi
add    %r13,%rdi
mov    %eax,%esi
add    %rdi,%rsi
sub    %eax,%edx
call   10c0 <memmove@plt>
cmpb   $0x0,0x12d00(%rip)
jne    14d0 <main+0x300>
jmp    1502 <main+0x332>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
movslq 0x2bf0(%rip),%rsi
shl    $0xc,%rsi
add    %r13,%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
mov    %eax,0x2be9(%rip)
cmpb   $0x0,0x12cc3(%rip)
je     1502 <main+0x332>
mov    0x2af9(%rip),%rax
mov    (%rax),%edi
mov    0x2bc8(%rip),%rax
xor    %ecx,%ecx
cmpl   $0x0,0x2bbb(%rip)
mov    (%rax),%edx
sete   %cl
mov    0x2bbb(%rip),%r8d
add    %ecx,%ecx
add    $0x3c,%ecx
mov    %r12,%rsi
call   1090 <fprintf@plt>
mov    0x2ba8(%rip),%eax
test   %eax,%eax
jns    1530 <main+0x360>
cmpl   $0x0,0x2b91(%rip)
lea    0xb05(%rip),%rdi
lea    0xb04(%rip),%rax
cmove  %rax,%rdi
call   10b0 <diesys@plt>
mov    0x2b80(%rip),%eax
mov    0x2b6e(%rip),%edx
movslq 0x2b63(%rip),%rcx
mov    %edx,%esi
or     %eax,%esi
jne    1550 <main+0x380>
mov    $0xfffffffe,%esi
rol    %cl,%esi
and    %esi,0x2c30(%rip)
mov    %eax,%esi
neg    %esi
cmp    $0x1,%edx
cmovne %eax,%esi
add    %esi,0x0(%rbp,%rcx,4)
cmp    $0x1,%edx
je     1590 <main+0x3c0>
lea    0x1(%rdx),%ecx
mov    %ecx,0x2b38(%rip)
mov    0x2b35(%rip),%rax
add    $0x4,%rax
mov    %rax,0x2b2a(%rip)
test   %edx,%edx
jle    1420 <main+0x250>
jmp    15c0 <main+0x3f0>
nopl   0x0(%rax,%rax,1)
movslq 0x2b09(%rip),%rcx
cmpl   $0x0,0x0(%rbp,%rcx,4)
jne    15c0 <main+0x3f0>
mov    0x2bdc(%rip),%edx
mov    $0x1,%eax
shl    %cl,%eax
bt     %ecx,%edx
jb     15c0 <main+0x3f0>
not    %eax
and    %eax,0x2bcc(%rip)
nopl   0x0(%rax,%rax,1)
movl   $0x0,0x2ada(%rip)
movslq 0x2acf(%rip),%rcx
lea    0x2ae8(%rip),%rax
lea    (%rax,%rcx,8),%rax
mov    %rax,0x2ac5(%rip)
xor    %edx,%edx
jmp    161f <main+0x44f>
call   1070 <close@plt>
nopl   0x0(%rax)
mov    0x2aae(%rip),%esi
lea    0x1(%rsi),%edx
mov    %edx,0x2aa5(%rip)
mov    0x2aa2(%rip),%rax
add    $0x4,%rax
mov    %rax,0x2a97(%rip)
mov    0x2a89(%rip),%ecx
test   %esi,%esi
jg     13f0 <main+0x220>
movslq %ecx,%rsi
xor    %edi,%edi
cmpl   $0x0,0x0(%rbp,%rsi,4)
setg   %dil
movslq %edx,%rsi
cmp    %edi,%edx
jne    1650 <main+0x480>
mov    (%r15,%rsi,4),%edx
bt     %ecx,%edx
jae    1650 <main+0x480>
mov    (%rax),%edi
lea    (%rbx,%rsi,4),%rsi
call   10f0 <FD_SET@plt>
jmp    165b <main+0x48b>
nopw   0x0(%rax,%rax,1)
mov    (%rax),%edi
lea    (%rbx,%rsi,4),%rsi
call   10e0 <FD_CLR@plt>
movslq 0x2a42(%rip),%rax
mov    (%r15,%rax,4),%ecx
mov    0x2a34(%rip),%edx
bt     %edx,%ecx
jb     15f0 <main+0x420>
mov    0x2a2c(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     15e7 <main+0x417>
mov    (%r14),%esi
call   1060 <shutdown@plt>
jmp    15f0 <main+0x420>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.i = internal global i32 0
@main.j = internal global i32 0
@main.fd = internal global i32* null
@main.bytes = internal global i32 0
@main.nfds = internal global i32 0
@main.maxfd = internal global i32 0
@main.fds = internal global [16 x [2 x i32]] zeroinitializer
@main.len = internal global [16 x i32] zeroinitializer
@main.active = internal global [2 x i32] zeroinitializer
@main.buf = internal global [16 x [4096 x i8]] zeroinitializer
@main.first = internal global i8 1
@main.verbose = internal global i8 0
@main.fdset = internal global [2 x i32] zeroinitializer
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str = [6 x i8] c"fcntl\00"
@.str.1 = [7 x i8] c"select\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"iocopy: %d %c %d\0A\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [5 x i8] c"read\00"
@SHUT_WR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), i32** @main.fd
%6 = load i32, i32* %4
%7 = add nsw i32 %6, -1
store i32 %7, i32* %4
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i32 1
store i8** %9, i8*** %5
br label %10
10: ; preds = %78, %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @main.nfds
%15 = icmp slt i32 %14, 16
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %85
18: ; preds = %16
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 118
br i1 %23, label %24, label %33
24: ; preds = %18
%25 = load i8, i8* @main.verbose
%26 = add i8 %25, 1
store i8 %26, i8* @main.verbose
%27 = load i32, i32* @main.nfds
%28 = add nsw i32 %27, -1
store i32 %28, i32* @main.nfds
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i32 -1
store i8** %32, i8*** %5
br label %78
33: ; preds = %18
store i32 0, i32* @main.j
br label %34
34: ; preds = %72, %33
%35 = load i32, i32* @main.j
%36 = icmp slt i32 %35, 2
br i1 %36, label %37, label %77
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = load i32, i32* @main.j
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
%44 = load i32*, i32** @main.fd
store i32 %43, i32* %44
%45 = load i32, i32* @main.maxfd
%46 = icmp sgt i32 %43, %45
br i1 %46, label %47, label %50
47: ; preds = %37
%48 = load i32*, i32** @main.fd
%49 = load i32, i32* %48
store i32 %49, i32* @main.maxfd
br label %50
50: ; preds = %47, %37
%51 = load i32*, i32** @main.fd
%52 = load i32, i32* %51
%53 = load i32, i32* @F_SETFL
%54 = load i32*, i32** @main.fd
%55 = load i32, i32* %54
%56 = load i32, i32* @F_GETFL
%57 = call i32 @fcntl(i32 %55, i32 %56, i32 0)
%58 = load i32, i32* @O_NONBLOCK
%59 = or i32 %57, %58
%60 = call i32 @fcntl(i32 %52, i32 %53, i32 %59)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %50
%63 = call i32 @diesys(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %64
64: ; preds = %62, %50
%65 = load i32, i32* @main.nfds
%66 = shl i32 1, %65
%67 = load i32, i32* @main.j
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = or i32 %70, %66
store i32 %71, i32* %69
br label %72
72: ; preds = %64
%73 = load i32, i32* @main.j
%74 = add nsw i32 %73, 1
store i32 %74, i32* @main.j
%75 = load i32*, i32** @main.fd
%76 = getelementptr inbounds i32, i32* %75, i32 1
store i32* %76, i32** @main.fd
br label %34
77: ; preds = %34
br label %78
78: ; preds = %77, %24
%79 = load i32, i32* @main.nfds
%80 = add nsw i32 %79, 1
store i32 %80, i32* @main.nfds
%81 = load i32, i32* %4
%82 = sub nsw i32 %81, 2
store i32 %82, i32* %4
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 2
store i8** %84, i8*** %5
br label %10
85: ; preds = %16
br label %86
86: ; preds = %312, %85
%87 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%88 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
%89 = or i32 %87, %88
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %313
91: ; preds = %86
%92 = load i8, i8* @main.first
%93 = icmp ne i8 %92, 0
br i1 %93, label %102, label %94
94: ; preds = %91
%95 = load i32, i32* @main.maxfd
%96 = add nsw i32 %95, 1
%97 = call i64 @select(i32 %96, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.fdset, i64 0, i64 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.fdset, i64 0, i64 1), i32 0, i32 0)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = call i32 @diesys(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %101
101: ; preds = %99, %94
br label %102
102: ; preds = %101, %91
store i8 0, i8* @main.first
store i32 0, i32* @main.i
store i32* getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), i32** @main.fd
br label %103
103: ; preds = %309, %102
%104 = load i32, i32* @main.i
%105 = load i32, i32* @main.nfds
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %312
107: ; preds = %103
store i32 0, i32* @main.j
br label %108
108: ; preds = %234, %107
%109 = load i32, i32* @main.j
%110 = icmp slt i32 %109, 2
br i1 %110, label %111, label %239
111: ; preds = %108
%112 = load i32*, i32** @main.fd
%113 = load i32, i32* %112
%114 = load i32, i32* @main.j
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %115
%117 = call i64 @FD_ISSET(i32 %113, i32* %116)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %212
119: ; preds = %111
%120 = load i32, i32* @main.j
%121 = icmp eq i32 %120, 1
br i1 %121, label %122, label %154
122: ; preds = %119
%123 = load i32*, i32** @main.fd
%124 = load i32, i32* %123
%125 = load i32, i32* @main.i
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %126
%128 = getelementptr inbounds [4096 x i8], [4096 x i8]* %127, i64 0, i64 0
%129 = load i32, i32* @main.i
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %130
%132 = load i32, i32* %131
%133 = call i32 @write(i32 %124, i8* %128, i32 %132)
store i32 %133, i32* @main.bytes
%134 = icmp sgt i32 %133, 0
br i1 %134, label %135, label %154
135: ; preds = %122
%136 = load i32, i32* @main.i
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %137
%139 = getelementptr inbounds [4096 x i8], [4096 x i8]* %138, i64 0, i64 0
%140 = load i32, i32* @main.i
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %141
%143 = getelementptr inbounds [4096 x i8], [4096 x i8]* %142, i64 0, i64 0
%144 = load i32, i32* @main.bytes
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = load i32, i32* @main.i
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %148
%150 = load i32, i32* %149
%151 = load i32, i32* @main.bytes
%152 = sub nsw i32 %150, %151
%153 = call i32 @memmove(i8* %139, i8* %146, i32 %152)
br label %162
154: ; preds = %122, %119
%155 = load i32*, i32** @main.fd
%156 = load i32, i32* %155
%157 = load i32, i32* @main.i
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %158
%160 = getelementptr inbounds [4096 x i8], [4096 x i8]* %159, i64 0, i64 0
%161 = call i32 @read(i32 %156, i8* %160, i32 4096)
store i32 %161, i32* @main.bytes
br label %162
162: ; preds = %154, %135
%163 = load i8, i8* @main.verbose
%164 = icmp ne i8 %163, 0
br i1 %164, label %165, label %176
165: ; preds = %162
%166 = load i32, i32* @stderr
%167 = load i32*, i32** @main.fd
%168 = load i32, i32* %167
%169 = load i32, i32* @main.j
%170 = icmp ne i32 %169, 0
%171 = zext i1 %170 to i64
%172 = select i1 %170, i32 60, i32 62
%173 = trunc i32 %172 to i8
%174 = load i32, i32* @main.bytes
%175 = call i32 @fprintf(i32 %166, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %168, i8 signext %173, i32 %174)
br label %176
176: ; preds = %165, %162
%177 = load i32, i32* @main.bytes
%178 = icmp slt i32 %177, 0
br i1 %178, label %179, label %185
179: ; preds = %176
%180 = load i32, i32* @main.j
%181 = icmp ne i32 %180, 0
%182 = zext i1 %181 to i64
%183 = select i1 %181, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
%184 = call i32 @diesys(i8* %183)
br label %185
185: ; preds = %179, %176
%186 = load i32, i32* @main.j
%187 = icmp eq i32 %186, 0
br i1 %187, label %188, label %197
188: ; preds = %185
%189 = load i32, i32* @main.bytes
%190 = icmp eq i32 %189, 0
br i1 %190, label %191, label %197
191: ; preds = %188
%192 = load i32, i32* @main.i
%193 = shl i32 1, %192
%194 = xor i32 %193, -1
%195 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%196 = and i32 %195, %194
store i32 %196, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
br label %197
197: ; preds = %191, %188, %185
%198 = load i32, i32* @main.j
%199 = icmp eq i32 %198, 1
br i1 %199, label %200, label %203
200: ; preds = %197
%201 = load i32, i32* @main.bytes
%202 = sub nsw i32 0, %201
br label %205
203: ; preds = %197
%204 = load i32, i32* @main.bytes
br label %205
205: ; preds = %203, %200
%206 = phi i32 [ %202, %200 ], [ %204, %203 ]
%207 = load i32, i32* @main.i
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %208
%210 = load i32, i32* %209
%211 = add nsw i32 %210, %206
store i32 %211, i32* %209
br label %212
212: ; preds = %205, %111
%213 = load i32, i32* @main.j
%214 = icmp eq i32 %213, 1
br i1 %214, label %215, label %233
215: ; preds = %212
%216 = load i32, i32* @main.i
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %217
%219 = load i32, i32* %218
%220 = icmp ne i32 %219, 0
br i1 %220, label %233, label %221
221: ; preds = %215
%222 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%223 = load i32, i32* @main.i
%224 = shl i32 1, %223
%225 = and i32 %222, %224
%226 = icmp ne i32 %225, 0
br i1 %226, label %233, label %227
227: ; preds = %221
%228 = load i32, i32* @main.i
%229 = shl i32 1, %228
%230 = xor i32 %229, -1
%231 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
%232 = and i32 %231, %230
store i32 %232, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
br label %233
233: ; preds = %227, %221, %215, %212
br label %234
234: ; preds = %233
%235 = load i32, i32* @main.j
%236 = add nsw i32 %235, 1
store i32 %236, i32* @main.j
%237 = load i32*, i32** @main.fd
%238 = getelementptr inbounds i32, i32* %237, i32 1
store i32* %238, i32** @main.fd
br label %108
239: ; preds = %108
store i32 0, i32* @main.j
%240 = load i32, i32* @main.i
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds [16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 %241
%243 = getelementptr inbounds [2 x i32], [2 x i32]* %242, i64 0, i64 0
store i32* %243, i32** @main.fd
br label %244
244: ; preds = %303, %239
%245 = load i32, i32* @main.j
%246 = icmp slt i32 %245, 2
br i1 %246, label %247, label %308
247: ; preds = %244
%248 = load i32, i32* @main.j
%249 = load i32, i32* @main.i
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %250
%252 = load i32, i32* %251
%253 = icmp sgt i32 %252, 0
%254 = zext i1 %253 to i32
%255 = icmp eq i32 %248, %254
br i1 %255, label %256, label %272
256: ; preds = %247
%257 = load i32, i32* @main.j
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %258
%260 = load i32, i32* %259
%261 = load i32, i32* @main.i
%262 = shl i32 1, %261
%263 = and i32 %260, %262
%264 = icmp ne i32 %263, 0
br i1 %264, label %265, label %272
265: ; preds = %256
%266 = load i32*, i32** @main.fd
%267 = load i32, i32* %266
%268 = load i32, i32* @main.j
%269 = sext i32 %268 to i64
%270 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %269
%271 = call i32 @FD_SET(i32 %267, i32* %270)
br label %279
272: ; preds = %256, %247
%273 = load i32*, i32** @main.fd
%274 = load i32, i32* %273
%275 = load i32, i32* @main.j
%276 = sext i32 %275 to i64
%277 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %276
%278 = call i32 @FD_CLR(i32 %274, i32* %277)
br label %279
279: ; preds = %272, %265
%280 = load i32, i32* @main.j
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %281
%283 = load i32, i32* %282
%284 = load i32, i32* @main.i
%285 = shl i32 1, %284
%286 = and i32 %283, %285
%287 = icmp ne i32 %286, 0
br i1 %287, label %302, label %288
288: ; preds = %279
%289 = load i32, i32* @main.j
%290 = icmp ne i32 %289, 0
br i1 %290, label %291, label %296
291: ; preds = %288
%292 = load i32*, i32** @main.fd
%293 = load i32, i32* %292
%294 = load i32, i32* @SHUT_WR
%295 = call i32 @shutdown(i32 %293, i32 %294)
br label %300
296: ; preds = %288
%297 = load i32*, i32** @main.fd
%298 = load i32, i32* %297
%299 = call i32 @close(i32 %298)
br label %300
300: ; preds = %296, %291
%301 = phi i32 [ %295, %291 ], [ %299, %296 ]
br label %302
302: ; preds = %300, %279
br label %303
303: ; preds = %302
%304 = load i32, i32* @main.j
%305 = add nsw i32 %304, 1
store i32 %305, i32* @main.j
%306 = load i32*, i32** @main.fd
%307 = getelementptr inbounds i32, i32* %306, i32 1
store i32* %307, i32** @main.fd
br label %244
308: ; preds = %244
br label %309
309: ; preds = %308
%310 = load i32, i32* @main.i
%311 = add nsw i32 %310, 1
store i32 %311, i32* @main.i
br label %103
312: ; preds = %103
br label %86
313: ; preds = %86
ret i32 0
}

LLVM IR (-O2):
@main.i = internal unnamed_addr global i32 0
@main.j = internal unnamed_addr global i32 0
@main.fd = internal unnamed_addr global i32* null
@main.bytes = internal unnamed_addr global i32 0
@main.nfds = internal unnamed_addr global i32 0
@main.maxfd = internal unnamed_addr global i32 0
@main.fds = internal global [16 x [2 x i32]] zeroinitializer
@main.len = internal unnamed_addr global [16 x i32] zeroinitializer
@main.active = internal unnamed_addr global [2 x i32] zeroinitializer
@main.buf = internal global [16 x [4096 x i8]] zeroinitializer
@main.first = internal unnamed_addr global i1 false
@main.verbose = internal unnamed_addr global i8 0
@main.fdset = internal global [2 x i32] zeroinitializer
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str = [6 x i8] c"fcntl\00"
@.str.1 = [7 x i8] c"select\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"iocopy: %d %c %d\0A\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [5 x i8] c"read\00"
@SHUT_WR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
store i32* getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), i32** @main.fd
%3 = icmp sgt i32 %0, 2
%4 = load i32, i32* @main.nfds
%5 = icmp slt i32 %4, 16
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = add nsw i32 %0, -1
br label %15
10: ; preds = %63, %2
%11 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%12 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
%13 = or i32 %12, %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %253, label %79
15: ; preds = %7, %63
%16 = phi i32* [ %65, %63 ], [ getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), %7 ]
%17 = phi i32 [ %68, %63 ], [ %4, %7 ]
%18 = phi i8** [ %70, %63 ], [ %8, %7 ]
%19 = phi i32 [ %69, %63 ], [ %9, %7 ]
%20 = load i8*, i8** %18
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 118
br i1 %22, label %23, label %29
23: ; preds = %15
%24 = load i8, i8* @main.verbose
%25 = add i8 %24, 1
store i8 %25, i8* @main.verbose
%26 = add nsw i32 %17, -1
%27 = add nuw nsw i32 %19, 1
%28 = getelementptr inbounds i8*, i8** %18, i64 -1
br label %63
29: ; preds = %15
store i32 0, i32* @main.j
br label %30
30: ; preds = %59, %29
%31 = phi i32* [ %16, %29 ], [ %57, %59 ]
%32 = phi i8* [ %20, %29 ], [ %62, %59 ]
%33 = tail call i32 @atoi(i8* %32)
store i32 %33, i32* %31
%34 = load i32, i32* @main.maxfd
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 %33, i32* @main.maxfd
br label %37
37: ; preds = %36, %30
%38 = load i32, i32* @F_SETFL
%39 = load i32, i32* @F_GETFL
%40 = tail call i32 @fcntl(i32 %33, i32 %39, i32 0)
%41 = load i32, i32* @O_NONBLOCK
%42 = or i32 %41, %40
%43 = tail call i32 @fcntl(i32 %33, i32 %38, i32 %42)
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = tail call i32 @diesys(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %47
47: ; preds = %45, %37
%48 = load i32, i32* @main.nfds
%49 = shl nuw i32 1, %48
%50 = load i32, i32* @main.j
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = or i32 %53, %49
store i32 %54, i32* %52
%55 = add nsw i32 %50, 1
store i32 %55, i32* @main.j
%56 = load i32*, i32** @main.fd
%57 = getelementptr inbounds i32, i32* %56, i64 1
store i32* %57, i32** @main.fd
%58 = icmp slt i32 %50, 1
br i1 %58, label %59, label %63
59: ; preds = %47
%60 = sext i32 %55 to i64
%61 = getelementptr inbounds i8*, i8** %18, i64 %60
%62 = load i8*, i8** %61
br label %30
63: ; preds = %47, %23
%64 = phi i32 [ %26, %23 ], [ %48, %47 ]
%65 = phi i32* [ %16, %23 ], [ %57, %47 ]
%66 = phi i32 [ %27, %23 ], [ %19, %47 ]
%67 = phi i8** [ %28, %23 ], [ %18, %47 ]
%68 = add nsw i32 %64, 1
store i32 %68, i32* @main.nfds
%69 = add nsw i32 %66, -2
%70 = getelementptr inbounds i8*, i8** %67, i64 2
%71 = icmp sgt i32 %66, 3
%72 = icmp slt i32 %64, 15
%73 = select i1 %71, i1 %72, i1 false
br i1 %73, label %15, label %10
74: ; preds = %249, %88
%75 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%76 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
%77 = or i32 %76, %75
%78 = icmp eq i32 %77, 0
br i1 %78, label %253, label %79
79: ; preds = %10, %74
%80 = load i1, i1* @main.first
br i1 %80, label %81, label %88
81: ; preds = %79
%82 = load i32, i32* @main.maxfd
%83 = add nsw i32 %82, 1
%84 = tail call i64 @select(i32 %83, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.fdset, i64 0, i64 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.fdset, i64 0, i64 1), i32 0, i32 0)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %81
%87 = tail call i32 @diesys(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %88
88: ; preds = %81, %86, %79
store i1 true, i1* @main.first
store i32 0, i32* @main.i
store i32* getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), i32** @main.fd
%89 = load i32, i32* @main.nfds
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %74
91: ; preds = %88, %249
%92 = phi i32* [ %246, %249 ], [ getelementptr inbounds ([16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 0, i64 0), %88 ]
store i32 0, i32* @main.j
br label %93
93: ; preds = %91, %190
%94 = phi i32* [ %92, %91 ], [ %193, %190 ]
%95 = phi i32 [ 0, %91 ], [ %191, %190 ]
%96 = load i32, i32* %94
%97 = sext i32 %95 to i64
%98 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %97
%99 = tail call i64 @FD_ISSET(i32 %96, i32* %98)
%100 = icmp eq i64 %99, 0
%101 = load i32, i32* @main.j
br i1 %100, label %172, label %102
102: ; preds = %93
%103 = icmp eq i32 %101, 1
br i1 %103, label %104, label %124
104: ; preds = %102
%105 = load i32*, i32** @main.fd
%106 = load i32, i32* %105
%107 = load i32, i32* @main.i
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %108, i64 0
%110 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %108
%111 = load i32, i32* %110
%112 = tail call i32 @write(i32 %106, i8* %109, i32 %111)
store i32 %112, i32* @main.bytes
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %124
114: ; preds = %104
%115 = load i32, i32* @main.i
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %116, i64 0
%118 = zext i32 %112 to i64
%119 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %116, i64 %118
%120 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %116
%121 = load i32, i32* %120
%122 = sub nsw i32 %121, %112
%123 = tail call i32 @memmove(i8* %117, i8* %119, i32 %122)
br label %131
124: ; preds = %104, %102
%125 = load i32*, i32** @main.fd
%126 = load i32, i32* %125
%127 = load i32, i32* @main.i
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [16 x [4096 x i8]], [16 x [4096 x i8]]* @main.buf, i64 0, i64 %128, i64 0
%130 = tail call i32 @read(i32 %126, i8* %129, i32 4096)
store i32 %130, i32* @main.bytes
br label %131
131: ; preds = %124, %114
%132 = load i8, i8* @main.verbose
%133 = icmp eq i8 %132, 0
br i1 %133, label %143, label %134
134: ; preds = %131
%135 = load i32, i32* @stderr
%136 = load i32*, i32** @main.fd
%137 = load i32, i32* %136
%138 = load i32, i32* @main.j
%139 = icmp eq i32 %138, 0
%140 = select i1 %139, i8 62, i8 60
%141 = load i32, i32* @main.bytes
%142 = tail call i32 @fprintf(i32 %135, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %137, i8 signext %140, i32 %141)
br label %143
143: ; preds = %134, %131
%144 = load i32, i32* @main.bytes
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %152
146: ; preds = %143
%147 = load i32, i32* @main.j
%148 = icmp eq i32 %147, 0
%149 = select i1 %148, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%150 = tail call i32 @diesys(i8* %149)
%151 = load i32, i32* @main.bytes
br label %152
152: ; preds = %146, %143
%153 = phi i32 [ %151, %146 ], [ %144, %143 ]
%154 = load i32, i32* @main.j
%155 = icmp eq i32 %154, 0
%156 = icmp eq i32 %153, 0
%157 = select i1 %155, i1 %156, i1 false
%158 = load i32, i32* @main.i
br i1 %157, label %159, label %164
159: ; preds = %152
%160 = shl nuw i32 1, %158
%161 = xor i32 %160, -1
%162 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%163 = and i32 %162, %161
store i32 %163, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
br label %164
164: ; preds = %152, %159
%165 = icmp eq i32 %154, 1
%166 = sub nsw i32 0, %153
%167 = select i1 %165, i32 %166, i32 %153
%168 = sext i32 %158 to i64
%169 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %168
%170 = load i32, i32* %169
%171 = add nsw i32 %170, %167
store i32 %171, i32* %169
br label %172
172: ; preds = %93, %164
%173 = phi i32 [ %154, %164 ], [ %101, %93 ]
%174 = icmp eq i32 %173, 1
br i1 %174, label %175, label %190
175: ; preds = %172
%176 = load i32, i32* @main.i
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %177
%179 = load i32, i32* %178
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %195
181: ; preds = %175
%182 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 0)
%183 = shl nuw i32 1, %176
%184 = and i32 %182, %183
%185 = icmp eq i32 %184, 0
br i1 %185, label %186, label %195
186: ; preds = %181
%187 = xor i32 %183, -1
%188 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
%189 = and i32 %188, %187
store i32 %189, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.active, i64 0, i64 1)
br label %195
190: ; preds = %172
%191 = add nsw i32 %173, 1
store i32 %191, i32* @main.j
%192 = load i32*, i32** @main.fd
%193 = getelementptr inbounds i32, i32* %192, i64 1
store i32* %193, i32** @main.fd
%194 = icmp slt i32 %173, 1
br i1 %194, label %93, label %195
195: ; preds = %190, %186, %181, %175
store i32 0, i32* @main.j
%196 = load i32, i32* @main.i
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds [16 x [2 x i32]], [16 x [2 x i32]]* @main.fds, i64 0, i64 %197, i64 0
store i32* %198, i32** @main.fd
br label %199
199: ; preds = %242, %195
%200 = phi i32 [ %196, %195 ], [ %248, %242 ]
%201 = phi i32* [ %198, %195 ], [ %246, %242 ]
%202 = phi i32 [ 0, %195 ], [ %244, %242 ]
%203 = sext i32 %200 to i64
%204 = getelementptr inbounds [16 x i32], [16 x i32]* @main.len, i64 0, i64 %203
%205 = load i32, i32* %204
%206 = icmp sgt i32 %205, 0
%207 = zext i1 %206 to i32
%208 = icmp eq i32 %202, %207
%209 = sext i32 %202 to i64
br i1 %208, label %210, label %220
210: ; preds = %199
%211 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %209
%212 = load i32, i32* %211
%213 = shl nuw i32 1, %200
%214 = and i32 %212, %213
%215 = icmp eq i32 %214, 0
br i1 %215, label %220, label %216
216: ; preds = %210
%217 = load i32, i32* %201
%218 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %209
%219 = tail call i32 @FD_SET(i32 %217, i32* %218)
br label %224
220: ; preds = %199, %210
%221 = load i32, i32* %201
%222 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fdset, i64 0, i64 %209
%223 = tail call i32 @FD_CLR(i32 %221, i32* %222)
br label %224
224: ; preds = %220, %216
%225 = load i32, i32* @main.j
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds [2 x i32], [2 x i32]* @main.active, i64 0, i64 %226
%228 = load i32, i32* %227
%229 = load i32, i32* @main.i
%230 = shl nuw i32 1, %229
%231 = and i32 %230, %228
%232 = icmp eq i32 %231, 0
br i1 %232, label %233, label %242
233: ; preds = %224
%234 = icmp eq i32 %225, 0
%235 = load i32*, i32** @main.fd
%236 = load i32, i32* %235
br i1 %234, label %240, label %237
237: ; preds = %233
%238 = load i32, i32* @SHUT_WR
%239 = tail call i32 @shutdown(i32 %236, i32 %238)
br label %242
240: ; preds = %233
%241 = tail call i32 @close(i32 %236)
br label %242
242: ; preds = %224, %240, %237
%243 = load i32, i32* @main.j
%244 = add nsw i32 %243, 1
store i32 %244, i32* @main.j
%245 = load i32*, i32** @main.fd
%246 = getelementptr inbounds i32, i32* %245, i64 1
store i32* %246, i32** @main.fd
%247 = icmp slt i32 %243, 1
%248 = load i32, i32* @main.i
br i1 %247, label %199, label %249
249: ; preds = %242
%250 = add nsw i32 %248, 1
store i32 %250, i32* @main.i
%251 = load i32, i32* @main.nfds
%252 = icmp slt i32 %250, %251
br i1 %252, label %91, label %74
253: ; preds = %74, %10
ret i32 0
}