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

/* Variables and functions */
scalar_t__ EWOULDBLOCK;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
scalar_t__ cl_message(char *, char **, char *, char **, char *, char **);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ sv_message(char *, char **, char *, char **, char *, char **);
scalar_t__ write(int, char *, scalar_t__);
void doproxy(int clsock, int svsock) {
  int maxsock, sockflags, closeconn;
  ssize_t nread, nwritten;
  fd_set rset, wset;
  char tosv[65535], frsv[65535], tocl[65535], frcl[65535];
  char *tosv_end, *frsv_end, *tocl_end, *frcl_end;
  sockflags = fcntl(clsock, F_GETFL, 0);
  fcntl(clsock, F_SETFL, sockflags | O_NONBLOCK);
  sockflags = fcntl(svsock, F_GETFL, 0);
  fcntl(svsock, F_SETFL, sockflags | O_NONBLOCK);
  tosv_end = tosv;
  frsv_end = frsv;
  tocl_end = tocl;
  frcl_end = frcl;
  closeconn = 0;
  if (clsock > svsock)
    maxsock = clsock + 1;
  else
    maxsock = svsock + 1;
  for (; !closeconn;) {
    FD_ZERO(&rset);
    FD_ZERO(&wset);
    if (closeconn == 0 && frcl_end < &frcl[65535])
      FD_SET(clsock, &rset);
    if (closeconn == 0 && frsv_end < &frsv[65535])
      FD_SET(svsock, &rset);
    if (tocl_end != tocl)
      FD_SET(clsock, &wset);
    if (tosv_end != tosv)
      FD_SET(svsock, &wset);
    select(maxsock, &rset, &wset, NULL, NULL);
    if (FD_ISSET(clsock, &rset)) {
      if ((nread = read(clsock, frcl_end, &frcl[65535] - frcl)) < 0) {
        if (errno != EWOULDBLOCK)
          fprintf(stderr, "read error on client socket\n");
      } else if (nread == 0) {
        fprintf(stderr, "EOF on client socket\n");
        closeconn = 1;
        close(svsock);
      } else {
        frcl_end += nread;
        while (cl_message(frcl, &frcl_end, tocl, &tocl_end, tosv, &tosv_end))
          ;
        FD_SET(svsock, &wset);
      }
    }
    if (FD_ISSET(svsock, &rset)) {
      if ((nread = read(svsock, frsv_end, &frsv[65535] - frsv)) < 0) {
        if (errno != EWOULDBLOCK)
          fprintf(stderr, "read error on server socket\n");
      } else if (nread == 0) {
        fprintf(stderr, "EOF on server socket\n");
        closeconn = 1;
        close(clsock);
      } else {
        frsv_end += nread;
        while (sv_message(frsv, &frsv_end, tocl, &tocl_end, tosv, &tosv_end))
          ;
        FD_SET(clsock, &wset);
      }
    }
    if (FD_ISSET(clsock, &wset) && ((nread = tocl_end - tocl) > 0)) {
      if ((nwritten = write(clsock, tocl, nread)) < 0) {
        if (errno != EWOULDBLOCK)
          fprintf(stderr, "Write error to client socket\n");
      } else {
        tocl_end -= nwritten;
        memcpy(tocl, (tocl + nwritten), (tocl_end - tocl));
      }
    }
    if (FD_ISSET(svsock, &wset) && ((nread = tosv_end - tosv) > 0)) {
      if ((nwritten = write(svsock, tosv, nread)) < 0) {
        if (errno != EWOULDBLOCK)
          fprintf(stderr, "Write error to server socket\n");
      } else {
        tosv_end -= nwritten;
        memcpy(tosv, (tosv + nwritten), (tosv_end - tosv));
      }
    }
  }
}


x86 assembly (clang, -O0):
<doproxy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40050,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%edx
mov    0x2deb(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    -0x8(%rbp),%edi
mov    0x2daa(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2dac(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%edx
mov    0x2db8(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
lea    -0x10030(%rbp),%rax
mov    %rax,-0x40038(%rbp)
lea    -0x20030(%rbp),%rax
mov    %rax,-0x40040(%rbp)
lea    -0x30030(%rbp),%rax
mov    %rax,-0x40048(%rbp)
lea    -0x40030(%rbp),%rax
mov    %rax,-0x40050(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1290 <doproxy+0xd0>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1299 <doproxy+0xd9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    129e <doproxy+0xde>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b4 <doproxy+0xf4>
jmp    176b <doproxy+0x5ab>
lea    -0x2c(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
lea    -0x30(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
cmpl   $0x0,-0x14(%rbp)
jne    12fa <doproxy+0x13a>
mov    -0x40050(%rbp),%rax
lea    -0x40030(%rbp),%rcx
add    $0xffff,%rcx
cmp    %rcx,%rax
jae    12fa <doproxy+0x13a>
mov    -0x4(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   10e0 <FD_SET@plt>
cmpl   $0x0,-0x14(%rbp)
jne    132e <doproxy+0x16e>
mov    -0x40040(%rbp),%rax
lea    -0x20030(%rbp),%rcx
add    $0xffff,%rcx
cmp    %rcx,%rax
jae    132e <doproxy+0x16e>
mov    -0x8(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x40048(%rbp),%rax
lea    -0x30030(%rbp),%rcx
cmp    %rcx,%rax
je     1351 <doproxy+0x191>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x40038(%rbp),%rax
lea    -0x10030(%rbp),%rcx
cmp    %rcx,%rax
je     1374 <doproxy+0x1b4>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0xc(%rbp),%edi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   10d0 <select@plt>
mov    -0x4(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14a6 <doproxy+0x2e6>
mov    -0x4(%rbp),%edi
mov    -0x40050(%rbp),%rsi
lea    -0x40030(%rbp),%rax
add    $0xffff,%rax
lea    -0x40030(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1070 <read@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    140c <doproxy+0x24c>
mov    0x2be9(%rip),%rax
mov    (%rax),%rax
mov    0x2bd7(%rip),%rcx
cmp    (%rcx),%rax
je     1407 <doproxy+0x247>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
lea    0xbfe(%rip),%rsi
call   1080 <fprintf@plt>
jmp    14a1 <doproxy+0x2e1>
cmpq   $0x0,-0x20(%rbp)
jne    1440 <doproxy+0x280>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
lea    0xbf6(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
jmp    149c <doproxy+0x2dc>
mov    -0x20(%rbp),%rax
add    -0x40050(%rbp),%rax
mov    %rax,-0x40050(%rbp)
lea    -0x40030(%rbp),%rdi
lea    -0x30030(%rbp),%rdx
lea    -0x10030(%rbp),%r8
lea    -0x40050(%rbp),%rsi
lea    -0x40048(%rbp),%rcx
lea    -0x40038(%rbp),%r9
call   10a0 <cl_message@plt>
cmp    $0x0,%rax
je     1490 <doproxy+0x2d0>
jmp    1452 <doproxy+0x292>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10e0 <FD_SET@plt>
jmp    14a1 <doproxy+0x2e1>
jmp    14a6 <doproxy+0x2e6>
mov    -0x8(%rbp),%edi
lea    -0x2c(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15c0 <doproxy+0x400>
mov    -0x8(%rbp),%edi
mov    -0x40040(%rbp),%rsi
lea    -0x20030(%rbp),%rax
add    $0xffff,%rax
lea    -0x20030(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1070 <read@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    1526 <doproxy+0x366>
mov    0x2acf(%rip),%rax
mov    (%rax),%rax
mov    0x2abd(%rip),%rcx
cmp    (%rcx),%rax
je     1521 <doproxy+0x361>
mov    0x2ac5(%rip),%rax
mov    (%rax),%edi
lea    0xb17(%rip),%rsi
call   1080 <fprintf@plt>
jmp    15bb <doproxy+0x3fb>
cmpq   $0x0,-0x20(%rbp)
jne    155a <doproxy+0x39a>
mov    0x2aa0(%rip),%rax
mov    (%rax),%edi
lea    0xb0f(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
jmp    15b6 <doproxy+0x3f6>
mov    -0x20(%rbp),%rax
add    -0x40040(%rbp),%rax
mov    %rax,-0x40040(%rbp)
lea    -0x20030(%rbp),%rdi
lea    -0x30030(%rbp),%rdx
lea    -0x10030(%rbp),%r8
lea    -0x40040(%rbp),%rsi
lea    -0x40048(%rbp),%rcx
lea    -0x40038(%rbp),%r9
call   10b0 <sv_message@plt>
cmp    $0x0,%rax
je     15aa <doproxy+0x3ea>
jmp    156c <doproxy+0x3ac>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10e0 <FD_SET@plt>
jmp    15bb <doproxy+0x3fb>
jmp    15c0 <doproxy+0x400>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1693 <doproxy+0x4d3>
mov    -0x40048(%rbp),%rax
lea    -0x30030(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jle    1693 <doproxy+0x4d3>
mov    -0x4(%rbp),%edi
lea    -0x30030(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <write@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jge    164a <doproxy+0x48a>
mov    0x29ab(%rip),%rax
mov    (%rax),%rax
mov    0x2999(%rip),%rcx
cmp    (%rcx),%rax
je     1645 <doproxy+0x485>
mov    0x29a1(%rip),%rax
mov    (%rax),%edi
lea    0xa26(%rip),%rsi
call   1080 <fprintf@plt>
jmp    168e <doproxy+0x4ce>
mov    -0x28(%rbp),%rdx
mov    -0x40048(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x40048(%rbp)
lea    -0x30030(%rbp),%rdi
lea    -0x30030(%rbp),%rsi
add    -0x28(%rbp),%rsi
mov    -0x40048(%rbp),%rax
lea    -0x30030(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
jmp    1693 <doproxy+0x4d3>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1766 <doproxy+0x5a6>
mov    -0x40038(%rbp),%rax
lea    -0x10030(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jle    1766 <doproxy+0x5a6>
mov    -0x8(%rbp),%edi
lea    -0x10030(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <write@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jge    171d <doproxy+0x55d>
mov    0x28d8(%rip),%rax
mov    (%rax),%rax
mov    0x28c6(%rip),%rcx
cmp    (%rcx),%rax
je     1718 <doproxy+0x558>
mov    0x28ce(%rip),%rax
mov    (%rax),%edi
lea    0x971(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1761 <doproxy+0x5a1>
mov    -0x28(%rbp),%rdx
mov    -0x40038(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x40038(%rbp)
lea    -0x10030(%rbp),%rdi
lea    -0x10030(%rbp),%rsi
add    -0x28(%rbp),%rsi
mov    -0x40038(%rbp),%rax
lea    -0x10030(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
jmp    1766 <doproxy+0x5a6>
jmp    129e <doproxy+0xde>
add    $0x40050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doproxy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40048,%rsp
mov    %esi,%r15d
mov    %edi,%ebx
mov    0x2ddb(%rip),%r14
mov    (%r14),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x2de2(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2df0(%rip),%r12
or     (%r12),%eax
mov    %ebx,%edi
mov    %eax,%edx
call   1030 <fcntl@plt>
mov    (%r14),%esi
mov    %r15d,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x0(%rbp),%esi
or     (%r12),%eax
mov    %ebx,%r14d
mov    %r15d,%edi
mov    %eax,%edx
call   1030 <fcntl@plt>
lea    0x30040(%rsp),%rcx
mov    %rcx,0x18(%rsp)
lea    0x10040(%rsp),%rax
mov    %rax,0x28(%rsp)
lea    0x20040(%rsp),%r13
mov    %r13,0x10(%rsp)
lea    0x40(%rsp),%r12
mov    %r12,0x20(%rsp)
cmp    %r15d,%ebx
mov    %r15d,(%rsp)
cmovg  %ebx,%r15d
add    $0x1,%r15d
mov    %r15d,0x34(%rsp)
mov    %rcx,%r15
lea    0xc(%rsp),%rbp
mov    %ebx,0x8(%rsp)
jmp    12ab <doproxy+0xeb>
nopl   0x0(%rax)
mov    0x18(%rsp),%rdx
sub    %rax,%rdx
mov    %rdx,0x18(%rsp)
lea    (%rsp,%rax,1),%rsi
add    $0x30040,%rsi
sub    %r15d,%edx
mov    %r15,%rdi
call   1090 <memcpy@plt>
test   %ebx,%ebx
jne    163f <doproxy+0x47f>
mov    %rbp,%rdi
call   10c0 <FD_ZERO@plt>
lea    0x4(%rsp),%rdi
call   10c0 <FD_ZERO@plt>
lea    0x1003f(%rsp),%rax
cmp    %rax,0x20(%rsp)
jae    12d7 <doproxy+0x117>
mov    %r14d,%edi
mov    %rbp,%rsi
call   10e0 <FD_SET@plt>
lea    0x2003f(%rsp),%rax
cmp    %rax,0x28(%rsp)
jae    12f1 <doproxy+0x131>
mov    (%rsp),%edi
mov    %rbp,%rsi
call   10e0 <FD_SET@plt>
cmp    %r13,0x10(%rsp)
je     1305 <doproxy+0x145>
mov    %r14d,%edi
lea    0x4(%rsp),%rsi
call   10e0 <FD_SET@plt>
cmp    %r15,0x18(%rsp)
lea    0x4(%rsp),%r14
je     131c <doproxy+0x15c>
mov    (%rsp),%edi
mov    %r14,%rsi
call   10e0 <FD_SET@plt>
xor    %ebx,%ebx
mov    0x34(%rsp),%edi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
mov    %rbp,%rsi
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     13f0 <doproxy+0x230>
mov    0x20(%rsp),%rsi
mov    %ebp,%edi
mov    $0xffff,%edx
call   1070 <read@plt>
test   %rax,%rax
js     13c0 <doproxy+0x200>
je     153d <doproxy+0x37d>
add    %rax,0x20(%rsp)
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%rbx
lea    0x20(%rsp),%rbp
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %rbx,%r9
call   10a0 <cl_message@plt>
test   %rax,%rax
jne    1380 <doproxy+0x1c0>
mov    (%rsp),%r14d
mov    %r14d,%edi
lea    0x4(%rsp),%rsi
call   10e0 <FD_SET@plt>
lea    0x40(%rsp),%r12
xor    %ebx,%ebx
jmp    13f4 <doproxy+0x234>
cs nopw 0x0(%rax,%rax,1)
mov    0x2c01(%rip),%rax
mov    (%rax),%rax
mov    0x2bef(%rip),%rcx
cmp    (%rcx),%rax
je     13f0 <doproxy+0x230>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    0xc1a(%rip),%rsi
call   1080 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%r14d
mov    %r14d,%edi
lea    0xc(%rsp),%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     14d0 <doproxy+0x310>
mov    0x28(%rsp),%rsi
mov    %r14d,%edi
mov    $0xffff,%edx
call   1070 <read@plt>
test   %rax,%rax
js     14a0 <doproxy+0x2e0>
je     1568 <doproxy+0x3a8>
mov    %rbx,0x38(%rsp)
add    %rax,0x28(%rsp)
lea    0x10040(%rsp),%r12
lea    0x28(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0x18(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
mov    %rbp,%r9
call   10b0 <sv_message@plt>
test   %rax,%rax
jne    1450 <doproxy+0x290>
mov    0x8(%rsp),%r14d
mov    %r14d,%edi
lea    0x4(%rsp),%rbx
mov    %rbx,%rsi
call   10e0 <FD_SET@plt>
mov    %rbx,%rsi
lea    0x40(%rsp),%r12
mov    0x38(%rsp),%rbx
lea    0xc(%rsp),%rbp
jmp    14df <doproxy+0x31f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2b21(%rip),%rax
mov    (%rax),%rax
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%rax
je     14d0 <doproxy+0x310>
mov    0x2b1b(%rip),%rax
mov    (%rax),%edi
lea    0xb6d(%rip),%rsi
call   1080 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
lea    0xc(%rsp),%rbp
lea    0x4(%rsp),%rsi
mov    0x8(%rsp),%r14d
mov    %r14d,%edi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     15d0 <doproxy+0x410>
mov    0x10(%rsp),%rdx
sub    %r13,%rdx
test   %rdx,%rdx
jle    15d0 <doproxy+0x410>
mov    %r14d,%edi
mov    %r13,%rsi
call   1040 <write@plt>
test   %rax,%rax
js     15a2 <doproxy+0x3e2>
mov    0x10(%rsp),%rdx
sub    %rax,%rdx
mov    %rdx,0x10(%rsp)
lea    (%rsp,%rax,1),%rsi
add    $0x20040,%rsi
sub    %r13d,%edx
mov    %r13,%rdi
call   1090 <memcpy@plt>
jmp    15d0 <doproxy+0x410>
mov    0x2a94(%rip),%rax
mov    (%rax),%edi
lea    0xad0(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%rsp),%r14d
mov    %r14d,%edi
call   1060 <close@plt>
mov    $0x1,%ebx
jmp    13f4 <doproxy+0x234>
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
lea    0xad8(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x1,%ebx
lea    0xc(%rsp),%rax
mov    %ebp,%r14d
mov    %rax,%rbp
lea    0x4(%rsp),%rsi
jmp    14df <doproxy+0x31f>
mov    0x2a1f(%rip),%rax
mov    (%rax),%rax
mov    0x2a0d(%rip),%rcx
cmp    (%rcx),%rax
je     15d0 <doproxy+0x410>
mov    0x2a19(%rip),%rax
mov    (%rax),%edi
lea    0xa9e(%rip),%rsi
call   1080 <fprintf@plt>
nopl   (%rax)
mov    (%rsp),%edi
lea    0x4(%rsp),%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     12a3 <doproxy+0xe3>
mov    0x18(%rsp),%rdx
sub    %r15,%rdx
test   %rdx,%rdx
jle    12a3 <doproxy+0xe3>
mov    (%rsp),%edi
mov    %r15,%rsi
call   1040 <write@plt>
test   %rax,%rax
jns    1280 <doproxy+0xc0>
mov    0x29b6(%rip),%rax
mov    (%rax),%rax
mov    0x29a4(%rip),%rcx
cmp    (%rcx),%rax
je     12a3 <doproxy+0xe3>
mov    0x29ac(%rip),%rax
mov    (%rax),%edi
lea    0xa4f(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12a3 <doproxy+0xe3>
add    $0x40048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i64 0
@EWOULDBLOCK = global i64 0
@stderr = global i32 0
@.str = [29 x i8] c"read error on client socket\0A\00"
@.str.1 = [22 x i8] c"EOF on client socket\0A\00"
@.str.2 = [29 x i8] c"read error on server socket\0A\00"
@.str.3 = [22 x i8] c"EOF on server socket\0A\00"
@.str.4 = [30 x i8] c"Write error to client socket\0A\00"
@.str.5 = [30 x i8] c"Write error to server socket\0A\00"
define void @doproxy(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [65535 x i8]
%6 = alloca [65535 x i8]
%7 = alloca [65535 x i8]
%8 = alloca [65535 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [65535 x i8], [65535 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [65535 x i8], [65535 x i8]* %7, i64 0, i64 0
%18 = getelementptr inbounds [65535 x i8], [65535 x i8]* %8, i64 0, i64 0
%19 = bitcast i8** %9 to i8*
%20 = bitcast i8** %10 to i8*
%21 = bitcast i8** %11 to i8*
%22 = bitcast i8** %12 to i8*
%23 = load i32, i32* @F_GETFL
%24 = tail call i32 @fcntl(i32 %0, i32 %23, i32 0)
%25 = load i32, i32* @F_SETFL
%26 = load i32, i32* @O_NONBLOCK
%27 = or i32 %26, %24
%28 = tail call i32 @fcntl(i32 %0, i32 %25, i32 %27)
%29 = load i32, i32* @F_GETFL
%30 = tail call i32 @fcntl(i32 %1, i32 %29, i32 0)
%31 = load i32, i32* @F_SETFL
%32 = load i32, i32* @O_NONBLOCK
%33 = or i32 %32, %30
%34 = tail call i32 @fcntl(i32 %1, i32 %31, i32 %33)
store i8* %15, i8** %9
store i8* %16, i8** %10
store i8* %17, i8** %11
store i8* %18, i8** %12
%35 = icmp sgt i32 %0, %1
%36 = select i1 %35, i32 %0, i32 %1
%37 = add nsw i32 %36, 1
%38 = getelementptr inbounds [65535 x i8], [65535 x i8]* %8, i64 0, i64 65535
%39 = getelementptr inbounds [65535 x i8], [65535 x i8]* %6, i64 0, i64 65535
%40 = ptrtoint [65535 x i8]* %7 to i64
%41 = ptrtoint [65535 x i8]* %5 to i64
br label %42
42: ; preds = %2, %177
%43 = call i32 @FD_ZERO(i32* %3)
%44 = call i32 @FD_ZERO(i32* %4)
%45 = load i8*, i8** %12
%46 = icmp ult i8* %45, %38
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @FD_SET(i32 %0, i32* %3)
br label %49
49: ; preds = %47, %42
%50 = load i8*, i8** %10
%51 = icmp ult i8* %50, %39
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @FD_SET(i32 %1, i32* %3)
br label %54
54: ; preds = %52, %49
%55 = load i8*, i8** %11
%56 = icmp eq i8* %55, %17
br i1 %56, label %59, label %57
57: ; preds = %54
%58 = call i32 @FD_SET(i32 %0, i32* %4)
br label %59
59: ; preds = %57, %54
%60 = load i8*, i8** %9
%61 = icmp eq i8* %60, %15
br i1 %61, label %64, label %62
62: ; preds = %59
%63 = call i32 @FD_SET(i32 %1, i32* %4)
br label %64
64: ; preds = %62, %59
%65 = call i32 @select(i32 %37, i32* %3, i32* %4, i32* null, i32* null)
%66 = call i64 @FD_ISSET(i32 %0, i32* %3)
%67 = icmp eq i64 %66, 0
br i1 %67, label %93, label %68
68: ; preds = %64
%69 = load i8*, i8** %12
%70 = call i64 @read(i32 %0, i8* %69, i32 65535)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %79
72: ; preds = %68
%73 = load i64, i64* @errno
%74 = load i64, i64* @EWOULDBLOCK
%75 = icmp eq i64 %73, %74
br i1 %75, label %93, label %76
76: ; preds = %72
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %93
79: ; preds = %68
%80 = icmp eq i64 %70, 0
br i1 %80, label %81, label %85
81: ; preds = %79
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%84 = call i32 @close(i32 %1)
br label %93
85: ; preds = %79
%86 = load i8*, i8** %12
%87 = getelementptr inbounds i8, i8* %86, i64 %70
store i8* %87, i8** %12
br label %88
88: ; preds = %88, %85
%89 = call i64 @cl_message(i8* %18, i8** %12, i8* %17, i8** %11, i8* %15, i8** %9)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %88
91: ; preds = %88
%92 = call i32 @FD_SET(i32 %1, i32* %4)
br label %93
93: ; preds = %76, %72, %91, %81, %64
%94 = phi i32 [ 0, %76 ], [ 0, %72 ], [ 1, %81 ], [ 0, %91 ], [ 0, %64 ]
%95 = call i64 @FD_ISSET(i32 %1, i32* %3)
%96 = icmp eq i64 %95, 0
br i1 %96, label %122, label %97
97: ; preds = %93
%98 = load i8*, i8** %10
%99 = call i64 @read(i32 %1, i8* %98, i32 65535)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %108
101: ; preds = %97
%102 = load i64, i64* @errno
%103 = load i64, i64* @EWOULDBLOCK
%104 = icmp eq i64 %102, %103
br i1 %104, label %122, label %105
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %122
108: ; preds = %97
%109 = icmp eq i64 %99, 0
br i1 %109, label %110, label %114
110: ; preds = %108
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%113 = call i32 @close(i32 %0)
br label %122
114: ; preds = %108
%115 = load i8*, i8** %10
%116 = getelementptr inbounds i8, i8* %115, i64 %99
store i8* %116, i8** %10
br label %117
117: ; preds = %117, %114
%118 = call i64 @sv_message(i8* %16, i8** %10, i8* %17, i8** %11, i8* %15, i8** %9)
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %117
120: ; preds = %117
%121 = call i32 @FD_SET(i32 %0, i32* %4)
br label %122
122: ; preds = %105, %101, %120, %110, %93
%123 = phi i32 [ %94, %105 ], [ %94, %101 ], [ 1, %110 ], [ %94, %120 ], [ %94, %93 ]
%124 = call i64 @FD_ISSET(i32 %0, i32* %4)
%125 = icmp eq i64 %124, 0
br i1 %125, label %150, label %126
126: ; preds = %122
%127 = load i8*, i8** %11
%128 = ptrtoint i8* %127 to i64
%129 = sub i64 %128, %40
%130 = icmp sgt i64 %129, 0
br i1 %130, label %131, label %150
131: ; preds = %126
%132 = call i64 @write(i32 %0, i8* %17, i64 %129)
%133 = icmp slt i64 %132, 0
br i1 %133, label %134, label %141
134: ; preds = %131
%135 = load i64, i64* @errno
%136 = load i64, i64* @EWOULDBLOCK
%137 = icmp eq i64 %135, %136
br i1 %137, label %150, label %138
138: ; preds = %134
%139 = load i32, i32* @stderr
%140 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %150
141: ; preds = %131
%142 = load i8*, i8** %11
%143 = sub nsw i64 0, %132
%144 = getelementptr inbounds i8, i8* %142, i64 %143
store i8* %144, i8** %11
%145 = getelementptr inbounds [65535 x i8], [65535 x i8]* %7, i64 0, i64 %132
%146 = ptrtoint i8* %144 to i64
%147 = sub i64 %146, %40
%148 = trunc i64 %147 to i32
%149 = call i32 @memcpy(i8* %17, i8* %145, i32 %148)
br label %150
150: ; preds = %141, %138, %134, %126, %122
%151 = call i64 @FD_ISSET(i32 %1, i32* %4)
%152 = icmp eq i64 %151, 0
br i1 %152, label %177, label %153
153: ; preds = %150
%154 = load i8*, i8** %9
%155 = ptrtoint i8* %154 to i64
%156 = sub i64 %155, %41
%157 = icmp sgt i64 %156, 0
br i1 %157, label %158, label %177
158: ; preds = %153
%159 = call i64 @write(i32 %1, i8* %15, i64 %156)
%160 = icmp slt i64 %159, 0
br i1 %160, label %161, label %168
161: ; preds = %158
%162 = load i64, i64* @errno
%163 = load i64, i64* @EWOULDBLOCK
%164 = icmp eq i64 %162, %163
br i1 %164, label %177, label %165
165: ; preds = %161
%166 = load i32, i32* @stderr
%167 = call i32 @fprintf(i32 %166, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %177
168: ; preds = %158
%169 = load i8*, i8** %9
%170 = sub nsw i64 0, %159
%171 = getelementptr inbounds i8, i8* %169, i64 %170
store i8* %171, i8** %9
%172 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 %159
%173 = ptrtoint i8* %171 to i64
%174 = sub i64 %173, %41
%175 = trunc i64 %174 to i32
%176 = call i32 @memcpy(i8* %15, i8* %172, i32 %175)
br label %177
177: ; preds = %168, %165, %161, %153, %150
%178 = icmp eq i32 %123, 0
br i1 %178, label %42, label %179
179: ; preds = %177
ret void
}