#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct stat {
  int /*<<< orphan*/ st_mode;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int BUFSIZ;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int O_CREAT;
int O_EXCL;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ SOCK_STREAM;
int STDIN_FILENO;
int STDOUT_FILENO;
int S_IRUSR;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int S_IWUSR;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fstat(int, struct stat *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  printf("client\n");
  if (argc != 2) {
    printf("argument error!\n");
    exit(1);
  }
  int sockfd = socket(AF_INET, SOCK_STREAM, 0);
  struct sockaddr_in servaddr;
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons(9999);
  inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
  if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) {
    printf("connect error!\n");
    exit(1);
  }
  fd_set rset;
  char cbuf[BUFSIZ], sbuf[BUFSIZ];
  int clen = 0, slen = 0;
  while (1) {
    FD_ZERO(&rset);
    FD_SET(sockfd, &rset);
    FD_SET(STDIN_FILENO, &rset);
    select(sockfd + 1, &rset, NULL, NULL, NULL);
    if (FD_ISSET(sockfd, &rset)) {
      if ((clen = read(sockfd, cbuf, BUFSIZ)) == 0) {
        printf("connection end\n");
        exit(0);
      } else if (clen < 0) {
        perror("read");
        exit(0);
      } else {
        if (cbuf[0] == '/') {
          printf("receive %s?[path] or n\n", cbuf);
          clen = read(STDIN_FILENO, cbuf, BUFSIZ);
          if (clen == 2 && cbuf[0] == 'n') {
            write(sockfd, cbuf, clen);
            printf("refuse file!\n");
          } else {
            int file;
            char path[clen];
            memcpy(path, cbuf, clen - 1);
            path[clen - 1] = '\0';
            if ((file = open(path, O_WRONLY | O_CREAT | O_EXCL,
                             S_IRUSR | S_IWUSR)) == -1) {
              write(sockfd, "n\n", 2);
              printf("create file error!\n");
            } else {
              write(sockfd, "y\n", 2);
              printf("start recving!\n");
              while ((clen = read(sockfd, cbuf, BUFSIZ)) > 0) {
                write(file, cbuf, clen);
                if (clen < BUFSIZ)
                  break;
              }
              printf("receive over!\n");
            }
          }
        } else
          write(STDOUT_FILENO, cbuf, clen);
      }
    }
    if (FD_ISSET(STDIN_FILENO, &rset)) {
      slen = read(STDIN_FILENO, sbuf, BUFSIZ);
      if (sbuf[0] == '/') {
        int file;
        char path[slen];
        memcpy(path, sbuf, slen - 1);
        path[slen - 1] = '\0';
        if ((file = open(path, O_RDONLY)) == -1) {
          printf("open error!\n");
        } else {
          struct stat buf;
          fstat(file, &buf);
          if (S_ISDIR(buf.st_mode)) {
            printf("error,it should not be a dir!\n");
          } else {
            write(sockfd, path, slen);
            slen = read(sockfd, sbuf, BUFSIZ);
            if (slen == 2 && sbuf[0] == 'n') {
              printf("remote refuse!\n");
            } else {
              printf("remote is recving!\n");
              while ((slen = read(file, sbuf, BUFSIZ)) > 0) {
                write(sockfd, sbuf, slen);
              }
              close(file);
              printf("send over!\n");
            }
          }
        }
      } else
        write(sockfd, sbuf, slen);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
je     1279 <main+0x49>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x270f,%edi
call   1050 <htons@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x20(%rbp),%rdx
call   10b0 <inet_pton@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    1308 <main+0xd8>
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
jmp    136b <main+0x13b>
lea    -0x24(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
lea    -0x24(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x24(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
mov    -0x14(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     160d <main+0x3dd>
mov    -0x90(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2bd5(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jne    13fb <main+0x1cb>
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
jge    1418 <main+0x1e8>
lea    0xc2d(%rip),%rdi
call   10f0 <perror@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x90(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    15e6 <main+0x3b6>
mov    -0x90(%rbp),%rsi
lea    0xc05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rsi
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
mov    0x2b51(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jne    14a3 <main+0x273>
mov    -0x90(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    14a3 <main+0x273>
mov    -0x90(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x44(%rbp),%edx
call   1030 <write@plt>
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15e1 <main+0x3b1>
mov    -0x90(%rbp),%rsi
mov    -0x44(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x98(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x60(%rbp)
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
call   10a0 <memcpy@plt>
mov    -0x98(%rbp),%rdi
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
mov    0x2a90(%rip),%rax
mov    (%rax),%esi
mov    0x2af7(%rip),%rax
or     (%rax),%esi
mov    0x2aae(%rip),%rax
or     (%rax),%esi
mov    0x2a8d(%rip),%rax
mov    (%rax),%edx
mov    0x2aac(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0xffffffff,%eax
jne    1558 <main+0x328>
mov    -0x14(%rbp),%edi
lea    0xb18(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0xb18(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15da <main+0x3aa>
mov    -0x14(%rbp),%edi
lea    0xb16(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0xb08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2a1d(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jle    15cc <main+0x39c>
mov    -0x90(%rbp),%rsi
mov    -0x4c(%rbp),%edi
mov    -0x44(%rbp),%edx
call   1030 <write@plt>
mov    -0x44(%rbp),%eax
mov    0x29ee(%rip),%rcx
cmp    (%rcx),%eax
jge    15c7 <main+0x397>
jmp    15cc <main+0x39c>
jmp    157a <main+0x34a>
lea    0xab8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
jmp    15fe <main+0x3ce>
mov    -0x90(%rbp),%rsi
mov    0x29f4(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
call   1030 <write@plt>
jmp    1603 <main+0x3d3>
jmp    1608 <main+0x3d8>
jmp    160d <main+0x3dd>
mov    0x2984(%rip),%rax
mov    (%rax),%edi
lea    -0x24(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     17f6 <main+0x5c6>
mov    -0x88(%rbp),%rsi
mov    0x2961(%rip),%rax
mov    (%rax),%edi
mov    0x2968(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,-0x48(%rbp)
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    17df <main+0x5af>
mov    -0x88(%rbp),%rsi
mov    -0x48(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xa0(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x78(%rbp)
mov    -0x48(%rbp),%edx
sub    $0x1,%edx
call   10a0 <memcpy@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x48(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
mov    0x291c(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x64(%rbp)
cmp    $0xffffffff,%eax
jne    16dc <main+0x4ac>
lea    0x9ca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    17d3 <main+0x5a3>
mov    -0x64(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1140 <fstat@plt>
mov    -0x80(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     170d <main+0x4dd>
lea    0x9a6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    17ce <main+0x59e>
mov    -0xa0(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%edx
call   1030 <write@plt>
mov    -0x88(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2878(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x2,-0x48(%rbp)
jne    176a <main+0x53a>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    176a <main+0x53a>
lea    0x968(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    17c9 <main+0x599>
lea    0x965(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x88(%rbp),%rsi
mov    -0x64(%rbp),%edi
mov    0x281f(%rip),%rax
mov    (%rax),%edx
call   1090 <read@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
jle    17b3 <main+0x583>
mov    -0x88(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%edx
call   1030 <write@plt>
jmp    1778 <main+0x548>
mov    -0x64(%rbp),%edi
call   1080 <close@plt>
lea    0x928(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    17ce <main+0x59e>
jmp    17d3 <main+0x5a3>
mov    -0x70(%rbp),%rax
mov    %rax,%rsp
jmp    17f1 <main+0x5c1>
mov    -0x88(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%edx
call   1030 <write@plt>
jmp    17f6 <main+0x5c6>
jmp    1366 <main+0x136>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xdc3(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebx
jne    12d5 <main+0x95>
mov    0x2d6a(%rip),%r15
mov    (%r15),%edi
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r13d
lea    -0x60(%rbp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    (%r15),%eax
mov    %eax,-0x58(%rbp)
mov    $0x270f,%edi
call   1060 <htons@plt>
mov    %eax,-0x5c(%rbp)
mov    (%r15),%edi
mov    0x8(%r14),%rsi
mov    %rbx,%rdx
call   10c0 <inet_pton@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0xffffffff,%eax
jne    12eb <main+0xab>
lea    0xdf7(%rip),%rdi
jmp    12dc <main+0x9c>
lea    0xdfd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2cb6(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %r13d,%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
lea    -0x30(%rbp),%r12
mov    0x2c71(%rip),%rbx
mov    %r13d,-0x2c(%rbp)
jmp    1348 <main+0x108>
nopl   (%rax)
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
mov    %r13d,%edx
mov    %edi,%r13d
call   1040 <write@plt>
mov    0x2c50(%rip),%rbx
mov    %r12,%rdi
call   10d0 <FD_ZERO@plt>
mov    %r13d,%edi
mov    %r12,%rsi
call   1140 <FD_SET@plt>
mov    (%rbx),%edi
mov    %r12,%rsi
call   1140 <FD_SET@plt>
mov    -0x44(%rbp),%edi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
mov    %r13d,%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1529 <main+0x2e9>
mov    (%r15),%edx
mov    %r13d,%edi
mov    %r14,%rsi
call   10a0 <read@plt>
test   %eax,%eax
je     169b <main+0x45b>
js     16ae <main+0x46e>
cmpb   $0x2f,(%r14)
jne    1400 <main+0x1c0>
lea    0xc51(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%edi
mov    (%r15),%edx
mov    %r14,%rsi
call   10a0 <read@plt>
cmp    $0x2,%eax
jne    1420 <main+0x1e0>
cmpb   $0x6e,(%r14)
jne    1420 <main+0x1e0>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0xcc1(%rip),%rdi
call   1030 <puts@plt>
jmp    1529 <main+0x2e9>
nopw   0x0(%rax,%rax,1)
mov    0x2be1(%rip),%rcx
mov    (%rcx),%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    1529 <main+0x2e9>
nopl   0x0(%rax,%rax,1)
mov    %rsp,%r12
mov    %eax,%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
movslq %eax,%r15
lea    -0x1(%r15),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <memcpy@plt>
mov    0x2ba9(%rip),%rax
mov    (%rax),%esi
mov    0x2b30(%rip),%rax
or     (%rax),%esi
mov    0x2b57(%rip),%rax
or     (%rax),%esi
movb   $0x0,-0x1(%r15,%rbx,1)
mov    0x2b58(%rip),%rax
mov    (%rax),%edx
mov    0x2b27(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     14f4 <main+0x2b4>
mov    %eax,%r15d
mov    %r13d,%edi
lea    0xb86(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0xbd6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2af4(%rip),%rax
mov    (%rax),%edx
cs nopw 0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
call   10a0 <read@plt>
test   %eax,%eax
jle    14eb <main+0x2ab>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x2ac3(%rip),%rax
mov    (%rax),%edx
cmp    %edx,%ebx
jge    14c0 <main+0x280>
lea    0xb9b(%rip),%rdi
jmp    150f <main+0x2cf>
mov    %r13d,%edi
lea    0xb1c(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0xb8c(%rip),%rdi
mov    0x2a92(%rip),%r15
mov    0x2a7b(%rip),%rbx
call   1030 <puts@plt>
mov    %r12,%rsp
lea    -0x30(%rbp),%r12
mov    (%rbx),%edi
mov    %r12,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1348 <main+0x108>
mov    (%rbx),%edi
mov    (%r15),%edx
mov    -0x38(%rbp),%rbx
mov    %rbx,%rsi
call   10a0 <read@plt>
mov    %eax,%r13d
cmpb   $0x2f,(%rbx)
jne    1330 <main+0xf0>
mov    %rsp,-0x50(%rbp)
mov    %r13d,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movslq %r13d,%r12
lea    -0x1(%r12),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10b0 <memcpy@plt>
movb   $0x0,-0x1(%r12,%r15,1)
mov    0x2a3f(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   10f0 <open@plt>
cmp    $0xffffffff,%eax
je     1670 <main+0x430>
mov    %eax,%r12d
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   1150 <fstat@plt>
mov    -0x40(%rbp),%edi
call   1080 <S_ISDIR@plt>
lea    0xa91(%rip),%rdi
test   %rax,%rax
jne    1677 <main+0x437>
mov    -0x2c(%rbp),%ebx
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <write@plt>
mov    0x29c5(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    -0x38(%rbp),%rsi
call   10a0 <read@plt>
cmp    $0x2,%eax
jne    1605 <main+0x3c5>
mov    -0x38(%rbp),%rax
cmpb   $0x6e,(%rax)
lea    0xa42(%rip),%rdi
je     1677 <main+0x437>
lea    0xa1b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2990(%rip),%r15
mov    (%r15),%edx
mov    %r12d,%edi
mov    -0x38(%rbp),%rbx
mov    %rbx,%rsi
call   10a0 <read@plt>
test   %eax,%eax
mov    -0x2c(%rbp),%r13d
jle    165f <main+0x41f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    (%r15),%edx
mov    %r12d,%edi
mov    %rbx,%rsi
call   10a0 <read@plt>
test   %eax,%eax
jg     1640 <main+0x400>
mov    %r12d,%edi
call   1090 <close@plt>
lea    0x9cc(%rip),%rdi
jmp    1677 <main+0x437>
lea    0x9fb(%rip),%rdi
call   1030 <puts@plt>
mov    -0x50(%rbp),%rsp
mov    -0x2c(%rbp),%r13d
mov    0x291d(%rip),%r15
lea    -0x30(%rbp),%r12
mov    0x2902(%rip),%rbx
jmp    1348 <main+0x108>
lea    0xa19(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    0x94b(%rip),%rdi
call   1100 <perror@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.stat = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"client\0A\00"
@.str.1 = [17 x i8] c"argument error!\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [16 x i8] c"connect error!\0A\00"
@BUFSIZ = global i32 0
@STDIN_FILENO = global i32 0
@.str.3 = [16 x i8] c"connection end\0A\00"
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [24 x i8] c"receive %s?[path] or n\0A\00"
@.str.6 = [14 x i8] c"refuse file!\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.7 = [3 x i8] c"n\0A\00"
@.str.8 = [20 x i8] c"create file error!\0A\00"
@.str.9 = [3 x i8] c"y\0A\00"
@.str.10 = [16 x i8] c"start recving!\0A\00"
@.str.11 = [15 x i8] c"receive over!\0A\00"
@STDOUT_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str.12 = [13 x i8] c"open error!\0A\00"
@.str.13 = [31 x i8] c"error,it should not be a dir!\0A\00"
@.str.14 = [16 x i8] c"remote refuse!\0A\00"
@.str.15 = [20 x i8] c"remote is recving!\0A\00"
@.str.16 = [12 x i8] c"send over!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i32, i32* @AF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
store i32 %30, i32* %6
%31 = call i32 @bzero(%struct.sockaddr_in* %7, i32 12)
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %32, i32* %33
%34 = call i32 @htons(i32 9999)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %34, i32* %35
%36 = load i32, i32* @AF_INET
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%41 = call i32 @inet_pton(i32 %36, i8* %39, i32* %40)
%42 = load i32, i32* %6
%43 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%44 = call i32 @connect(i32 %42, %struct.sockaddr* %43, i32 12)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %27
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %27
%50 = load i32, i32* @BUFSIZ
%51 = zext i32 %50 to i64
%52 = call i8* @llvm.stacksave()
store i8* %52, i8** %9
%53 = alloca i8, i64 %51
store i64 %51, i64* %10
%54 = load i32, i32* @BUFSIZ
%55 = zext i32 %54 to i64
%56 = alloca i8, i64 %55
store i64 %55, i64* %11
store i32 0, i32* %12
store i32 0, i32* %13
br label %57
57: ; preds = %240, %49
br label %58
58: ; preds = %57
%59 = call i32 @FD_ZERO(i32* %8)
%60 = load i32, i32* %6
%61 = call i32 @FD_SET(i32 %60, i32* %8)
%62 = load i32, i32* @STDIN_FILENO
%63 = call i32 @FD_SET(i32 %62, i32* %8)
%64 = load i32, i32* %6
%65 = add nsw i32 %64, 1
%66 = call i32 @select(i32 %65, i32* %8, i32* null, i32* null, i32* null)
%67 = load i32, i32* %6
%68 = call i64 @FD_ISSET(i32 %67, i32* %8)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %162
70: ; preds = %58
%71 = load i32, i32* %6
%72 = load i32, i32* @BUFSIZ
%73 = call i32 @read(i32 %71, i8* %53, i32 %72)
store i32 %73, i32* %12
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %70
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%77 = call i32 @exit(i32 0)
unreachable
78: ; preds = %70
%79 = load i32, i32* %12
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%83 = call i32 @exit(i32 0)
unreachable
84: ; preds = %78
%85 = getelementptr inbounds i8, i8* %53, i64 0
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 47
br i1 %88, label %89, label %155
89: ; preds = %84
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%91 = load i32, i32* @STDIN_FILENO
%92 = load i32, i32* @BUFSIZ
%93 = call i32 @read(i32 %91, i8* %53, i32 %92)
store i32 %93, i32* %12
%94 = load i32, i32* %12
%95 = icmp eq i32 %94, 2
br i1 %95, label %96, label %106
96: ; preds = %89
%97 = getelementptr inbounds i8, i8* %53, i64 0
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp eq i32 %99, 110
br i1 %100, label %101, label %106
101: ; preds = %96
%102 = load i32, i32* %6
%103 = load i32, i32* %12
%104 = call i32 @write(i32 %102, i8* %53, i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %154
106: ; preds = %96, %89
%107 = load i32, i32* %12
%108 = zext i32 %107 to i64
%109 = call i8* @llvm.stacksave()
store i8* %109, i8** %15
%110 = alloca i8, i64 %108
store i64 %108, i64* %16
%111 = load i32, i32* %12
%112 = sub nsw i32 %111, 1
%113 = call i32 @memcpy(i8* %110, i8* %53, i32 %112)
%114 = load i32, i32* %12
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %110, i64 %116
store i8 0, i8* %117
%118 = load i32, i32* @O_WRONLY
%119 = load i32, i32* @O_CREAT
%120 = or i32 %118, %119
%121 = load i32, i32* @O_EXCL
%122 = or i32 %120, %121
%123 = load i32, i32* @S_IRUSR
%124 = load i32, i32* @S_IWUSR
%125 = or i32 %123, %124
%126 = call i32 (i8*, i32, ...) @open(i8* %110, i32 %122, i32 %125)
store i32 %126, i32* %14
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %132
128: ; preds = %106
%129 = load i32, i32* %6
%130 = call i32 @write(i32 %129, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %152
132: ; preds = %106
%133 = load i32, i32* %6
%134 = call i32 @write(i32 %133, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %136
136: ; preds = %149, %132
%137 = load i32, i32* %6
%138 = load i32, i32* @BUFSIZ
%139 = call i32 @read(i32 %137, i8* %53, i32 %138)
store i32 %139, i32* %12
%140 = icmp sgt i32 %139, 0
br i1 %140, label %141, label %150
141: ; preds = %136
%142 = load i32, i32* %14
%143 = load i32, i32* %12
%144 = call i32 @write(i32 %142, i8* %53, i32 %143)
%145 = load i32, i32* %12
%146 = load i32, i32* @BUFSIZ
%147 = icmp slt i32 %145, %146
br i1 %147, label %148, label %149
148: ; preds = %141
br label %150
149: ; preds = %141
br label %136
150: ; preds = %148, %136
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
br label %152
152: ; preds = %150, %128
%153 = load i8*, i8** %15
br label %154
154: ; preds = %152, %101
br label %159
155: ; preds = %84
%156 = load i32, i32* @STDOUT_FILENO
%157 = load i32, i32* %12
%158 = call i32 @write(i32 %156, i8* %53, i32 %157)
br label %159
159: ; preds = %155, %154
br label %160
160: ; preds = %159
br label %161
161: ; preds = %160
br label %162
162: ; preds = %161, %58
%163 = load i32, i32* @STDIN_FILENO
%164 = call i64 @FD_ISSET(i32 %163, i32* %8)
%165 = icmp ne i64 %164, 0
br i1 %165, label %166, label %240
166: ; preds = %162
%167 = load i32, i32* @STDIN_FILENO
%168 = load i32, i32* @BUFSIZ
%169 = call i32 @read(i32 %167, i8* %56, i32 %168)
store i32 %169, i32* %13
%170 = getelementptr inbounds i8, i8* %56, i64 0
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp eq i32 %172, 47
br i1 %173, label %174, label %235
174: ; preds = %166
%175 = load i32, i32* %13
%176 = zext i32 %175 to i64
%177 = call i8* @llvm.stacksave()
store i8* %177, i8** %18
%178 = alloca i8, i64 %176
store i64 %176, i64* %19
%179 = load i32, i32* %13
%180 = sub nsw i32 %179, 1
%181 = call i32 @memcpy(i8* %178, i8* %56, i32 %180)
%182 = load i32, i32* %13
%183 = sub nsw i32 %182, 1
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds i8, i8* %178, i64 %184
store i8 0, i8* %185
%186 = load i32, i32* @O_RDONLY
%187 = call i32 (i8*, i32, ...) @open(i8* %178, i32 %186)
store i32 %187, i32* %17
%188 = icmp eq i32 %187, -1
br i1 %188, label %189, label %191
189: ; preds = %174
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %233
191: ; preds = %174
%192 = load i32, i32* %17
%193 = call i32 @fstat(i32 %192, %struct.stat* %20)
%194 = getelementptr inbounds %struct.stat, %struct.stat* %20, i32 0, i32 0
%195 = load i32, i32* %194
%196 = call i64 @S_ISDIR(i32 %195)
%197 = icmp ne i64 %196, 0
br i1 %197, label %198, label %200
198: ; preds = %191
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %232
200: ; preds = %191
%201 = load i32, i32* %6
%202 = load i32, i32* %13
%203 = call i32 @write(i32 %201, i8* %178, i32 %202)
%204 = load i32, i32* %6
%205 = load i32, i32* @BUFSIZ
%206 = call i32 @read(i32 %204, i8* %56, i32 %205)
store i32 %206, i32* %13
%207 = load i32, i32* %13
%208 = icmp eq i32 %207, 2
br i1 %208, label %209, label %216
209: ; preds = %200
%210 = getelementptr inbounds i8, i8* %56, i64 0
%211 = load i8, i8* %210
%212 = sext i8 %211 to i32
%213 = icmp eq i32 %212, 110
br i1 %213, label %214, label %216
214: ; preds = %209
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
br label %231
216: ; preds = %209, %200
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
br label %218
218: ; preds = %223, %216
%219 = load i32, i32* %17
%220 = load i32, i32* @BUFSIZ
%221 = call i32 @read(i32 %219, i8* %56, i32 %220)
store i32 %221, i32* %13
%222 = icmp sgt i32 %221, 0
br i1 %222, label %223, label %227
223: ; preds = %218
%224 = load i32, i32* %6
%225 = load i32, i32* %13
%226 = call i32 @write(i32 %224, i8* %56, i32 %225)
br label %218
227: ; preds = %218
%228 = load i32, i32* %17
%229 = call i32 @close(i32 %228)
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0))
br label %231
231: ; preds = %227, %214
br label %232
232: ; preds = %231, %198
br label %233
233: ; preds = %232, %189
%234 = load i8*, i8** %18
br label %239
235: ; preds = %166
%236 = load i32, i32* %6
%237 = load i32, i32* %13
%238 = call i32 @write(i32 %236, i8* %56, i32 %237)
br label %239
239: ; preds = %235, %233
br label %240
240: ; preds = %239, %162
br label %57
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.stat = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@BUFSIZ = global i32 0
@STDIN_FILENO = global i32 0
@.str.4 = [5 x i8] c"read\00"
@.str.5 = [24 x i8] c"receive %s?[path] or n\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.7 = [3 x i8] c"n\0A\00"
@.str.9 = [3 x i8] c"y\0A\00"
@STDOUT_FILENO = global i32 0
@O_RDONLY = global i32 0
@str = [7 x i8] c"client\00"
@str.17 = [19 x i8] c"remote is recving!\00"
@str.18 = [11 x i8] c"send over!\00"
@str.19 = [15 x i8] c"remote refuse!\00"
@str.20 = [30 x i8] c"error,it should not be a dir!\00"
@str.21 = [12 x i8] c"open error!\00"
@str.22 = [15 x i8] c"start recving!\00"
@str.23 = [14 x i8] c"receive over!\00"
@str.24 = [19 x i8] c"create file error!\00"
@str.25 = [13 x i8] c"refuse file!\00"
@str.26 = [15 x i8] c"connection end\00"
@str.27 = [15 x i8] c"connect error!\00"
@str.28 = [16 x i8] c"argument error!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca %struct.stat
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.28, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = bitcast %struct.sockaddr_in* %3 to i8*
%16 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %17, i32* %18
%19 = tail call i32 @htons(i32 9999)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %19, i32* %20
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%25 = call i32 @inet_pton(i32 %21, i8* %23, i32* %24)
%26 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%27 = call i32 @connect(i32 %14, %struct.sockaddr* %26, i32 12)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %11
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.27, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %11
%33 = bitcast i32* %4 to i8*
%34 = load i32, i32* @BUFSIZ
%35 = zext i32 %34 to i64
%36 = alloca i8, i64 %35
%37 = alloca i8, i64 %35
%38 = add nsw i32 %14, 1
%39 = bitcast %struct.stat* %5 to i8*
%40 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %41
41: ; preds = %167, %32
%42 = call i32 @FD_ZERO(i32* %4)
%43 = call i32 @FD_SET(i32 %14, i32* %4)
%44 = load i32, i32* @STDIN_FILENO
%45 = call i32 @FD_SET(i32 %44, i32* %4)
%46 = call i32 @select(i32 %38, i32* %4, i32* null, i32* null, i32* null)
%47 = call i64 @FD_ISSET(i32 %14, i32* %4)
%48 = icmp eq i64 %47, 0
br i1 %48, label %114, label %49
49: ; preds = %41
%50 = load i32, i32* @BUFSIZ
%51 = call i32 @read(i32 %14, i8* %36, i32 %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.26, i64 0, i64 0))
%55 = call i32 @exit(i32 0)
unreachable
56: ; preds = %49
%57 = icmp slt i32 %51, 0
br i1 %57, label %58, label %61
58: ; preds = %56
%59 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 @exit(i32 0)
unreachable
61: ; preds = %56
%62 = load i8, i8* %36
%63 = icmp eq i8 %62, 47
br i1 %63, label %64, label %111
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %36)
%66 = load i32, i32* @STDIN_FILENO
%67 = load i32, i32* @BUFSIZ
%68 = call i32 @read(i32 %66, i8* %36, i32 %67)
%69 = icmp eq i32 %68, 2
br i1 %69, label %70, label %76
70: ; preds = %64
%71 = load i8, i8* %36
%72 = icmp eq i8 %71, 110
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = call i32 @write(i32 %14, i8* %36, i32 2)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.25, i64 0, i64 0))
br label %114
76: ; preds = %70, %64
%77 = zext i32 %68 to i64
%78 = call i8* @llvm.stacksave()
%79 = alloca i8, i64 %77
%80 = add nsw i32 %68, -1
%81 = call i32 @memcpy(i8* %79, i8* %36, i32 %80)
%82 = sext i32 %80 to i64
%83 = getelementptr inbounds i8, i8* %79, i64 %82
store i8 0, i8* %83
%84 = load i32, i32* @O_WRONLY
%85 = load i32, i32* @O_CREAT
%86 = or i32 %85, %84
%87 = load i32, i32* @O_EXCL
%88 = or i32 %86, %87
%89 = load i32, i32* @S_IRUSR
%90 = load i32, i32* @S_IWUSR
%91 = or i32 %90, %89
%92 = call i32 (i8*, i32, ...) @open(i8* %79, i32 %88, i32 %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %96
94: ; preds = %76
%95 = call i32 @write(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
br label %108
96: ; preds = %76
%97 = call i32 @write(i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.22, i64 0, i64 0))
%99 = load i32, i32* @BUFSIZ
br label %100
100: ; preds = %104, %96
%101 = phi i32 [ %106, %104 ], [ %99, %96 ]
%102 = call i32 @read(i32 %14, i8* %36, i32 %101)
%103 = icmp sgt i32 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %100
%105 = call i32 @write(i32 %92, i8* %36, i32 %102)
%106 = load i32, i32* @BUFSIZ
%107 = icmp slt i32 %102, %106
br i1 %107, label %108, label %100
108: ; preds = %100, %104, %94
%109 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.24, i64 0, i64 0), %94 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.23, i64 0, i64 0), %104 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.23, i64 0, i64 0), %100 ]
%110 = call i32 @puts(i8* dereferenceable(1) %109)
br label %114
111: ; preds = %61
%112 = load i32, i32* @STDOUT_FILENO
%113 = call i32 @write(i32 %112, i8* %36, i32 %51)
br label %114
114: ; preds = %111, %108, %73, %41
%115 = load i32, i32* @STDIN_FILENO
%116 = call i64 @FD_ISSET(i32 %115, i32* %4)
%117 = icmp eq i64 %116, 0
br i1 %117, label %167, label %118
118: ; preds = %114
%119 = load i32, i32* @STDIN_FILENO
%120 = load i32, i32* @BUFSIZ
%121 = call i32 @read(i32 %119, i8* %37, i32 %120)
%122 = load i8, i8* %37
%123 = icmp eq i8 %122, 47
br i1 %123, label %124, label %168
124: ; preds = %118
%125 = zext i32 %121 to i64
%126 = call i8* @llvm.stacksave()
%127 = alloca i8, i64 %125
%128 = add nsw i32 %121, -1
%129 = call i32 @memcpy(i8* %127, i8* %37, i32 %128)
%130 = sext i32 %128 to i64
%131 = getelementptr inbounds i8, i8* %127, i64 %130
store i8 0, i8* %131
%132 = load i32, i32* @O_RDONLY
%133 = call i32 (i8*, i32, ...) @open(i8* %127, i32 %132)
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %137
135: ; preds = %124
%136 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.21, i64 0, i64 0))
br label %166
137: ; preds = %124
%138 = call i32 @fstat(i32 %133, %struct.stat* %5)
%139 = load i32, i32* %40
%140 = call i64 @S_ISDIR(i32 %139)
%141 = icmp eq i64 %140, 0
br i1 %141, label %142, label %163
142: ; preds = %137
%143 = call i32 @write(i32 %14, i8* %127, i32 %121)
%144 = load i32, i32* @BUFSIZ
%145 = call i32 @read(i32 %14, i8* %37, i32 %144)
%146 = icmp eq i32 %145, 2
br i1 %146, label %147, label %150
147: ; preds = %142
%148 = load i8, i8* %37
%149 = icmp eq i8 %148, 110
br i1 %149, label %163, label %150
150: ; preds = %147, %142
%151 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0))
%152 = load i32, i32* @BUFSIZ
%153 = call i32 @read(i32 %133, i8* %37, i32 %152)
%154 = icmp sgt i32 %153, 0
br i1 %154, label %155, label %161
155: ; preds = %150, %155
%156 = phi i32 [ %159, %155 ], [ %153, %150 ]
%157 = call i32 @write(i32 %14, i8* %37, i32 %156)
%158 = load i32, i32* @BUFSIZ
%159 = call i32 @read(i32 %133, i8* %37, i32 %158)
%160 = icmp sgt i32 %159, 0
br i1 %160, label %155, label %161
161: ; preds = %155, %150
%162 = call i32 @close(i32 %133)
br label %163
163: ; preds = %147, %137, %161
%164 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0), %161 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.20, i64 0, i64 0), %137 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.19, i64 0, i64 0), %147 ]
%165 = call i32 @puts(i8* dereferenceable(1) %164)
br label %166
166: ; preds = %163, %135
br label %167
167: ; preds = %166, %168, %114
br label %41
168: ; preds = %118
%169 = call i32 @write(i32 %14, i8* %37, i32 %121)
br label %167
}