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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int result;
  FILE *fp_in;
  FILE *fp_out;
  unsigned long cnt_in;
  unsigned long cnt_out;
  long size_in;
  long size_out;
  char *buf_in;
  char *buf_out;
  long rec_len_in;
  long rec_len_out;
  int cnt_readed;
  int cnt_wroten;
  result = 0;
  fp_in = NULL;
  fp_out = NULL;
  buf_in = NULL;
  buf_out = NULL;
  fp_in = fopen(".\\input.txt", "rb");
  if (fp_in == NULL) {
    printf("in file open error.\r\n");
    result = -1;
  }
  if (result == 0) {
    fseek(fp_in, 0, SEEK_END);
    size_in = ftell(fp_in);
    printf("input file's size:%d.\r\n", size_in);
    fseek(fp_in, 0, SEEK_SET);
  }
  if (result == 0) {
    fp_out = fopen(".\\output.txt", "wb");
    if (fp_out == NULL) {
      printf("out file open error.\r\n");
      result = -1;
    }
  }
  rec_len_in = 512;
  rec_len_out = rec_len_in;
  if (result == 0) {
    buf_in = (char *)malloc(sizeof(char) * rec_len_in);
    if (buf_in == NULL) {
      printf("memory alloc error.\r\n");
      result = -1;
    }
  }
  if (result == 0) {
    buf_out = (char *)malloc(sizeof(char) * rec_len_out);
    if (buf_out == NULL) {
      printf("memory alloc error.\r\n");
      result = -1;
    }
  }
  cnt_in = 0;
  cnt_out = 0;
  while (result == 0 && !feof(fp_in)) {
    memset(buf_in, 0, sizeof(char) * rec_len_in);
    cnt_readed = fread(buf_in, sizeof(char), rec_len_in, fp_in);
    if (cnt_readed <= 0) {
      printf("end of read file by %d.\r\n", cnt_readed);
      break;
    }
    cnt_in++;
    memset(buf_out, 0, sizeof(char) * rec_len_out);
    memcpy(buf_out, buf_in, cnt_readed);
    cnt_wroten = fwrite(buf_out, sizeof(char), cnt_readed, fp_out);
    if (cnt_wroten != cnt_readed) {
      printf("write out file error.\r\n");
      result = -1;
      break;
    }
    cnt_out++;
  }
  if (result == 0) {
    size_out = ftell(fp_out);
    printf("output file's size:%d.\r\n", size_out);
  }
  if (buf_out != NULL) {
    free(buf_out);
    buf_out = NULL;
  }
  if (buf_in != NULL) {
    free(buf_in);
    buf_in = NULL;
  }
  if (fp_in != NULL) {
    fclose(fp_in);
    fp_in = NULL;
  }
  if (fp_out != NULL) {
    fclose(fp_out);
    fp_out = NULL;
  }
  printf("---- ----- ---------\r\n");
  printf("  in count:%09d.\r\n", cnt_in);
  printf(" out count:%09d.\r\n", cnt_out);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
lea    0xdf9(%rip),%rdi
lea    0xdfe(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1237 <main+0x77>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1288 <main+0xc8>
mov    -0x20(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d59(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
cmpl   $0x0,-0x14(%rbp)
jne    12ce <main+0x10e>
lea    0xda4(%rip),%rdi
lea    0xdaa(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12c9 <main+0x109>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    12ce <main+0x10e>
movq   $0x200,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1320 <main+0x160>
mov    -0x60(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    131b <main+0x15b>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1320 <main+0x160>
cmpl   $0x0,-0x14(%rbp)
jne    1362 <main+0x1a2>
mov    -0x68(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    135d <main+0x19d>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1362 <main+0x1a2>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x71(%rbp)
jne    1395 <main+0x1d5>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    13a5 <main+0x1e5>
jmp    1473 <main+0x2b3>
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jg     13f3 <main+0x233>
mov    -0x6c(%rbp),%esi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1473 <main+0x2b3>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x68(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x6c(%rbp),%edx
call   10a0 <memcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x6c(%rbp),%eax
je     1462 <main+0x2a2>
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    1473 <main+0x2b3>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1372 <main+0x1b2>
cmpl   $0x0,-0x14(%rbp)
jne    149c <main+0x2dc>
mov    -0x28(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xc17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x58(%rbp)
je     14b8 <main+0x2f8>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     14d4 <main+0x314>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     14f0 <main+0x330>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     150c <main+0x34c>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x28(%rbp)
lea    0xbb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xbb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe1b(%rip),%rdi
lea    0xe20(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     132b <main+0x15b>
mov    %rax,%r15
mov    0x2de4(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %r15,%rdi
call   1090 <ftell@plt>
lea    0xdf0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
lea    0xde4(%rip),%rdi
lea    0xdea(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1346 <main+0x176>
mov    %rax,%r14
mov    $0x200,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     1352 <main+0x182>
mov    %rax,%r12
mov    $0x200,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     136a <main+0x19a>
mov    %rax,%rbp
mov    %r14,0x10(%rsp)
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %rbx,%r13
mov    %r15,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1393 <main+0x1c3>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    $0x200,%edx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1050 <fread@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    1382 <main+0x1b2>
lea    0x1(%r13),%rbx
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   10b0 <memcpy@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    0x10(%rsp),%rcx
call   10f0 <fwrite@plt>
cmp    %r14d,%eax
je     1290 <main+0xc0>
lea    0xd92(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,0xc(%rsp)
ff
mov    0x10(%rsp),%r14
jmp    13bc <main+0x1ec>
lea    0xdb6(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    13ea <main+0x21a>
lea    0xd85(%rip),%rdi
xor    %r14d,%r14d
jmp    1359 <main+0x189>
lea    0xd64(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    13d5 <main+0x205>
lea    0xd4c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    13c8 <main+0x1f8>
lea    0xcae(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%r14
mov    %r14,%rdi
call   1090 <ftell@plt>
lea    0xcaa(%rip),%rdi
movl   $0x0,0xc(%rsp)
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rbx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%ebp
mov    %r12,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     13dd <main+0x20d>
mov    %r15,%rdi
call   1060 <fclose@plt>
test   %r14,%r14
je     13ea <main+0x21a>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xc9f(%rip),%rdi
call   1040 <puts@plt>
lea    0xc6d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc6f(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c".\\input.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [22 x i8] c"in file open error.\0D\0A\00"
@SEEK_END = global i32 0
@.str.3 = [24 x i8] c"input file's size:%d.\0D\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c".\\output.txt\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [23 x i8] c"out file open error.\0D\0A\00"
@.str.7 = [22 x i8] c"memory alloc error.\0D\0A\00"
@.str.8 = [26 x i8] c"end of read file by %d.\0D\0A\00"
@.str.9 = [24 x i8] c"write out file error.\0D\0A\00"
@.str.10 = [25 x i8] c"output file's size:%d.\0D\0A\00"
@.str.11 = [23 x i8] c"---- ----- ---------\0D\0A\00"
@.str.12 = [19 x i8] c" in count:%09d.\0D\0A\00"
@.str.13 = [19 x i8] c" out count:%09d.\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32* null, i32** %7
store i32* null, i32** %8
store i8* null, i8** %13
store i8* null, i8** %14
%19 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %6
br label %24
24: ; preds = %22, %2
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = load i32*, i32** %7
%29 = load i32, i32* @SEEK_END
%30 = call i32 @fseek(i32* %28, i32 0, i32 %29)
%31 = load i32*, i32** %7
%32 = call i64 @ftell(i32* %31)
store i64 %32, i64* %11
%33 = load i64, i64* %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %33)
%35 = load i32*, i32** %7
%36 = load i32, i32* @SEEK_SET
%37 = call i32 @fseek(i32* %35, i32 0, i32 %36)
br label %38
38: ; preds = %27, %24
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %42, i32** %8
%43 = load i32*, i32** %8
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %6
br label %47
47: ; preds = %45, %41
br label %48
48: ; preds = %47, %38
store i64 512, i64* %15
%49 = load i64, i64* %15
store i64 %49, i64* %16
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %63
52: ; preds = %48
%53 = load i64, i64* %15
%54 = mul i64 1, %53
%55 = trunc i64 %54 to i32
%56 = call i64 @malloc(i32 %55)
%57 = inttoptr i64 %56 to i8*
store i8* %57, i8** %13
%58 = load i8*, i8** %13
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %62
60: ; preds = %52
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %6
br label %62
62: ; preds = %60, %52
br label %63
63: ; preds = %62, %48
%64 = load i32, i32* %6
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %77
66: ; preds = %63
%67 = load i64, i64* %16
%68 = mul i64 1, %67
%69 = trunc i64 %68 to i32
%70 = call i64 @malloc(i32 %69)
%71 = inttoptr i64 %70 to i8*
store i8* %71, i8** %14
%72 = load i8*, i8** %14
%73 = icmp eq i8* %72, null
br i1 %73, label %74, label %76
74: ; preds = %66
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %6
br label %76
76: ; preds = %74, %66
br label %77
77: ; preds = %76, %63
store i64 0, i64* %9
store i64 0, i64* %10
br label %78
78: ; preds = %124, %77
%79 = load i32, i32* %6
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %78
%82 = load i32*, i32** %7
%83 = call i32 @feof(i32* %82)
%84 = icmp ne i32 %83, 0
%85 = xor i1 %84, true
br label %86
86: ; preds = %81, %78
%87 = phi i1 [ false, %78 ], [ %85, %81 ]
br i1 %87, label %88, label %127
88: ; preds = %86
%89 = load i8*, i8** %13
%90 = load i64, i64* %15
%91 = mul i64 1, %90
%92 = trunc i64 %91 to i32
%93 = call i32 @memset(i8* %89, i32 0, i32 %92)
%94 = load i8*, i8** %13
%95 = load i64, i64* %15
%96 = load i32*, i32** %7
%97 = call i32 @fread(i8* %94, i32 1, i64 %95, i32* %96)
store i32 %97, i32* %17
%98 = load i32, i32* %17
%99 = icmp sle i32 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %88
%101 = load i32, i32* %17
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %101)
br label %127
103: ; preds = %88
%104 = load i64, i64* %9
%105 = add i64 %104, 1
store i64 %105, i64* %9
%106 = load i8*, i8** %14
%107 = load i64, i64* %16
%108 = mul i64 1, %107
%109 = trunc i64 %108 to i32
%110 = call i32 @memset(i8* %106, i32 0, i32 %109)
%111 = load i8*, i8** %14
%112 = load i8*, i8** %13
%113 = load i32, i32* %17
%114 = call i32 @memcpy(i8* %111, i8* %112, i32 %113)
%115 = load i8*, i8** %14
%116 = load i32, i32* %17
%117 = load i32*, i32** %8
%118 = call i32 @fwrite(i8* %115, i32 1, i32 %116, i32* %117)
store i32 %118, i32* %18
%119 = load i32, i32* %18
%120 = load i32, i32* %17
%121 = icmp ne i32 %119, %120
br i1 %121, label %122, label %124
122: ; preds = %103
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %6
br label %127
124: ; preds = %103
%125 = load i64, i64* %10
%126 = add i64 %125, 1
store i64 %126, i64* %10
br label %78
127: ; preds = %122, %100, %86
%128 = load i32, i32* %6
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %135
130: ; preds = %127
%131 = load i32*, i32** %8
%132 = call i64 @ftell(i32* %131)
store i64 %132, i64* %12
%133 = load i64, i64* %12
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i64 %133)
br label %135
135: ; preds = %130, %127
%136 = load i8*, i8** %14
%137 = icmp ne i8* %136, null
br i1 %137, label %138, label %141
138: ; preds = %135
%139 = load i8*, i8** %14
%140 = call i32 @free(i8* %139)
store i8* null, i8** %14
br label %141
141: ; preds = %138, %135
%142 = load i8*, i8** %13
%143 = icmp ne i8* %142, null
br i1 %143, label %144, label %147
144: ; preds = %141
%145 = load i8*, i8** %13
%146 = call i32 @free(i8* %145)
store i8* null, i8** %13
br label %147
147: ; preds = %144, %141
%148 = load i32*, i32** %7
%149 = icmp ne i32* %148, null
br i1 %149, label %150, label %153
150: ; preds = %147
%151 = load i32*, i32** %7
%152 = call i32 @fclose(i32* %151)
store i32* null, i32** %7
br label %153
153: ; preds = %150, %147
%154 = load i32*, i32** %8
%155 = icmp ne i32* %154, null
br i1 %155, label %156, label %159
156: ; preds = %153
%157 = load i32*, i32** %8
%158 = call i32 @fclose(i32* %157)
store i32* null, i32** %8
br label %159
159: ; preds = %156, %153
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
%161 = load i64, i64* %9
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64 %161)
%163 = load i64, i64* %10
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i64 %163)
%165 = load i32, i32* %6
ret i32 %165
}

LLVM IR (-O2):
@.str = [12 x i8] c".\\input.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@.str.3 = [24 x i8] c"input file's size:%d.\0D\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c".\\output.txt\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.8 = [26 x i8] c"end of read file by %d.\0D\0A\00"
@.str.10 = [25 x i8] c"output file's size:%d.\0D\0A\00"
@.str.12 = [19 x i8] c" in count:%09d.\0D\0A\00"
@.str.13 = [19 x i8] c" out count:%09d.\0D\0A\00"
@str = [22 x i8] c"---- ----- ---------\0D\00"
@str.14 = [23 x i8] c"write out file error.\0D\00"
@str.16 = [21 x i8] c"memory alloc error.\0D\00"
@str.17 = [22 x i8] c"out file open error.\0D\00"
@str.18 = [21 x i8] c"in file open error.\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.18, i64 0, i64 0))
br label %74
7: ; preds = %2
%8 = load i32, i32* @SEEK_END
%9 = tail call i32 @fseek(i32* %3, i32 0, i32 %8)
%10 = tail call i64 @ftell(i32* %3)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %10)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @fseek(i32* %3, i32 0, i32 %12)
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %56, label %16
16: ; preds = %7
%17 = tail call i64 @malloc(i32 512)
%18 = inttoptr i64 %17 to i8*
%19 = icmp eq i64 %17, 0
br i1 %19, label %56, label %20
20: ; preds = %16
%21 = tail call i64 @malloc(i32 512)
%22 = inttoptr i64 %21 to i8*
%23 = icmp eq i64 %21, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0))
br label %51
26: ; preds = %20, %36
%27 = phi i64 [ %37, %36 ], [ 0, %20 ]
%28 = tail call i32 @feof(i32* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %44
30: ; preds = %26
%31 = tail call i32 @memset(i8* %18, i32 0, i32 512)
%32 = tail call i32 @fread(i8* %18, i32 1, i64 512, i32* %3)
%33 = icmp slt i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %32)
br label %44
36: ; preds = %30
%37 = add i64 %27, 1
%38 = tail call i32 @memset(i8* %22, i32 0, i32 512)
%39 = tail call i32 @memcpy(i8* %22, i8* %18, i32 %32)
%40 = tail call i32 @fwrite(i8* %22, i32 1, i32 %32, i32* %14)
%41 = icmp eq i32 %40, %32
br i1 %41, label %26, label %42
42: ; preds = %36
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0))
br label %47
44: ; preds = %26, %34
%45 = tail call i64 @ftell(i32* %14)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i64 %45)
br label %47
47: ; preds = %44, %42
%48 = phi i32 [ 0, %44 ], [ -1, %42 ]
%49 = phi i64 [ %27, %44 ], [ %37, %42 ]
%50 = tail call i32 @free(i8* %22)
br label %51
51: ; preds = %47, %24
%52 = phi i64 [ %49, %47 ], [ 0, %24 ]
%53 = phi i32 [ %48, %47 ], [ -1, %24 ]
%54 = phi i64 [ %27, %47 ], [ 0, %24 ]
%55 = tail call i32 @free(i8* %18)
br i1 %4, label %66, label %60
56: ; preds = %16, %7
%57 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.17, i64 0, i64 0), %7 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0), %16 ]
%58 = phi i32* [ null, %7 ], [ %14, %16 ]
%59 = tail call i32 @puts(i8* dereferenceable(1) %57)
br label %60
60: ; preds = %56, %51
%61 = phi i64 [ %52, %51 ], [ 0, %56 ]
%62 = phi i32 [ %53, %51 ], [ -1, %56 ]
%63 = phi i64 [ %54, %51 ], [ 0, %56 ]
%64 = phi i32* [ %14, %51 ], [ %58, %56 ]
%65 = tail call i32 @fclose(i32* %3)
br label %66
66: ; preds = %60, %51
%67 = phi i64 [ %61, %60 ], [ %52, %51 ]
%68 = phi i32 [ %62, %60 ], [ %53, %51 ]
%69 = phi i64 [ %63, %60 ], [ %54, %51 ]
%70 = phi i32* [ %64, %60 ], [ %14, %51 ]
%71 = icmp eq i32* %70, null
br i1 %71, label %74, label %72
72: ; preds = %66
%73 = tail call i32 @fclose(i32* %70)
br label %74
74: ; preds = %5, %72, %66
%75 = phi i64 [ 0, %5 ], [ %69, %72 ], [ %69, %66 ]
%76 = phi i32 [ -1, %5 ], [ %68, %72 ], [ %68, %66 ]
%77 = phi i64 [ 0, %5 ], [ %67, %72 ], [ %67, %66 ]
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64 %77)
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i64 %75)
ret i32 %76
}