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

/* Variables and functions */
scalar_t__ EWOULDBLOCK;
int /*<<< orphan*/ EXIT_FAILURE;
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;
int /*<<< orphan*/ SHUT_WR;
int STDIN_FILENO;
int STDOUT_FILENO;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
char *gf_time();
int max(int, int);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
void str_cli(FILE *fp, int sockfd) {
  int n, nread, nwritten;
  int val, stdineof, maxfd;
  char *toiptr, *tooptr;
  char *friptr, *froptr;
  char to[1024], fr[1024];
  fd_set rset, wset;
  val = fcntl(sockfd, F_GETFL, 0);
  fcntl(sockfd, F_SETFL, val | O_NONBLOCK);
  val = fcntl(STDIN_FILENO, F_GETFL, 0);
  fcntl(STDIN_FILENO, F_SETFL, val | O_NONBLOCK);
  val = fcntl(STDOUT_FILENO, F_GETFL, 0);
  fcntl(STDOUT_FILENO, F_SETFL, val | O_NONBLOCK);
  toiptr = tooptr = to;
  friptr = froptr = fr;
  stdineof = 0;
  maxfd = max(max(STDIN_FILENO, STDOUT_FILENO), sockfd) + 1;
  while (1) {
    FD_ZERO(&rset);
    FD_ZERO(&wset);
    if (0 == stdineof && toiptr < &to[1024]) {
      FD_SET(STDIN_FILENO, &rset);
    }
    if (friptr < &fr[1024]) {
      FD_SET(sockfd, &rset);
    }
    if (tooptr != toiptr) {
      FD_SET(sockfd, &wset);
    }
    if (froptr != friptr) {
      FD_SET(STDOUT_FILENO, &wset);
    }
    select(maxfd, &rset, &wset, NULL, NULL);
    if (FD_ISSET(STDIN_FILENO, &rset)) {
      if ((nread = read(STDIN_FILENO, toiptr, &to[1024] - toiptr)) < 0) {
        if (EWOULDBLOCK != errno) {
          printf("read error on stdin\n");
          exit(EXIT_FAILURE);
        }
      } else if (0 == nread) {
        fprintf(stderr, "%s, EOF on stdin\n", gf_time());
        stdineof = 1;
        if (tooptr == toiptr) {
          shutdown(sockfd, SHUT_WR);
        }
      } else {
        fprintf(stderr, "%s : read %d bytes from stdin\n", gf_time(), nread);
        toiptr += nread;
        FD_SET(sockfd, &wset);
      }
    }
    if (FD_ISSET(sockfd, &rset)) {
      if ((nread = read(sockfd, friptr, &fr[1024] - friptr)) < 0) {
        if (EWOULDBLOCK != errno) {
          printf("read error on socket\n");
          exit(EXIT_FAILURE);
        }
      } else if (0 == nread) {
        fprintf(stderr, "%s, EOF on socket\n", gf_time());
        if (stdineof) {
          return;
        } else {
          printf("str_cli : server terminated prematurely\n");
          exit(EXIT_FAILURE);
        }
      } else {
        fprintf(stderr, "%s : read %d bytes from socket\n", gf_time(), nread);
        friptr += nread;
        FD_SET(STDOUT_FILENO, &wset);
      }
    }
    if (FD_ISSET(STDOUT_FILENO, &wset) && (n = friptr - froptr) > 0) {
      if ((nwritten = write(STDOUT_FILENO, froptr, n)) < 0) {
        if (EWOULDBLOCK != errno) {
          printf("write error to stdout\n");
          exit(EXIT_FAILURE);
        }
      } else {
        fprintf(stderr, "%s wrote %d bytes to stdout\n", gf_time(), nwritten);
        froptr += nwritten;
        if (froptr == friptr) {
          froptr = friptr = fr;
        }
      }
    }
    if (FD_ISSET(sockfd, &wset) && (n = toiptr - tooptr) > 0) {
      if ((nwritten = write(sockfd, tooptr, n)) < 0) {
        if (EWOULDBLOCK != errno) {
          printf("write error to sockfd\n");
          exit(EXIT_FAILURE);
        }
      } else {
        fprintf(stderr, "%s wrote %d bytes to stdout\n", gf_time(), nwritten);
        tooptr += nwritten;
        if (tooptr == toiptr) {
          tooptr = toiptr = to;
          if (stdineof) {
            shutdown(sockfd, SHUT_WR);
          }
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<str_cli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%edx
mov    0x2dd2(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    0x2d83(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%edx
mov    0x2d93(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%edx
mov    0x2d54(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
lea    -0x450(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    %rax,-0x30(%rbp)
lea    -0x850(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
call   1080 <max@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1080 <max@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    -0x854(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
lea    -0x858(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%eax
jne    1332 <str_cli+0x162>
mov    -0x30(%rbp),%rax
lea    -0x450(%rbp),%rcx
add    $0x400,%rcx
cmp    %rcx,%rax
jae    1332 <str_cli+0x162>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    -0x854(%rbp),%rsi
call   10f0 <FD_SET@plt>
mov    -0x40(%rbp),%rax
lea    -0x850(%rbp),%rcx
add    $0x400,%rcx
cmp    %rcx,%rax
jae    135c <str_cli+0x18c>
mov    -0xc(%rbp),%edi
lea    -0x854(%rbp),%rsi
call   10f0 <FD_SET@plt>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1379 <str_cli+0x1a9>
mov    -0xc(%rbp),%edi
lea    -0x858(%rbp),%rsi
call   10f0 <FD_SET@plt>
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
je     139c <str_cli+0x1cc>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    -0x858(%rbp),%rsi
call   10f0 <FD_SET@plt>
mov    -0x24(%rbp),%edi
lea    -0x854(%rbp),%rsi
lea    -0x858(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   10c0 <select@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
lea    -0x854(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1503 <str_cli+0x333>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
lea    -0x450(%rbp),%rax
add    $0x400,%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1090 <read@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1446 <str_cli+0x276>
mov    0x2b9c(%rip),%rax
mov    (%rax),%rax
mov    0x2b9a(%rip),%rcx
cmp    (%rcx),%rax
je     1441 <str_cli+0x271>
lea    0xbd2(%rip),%rdi
call   1070 <printf@plt>
mov    0x2b66(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    14fe <str_cli+0x32e>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    14a9 <str_cli+0x2d9>
mov    0x2b70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x85c(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x85c(%rbp),%edi
mov    %rax,%rdx
lea    0xb9e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    14a4 <str_cli+0x2d4>
mov    -0xc(%rbp),%edi
mov    0x2b3b(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
jmp    14f9 <str_cli+0x329>
mov    0x2b18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x860(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x860(%rbp),%edi
mov    %rax,%rdx
mov    -0x14(%rbp),%ecx
lea    0xb55(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x858(%rbp),%rsi
call   10f0 <FD_SET@plt>
jmp    14fe <str_cli+0x32e>
jmp    1503 <str_cli+0x333>
mov    -0xc(%rbp),%edi
lea    -0x854(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1648 <str_cli+0x478>
mov    -0xc(%rbp),%edi
mov    -0x40(%rbp),%rsi
lea    -0x850(%rbp),%rax
add    $0x400,%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1090 <read@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1583 <str_cli+0x3b3>
mov    0x2a5f(%rip),%rax
mov    (%rax),%rax
mov    0x2a5d(%rip),%rcx
cmp    (%rcx),%rax
je     157e <str_cli+0x3ae>
lea    0xadb(%rip),%rdi
call   1070 <printf@plt>
mov    0x2a29(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1643 <str_cli+0x473>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    15e8 <str_cli+0x418>
mov    0x2a33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x864(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x864(%rbp),%edi
mov    %rax,%rdx
lea    0xaa8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpl   $0x0,-0x20(%rbp)
je     15ce <str_cli+0x3fe>
add    $0x870,%rsp
pop    %rbp
ret
lea    0xa9a(%rip),%rdi
call   1070 <printf@plt>
mov    0x29bf(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x29d9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x868(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x868(%rbp),%edi
mov    %rax,%rdx
mov    -0x14(%rbp),%ecx
lea    0xa87(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    0x29c0(%rip),%rax
mov    (%rax),%edi
lea    -0x858(%rbp),%rsi
call   10f0 <FD_SET@plt>
jmp    1643 <str_cli+0x473>
jmp    1648 <str_cli+0x478>
mov    0x29a1(%rip),%rax
mov    (%rax),%edi
lea    -0x858(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1740 <str_cli+0x570>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    1740 <str_cli+0x570>
mov    0x296b(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    16d8 <str_cli+0x508>
mov    0x290a(%rip),%rax
mov    (%rax),%rax
mov    0x2908(%rip),%rcx
cmp    (%rcx),%rax
je     16d3 <str_cli+0x503>
lea    0x9f8(%rip),%rdi
call   1070 <printf@plt>
mov    0x28d4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    173b <str_cli+0x56b>
mov    0x28e9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x86c(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x86c(%rbp),%edi
mov    %rax,%rdx
mov    -0x18(%rbp),%ecx
lea    0x9ce(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    1736 <str_cli+0x566>
lea    -0x850(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    %rax,-0x48(%rbp)
jmp    173b <str_cli+0x56b>
jmp    1740 <str_cli+0x570>
mov    -0xc(%rbp),%edi
lea    -0x858(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     184c <str_cli+0x67c>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    184c <str_cli+0x67c>
mov    -0xc(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    17c4 <str_cli+0x5f4>
mov    0x281e(%rip),%rax
mov    (%rax),%rax
mov    0x281c(%rip),%rcx
cmp    (%rcx),%rax
je     17bf <str_cli+0x5ef>
lea    0x940(%rip),%rdi
call   1070 <printf@plt>
mov    0x27e8(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    1847 <str_cli+0x677>
mov    0x27fd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x870(%rbp)
mov    $0x0,%al
call   10d0 <gf_time@plt>
mov    -0x870(%rbp),%edi
mov    %rax,%rdx
mov    -0x18(%rbp),%ecx
lea    0x8e2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1842 <str_cli+0x672>
lea    -0x450(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     183d <str_cli+0x66d>
mov    -0xc(%rbp),%edi
mov    0x27a2(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
jmp    1842 <str_cli+0x672>
jmp    1847 <str_cli+0x677>
jmp    184c <str_cli+0x67c>
jmp    12df <str_cli+0x10f>

x86 assembly (clang, -O2):
<str_cli>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %esi,%ebp
mov    0x2dbe(%rip),%r14
mov    (%r14),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    0x2dc3(%rip),%r13
mov    0x0(%r13),%esi
mov    0x2dd8(%rip),%r15
or     (%r15),%eax
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <fcntl@plt>
mov    0x2d7d(%rip),%r12
mov    (%r12),%edi
mov    (%r14),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    (%r12),%edi
mov    0x0(%r13),%esi
or     (%r15),%eax
mov    %eax,%edx
call   1040 <fcntl@plt>
mov    0x2dae(%rip),%rbx
mov    (%rbx),%edi
mov    (%r14),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    (%rbx),%edi
mov    0x0(%r13),%esi
or     (%r15),%eax
mov    %eax,%edx
call   1040 <fcntl@plt>
mov    (%r12),%edi
mov    (%rbx),%esi
call   1080 <max@plt>
mov    %eax,%edi
mov    %ebp,(%rsp)
mov    %ebp,%esi
call   1080 <max@plt>
add    $0x1,%eax
mov    %eax,0x1c(%rsp)
lea    0x4(%rsp),%rbp
movl   $0x0,0x8(%rsp)
lea    0x20(%rsp),%r13
mov    %r13,%r14
mov    %r12,%r15
lea    0x420(%rsp),%rax
mov    %rax,%r12
mov    %rax,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xc(%rsp),%rdi
call   10b0 <FD_ZERO@plt>
mov    %rbp,%rdi
call   10b0 <FD_ZERO@plt>
cmpl   $0x0,0x8(%rsp)
jne    12e3 <str_cli+0x113>
lea    0x420(%rsp),%rax
cmp    %rax,%r14
jae    12e3 <str_cli+0x113>
mov    (%r15),%edi
lea    0xc(%rsp),%rsi
call   10f0 <FD_SET@plt>
lea    0x820(%rsp),%rax
cmp    %rax,%r12
jae    12fd <str_cli+0x12d>
mov    (%rsp),%edi
lea    0xc(%rsp),%rsi
call   10f0 <FD_SET@plt>
cmp    %r14,%r13
je     130d <str_cli+0x13d>
mov    (%rsp),%edi
mov    %rbp,%rsi
call   10f0 <FD_SET@plt>
cmp    %r12,0x10(%rsp)
je     131e <str_cli+0x14e>
mov    (%rbx),%edi
mov    %rbp,%rsi
call   10f0 <FD_SET@plt>
mov    0x1c(%rsp),%edi
mov    %rbp,%rdx
lea    0xc(%rsp),%rbp
mov    %rbp,%rsi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10c0 <select@plt>
mov    (%r15),%edi
mov    %rbp,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     140a <str_cli+0x23a>
mov    %r15,%rbp
mov    (%r15),%edi
lea    0x420(%rsp),%rax
mov    %eax,%edx
sub    %r14d,%edx
mov    %r14,%rsi
call   1090 <read@plt>
test   %eax,%eax
js     13b0 <str_cli+0x1e0>
mov    %eax,%r15d
mov    0x2c54(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   10d0 <gf_time@plt>
mov    %ebx,%edi
test   %r15d,%r15d
je     13ce <str_cli+0x1fe>
lea    0xc87(%rip),%rsi
mov    %rax,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r15d,%eax
add    %rax,%r14
mov    (%rsp),%edi
lea    0x4(%rsp),%rsi
call   10f0 <FD_SET@plt>
jmp    1400 <str_cli+0x230>
nopl   (%rax)
mov    0x2bf9(%rip),%rax
mov    (%rax),%rax
mov    0x2bf7(%rip),%rcx
cmp    (%rcx),%rax
mov    %rbp,%r15
je     140a <str_cli+0x23a>
jmp    168c <str_cli+0x4bc>
lea    0xc2b(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
movl   $0x1,0x8(%rsp)
cmp    %r14,%r13
jne    1400 <str_cli+0x230>
mov    0x2be5(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edi
call   1070 <shutdown@plt>
nopl   (%rax)
mov    %rbp,%r15
mov    0x2be6(%rip),%rbx
mov    (%rsp),%ebp
mov    %ebp,%edi
lea    0xc(%rsp),%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1490 <str_cli+0x2c0>
lea    0x820(%rsp),%rax
mov    %eax,%edx
sub    %r12d,%edx
mov    %ebp,%edi
mov    %r12,%rsi
call   1090 <read@plt>
test   %eax,%eax
js     14a0 <str_cli+0x2d0>
mov    %eax,%ebp
mov    0x2b86(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   10d0 <gf_time@plt>
test   %ebp,%ebp
je     1657 <str_cli+0x487>
mov    %ebx,%edi
lea    0xbe8(%rip),%rsi
mov    %rax,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%eax
add    %rax,%r12
mov    0x2b7c(%rip),%rbx
mov    (%rbx),%edi
lea    0x4(%rsp),%rbp
mov    %rbp,%rsi
call   10f0 <FD_SET@plt>
jmp    14bf <str_cli+0x2ef>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x4(%rsp),%rbp
jmp    14bf <str_cli+0x2ef>
nopw   0x0(%rax,%rax,1)
mov    0x2b09(%rip),%rax
mov    (%rax),%rax
mov    0x2b07(%rip),%rcx
cmp    (%rcx),%rax
lea    0x4(%rsp),%rbp
jne    1695 <str_cli+0x4c5>
mov    (%rbx),%edi
mov    %rbp,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1590 <str_cli+0x3c0>
mov    %r12d,%edx
mov    0x10(%rsp),%rax
sub    %eax,%edx
test   %edx,%edx
jle    1590 <str_cli+0x3c0>
mov    %r14,%r15
mov    %r13,%r14
mov    (%rbx),%edi
mov    %rax,%rbp
mov    %rax,%rsi
call   1050 <write@plt>
test   %eax,%eax
js     155d <str_cli+0x38d>
mov    %eax,%r13d
mov    0x2ac3(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   10d0 <gf_time@plt>
mov    %ebx,%edi
mov    0x2ad9(%rip),%rbx
lea    0xb46(%rip),%rsi
mov    %rax,%rdx
mov    %r13d,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r13d,%eax
add    %rax,%rbp
cmp    %r12,%rbp
lea    0x420(%rsp),%rax
cmove  %rax,%r12
cmove  %rax,%rbp
mov    %rbp,0x10(%rsp)
lea    0x4(%rsp),%rbp
mov    %r14,%r13
mov    %r15,%r14
mov    0x2a3d(%rip),%r15
jmp    1590 <str_cli+0x3c0>
mov    0x2a4c(%rip),%rax
mov    (%rax),%rax
mov    0x2a4a(%rip),%rcx
cmp    (%rcx),%rax
lea    0x4(%rsp),%rbp
mov    %r14,%r13
mov    %r15,%r14
mov    0x2a15(%rip),%r15
jne    169e <str_cli+0x4ce>
nopl   0x0(%rax)
mov    (%rsp),%edi
mov    %rbp,%rsi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     12b0 <str_cli+0xe0>
mov    %r14d,%edx
sub    %r13d,%edx
test   %edx,%edx
jle    12b0 <str_cli+0xe0>
mov    (%rsp),%edi
mov    %r13,%rsi
call   1050 <write@plt>
test   %eax,%eax
jns    15e5 <str_cli+0x415>
mov    0x29e8(%rip),%rax
mov    (%rax),%rax
mov    0x29e6(%rip),%rcx
cmp    (%rcx),%rax
lea    0x4(%rsp),%rbp
je     12b0 <str_cli+0xe0>
jmp    1683 <str_cli+0x4b3>
mov    %eax,%ebp
mov    0x29da(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   10d0 <gf_time@plt>
mov    %ebx,%edi
mov    0x29f0(%rip),%rbx
lea    0xa5d(%rip),%rsi
mov    %rax,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%eax
add    %rax,%r13
cmp    %r14,%r13
lea    0x4(%rsp),%rbp
jne    12b0 <str_cli+0xe0>
lea    0x20(%rsp),%r13
mov    %r13,%r14
cmpl   $0x0,0x8(%rsp)
je     12b0 <str_cli+0xe0>
mov    0x2998(%rip),%rax
mov    (%rax),%esi
mov    (%rsp),%edi
call   1070 <shutdown@plt>
lea    0x20(%rsp),%r13
mov    %r13,%r14
jmp    12b0 <str_cli+0xe0>
lea    0x9d3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpl   $0x0,0x8(%rsp)
je     16b8 <str_cli+0x4e8>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9f7(%rip),%rdi
jmp    16a5 <str_cli+0x4d5>
lea    0xa57(%rip),%rdi
jmp    16a5 <str_cli+0x4d5>
lea    0xa39(%rip),%rdi
jmp    16a5 <str_cli+0x4d5>
lea    0x9f2(%rip),%rdi
call   1030 <puts@plt>
mov    0x28ef(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0x9ee(%rip),%rdi
jmp    16a5 <str_cli+0x4d5>

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

LLVM IR (-O2):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@EWOULDBLOCK = global i64 0
@errno = global i64 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [18 x i8] c"%s, EOF on stdin\0A\00"
@SHUT_WR = global i32 0
@.str.2 = [31 x i8] c"%s : read %d bytes from stdin\0A\00"
@.str.4 = [19 x i8] c"%s, EOF on socket\0A\00"
@.str.6 = [32 x i8] c"%s : read %d bytes from socket\0A\00"
@.str.8 = [29 x i8] c"%s wrote %d bytes to stdout\0A\00"
@str = [22 x i8] c"write error to sockfd\00"
@str.10 = [22 x i8] c"write error to stdout\00"
@str.11 = [40 x i8] c"str_cli : server terminated prematurely\00"
@str.12 = [21 x i8] c"read error on socket\00"
@str.13 = [20 x i8] c"read error on stdin\00"
define void @str_cli(i32* nocapture readnone %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = load i32, i32* @F_GETFL
%12 = tail call i32 @fcntl(i32 %1, i32 %11, i32 0)
%13 = load i32, i32* @F_SETFL
%14 = load i32, i32* @O_NONBLOCK
%15 = or i32 %14, %12
%16 = tail call i32 @fcntl(i32 %1, i32 %13, i32 %15)
%17 = load i32, i32* @STDIN_FILENO
%18 = load i32, i32* @F_GETFL
%19 = tail call i32 @fcntl(i32 %17, i32 %18, i32 0)
%20 = load i32, i32* @STDIN_FILENO
%21 = load i32, i32* @F_SETFL
%22 = load i32, i32* @O_NONBLOCK
%23 = or i32 %22, %19
%24 = tail call i32 @fcntl(i32 %20, i32 %21, i32 %23)
%25 = load i32, i32* @STDOUT_FILENO
%26 = load i32, i32* @F_GETFL
%27 = tail call i32 @fcntl(i32 %25, i32 %26, i32 0)
%28 = load i32, i32* @STDOUT_FILENO
%29 = load i32, i32* @F_SETFL
%30 = load i32, i32* @O_NONBLOCK
%31 = or i32 %30, %27
%32 = tail call i32 @fcntl(i32 %28, i32 %29, i32 %31)
%33 = load i32, i32* @STDIN_FILENO
%34 = load i32, i32* @STDOUT_FILENO
%35 = tail call i32 @max(i32 %33, i32 %34)
%36 = tail call i32 @max(i32 %35, i32 %1)
%37 = add nsw i32 %36, 1
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1024
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 1024
%40 = ptrtoint i8* %38 to i64
%41 = ptrtoint i8* %39 to i64
br label %42
42: ; preds = %209, %2
%43 = phi i32 [ 0, %2 ], [ %110, %209 ]
%44 = phi i8* [ %7, %2 ], [ %210, %209 ]
%45 = phi i8* [ %7, %2 ], [ %211, %209 ]
%46 = phi i8* [ %8, %2 ], [ %179, %209 ]
%47 = phi i8* [ %8, %2 ], [ %180, %209 ]
%48 = ptrtoint i8* %45 to i64
br label %49
49: ; preds = %195, %42
%50 = phi i32 [ %43, %42 ], [ %110, %195 ]
%51 = phi i8* [ %44, %42 ], [ %111, %195 ]
%52 = phi i8* [ %46, %42 ], [ %179, %195 ]
%53 = phi i8* [ %47, %42 ], [ %180, %195 ]
%54 = call i32 @FD_ZERO(i32* %5)
%55 = call i32 @FD_ZERO(i32* %6)
%56 = icmp eq i32 %50, 0
%57 = icmp ult i8* %51, %38
%58 = select i1 %56, i1 %57, i1 false
br i1 %58, label %59, label %62
59: ; preds = %49
%60 = load i32, i32* @STDIN_FILENO
%61 = call i32 @FD_SET(i32 %60, i32* %5)
br label %62
62: ; preds = %59, %49
%63 = icmp ult i8* %52, %39
br i1 %63, label %64, label %66
64: ; preds = %62
%65 = call i32 @FD_SET(i32 %1, i32* %5)
br label %66
66: ; preds = %64, %62
%67 = icmp eq i8* %45, %51
br i1 %67, label %70, label %68
68: ; preds = %66
%69 = call i32 @FD_SET(i32 %1, i32* %6)
br label %70
70: ; preds = %68, %66
%71 = icmp eq i8* %53, %52
br i1 %71, label %75, label %72
72: ; preds = %70
%73 = load i32, i32* @STDOUT_FILENO
%74 = call i32 @FD_SET(i32 %73, i32* %6)
br label %75
75: ; preds = %72, %70
%76 = call i32 @select(i32 %37, i32* %5, i32* %6, i32* null, i32* null)
%77 = load i32, i32* @STDIN_FILENO
%78 = call i64 @FD_ISSET(i32 %77, i32* %5)
%79 = icmp eq i64 %78, 0
br i1 %79, label %109, label %80
80: ; preds = %75
%81 = load i32, i32* @STDIN_FILENO
%82 = ptrtoint i8* %51 to i64
%83 = sub i64 %40, %82
%84 = trunc i64 %83 to i32
%85 = call i32 @read(i32 %81, i8* %51, i32 %84)
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %95
87: ; preds = %80
%88 = load i64, i64* @EWOULDBLOCK
%89 = load i64, i64* @errno
%90 = icmp eq i64 %88, %89
br i1 %90, label %109, label %91
91: ; preds = %87
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0))
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @exit(i32 %93)
unreachable
95: ; preds = %80
%96 = icmp eq i32 %85, 0
%97 = load i32, i32* @stderr
%98 = call i8* (...) @gf_time()
br i1 %96, label %99, label %104
99: ; preds = %95
%100 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %98)
br i1 %67, label %101, label %109
101: ; preds = %99
%102 = load i32, i32* @SHUT_WR
%103 = call i32 @shutdown(i32 %1, i32 %102)
br label %109
104: ; preds = %95
%105 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %98, i32 %85)
%106 = zext i32 %85 to i64
%107 = getelementptr inbounds i8, i8* %51, i64 %106
%108 = call i32 @FD_SET(i32 %1, i32* %6)
br label %109
109: ; preds = %87, %99, %101, %104, %75
%110 = phi i32 [ %50, %87 ], [ 1, %101 ], [ 1, %99 ], [ %50, %104 ], [ %50, %75 ]
%111 = phi i8* [ %51, %87 ], [ %51, %101 ], [ %51, %99 ], [ %107, %104 ], [ %51, %75 ]
%112 = call i64 @FD_ISSET(i32 %1, i32* %5)
%113 = icmp eq i64 %112, 0
br i1 %113, label %146, label %114
114: ; preds = %109
%115 = ptrtoint i8* %52 to i64
%116 = sub i64 %41, %115
%117 = trunc i64 %116 to i32
%118 = call i32 @read(i32 %1, i8* %52, i32 %117)
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %128
120: ; preds = %114
%121 = load i64, i64* @EWOULDBLOCK
%122 = load i64, i64* @errno
%123 = icmp eq i64 %121, %122
br i1 %123, label %146, label %124
124: ; preds = %120
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%126 = load i32, i32* @EXIT_FAILURE
%127 = call i32 @exit(i32 %126)
unreachable
128: ; preds = %114
%129 = icmp eq i32 %118, 0
%130 = load i32, i32* @stderr
%131 = call i8* (...) @gf_time()
br i1 %129, label %132, label %140
132: ; preds = %128
%133 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %131)
%134 = icmp eq i32 %110, 0
br i1 %134, label %136, label %135
135: ; preds = %132
ret void
136: ; preds = %132
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.11, i64 0, i64 0))
%138 = load i32, i32* @EXIT_FAILURE
%139 = call i32 @exit(i32 %138)
unreachable
140: ; preds = %128
%141 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %131, i32 %118)
%142 = zext i32 %118 to i64
%143 = getelementptr inbounds i8, i8* %52, i64 %142
%144 = load i32, i32* @STDOUT_FILENO
%145 = call i32 @FD_SET(i32 %144, i32* %6)
br label %146
146: ; preds = %140, %120, %109
%147 = phi i8* [ %52, %120 ], [ %143, %140 ], [ %52, %109 ]
%148 = load i32, i32* @STDOUT_FILENO
%149 = call i64 @FD_ISSET(i32 %148, i32* %6)
%150 = icmp eq i64 %149, 0
br i1 %150, label %178, label %151
151: ; preds = %146
%152 = ptrtoint i8* %147 to i64
%153 = ptrtoint i8* %53 to i64
%154 = sub i64 %152, %153
%155 = trunc i64 %154 to i32
%156 = icmp sgt i32 %155, 0
br i1 %156, label %157, label %178
157: ; preds = %151
%158 = load i32, i32* @STDOUT_FILENO
%159 = call i32 @write(i32 %158, i8* %53, i32 %155)
%160 = icmp slt i32 %159, 0
br i1 %160, label %161, label %169
161: ; preds = %157
%162 = load i64, i64* @EWOULDBLOCK
%163 = load i64, i64* @errno
%164 = icmp eq i64 %162, %163
br i1 %164, label %178, label %165
165: ; preds = %161
%166 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%167 = load i32, i32* @EXIT_FAILURE
%168 = call i32 @exit(i32 %167)
unreachable
169: ; preds = %157
%170 = load i32, i32* @stderr
%171 = call i8* (...) @gf_time()
%172 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %171, i32 %159)
%173 = zext i32 %159 to i64
%174 = getelementptr inbounds i8, i8* %53, i64 %173
%175 = icmp eq i8* %174, %147
%176 = select i1 %175, i8* %8, i8* %147
%177 = select i1 %175, i8* %8, i8* %174
br label %178
178: ; preds = %169, %161, %151, %146
%179 = phi i8* [ %147, %161 ], [ %147, %151 ], [ %147, %146 ], [ %176, %169 ]
%180 = phi i8* [ %53, %161 ], [ %53, %151 ], [ %53, %146 ], [ %177, %169 ]
%181 = call i64 @FD_ISSET(i32 %1, i32* %6)
%182 = icmp eq i64 %181, 0
br i1 %182, label %195, label %183
183: ; preds = %178
%184 = ptrtoint i8* %111 to i64
%185 = sub i64 %184, %48
%186 = trunc i64 %185 to i32
%187 = icmp sgt i32 %186, 0
br i1 %187, label %188, label %195
188: ; preds = %183
%189 = call i32 @write(i32 %1, i8* %45, i32 %186)
%190 = icmp slt i32 %189, 0
br i1 %190, label %191, label %200
191: ; preds = %188
%192 = load i64, i64* @EWOULDBLOCK
%193 = load i64, i64* @errno
%194 = icmp eq i64 %192, %193
br i1 %194, label %195, label %196
195: ; preds = %191, %183, %178
br label %49
196: ; preds = %191
%197 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%198 = load i32, i32* @EXIT_FAILURE
%199 = call i32 @exit(i32 %198)
unreachable
200: ; preds = %188
%201 = load i32, i32* @stderr
%202 = call i8* (...) @gf_time()
%203 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %201, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %202, i32 %189)
%204 = zext i32 %189 to i64
%205 = getelementptr inbounds i8, i8* %45, i64 %204
%206 = icmp eq i8* %205, %111
br i1 %206, label %207, label %209
207: ; preds = %200
%208 = icmp eq i32 %110, 0
br i1 %208, label %209, label %212
209: ; preds = %207, %212, %200
%210 = phi i8* [ %111, %200 ], [ %7, %212 ], [ %7, %207 ]
%211 = phi i8* [ %205, %200 ], [ %7, %212 ], [ %7, %207 ]
br label %42
212: ; preds = %207
%213 = load i32, i32* @SHUT_WR
%214 = call i32 @shutdown(i32 %1, i32 %213)
br label %209
}