#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 uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  FILE *in = NULL, *out = NULL;
  uint8_t buf;
  uint32_t magic = 0xfeed1281L;
  uint32_t reclength = 0;
  uint32_t loadaddress = 0;
  uint32_t checksum = 0;
  uint32_t checksum_calc = 0;
  uint32_t compsize = 0;
  uint32_t zero = 0;
  uint32_t entry = 0;
  if (argc != 3)
    usage();
  in = fopen(argv[1], "rb");
  if (!in)
    pexit("fopen");
  out = fopen(argv[2], "w+b");
  if (!out)
    pexit("fopen");
  if (1 != fread(&magic, sizeof magic, 1, in))
    pexit("fread");
  printf("MAGIC=0x%X\n", magic);
  if (1 != fread(&reclength, sizeof reclength, 1, in))
    pexit("fread");
  printf("RECLENGHT=0x%X\n", reclength);
  if (1 != fread(&loadaddress, sizeof loadaddress, 1, in))
    pexit("fread");
  printf("LOADADDR=0x%X\n", loadaddress);
  checksum_calc = reclength + loadaddress;
  while (compsize < reclength) {
    if (1 != fread(&buf, sizeof buf, 1, in))
      pexit("fread");
    compsize++;
    if (1 != fwrite(&buf, sizeof buf, 1, out))
      pexit("fwrite");
    checksum_calc += buf;
  }
  checksum_calc = ~checksum_calc + 1;
  printf("CHECKSUM_CALC=0x%X\n", checksum_calc);
  if (1 != fread(&checksum, sizeof checksum, 1, in))
    pexit("fread");
  printf("CHECKSUM=0x%X\n", checksum);
  if (1 != fread(&zero, sizeof zero, 1, in))
    pexit("fread");
  printf("ZERO=0x%X\n", zero);
  if (1 != fread(&entry, sizeof entry, 1, in))
    pexit("fread");
  printf("ENTRY=0x%X\n", entry);
  fclose(in);
  if (fclose(out))
    pexit("fclose");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xfeed1281,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11df <main+0x6f>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe12(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120e <main+0x9e>
lea    0xdfa(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdec(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123d <main+0xcd>
lea    0xdcb(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     126f <main+0xff>
lea    0xda3(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x28(%rbp),%esi
lea    0xd9a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     12b0 <main+0x140>
lea    0xd62(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x2c(%rbp),%esi
lea    0xd65(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     12f1 <main+0x181>
lea    0xd21(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x30(%rbp),%esi
lea    0xd34(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1390 <main+0x220>
mov    -0x18(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1347 <main+0x1d7>
lea    0xccb(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1382 <main+0x212>
lea    0xcc1(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x24(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1309 <main+0x199>
mov    -0x38(%rbp),%eax
xor    $0xffffffff,%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xc9f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x34(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     13dd <main+0x26d>
lea    0xc35(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x34(%rbp),%esi
lea    0xc72(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x40(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     141e <main+0x2ae>
lea    0xbf4(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x40(%rbp),%esi
lea    0xc40(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x44(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     145f <main+0x2ef>
lea    0xbb3(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x44(%rbp),%esi
lea    0xc0a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1496 <main+0x326>
lea    0xbee(%rip),%rdi
call   1090 <pexit@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
movl   $0xfeed1281,0x20(%rsp)
fe
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
cmp    $0x3,%edi
je     11bd <main+0x4d>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe38(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11e1 <main+0x71>
lea    0xe27(%rip),%rdi
call   1090 <pexit@plt>
mov    0x10(%rbx),%rdi
lea    0xe1d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1205 <main+0x95>
lea    0xe03(%rip),%rdi
call   1090 <pexit@plt>
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     122d <main+0xbd>
lea    0xde5(%rip),%rdi
call   1090 <pexit@plt>
mov    0x20(%rsp),%esi
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
lea    0x1c(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1265 <main+0xf5>
lea    0xdad(%rip),%rdi
call   1090 <pexit@plt>
mov    0x1c(%rsp),%ebp
lea    0xdaf(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
lea    0x18(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     129f <main+0x12f>
lea    0xd73(%rip),%rdi
call   1090 <pexit@plt>
mov    0x18(%rsp),%ebx
lea    0xd85(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
add    %ebp,%ebx
test   %ebp,%ebp
jle    1323 <main+0x1b3>
lea    0x24(%rsp),%r12
lea    0xd4a(%rip),%r13
jmp    12d9 <main+0x169>
cs nopw 0x0(%rax,%rax,1)
nop
add    0x24(%rsp),%ebx
add    $0xffffffff,%ebp
je     1323 <main+0x1b3>
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     12fb <main+0x18b>
mov    %r13,%rdi
call   1090 <pexit@plt>
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
cmp    $0x1,%eax
je     12d0 <main+0x160>
lea    0xd22(%rip),%rdi
call   1090 <pexit@plt>
jmp    12d0 <main+0x160>
neg    %ebx
lea    0xd19(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
lea    0x14(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     135b <main+0x1eb>
lea    0xcb7(%rip),%rdi
call   1090 <pexit@plt>
mov    0x14(%rsp),%esi
lea    0xcf3(%rip),%rdi
call   1050 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1393 <main+0x223>
lea    0xc7f(%rip),%rdi
call   1090 <pexit@plt>
mov    0x10(%rsp),%esi
lea    0xcca(%rip),%rdi
call   1050 <printf@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     13cb <main+0x25b>
lea    0xc47(%rip),%rdi
call   1090 <pexit@plt>
mov    0xc(%rsp),%esi
lea    0xc9d(%rip),%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     13fc <main+0x28c>
lea    0xc88(%rip),%rdi
call   1090 <pexit@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [6 x i8] c"fopen\00"
@.str.2 = [4 x i8] c"w+b\00"
@.str.3 = [6 x i8] c"fread\00"
@.str.4 = [12 x i8] c"MAGIC=0x%X\0A\00"
@.str.5 = [16 x i8] c"RECLENGHT=0x%X\0A\00"
@.str.6 = [15 x i8] c"LOADADDR=0x%X\0A\00"
@.str.7 = [7 x i8] c"fwrite\00"
@.str.8 = [20 x i8] c"CHECKSUM_CALC=0x%X\0A\00"
@.str.9 = [15 x i8] c"CHECKSUM=0x%X\0A\00"
@.str.10 = [11 x i8] c"ZERO=0x%X\0A\00"
@.str.11 = [12 x i8] c"ENTRY=0x%X\0A\00"
@.str.12 = [7 x i8] c"fclose\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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 -18017663, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (...) @usage()
br label %21
21: ; preds = %19, %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp ne i32* %26, null
br i1 %27, label %30, label %28
28: ; preds = %21
%29 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %21
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32* @fopen(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %7
%35 = load i32*, i32** %7
%36 = icmp ne i32* %35, null
br i1 %36, label %39, label %37
37: ; preds = %30
%38 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %30
%40 = load i32*, i32** %6
%41 = call i32 @fread(i32* %9, i32 4, i32 1, i32* %40)
%42 = icmp ne i32 1, %41
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
%46 = load i32, i32* %9
%47 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = load i32*, i32** %6
%49 = call i32 @fread(i32* %10, i32 4, i32 1, i32* %48)
%50 = icmp ne i32 1, %49
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %51, %45
%54 = load i32, i32* %10
%55 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = load i32*, i32** %6
%57 = call i32 @fread(i32* %11, i32 4, i32 1, i32* %56)
%58 = icmp ne i32 1, %57
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %53
%62 = load i32, i32* %11
%63 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %10
%65 = load i32, i32* %11
%66 = add nsw i32 %64, %65
store i32 %66, i32* %13
br label %67
67: ; preds = %85, %61
%68 = load i32, i32* %14
%69 = load i32, i32* %10
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %89
71: ; preds = %67
%72 = load i32*, i32** %6
%73 = call i32 @fread(i32* %8, i32 4, i32 1, i32* %72)
%74 = icmp ne i32 1, %73
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %75, %71
%78 = load i32, i32* %14
%79 = add nsw i32 %78, 1
store i32 %79, i32* %14
%80 = load i32*, i32** %7
%81 = call i32 @fwrite(i32* %8, i32 4, i32 1, i32* %80)
%82 = icmp ne i32 1, %81
br i1 %82, label %83, label %85
83: ; preds = %77
%84 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %85
85: ; preds = %83, %77
%86 = load i32, i32* %8
%87 = load i32, i32* %13
%88 = add nsw i32 %87, %86
store i32 %88, i32* %13
br label %67
89: ; preds = %67
%90 = load i32, i32* %13
%91 = xor i32 %90, -1
%92 = add nsw i32 %91, 1
store i32 %92, i32* %13
%93 = load i32, i32* %13
%94 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %93)
%95 = load i32*, i32** %6
%96 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %95)
%97 = icmp ne i32 1, %96
br i1 %97, label %98, label %100
98: ; preds = %89
%99 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %100
100: ; preds = %98, %89
%101 = load i32, i32* %12
%102 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %101)
%103 = load i32*, i32** %6
%104 = call i32 @fread(i32* %15, i32 4, i32 1, i32* %103)
%105 = icmp ne i32 1, %104
br i1 %105, label %106, label %108
106: ; preds = %100
%107 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %108
108: ; preds = %106, %100
%109 = load i32, i32* %15
%110 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %109)
%111 = load i32*, i32** %6
%112 = call i32 @fread(i32* %16, i32 4, i32 1, i32* %111)
%113 = icmp ne i32 1, %112
br i1 %113, label %114, label %116
114: ; preds = %108
%115 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %116
116: ; preds = %114, %108
%117 = load i32, i32* %16
%118 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %117)
%119 = load i32*, i32** %6
%120 = call i64 @fclose(i32* %119)
%121 = load i32*, i32** %7
%122 = call i64 @fclose(i32* %121)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %126
124: ; preds = %116
%125 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %126
126: ; preds = %124, %116
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [6 x i8] c"fopen\00"
@.str.2 = [4 x i8] c"w+b\00"
@.str.3 = [6 x i8] c"fread\00"
@.str.4 = [12 x i8] c"MAGIC=0x%X\0A\00"
@.str.5 = [16 x i8] c"RECLENGHT=0x%X\0A\00"
@.str.6 = [15 x i8] c"LOADADDR=0x%X\0A\00"
@.str.7 = [7 x i8] c"fwrite\00"
@.str.8 = [20 x i8] c"CHECKSUM_CALC=0x%X\0A\00"
@.str.9 = [15 x i8] c"CHECKSUM=0x%X\0A\00"
@.str.10 = [11 x i8] c"ZERO=0x%X\0A\00"
@.str.11 = [12 x i8] c"ENTRY=0x%X\0A\00"
@.str.12 = [7 x i8] c"fclose\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
store i32 -18017663, i32* %4
%12 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%13 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%14 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%15 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%16 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%17 = icmp eq i32 %0, 3
br i1 %17, label %20, label %18
18: ; preds = %2
%19 = tail call i32 (...) @usage()
br label %20
20: ; preds = %18, %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %20
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
%35 = call i32 @fread(i32* %4, i32 4, i32 1, i32* %23)
%36 = icmp eq i32 %35, 1
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = load i32, i32* %4
%41 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = call i32 @fread(i32* %5, i32 4, i32 1, i32* %23)
%43 = icmp eq i32 %42, 1
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %39
%47 = load i32, i32* %5
%48 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = call i32 @fread(i32* %6, i32 4, i32 1, i32* %23)
%50 = icmp eq i32 %49, 1
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %51, %46
%54 = load i32, i32* %6
%55 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = add nsw i32 %54, %47
%57 = icmp sgt i32 %47, 0
br i1 %57, label %58, label %75
58: ; preds = %53, %71
%59 = phi i32 [ %66, %71 ], [ 0, %53 ]
%60 = phi i32 [ %73, %71 ], [ %56, %53 ]
%61 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %23)
%62 = icmp eq i32 %61, 1
br i1 %62, label %65, label %63
63: ; preds = %58
%64 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
%66 = add nuw nsw i32 %59, 1
%67 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32* %30)
%68 = icmp eq i32 %67, 1
br i1 %68, label %71, label %69
69: ; preds = %65
%70 = tail call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %71
71: ; preds = %69, %65
%72 = load i32, i32* %3
%73 = add nsw i32 %72, %60
%74 = icmp eq i32 %66, %47
br i1 %74, label %75, label %58
75: ; preds = %71, %53
%76 = phi i32 [ %56, %53 ], [ %73, %71 ]
%77 = sub i32 0, %76
%78 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %77)
%79 = call i32 @fread(i32* %7, i32 4, i32 1, i32* %23)
%80 = icmp eq i32 %79, 1
br i1 %80, label %83, label %81
81: ; preds = %75
%82 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %83
83: ; preds = %81, %75
%84 = load i32, i32* %7
%85 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %84)
%86 = call i32 @fread(i32* %8, i32 4, i32 1, i32* %23)
%87 = icmp eq i32 %86, 1
br i1 %87, label %90, label %88
88: ; preds = %83
%89 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %88, %83
%91 = load i32, i32* %8
%92 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i32 %91)
%93 = call i32 @fread(i32* %9, i32 4, i32 1, i32* %23)
%94 = icmp eq i32 %93, 1
br i1 %94, label %97, label %95
95: ; preds = %90
%96 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %97
97: ; preds = %95, %90
%98 = load i32, i32* %9
%99 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %98)
%100 = tail call i64 @fclose(i32* %23)
%101 = tail call i64 @fclose(i32* %30)
%102 = icmp eq i64 %101, 0
br i1 %102, label %105, label %103
103: ; preds = %97
%104 = tail call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %105
105: ; preds = %103, %97
ret i32 0
}