#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 errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned int fread(unsigned char *, int, unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
unsigned int fwrite(unsigned char *, int, unsigned int, int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ memcpy(unsigned char *, ...);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int main(int argc, char **argv) {
  FILE *fp;
  int ret;
  unsigned int file_len = 0;
  unsigned int check_sum = 0;
  unsigned char *buf16K;
  unsigned char *tmp_count;
  unsigned int rw_len = 0;
  unsigned int count;
  if (argc != 3) {
    fprintf(stderr,
            "Please Use mk210header <source file> <destination file>\n");
    return -1;
  }
  fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    fprintf(stderr, "fopen %s error:%s!\n", argv[1], strerror(errno));
    return errno;
  }
  ret = fseek(fp, 0, SEEK_END);
  if (ret < 0) {
    fprintf(stderr, "fseek file %s error:%s\n", argv[1], strerror(errno));
    fclose(fp);
    return errno;
  }
  file_len = ftell(fp);
  ret =
      (file_len >= ((0x1 << 14) - (0x10))) ? (0x1 << 14) : (file_len + (0x10));
  file_len =
      (file_len >= ((0x1 << 14) - (0x10))) ? ((0x1 << 14) - (0x10)) : file_len;
  buf16K = (unsigned char *)malloc(file_len + (0x10));
  memset(buf16K, 0, file_len + (0x10));
  memcpy(buf16K, &ret, 4);
  rewind(fp);
  rw_len = fread(buf16K + (0x10), 1, file_len, fp);
  if (rw_len != file_len) {
    fprintf(stderr, "fread buf error %s\n", strerror(errno));
    free(buf16K);
    fclose(fp);
    return errno;
  }
  tmp_count = buf16K + (0x10);
  for (count = 0; count < rw_len; count++) {
    check_sum += tmp_count[count];
  }
  memcpy(buf16K + 0x8, &check_sum, 4);
  fclose(fp);
  fp = fopen(argv[2], "wb");
  if (fp == NULL) {
    fprintf(stderr, "fopen %s file error:%s!\n", argv[2], strerror(errno));
    return errno;
  }
  rw_len = fwrite(buf16K, 1, file_len + (0x10), fp);
  if (rw_len != file_len + (0x10)) {
    fprintf(stderr, "fwrite buf error %s\n", strerror(errno));
    free(buf16K);
    fclose(fp);
    return errno;
  }
  printf("the file %s create success!\n", argv[2]);
  free(buf16K);
  fclose(fp);
  return 0;
}


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,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     123b <main+0x5b>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdef(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12ad <main+0xcd>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x18(%rbp),%rdi
mov    0x2d30(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1326 <main+0x146>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x18(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x3ff0,-0x20(%rbp)
jb     134c <main+0x16c>
mov    $0x4000,%eax
mov    %eax,-0x60(%rbp)
jmp    1355 <main+0x175>
mov    -0x20(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3ff0,-0x20(%rbp)
jb     1375 <main+0x195>
mov    $0x3ff0,%eax
mov    %eax,-0x64(%rbp)
jmp    137b <main+0x19b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
add    $0x10,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%edx
add    $0x10,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x30(%rbp),%rdi
add    $0x10,%rdi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1437 <main+0x257>
mov    0x2beb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rdx
lea    0xc5b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2ba3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x30(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jae    1475 <main+0x295>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    144a <main+0x26a>
mov    -0x30(%rbp),%rdi
add    $0x8,%rdi
xor    %eax,%eax
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xbd7(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1508 <main+0x328>
mov    0x2b18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xb8f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ad2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%edx
add    $0x10,%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    $0x10,%ecx
cmp    %ecx,%eax
je     1585 <main+0x3a5>
mov    0x2a9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2a89(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x78(%rbp),%edi
mov    %rax,%rdx
lea    0xb3d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15b2 <main+0x3d2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xb19(%rip),%rdi
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jne    12d6 <main+0xf6>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe2e(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     12f7 <main+0x117>
mov    %rax,%r15
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
test   %eax,%eax
js     132b <main+0x14b>
mov    %r15,%rdi
call   10a0 <ftell@plt>
lea    0x10(%rax),%ecx
cmp    $0x3ff0,%eax
mov    $0x4000,%edx
cmovb  %ecx,%edx
mov    %edx,0xc(%rsp)
mov    $0x3ff0,%ebp
cmovb  %eax,%ebp
lea    0x10(%rbp),%r12d
mov    %r12d,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1080 <memset@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <memcpy@plt>
mov    %r15,%rdi
call   1070 <rewind@plt>
lea    0x10(%rbx),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    %ebp,%eax
jne    135f <main+0x17f>
test   %ebp,%ebp
je     1413 <main+0x233>
mov    %ebp,%edx
mov    0x8(%rsp),%ecx
lea    -0x1(%rdx),%rsi
mov    %edx,%eax
and    $0x3,%eax
cmp    $0x3,%rsi
jae    13aa <main+0x1ca>
xor    %esi,%esi
jmp    13e5 <main+0x205>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xd1a(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    139d <main+0x1bd>
mov    0x2cda(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%r14),%rbp
mov    0x2cc5(%rip),%r14
mov    (%r14),%edi
call   1100 <strerror@plt>
lea    0xd22(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    139a <main+0x1ba>
mov    0x2ca6(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%r14),%rbp
mov    0x2c91(%rip),%r14
mov    (%r14),%edi
call   1100 <strerror@plt>
lea    0xd02(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1392 <main+0x1b2>
mov    0x2c72(%rip),%rax
mov    (%rax),%ebp
mov    0x2c61(%rip),%r14
mov    (%r14),%edi
call   1100 <strerror@plt>
lea    0xcea(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    (%r14),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%edx
xor    %esi,%esi
nop
movzbl 0x10(%rbx,%rsi,1),%edi
add    %ecx,%edi
mov    %edi,0x8(%rsp)
movzbl 0x11(%rbx,%rsi,1),%ecx
add    %edi,%ecx
mov    %ecx,0x8(%rsp)
movzbl 0x12(%rbx,%rsi,1),%edi
add    %ecx,%edi
mov    %edi,0x8(%rsp)
movzbl 0x13(%rbx,%rsi,1),%ecx
add    %edi,%ecx
mov    %ecx,0x8(%rsp)
add    $0x4,%rsi
cmp    %rsi,%rdx
jne    13b0 <main+0x1d0>
test   %rax,%rax
je     1413 <main+0x233>
lea    (%rsi,%rbx,1),%rdx
add    $0x10,%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rdx,%rsi,1),%edi
add    %edi,%ecx
mov    %ecx,0x8(%rsp)
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1400 <main+0x220>
mov    %rbx,%rdi
add    $0x8,%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   10b0 <memcpy@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x10(%r14),%rdi
lea    0xc3e(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     148a <main+0x2aa>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rax,%rcx
call   10f0 <fwrite@plt>
cmp    %r12d,%eax
jne    14b2 <main+0x2d2>
mov    0x10(%r14),%rsi
lea    0xc3f(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    139d <main+0x1bd>
mov    0x2b47(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%r14),%rbp
mov    0x2b32(%rip),%r14
mov    (%r14),%edi
call   1100 <strerror@plt>
lea    0xbd2(%rip),%rsi
jmp    131a <main+0x13a>
mov    0x2b1f(%rip),%rax
mov    (%rax),%r14d
mov    0x2b0d(%rip),%r15
mov    (%r15),%edi
call   1100 <strerror@plt>
lea    0xbc6(%rip),%rsi
mov    %r14d,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    (%r15),%eax
jmp    139d <main+0x1bd>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"Please Use mk210header <source file> <destination file>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [20 x i8] c"fopen %s error:%s!\0A\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.3 = [24 x i8] c"fseek file %s error:%s\0A\00"
@.str.4 = [20 x i8] c"fread buf error %s\0A\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [25 x i8] c"fopen %s file error:%s!\0A\00"
@.str.7 = [21 x i8] c"fwrite buf error %s\0A\00"
@.str.8 = [29 x i8] c"the file %s create success!\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 i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %12
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %169
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %35
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %32)
%34 = load i32, i32* @errno
store i32 %34, i32* %3
br label %169
35: ; preds = %19
%36 = load i32*, i32** %6
%37 = load i32, i32* @SEEK_END
%38 = call i32 @fseek(i32* %36, i32 0, i32 %37)
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %52
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %45, i8* %47)
%49 = load i32*, i32** %6
%50 = call i32 @fclose(i32* %49)
%51 = load i32, i32* @errno
store i32 %51, i32* %3
br label %169
52: ; preds = %35
%53 = load i32*, i32** %6
%54 = call i32 @ftell(i32* %53)
store i32 %54, i32* %8
%55 = load i32, i32* %8
%56 = icmp uge i32 %55, 16368
br i1 %56, label %57, label %58
57: ; preds = %52
br label %61
58: ; preds = %52
%59 = load i32, i32* %8
%60 = add i32 %59, 16
br label %61
61: ; preds = %58, %57
%62 = phi i32 [ 16384, %57 ], [ %60, %58 ]
store i32 %62, i32* %7
%63 = load i32, i32* %8
%64 = icmp uge i32 %63, 16368
br i1 %64, label %65, label %66
65: ; preds = %61
br label %68
66: ; preds = %61
%67 = load i32, i32* %8
br label %68
68: ; preds = %66, %65
%69 = phi i32 [ 16368, %65 ], [ %67, %66 ]
store i32 %69, i32* %8
%70 = load i32, i32* %8
%71 = add i32 %70, 16
%72 = call i64 @malloc(i32 %71)
%73 = inttoptr i64 %72 to i8*
store i8* %73, i8** %10
%74 = load i8*, i8** %10
%75 = load i32, i32* %8
%76 = add i32 %75, 16
%77 = call i32 @memset(i8* %74, i32 0, i32 %76)
%78 = load i8*, i8** %10
%79 = call i32 (i8*, ...) @memcpy(i8* %78, i32* %7, i32 4)
%80 = load i32*, i32** %6
%81 = call i32 @rewind(i32* %80)
%82 = load i8*, i8** %10
%83 = getelementptr inbounds i8, i8* %82, i64 16
%84 = load i32, i32* %8
%85 = load i32*, i32** %6
%86 = call i32 @fread(i8* %83, i32 1, i32 %84, i32* %85)
store i32 %86, i32* %12
%87 = load i32, i32* %12
%88 = load i32, i32* %8
%89 = icmp ne i32 %87, %88
br i1 %89, label %90, label %100
90: ; preds = %68
%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 ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %93)
%95 = load i8*, i8** %10
%96 = call i32 @free(i8* %95)
%97 = load i32*, i32** %6
%98 = call i32 @fclose(i32* %97)
%99 = load i32, i32* @errno
store i32 %99, i32* %3
br label %169
100: ; preds = %68
%101 = load i8*, i8** %10
%102 = getelementptr inbounds i8, i8* %101, i64 16
store i8* %102, i8** %11
store i32 0, i32* %13
br label %103
103: ; preds = %116, %100
%104 = load i32, i32* %13
%105 = load i32, i32* %12
%106 = icmp ult i32 %104, %105
br i1 %106, label %107, label %119
107: ; preds = %103
%108 = load i8*, i8** %11
%109 = load i32, i32* %13
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %108, i64 %110
%112 = load i8, i8* %111
%113 = zext i8 %112 to i32
%114 = load i32, i32* %9
%115 = add i32 %114, %113
store i32 %115, i32* %9
br label %116
116: ; preds = %107
%117 = load i32, i32* %13
%118 = add i32 %117, 1
store i32 %118, i32* %13
br label %103
119: ; preds = %103
%120 = load i8*, i8** %10
%121 = getelementptr inbounds i8, i8* %120, i64 8
%122 = call i32 (i8*, ...) @memcpy(i8* %121, i32* %9, i32 4)
%123 = load i32*, i32** %6
%124 = call i32 @fclose(i32* %123)
%125 = load i8**, i8*** %5
%126 = getelementptr inbounds i8*, i8** %125, i64 2
%127 = load i8*, i8** %126
%128 = call i32* @fopen(i8* %127, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %128, i32** %6
%129 = load i32*, i32** %6
%130 = icmp eq i32* %129, null
br i1 %130, label %131, label %140
131: ; preds = %119
%132 = load i32, i32* @stderr
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 2
%135 = load i8*, i8** %134
%136 = load i32, i32* @errno
%137 = call i8* @strerror(i32 %136)
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %135, i8* %137)
%139 = load i32, i32* @errno
store i32 %139, i32* %3
br label %169
140: ; preds = %119
%141 = load i8*, i8** %10
%142 = load i32, i32* %8
%143 = add i32 %142, 16
%144 = load i32*, i32** %6
%145 = call i32 @fwrite(i8* %141, i32 1, i32 %143, i32* %144)
store i32 %145, i32* %12
%146 = load i32, i32* %12
%147 = load i32, i32* %8
%148 = add i32 %147, 16
%149 = icmp ne i32 %146, %148
br i1 %149, label %150, label %160
150: ; preds = %140
%151 = load i32, i32* @stderr
%152 = load i32, i32* @errno
%153 = call i8* @strerror(i32 %152)
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %153)
%155 = load i8*, i8** %10
%156 = call i32 @free(i8* %155)
%157 = load i32*, i32** %6
%158 = call i32 @fclose(i32* %157)
%159 = load i32, i32* @errno
store i32 %159, i32* %3
br label %169
160: ; preds = %140
%161 = load i8**, i8*** %5
%162 = getelementptr inbounds i8*, i8** %161, i64 2
%163 = load i8*, i8** %162
%164 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %163)
%165 = load i8*, i8** %10
%166 = call i32 @free(i8* %165)
%167 = load i32*, i32** %6
%168 = call i32 @fclose(i32* %167)
store i32 0, i32* %3
br label %169
169: ; preds = %160, %150, %131, %90, %41, %26, %16
%170 = load i32, i32* %3
ret i32 %170
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"Please Use mk210header <source file> <destination file>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [20 x i8] c"fopen %s error:%s!\0A\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.3 = [24 x i8] c"fseek file %s error:%s\0A\00"
@.str.4 = [20 x i8] c"fread buf error %s\0A\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [25 x i8] c"fopen %s file error:%s!\0A\00"
@.str.7 = [21 x i8] c"fwrite buf error %s\0A\00"
@.str.8 = [29 x i8] c"the file %s create success!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %140
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %20)
%22 = load i32, i32* @errno
br label %140
23: ; preds = %11
%24 = load i32, i32* @SEEK_END
%25 = tail call i32 @fseek(i32* %14, i32 0, i32 %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %12
%30 = load i32, i32* @errno
%31 = tail call i8* @strerror(i32 %30)
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* %31)
%33 = tail call i32 @fclose(i32* %14)
%34 = load i32, i32* @errno
br label %140
35: ; preds = %23
%36 = tail call i32 @ftell(i32* %14)
%37 = icmp ugt i32 %36, 16367
%38 = add i32 %36, 16
%39 = select i1 %37, i32 16384, i32 %38
store i32 %39, i32* %3
%40 = select i1 %37, i32 16368, i32 %36
%41 = add nuw nsw i32 %40, 16
%42 = tail call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
%44 = tail call i32 @memset(i8* %43, i32 0, i32 %41)
%45 = call i32 (i8*, ...) @memcpy(i8* %43, i32* %3, i32 4)
%46 = call i32 @rewind(i32* %14)
%47 = getelementptr inbounds i8, i8* %43, i64 16
%48 = call i32 @fread(i8* %47, i32 1, i32 %40, i32* %14)
%49 = icmp eq i32 %48, %40
br i1 %49, label %50, label %60
50: ; preds = %35
%51 = icmp eq i32 %40, 0
br i1 %51, label %109, label %52
52: ; preds = %50
%53 = zext i32 %40 to i64
%54 = load i32, i32* %4
%55 = add nsw i64 %53, -1
%56 = and i64 %53, 3
%57 = icmp ult i64 %55, 3
br i1 %57, label %94, label %58
58: ; preds = %52
%59 = and i64 %53, 4294967292
br label %68
60: ; preds = %35
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %63)
%65 = call i32 @free(i8* %43)
%66 = call i32 @fclose(i32* %14)
%67 = load i32, i32* @errno
br label %140
68: ; preds = %68, %58
%69 = phi i32 [ %54, %58 ], [ %90, %68 ]
%70 = phi i64 [ 0, %58 ], [ %91, %68 ]
%71 = phi i64 [ 0, %58 ], [ %92, %68 ]
%72 = getelementptr inbounds i8, i8* %47, i64 %70
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = add i32 %69, %74
store i32 %75, i32* %4
%76 = or i64 %70, 1
%77 = getelementptr inbounds i8, i8* %47, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = add i32 %75, %79
store i32 %80, i32* %4
%81 = or i64 %70, 2
%82 = getelementptr inbounds i8, i8* %47, i64 %81
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = add i32 %80, %84
store i32 %85, i32* %4
%86 = or i64 %70, 3
%87 = getelementptr inbounds i8, i8* %47, i64 %86
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = add i32 %85, %89
store i32 %90, i32* %4
%91 = add nuw nsw i64 %70, 4
%92 = add i64 %71, 4
%93 = icmp eq i64 %92, %59
br i1 %93, label %94, label %68
94: ; preds = %68, %52
%95 = phi i32 [ %54, %52 ], [ %90, %68 ]
%96 = phi i64 [ 0, %52 ], [ %91, %68 ]
%97 = icmp eq i64 %56, 0
br i1 %97, label %109, label %98
98: ; preds = %94, %98
%99 = phi i32 [ %105, %98 ], [ %95, %94 ]
%100 = phi i64 [ %106, %98 ], [ %96, %94 ]
%101 = phi i64 [ %107, %98 ], [ 0, %94 ]
%102 = getelementptr inbounds i8, i8* %47, i64 %100
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = add i32 %99, %104
store i32 %105, i32* %4
%106 = add nuw nsw i64 %100, 1
%107 = add i64 %101, 1
%108 = icmp eq i64 %107, %56
br i1 %108, label %109, label %98
109: ; preds = %94, %98, %50
%110 = getelementptr inbounds i8, i8* %43, i64 8
%111 = call i32 (i8*, ...) @memcpy(i8* %110, i32* %4, i32 4)
%112 = call i32 @fclose(i32* %14)
%113 = getelementptr inbounds i8*, i8** %1, i64 2
%114 = load i8*, i8** %113
%115 = call i32* @fopen(i8* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%116 = icmp eq i32* %115, null
br i1 %116, label %117, label %124
117: ; preds = %109
%118 = load i32, i32* @stderr
%119 = load i8*, i8** %113
%120 = load i32, i32* @errno
%121 = call i8* @strerror(i32 %120)
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %119, i8* %121)
%123 = load i32, i32* @errno
br label %140
124: ; preds = %109
%125 = call i32 @fwrite(i8* %43, i32 1, i32 %41, i32* %115)
%126 = icmp eq i32 %125, %41
br i1 %126, label %135, label %127
127: ; preds = %124
%128 = load i32, i32* @stderr
%129 = load i32, i32* @errno
%130 = call i8* @strerror(i32 %129)
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %130)
%132 = call i32 @free(i8* %43)
%133 = call i32 @fclose(i32* %115)
%134 = load i32, i32* @errno
br label %140
135: ; preds = %124
%136 = load i8*, i8** %113
%137 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %136)
%138 = call i32 @free(i8* %43)
%139 = call i32 @fclose(i32* %115)
br label %140
140: ; preds = %135, %127, %117, %60, %27, %16, %8
%141 = phi i32 [ -1, %8 ], [ %22, %16 ], [ %34, %27 ], [ %67, %60 ], [ %123, %117 ], [ %134, %127 ], [ 0, %135 ]
ret i32 %141
}