#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ is_little_endian();
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *in;
  FILE *out;
  char *infname = argv[1];
  char *outfname = argv[2];
  unsigned char c;
  unsigned char tempArray[9] = {0};
  unsigned int tempInt = 0;
  unsigned int dataInt = 0;
  unsigned int hex_digit, i;
  unsigned int convert_base[8] = {268435456, 16777216, 1048576, 65536,
                                  4096,      256,      16,      1};
  if ((infname == NULL) || (outfname == NULL)) {
    printf("input name error\n");
    return -1;
  }
  if ((in = fopen(infname, "rb")) == NULL) {
    printf("open input file fails\n");
    return -1;
  }
  if ((out = fopen(outfname, "wb")) == NULL) {
    printf("open output file fails\n");
    return -1;
  }
  while (fread(&c, sizeof(unsigned char), 1, in)) {
    if (c == '0') {
      fread(&c, sizeof(unsigned char), 1, in);
      if (c == 'x') {
        fread(tempArray, sizeof(unsigned char), 8, in);
        tempArray[8] = 0;
        for (i = 8; i > 0; i--) {
          if ((tempArray[i - 1] > 47) && (tempArray[i - 1] < 58)) {
            hex_digit = tempArray[i - 1] - 48;
          } else if ((tempArray[i - 1] > 64) && (tempArray[i - 1] < 71)) {
            hex_digit = tempArray[i - 1] - 55;
          } else {
            printf("input name error\n");
            return -1;
          }
          tempInt += (hex_digit * convert_base[i - 1]);
        }
        if (is_little_endian()) {
          for (i = 0; i < 4; i++) {
            *(((char *)&dataInt) + i) = *(((char *)&tempInt) + (3 - i));
          }
        } else {
          dataInt = tempInt;
        }
        fwrite((char *)&dataInt, sizeof(unsigned char), 4, out);
        tempInt = 0;
        dataInt = 0;
      }
    }
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    -0x3a(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <memset@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    0xe3d(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe3a(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe37(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe34(%rip),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11fe <main+0x8e>
cmpq   $0x0,-0x30(%rbp)
jne    1216 <main+0xa6>
lea    0xe1b(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1460 <main+0x2f0>
mov    -0x28(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    124c <main+0xdc>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1460 <main+0x2f0>
mov    -0x30(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1282 <main+0x112>
lea    0xdde(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1460 <main+0x2f0>
jmp    1287 <main+0x117>
mov    -0x18(%rbp),%rcx
lea    -0x31(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
je     1447 <main+0x2d7>
movzbl -0x31(%rbp),%eax
cmp    $0x30,%eax
jne    1442 <main+0x2d2>
mov    -0x18(%rbp),%rcx
lea    -0x31(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movzbl -0x31(%rbp),%eax
cmp    $0x78,%eax
jne    143d <main+0x2cd>
lea    -0x3a(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
movb   $0x0,-0x32(%rbp)
movl   $0x8,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jbe    13c8 <main+0x258>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
cmp    $0x2f,%eax
jle    1343 <main+0x1d3>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
cmp    $0x3a,%eax
jge    1343 <main+0x1d3>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
sub    $0x30,%eax
mov    %eax,-0x48(%rbp)
jmp    13a4 <main+0x234>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
cmp    $0x40,%eax
jle    1387 <main+0x217>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
cmp    $0x47,%eax
jge    1387 <main+0x217>
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
movzbl -0x3a(%rbp,%rax,1),%eax
sub    $0x37,%eax
mov    %eax,-0x48(%rbp)
jmp    139f <main+0x22f>
lea    0xc92(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1460 <main+0x2f0>
jmp    13a4 <main+0x234>
mov    -0x48(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
imul   -0x70(%rbp,%rcx,4),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x4c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4c(%rbp)
jmp    12f5 <main+0x185>
mov    $0x0,%al
call   1090 <is_little_endian@plt>
cmp    $0x0,%rax
je     1412 <main+0x2a2>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x4,-0x4c(%rbp)
jae    140d <main+0x29d>
mov    $0x3,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,%eax
mov    -0x40(%rbp,%rax,1),%cl
mov    -0x4c(%rbp),%eax
mov    %cl,-0x44(%rbp,%rax,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13e0 <main+0x270>
jmp    1418 <main+0x2a8>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x44(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1080 <fwrite@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
jmp    1442 <main+0x2d2>
jmp    1287 <main+0x117>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbx
movb   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
test   %rdi,%rdi
je     1432 <main+0x2d2>
test   %rbx,%rbx
je     1432 <main+0x2d2>
lea    0xe63(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     143b <main+0x2db>
mov    %rax,%rbp
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     145a <main+0x2fa>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1444 <main+0x2e4>
lea    0x7(%rsp),%rbx
jmp    1249 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,0x14(%rsp)
lea    0x7(%rsp),%rbx
lea    0x14(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    0x18(%rsp),%rcx
call   1070 <fwrite@plt>
movl   $0x0,0x14(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1444 <main+0x2e4>
cmpb   $0x30,0x7(%rsp)
jne    122b <main+0xcb>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
cmpb   $0x78,0x7(%rsp)
jne    122b <main+0xcb>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
movb   $0x0,0x10(%rsp)
movzbl 0xf(%rsp),%eax
mov    %rax,0x30(%rsp)
add    $0xffffffd0,%eax
mov    $0xffffffd0,%ecx
mov    $0xffffffd0,%edx
cmp    $0xa,%al
jb     12b8 <main+0x158>
mov    0x30(%rsp),%rax
add    $0xffffffbf,%eax
mov    $0xffffffc9,%edx
cmp    $0x6,%al
jae    1432 <main+0x2d2>
movzbl 0xe(%rsp),%eax
mov    %rax,0x28(%rsp)
add    $0xffffffd0,%eax
cmp    $0xa,%al
jb     12de <main+0x17e>
mov    0x28(%rsp),%rax
add    $0xffffffbf,%eax
mov    $0xffffffc9,%ecx
cmp    $0x5,%al
ja     1432 <main+0x2d2>
movzbl 0xd(%rsp),%eax
mov    %rax,0x20(%rsp)
lea    -0x30(%rax),%esi
mov    $0xffffffd0,%edi
mov    $0xffffffd0,%eax
cmp    $0xa,%sil
jb     1312 <main+0x1b2>
mov    0x20(%rsp),%rax
lea    -0x41(%rax),%esi
mov    $0xffffffc9,%eax
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
movzbl 0xc(%rsp),%r11d
lea    -0x30(%r11),%esi
cmp    $0xa,%sil
jb     1335 <main+0x1d5>
lea    -0x41(%r11),%esi
mov    $0xffffffc9,%edi
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
movzbl 0xb(%rsp),%r10d
lea    -0x30(%r10),%esi
mov    $0xffffffd0,%ebx
mov    $0xffffffd0,%r13d
cmp    $0xa,%sil
jb     1364 <main+0x204>
lea    -0x41(%r10),%esi
mov    $0xffffffc9,%r13d
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
movzbl 0xa(%rsp),%r12d
lea    -0x30(%r12),%esi
cmp    $0xa,%sil
jb     1389 <main+0x229>
lea    -0x41(%r12),%esi
mov    $0xffffffc9,%ebx
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
movzbl 0x9(%rsp),%r15d
lea    -0x30(%r15),%esi
mov    $0xffffffd0,%r14d
mov    $0xffffffd0,%r8d
cmp    $0xa,%sil
jb     13b5 <main+0x255>
lea    -0x41(%r15),%esi
mov    $0xffffffc9,%r8d
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
movzbl 0x8(%rsp),%r9d
lea    -0x30(%r9),%esi
cmp    $0xa,%sil
jb     13d5 <main+0x275>
lea    -0x41(%r9),%esi
mov    $0xffffffc9,%r14d
cmp    $0x5,%sil
ja     1432 <main+0x2d2>
add    0x30(%rsp),%edx
add    0x28(%rsp),%ecx
shl    $0x4,%ecx
add    %edx,%ecx
add    0x20(%rsp),%eax
shl    $0x8,%eax
add    %ecx,%eax
add    %r11d,%edi
shl    $0xc,%edi
add    %eax,%edi
add    %r10d,%r13d
shl    $0x10,%r13d
add    %edi,%r13d
add    %r12d,%ebx
shl    $0x14,%ebx
add    %r13d,%ebx
add    %r15d,%r8d
shl    $0x18,%r8d
add    %ebx,%r8d
add    %r9d,%r14d
shl    $0x1c,%r14d
add    %r8d,%r14d
xor    %eax,%eax
call   1080 <is_little_endian@plt>
test   %rax,%rax
je     1200 <main+0xa0>
bswap  %r14d
jmp    1200 <main+0xa0>
lea    0xbfa(%rip),%rdi
jmp    1461 <main+0x301>
lea    0xbdb(%rip),%rdi
jmp    1461 <main+0x301>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    146b <main+0x30b>
lea    0xba5(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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