#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int uint32_t;
typedef char uint16_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
char atoi(char *);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int htonl(size_t);
void *htons(char);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memcpy(char *, ...);
int /*<<< orphan*/ memset(struct sockaddr_in *, int, int);
int ntohl(int);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  int fd;
  char *fid;
  FILE *file;
  size_t fid_len;
  ssize_t n, nread;
  uint16_t qtype, type = 0x0002;
  uint32_t body_n;
  struct sockaddr_in sin;
  char send_buf[1024], recv_buf[10240];
  file = fopen("upload_list", "r");
  if (file == NULL) {
    fprintf(stderr, "fopen() failed %s\n", strerror(errno));
    return -1;
  }
  if (argc != 4) {
    fprintf(stderr, "dfs_client_download <ip> <port> <fid>\n");
    fprintf(stderr, "dfs_client_download 10.101.69.16 1304 <fid>\n");
    return -1;
  }
  fid = argv[3];
  memset(&sin, 0x00, sizeof(struct sockaddr_in));
  sin.sin_family = AF_INET;
  sin.sin_port = htons(atoi(argv[2]));
  sin.sin_addr.s_addr = inet_addr(argv[1]);
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd == -1) {
    fprintf(stderr, "socket() failed: %s\n", strerror(errno));
    return 1;
  }
  if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == -1) {
    fprintf(stderr, "connect(%s:%hu) failed: %s\n", argv[1], atoi(argv[2]),
            strerror(errno));
    return 1;
  }
  fid_len = strlen(fid);
  body_n = htonl(fid_len);
  qtype = htons(type);
  memcpy(send_buf, &body_n, 4);
  memcpy(send_buf + 6, &qtype, 2);
  memcpy(send_buf + 8, fid, fid_len);
  n = send(fd, send_buf, 8 + fid_len, 0);
  if (n == -1) {
    fprintf(stderr, "send() failed: %s\n", strerror(errno));
    return 1;
  }
  fprintf(stderr, "send %ld\n", n);
  nread = 0;
  for (;;) {
    n = recv(fd, recv_buf + nread, 10240, 0);
    if (n == -1) {
      fprintf(stderr, "recv() failed: %s\n", strerror(errno));
      return 1;
    }
    if (n == 0) {
      fprintf(stderr, "server close\n");
      break;
    }
    fprintf(stderr, "recv %ld\n", n);
    nread += n;
    if (nread >= 8) {
      body_n = ntohl(*((uint32_t *)recv_buf));
      break;
    }
  }
  nread -= 8;
  for (;;) {
    if (nread >= body_n) {
      break;
    }
    n = recv(fd, recv_buf + nread, 10240, 0);
    if (n == -1) {
      fprintf(stderr, "recv() failed: %s\n", strerror(errno));
      return 1;
    }
    if (n == 0) {
      fprintf(stderr, "server close\n");
      break;
    }
    fprintf(stderr, "recv %ld\n", n);
    nread += n;
  }
  fprintf(stderr, "recv %u, upload fid %s, download body_n %u\n", body_n + 8,
          fid, body_n);
  if (ferror(file) != 0) {
    fprintf(stderr, "file error\n");
  }
  fprintf(stderr, "process over\n");
  close(fd);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x2,-0x3a(%rbp)
lea    0xdbc(%rip),%rdi
lea    0xdc1(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129f <main+0x7f>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c64(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c64(%rbp),%edi
mov    %rax,%rdx
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1745 <main+0x525>
cmpl   $0x4,-0x8(%rbp)
je     12e3 <main+0xc3>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1745 <main+0x525>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
movsbl %al,%edi
call   1070 <htons@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x58(%rbp)
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
mov    0x2c8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    139a <main+0x17a>
mov    0x2c77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c68(%rbp)
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c68(%rbp),%edi
mov    %rax,%rdx
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1745 <main+0x525>
mov    -0x14(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x18,%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    1426 <main+0x206>
mov    0x2c1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c7c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x2c78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
movsbl %al,%eax
mov    %eax,-0x2c6c(%rbp)
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c7c(%rbp),%edi
mov    -0x2c78(%rbp),%rdx
mov    -0x2c6c(%rbp),%ecx
mov    %rax,%r8
lea    0xc77(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1745 <main+0x525>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <htonl@plt>
mov    %eax,-0x40(%rbp)
movsbl -0x3a(%rbp),%edi
call   1070 <htons@plt>
mov    %al,-0x39(%rbp)
lea    -0x460(%rbp),%rdi
xor    %eax,%eax
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   10e0 <memcpy@plt>
lea    -0x460(%rbp),%rdi
add    $0x6,%rdi
xor    %eax,%eax
lea    -0x39(%rbp),%rsi
mov    $0x2,%edx
call   10e0 <memcpy@plt>
lea    -0x460(%rbp),%rdi
add    $0x8,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
call   10e0 <memcpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x460(%rbp),%rsi
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    14ff <main+0x2df>
mov    0x2b12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c80(%rbp)
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c80(%rbp),%edi
mov    %rax,%rdx
lea    0xbba(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1745 <main+0x525>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xba7(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x2c60(%rbp),%rsi
movslq -0x38(%rbp),%rax
add    %rax,%rsi
mov    $0x2800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    158a <main+0x36a>
mov    0x2a87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c84(%rbp)
mov    0x2a68(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c84(%rbp),%edi
mov    %rax,%rdx
lea    0xb4c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1745 <main+0x525>
cmpl   $0x0,-0x34(%rbp)
jne    15b0 <main+0x390>
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    15f5 <main+0x3d5>
mov    0x2a21(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xb21(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jl     15f0 <main+0x3d0>
mov    -0x2c60(%rbp),%edi
call   1120 <ntohl@plt>
mov    %eax,-0x40(%rbp)
jmp    15f5 <main+0x3d5>
jmp    1520 <main+0x300>
mov    -0x38(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
jl     160f <main+0x3ef>
jmp    16c7 <main+0x4a7>
mov    -0x14(%rbp),%edi
lea    -0x2c60(%rbp),%rsi
movslq -0x38(%rbp),%rax
add    %rax,%rsi
mov    $0x2800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1679 <main+0x459>
mov    0x2998(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c88(%rbp)
mov    0x2979(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x2c88(%rbp),%edi
mov    %rax,%rdx
lea    0xa5d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1745 <main+0x525>
cmpl   $0x0,-0x34(%rbp)
jne    169f <main+0x47f>
mov    0x294e(%rip),%rax
mov    (%rax),%edi
lea    0xa43(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    16c7 <main+0x4a7>
mov    0x2932(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xa32(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    15fe <main+0x3de>
mov    0x290a(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
add    $0x8,%edx
mov    -0x20(%rbp),%rcx
mov    -0x40(%rbp),%r8d
lea    0xa09(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1716 <main+0x4f6>
mov    0x28d2(%rip),%rax
mov    (%rax),%edi
lea    0xa0b(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x28bb(%rip),%rax
mov    (%rax),%edi
lea    0xa00(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2c90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2c38,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdc3(%rip),%rdi
lea    0xdc8(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13f0 <main+0x1d0>
cmp    $0x4,%ebp
jne    1424 <main+0x204>
mov    %rax,%r15
mov    0x18(%rbx),%r14
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2d6e(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    0x10(%rbx),%rdi
call   1100 <atoi@plt>
movsbl %al,%edi
call   1070 <htons@plt>
mov    %rax,0x20(%rsp)
mov    0x8(%rbx),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0x18(%rsp)
mov    0x0(%rbp),%edi
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
je     1455 <main+0x235>
mov    %eax,%ebp
lea    0x18(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
je     1478 <main+0x258>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    $0x2,%edi
call   1070 <htons@plt>
mov    %al,0xb(%rsp)
lea    0x30(%rsp),%r12
lea    0xc(%rsp),%rsi
mov    %r12,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10e0 <memcpy@plt>
lea    0x36(%rsp),%rdi
lea    0xb(%rsp),%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   10e0 <memcpy@plt>
lea    0x38(%rsp),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   10e0 <memcpy@plt>
add    $0x8,%ebx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    0x2c7e(%rip),%r13
mov    0x0(%r13),%ebx
cmp    $0xffffffff,%eax
je     14bc <main+0x29c>
mov    %r14,0x10(%rsp)
lea    0xd46(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
lea    0xd5f(%rip),%r12
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movslq %r14d,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x430,%rsi
mov    %ebp,%edi
mov    $0x2800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
je     14d6 <main+0x2b6>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1556 <main+0x336>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
add    %ebx,%r14d
cmp    $0x8,%r14d
jl     1390 <main+0x170>
mov    0x430(%rsp),%edi
call   1120 <ntohl@plt>
mov    %eax,%r8d
mov    %eax,0xc(%rsp)
jmp    14ed <main+0x2cd>
mov    0x2be1(%rip),%rax
mov    (%rax),%ebx
mov    0x2bc8(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc00(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1580 <main+0x360>
mov    0x2bad(%rip),%rbx
mov    (%rbx),%edi
lea    0xbed(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc04(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1580 <main+0x360>
mov    0x2b7c(%rip),%rax
mov    (%rax),%ebx
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xc02(%rip),%rsi
jmp    156f <main+0x34f>
mov    0x2b59(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
call   1100 <atoi@plt>
movsbl %al,%ebx
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xbe4(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    157b <main+0x35b>
mov    0x2b05(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xbd5(%rip),%rsi
jmp    156f <main+0x34f>
mov    0x0(%r13),%edi
lea    0xbf5(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0xc(%rsp),%r8d
add    $0xfffffff8,%r14d
cmp    %r8d,%r14d
jge    15ab <main+0x38b>
lea    0xbe3(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %r14d,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x430,%rsi
mov    %ebp,%edi
mov    $0x2800,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
je     1594 <main+0x374>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1556 <main+0x336>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
add    %ebx,%r14d
mov    0xc(%rsp),%r8d
cmp    %r8d,%r14d
jl     1510 <main+0x2f0>
jmp    15ab <main+0x38b>
mov    0x0(%r13),%ebx
mov    0x2a67(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb54(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x2c38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%edi
lea    0xb37(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0xc(%rsp),%r8d
mov    0x0(%r13),%edi
lea    0x8(%r8),%edx
lea    0xb34(%rip),%rsi
xor    %ebx,%ebx
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r15,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     15e7 <main+0x3c7>
mov    0x0(%r13),%edi
lea    0xb3a(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xb34(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
jmp    1580 <main+0x360>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"upload_list\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"fopen() failed %s\0A\00"
@errno = global i32 0
@.str.3 = [39 x i8] c"dfs_client_download <ip> <port> <fid>\0A\00"
@.str.4 = [45 x i8] c"dfs_client_download 10.101.69.16 1304 <fid>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [21 x i8] c"socket() failed: %s\0A\00"
@.str.6 = [28 x i8] c"connect(%s:%hu) failed: %s\0A\00"
@.str.7 = [19 x i8] c"send() failed: %s\0A\00"
@.str.8 = [10 x i8] c"send %ld\0A\00"
@.str.9 = [19 x i8] c"recv() failed: %s\0A\00"
@.str.10 = [14 x i8] c"server close\0A\00"
@.str.11 = [10 x i8] c"recv %ld\0A\00"
@.str.12 = [44 x i8] c"recv %u, upload fid %s, download body_n %u\0A\00"
@.str.13 = [12 x i8] c"file error\0A\00"
@.str.14 = [14 x i8] c"process over\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32
%15 = alloca %struct.sockaddr_in
%16 = alloca [1024 x i8]
%17 = alloca [10240 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 2, i8* %13
%18 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %8
%19 = load i32*, i32** %8
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 -1, i32* %3
br label %206
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 4
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %206
34: ; preds = %26
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
store i8* %37, i8** %7
%38 = call i32 @memset(%struct.sockaddr_in* %15, i32 0, i32 24)
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %39, i32* %40
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call signext i8 @atoi(i8* %43)
%45 = call i8* @htons(i8 signext %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i8* %45, i8** %46
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @inet_addr(i8* %49)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 0
store i32 %50, i32* %52
%53 = load i32, i32* @AF_INET
%54 = load i32, i32* @SOCK_STREAM
%55 = call i32 @socket(i32 %53, i32 %54, i32 0)
store i32 %55, i32* %6
%56 = load i32, i32* %6
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %63
58: ; preds = %34
%59 = load i32, i32* @stderr
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %61)
store i32 1, i32* %3
br label %206
63: ; preds = %34
%64 = load i32, i32* %6
%65 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%66 = call i32 @connect(i32 %64, %struct.sockaddr* %65, i32 24)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %81
68: ; preds = %63
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call signext i8 @atoi(i8* %75)
%77 = sext i8 %76 to i32
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %72, i32 %77, i8* %79)
store i32 1, i32* %3
br label %206
81: ; preds = %63
%82 = load i8*, i8** %7
%83 = call i64 @strlen(i8* %82)
store i64 %83, i64* %9
%84 = load i64, i64* %9
%85 = call i32 @htonl(i64 %84)
store i32 %85, i32* %14
%86 = load i8, i8* %13
%87 = call i8* @htons(i8 signext %86)
%88 = ptrtoint i8* %87 to i8
store i8 %88, i8* %12
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%90 = call i32 (i8*, ...) @memcpy(i8* %89, i32* %14, i32 4)
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%92 = getelementptr inbounds i8, i8* %91, i64 6
%93 = call i32 (i8*, ...) @memcpy(i8* %92, i8* %12, i32 2)
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%95 = getelementptr inbounds i8, i8* %94, i64 8
%96 = load i8*, i8** %7
%97 = load i64, i64* %9
%98 = call i32 (i8*, ...) @memcpy(i8* %95, i8* %96, i64 %97)
%99 = load i32, i32* %6
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%101 = load i64, i64* %9
%102 = add i64 8, %101
%103 = trunc i64 %102 to i32
%104 = call i32 @send(i32 %99, i8* %100, i32 %103, i32 0)
store i32 %104, i32* %10
%105 = load i32, i32* %10
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %112
107: ; preds = %81
%108 = load i32, i32* @stderr
%109 = load i32, i32* @errno
%110 = call i8* @strerror(i32 %109)
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %110)
store i32 1, i32* %3
br label %206
112: ; preds = %81
%113 = load i32, i32* @stderr
%114 = load i32, i32* %10
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %114)
store i32 0, i32* %11
br label %116
116: ; preds = %150, %112
%117 = load i32, i32* %6
%118 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%119 = load i32, i32* %11
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = call i32 @recv(i32 %117, i8* %121, i32 10240, i32 0)
store i32 %122, i32* %10
%123 = load i32, i32* %10
%124 = icmp eq i32 %123, -1
br i1 %124, label %125, label %130
125: ; preds = %116
%126 = load i32, i32* @stderr
%127 = load i32, i32* @errno
%128 = call i8* @strerror(i32 %127)
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %128)
store i32 1, i32* %3
br label %206
130: ; preds = %116
%131 = load i32, i32* %10
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %130
%134 = load i32, i32* @stderr
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %151
136: ; preds = %130
%137 = load i32, i32* @stderr
%138 = load i32, i32* %10
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %138)
%140 = load i32, i32* %10
%141 = load i32, i32* %11
%142 = add nsw i32 %141, %140
store i32 %142, i32* %11
%143 = load i32, i32* %11
%144 = icmp sge i32 %143, 8
br i1 %144, label %145, label %150
145: ; preds = %136
%146 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%147 = bitcast i8* %146 to i32*
%148 = load i32, i32* %147
%149 = call i32 @ntohl(i32 %148)
store i32 %149, i32* %14
br label %151
150: ; preds = %136
br label %116
151: ; preds = %145, %133
%152 = load i32, i32* %11
%153 = sub nsw i32 %152, 8
store i32 %153, i32* %11
br label %154
154: ; preds = %179, %151
%155 = load i32, i32* %11
%156 = load i32, i32* %14
%157 = icmp sge i32 %155, %156
br i1 %157, label %158, label %159
158: ; preds = %154
br label %186
159: ; preds = %154
%160 = load i32, i32* %6
%161 = getelementptr inbounds [10240 x i8], [10240 x i8]* %17, i64 0, i64 0
%162 = load i32, i32* %11
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %161, i64 %163
%165 = call i32 @recv(i32 %160, i8* %164, i32 10240, i32 0)
store i32 %165, i32* %10
%166 = load i32, i32* %10
%167 = icmp eq i32 %166, -1
br i1 %167, label %168, label %173
168: ; preds = %159
%169 = load i32, i32* @stderr
%170 = load i32, i32* @errno
%171 = call i8* @strerror(i32 %170)
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %171)
store i32 1, i32* %3
br label %206
173: ; preds = %159
%174 = load i32, i32* %10
%175 = icmp eq i32 %174, 0
br i1 %175, label %176, label %179
176: ; preds = %173
%177 = load i32, i32* @stderr
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %186
179: ; preds = %173
%180 = load i32, i32* @stderr
%181 = load i32, i32* %10
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %181)
%183 = load i32, i32* %10
%184 = load i32, i32* %11
%185 = add nsw i32 %184, %183
store i32 %185, i32* %11
br label %154
186: ; preds = %176, %158
%187 = load i32, i32* @stderr
%188 = load i32, i32* %14
%189 = add nsw i32 %188, 8
%190 = load i8*, i8** %7
%191 = load i32, i32* %14
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %189, i8* %190, i32 %191)
%193 = load i32*, i32** %8
%194 = call i64 @ferror(i32* %193)
%195 = icmp ne i64 %194, 0
br i1 %195, label %196, label %199
196: ; preds = %186
%197 = load i32, i32* @stderr
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %197, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %199
199: ; preds = %196, %186
%200 = load i32, i32* @stderr
%201 = call i32 (i32, i8*, ...) @fprintf(i32 %200, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%202 = load i32, i32* %6
%203 = call i32 @close(i32 %202)
%204 = load i32*, i32** %8
%205 = call i32 @fclose(i32* %204)
store i32 0, i32* %3
br label %206
206: ; preds = %199, %168, %125, %107, %68, %58, %29, %21
%207 = load i32, i32* %3
ret i32 %207
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"upload_list\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"fopen() failed %s\0A\00"
@errno = global i32 0
@.str.3 = [39 x i8] c"dfs_client_download <ip> <port> <fid>\0A\00"
@.str.4 = [45 x i8] c"dfs_client_download 10.101.69.16 1304 <fid>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [21 x i8] c"socket() failed: %s\0A\00"
@.str.6 = [28 x i8] c"connect(%s:%hu) failed: %s\0A\00"
@.str.7 = [19 x i8] c"send() failed: %s\0A\00"
@.str.8 = [10 x i8] c"send %ld\0A\00"
@.str.9 = [19 x i8] c"recv() failed: %s\0A\00"
@.str.10 = [14 x i8] c"server close\0A\00"
@.str.11 = [10 x i8] c"recv %ld\0A\00"
@.str.12 = [44 x i8] c"recv %u, upload fid %s, download body_n %u\0A\00"
@.str.13 = [12 x i8] c"file error\0A\00"
@.str.14 = [14 x i8] c"process over\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca [1024 x i8]
%7 = alloca [10240 x i8]
%8 = bitcast i32* %4 to i8*
%9 = bitcast %struct.sockaddr_in* %5 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 0
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %148
19: ; preds = %2
%20 = icmp eq i32 %0, 4
br i1 %20, label %26, label %21
21: ; preds = %19
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %148
26: ; preds = %19
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 24)
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %30, i32* %31
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = call signext i8 @atoi(i8* %33)
%35 = call i8* @htons(i8 signext %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i8* %35, i8** %36
%37 = getelementptr inbounds i8*, i8** %1, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @inet_addr(i8* %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %39, i32* %40
%41 = load i32, i32* @AF_INET
%42 = load i32, i32* @SOCK_STREAM
%43 = call i32 @socket(i32 %41, i32 %42, i32 0)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %50
45: ; preds = %26
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i8* @strerror(i32 %47)
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %48)
br label %148
50: ; preds = %26
%51 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%52 = call i32 @connect(i32 %43, %struct.sockaddr* %51, i32 24)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %63
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = load i8*, i8** %37
%57 = load i8*, i8** %32
%58 = call signext i8 @atoi(i8* %57)
%59 = sext i8 %58 to i32
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %56, i32 %59, i8* %61)
br label %148
63: ; preds = %50
%64 = call i64 @strlen(i8* dereferenceable(1) %28)
%65 = call i32 @htonl(i64 %64)
store i32 %65, i32* %4
%66 = call i8* @htons(i8 signext 2)
%67 = ptrtoint i8* %66 to i64
%68 = trunc i64 %67 to i8
store i8 %68, i8* %3
%69 = call i32 (i8*, ...) @memcpy(i8* %10, i32* %4, i32 4)
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 6
%71 = call i32 (i8*, ...) @memcpy(i8* %70, i8* %3, i32 2)
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 8
%73 = call i32 (i8*, ...) @memcpy(i8* %72, i8* %28, i64 %64)
%74 = trunc i64 %64 to i32
%75 = add i32 %74, 8
%76 = call i32 @send(i32 %43, i8* %10, i32 %75, i32 0)
%77 = icmp eq i32 %76, -1
%78 = load i32, i32* @stderr
br i1 %77, label %79, label %83
79: ; preds = %63
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %81)
br label %148
83: ; preds = %63
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %76)
br label %85
85: ; preds = %99, %83
%86 = phi i32 [ 0, %83 ], [ %102, %99 ]
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 %87
%89 = call i32 @recv(i32 %43, i8* %88, i32 10240, i32 0)
switch i32 %89, label %99 [
i32 -1, label %90
i32 0, label %95
]
90: ; preds = %85
%91 = load i32, i32* @stderr
%92 = load i32, i32* @errno
%93 = call i8* @strerror(i32 %92)
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %93)
br label %148
95: ; preds = %85
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%98 = load i32, i32* %4
br label %108
99: ; preds = %85
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %89)
%102 = add nsw i32 %89, %86
%103 = icmp sgt i32 %102, 7
br i1 %103, label %104, label %85
104: ; preds = %99
%105 = bitcast [10240 x i8]* %7 to i32*
%106 = load i32, i32* %105
%107 = call i32 @ntohl(i32 %106)
store i32 %107, i32* %4
br label %108
108: ; preds = %104, %95
%109 = phi i32 [ %98, %95 ], [ %107, %104 ]
%110 = phi i32 [ %86, %95 ], [ %102, %104 ]
%111 = add nsw i32 %110, -8
%112 = icmp slt i32 %111, %109
br i1 %112, label %113, label %133
113: ; preds = %108, %127
%114 = phi i32 [ %130, %127 ], [ %111, %108 ]
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [10240 x i8], [10240 x i8]* %7, i64 0, i64 %115
%117 = call i32 @recv(i32 %43, i8* %116, i32 10240, i32 0)
switch i32 %117, label %127 [
i32 -1, label %118
i32 0, label %123
]
118: ; preds = %113
%119 = load i32, i32* @stderr
%120 = load i32, i32* @errno
%121 = call i8* @strerror(i32 %120)
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %121)
br label %148
123: ; preds = %113
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%126 = load i32, i32* %4
br label %133
127: ; preds = %113
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 %117)
%130 = add nsw i32 %117, %114
%131 = load i32, i32* %4
%132 = icmp slt i32 %130, %131
br i1 %132, label %113, label %133
133: ; preds = %127, %108, %123
%134 = phi i32 [ %109, %108 ], [ %126, %123 ], [ %131, %127 ]
%135 = load i32, i32* @stderr
%136 = add nsw i32 %134, 8
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %136, i8* %28, i32 %134)
%138 = call i64 @ferror(i32* %12)
%139 = icmp eq i64 %138, 0
br i1 %139, label %143, label %140
140: ; preds = %133
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %143
143: ; preds = %140, %133
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%146 = call i32 @close(i32 %43)
%147 = call i32 @fclose(i32* %12)
br label %148
148: ; preds = %143, %118, %90, %79, %54, %45, %21, %14
%149 = phi i32 [ -1, %14 ], [ -1, %21 ], [ 1, %45 ], [ 1, %54 ], [ 1, %79 ], [ 1, %90 ], [ 0, %143 ], [ 1, %118 ]
ret i32 %149
}