#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char *Buf, *a;
  int BufLen;
  int nbytes, fileLen;
  unsigned int checksum;
  int i;
  if (argc != 4) {
    printf("Usage: mkbl1 <source file> <destination file> <size> \n");
    return -1;
  }
  BufLen = atoi(argv[3]);
  Buf = (char *)malloc(BufLen);
  memset(Buf, 0x00, BufLen);
  fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    printf("source file open error\n");
    free(Buf);
    return -1;
  }
  fseek(fp, 0L, SEEK_END);
  fileLen = ftell(fp);
  fseek(fp, 0L, SEEK_SET);
  if (BufLen > fileLen) {
    printf("Usage: unsupported size\n");
    free(Buf);
    fclose(fp);
    return -1;
  }
  nbytes = fread(Buf, 1, BufLen, fp);
  if (nbytes != BufLen) {
    printf("source file read error\n");
    free(Buf);
    fclose(fp);
    return -1;
  }
  fclose(fp);
  a = Buf + 16;
  for (i = 0, checksum = 0; i < BufLen - 16; i++)
    checksum += (0x000000FF) & *a++;
  a = Buf + 8;
  *((unsigned int *)a) = checksum;
  fp = fopen(argv[2], "wb");
  if (fp == NULL) {
    printf("destination file open error\n");
    free(Buf);
    return -1;
  }
  a = Buf;
  nbytes = fwrite(a, 1, BufLen, fp);
  if (nbytes != BufLen) {
    printf("destination file write error\n");
    free(Buf);
    fclose(fp);
    return -1;
  }
  free(Buf);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11e8 <main+0x38>
lea    0xe29(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1256 <main+0xa6>
lea    0xdfe(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x18(%rbp),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d55(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    12c4 <main+0x114>
lea    0xdb1(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1312 <main+0x162>
lea    0xd7c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x10,%ecx
cmp    %ecx,%eax
jge    1371 <main+0x1c1>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%eax
and    $0xff,%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1335 <main+0x185>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcee(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13ca <main+0x21a>
lea    0xcd6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1420 <main+0x270>
lea    0xca6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1439 <main+0x289>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    123c <main+0x8c>
mov    %rsi,%r15
mov    0x18(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1070 <memset@plt>
mov    0x8(%r15),%rdi
lea    0xe12(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     124d <main+0x9d>
mov    %rax,%rbx
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %eax,%ebp
mov    0x2db9(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
cmp    %ebp,%r14d
jle    1266 <main+0xb6>
lea    0xe1f(%rip),%rdi
jmp    141a <main+0x26a>
lea    0xe42(%rip),%rdi
call   1040 <puts@plt>
jmp    142f <main+0x27f>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    142f <main+0x27f>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
cmp    %r14d,%eax
jne    12ab <main+0xfb>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %esi,%esi
cmp    $0x11,%r14d
jl     13be <main+0x20e>
mov    %r12,%rax
add    $0x10,%rax
lea    -0x11(%r14),%edx
xor    %ecx,%ecx
cmp    $0x7,%edx
jae    12b7 <main+0x107>
xor    %esi,%esi
jmp    13a1 <main+0x1f1>
lea    0xd8d(%rip),%rdi
jmp    141a <main+0x26a>
add    $0x1,%rdx
mov    %rdx,%rcx
and    $0xfffffffffffffff8,%rcx
lea    -0x8(%rcx),%rsi
mov    %rsi,%rbp
shr    $0x3,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     1348 <main+0x198>
mov    %rbp,%rsi
and    $0xfffffffffffffffe,%rsi
pxor   %xmm2,%xmm2
xor    %edi,%edi
pxor   %xmm0,%xmm0
pxor   %xmm1,%xmm1
nopl   0x0(%rax,%rax,1)
movd   0x10(%r12,%rdi,1),%xmm3
movd   0x14(%r12,%rdi,1),%xmm4
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
paddd  %xmm0,%xmm3
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
paddd  %xmm1,%xmm4
movd   0x18(%r12,%rdi,1),%xmm0
movd   0x1c(%r12,%rdi,1),%xmm1
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
paddd  %xmm3,%xmm0
punpcklbw %xmm2,%xmm1
punpcklwd %xmm2,%xmm1
paddd  %xmm4,%xmm1
add    $0x10,%rdi
add    $0xfffffffffffffffe,%rsi
jne    12f0 <main+0x140>
jmp    1352 <main+0x1a2>
pxor   %xmm0,%xmm0
xor    %edi,%edi
pxor   %xmm1,%xmm1
test   $0x1,%bpl
je     137f <main+0x1cf>
movd   (%rax,%rdi,1),%xmm2
movd   0x4(%rax,%rdi,1),%xmm3
pxor   %xmm4,%xmm4
punpcklbw %xmm4,%xmm2
punpcklwd %xmm4,%xmm2
paddd  %xmm2,%xmm0
punpcklbw %xmm4,%xmm3
punpcklwd %xmm4,%xmm3
paddd  %xmm3,%xmm1
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%esi
cmp    %rcx,%rdx
je     13be <main+0x20e>
add    %rcx,%rax
mov    %r14d,%edx
sub    %ecx,%edx
add    $0xfffffff0,%edx
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl (%rax,%rcx,1),%edi
add    %edi,%esi
add    $0x1,%rcx
cmp    %ecx,%edx
jne    13b0 <main+0x200>
mov    %esi,0x8(%r12)
mov    0x10(%r15),%rdi
lea    0xc35(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1407 <main+0x257>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
cmp    %r14d,%eax
jne    1413 <main+0x263>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1434 <main+0x284>
lea    0xc15(%rip),%rdi
jmp    1254 <main+0xa4>
lea    0xbec(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Usage: mkbl1 <source file> <destination file> <size> \0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"source file open error\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [25 x i8] c"Usage: unsupported size\0A\00"
@.str.4 = [24 x i8] c"source file read error\0A\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [29 x i8] c"destination file open error\0A\00"
@.str.7 = [30 x i8] c"destination file write error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %128
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = load i32, i32* %9
%28 = call i32 @memset(i8* %26, i32 0, i32 %27)
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %6
%33 = load i32*, i32** %6
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %39
35: ; preds = %18
%36 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8*, i8** %7
%38 = call i32 @free(i8* %37)
store i32 -1, i32* %3
br label %128
39: ; preds = %18
%40 = load i32*, i32** %6
%41 = load i32, i32* @SEEK_END
%42 = call i32 @fseek(i32* %40, i64 0, i32 %41)
%43 = load i32*, i32** %6
%44 = call i32 @ftell(i32* %43)
store i32 %44, i32* %11
%45 = load i32*, i32** %6
%46 = load i32, i32* @SEEK_SET
%47 = call i32 @fseek(i32* %45, i64 0, i32 %46)
%48 = load i32, i32* %9
%49 = load i32, i32* %11
%50 = icmp sgt i32 %48, %49
br i1 %50, label %51, label %57
51: ; preds = %39
%52 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%53 = load i8*, i8** %7
%54 = call i32 @free(i8* %53)
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
store i32 -1, i32* %3
br label %128
57: ; preds = %39
%58 = load i8*, i8** %7
%59 = load i32, i32* %9
%60 = load i32*, i32** %6
%61 = call i32 @fread(i8* %58, i32 1, i32 %59, i32* %60)
store i32 %61, i32* %10
%62 = load i32, i32* %10
%63 = load i32, i32* %9
%64 = icmp ne i32 %62, %63
br i1 %64, label %65, label %71
65: ; preds = %57
%66 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%67 = load i8*, i8** %7
%68 = call i32 @free(i8* %67)
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
store i32 -1, i32* %3
br label %128
71: ; preds = %57
%72 = load i32*, i32** %6
%73 = call i32 @fclose(i32* %72)
%74 = load i8*, i8** %7
%75 = getelementptr inbounds i8, i8* %74, i64 16
store i8* %75, i8** %8
store i32 0, i32* %13
store i32 0, i32* %12
br label %76
76: ; preds = %89, %71
%77 = load i32, i32* %13
%78 = load i32, i32* %9
%79 = sub nsw i32 %78, 16
%80 = icmp slt i32 %77, %79
br i1 %80, label %81, label %92
81: ; preds = %76
%82 = load i8*, i8** %8
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %8
%84 = load i8, i8* %82
%85 = sext i8 %84 to i32
%86 = and i32 255, %85
%87 = load i32, i32* %12
%88 = add i32 %87, %86
store i32 %88, i32* %12
br label %89
89: ; preds = %81
%90 = load i32, i32* %13
%91 = add nsw i32 %90, 1
store i32 %91, i32* %13
br label %76
92: ; preds = %76
%93 = load i8*, i8** %7
%94 = getelementptr inbounds i8, i8* %93, i64 8
store i8* %94, i8** %8
%95 = load i32, i32* %12
%96 = load i8*, i8** %8
%97 = bitcast i8* %96 to i32*
store i32 %95, i32* %97
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 2
%100 = load i8*, i8** %99
%101 = call i32* @fopen(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %101, i32** %6
%102 = load i32*, i32** %6
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %108
104: ; preds = %92
%105 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%106 = load i8*, i8** %7
%107 = call i32 @free(i8* %106)
store i32 -1, i32* %3
br label %128
108: ; preds = %92
%109 = load i8*, i8** %7
store i8* %109, i8** %8
%110 = load i8*, i8** %8
%111 = load i32, i32* %9
%112 = load i32*, i32** %6
%113 = call i32 @fwrite(i8* %110, i32 1, i32 %111, i32* %112)
store i32 %113, i32* %10
%114 = load i32, i32* %10
%115 = load i32, i32* %9
%116 = icmp ne i32 %114, %115
br i1 %116, label %117, label %123
117: ; preds = %108
%118 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%119 = load i8*, i8** %7
%120 = call i32 @free(i8* %119)
%121 = load i32*, i32** %6
%122 = call i32 @fclose(i32* %121)
store i32 -1, i32* %3
br label %128
123: ; preds = %108
%124 = load i8*, i8** %7
%125 = call i32 @free(i8* %124)
%126 = load i32*, i32** %6
%127 = call i32 @fclose(i32* %126)
store i32 0, i32* %3
br label %128
128: ; preds = %123, %117, %104, %65, %51, %35, %16
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [3 x i8] c"wb\00"
@str = [29 x i8] c"destination file write error\00"
@str.8 = [28 x i8] c"destination file open error\00"
@str.9 = [23 x i8] c"source file read error\00"
@str.10 = [24 x i8] c"Usage: unsupported size\00"
@str.11 = [23 x i8] c"source file open error\00"
@str.12 = [54 x i8] c"Usage: mkbl1 <source file> <destination file> <size> \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.12, i64 0, i64 0))
br label %147
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @memset(i8* %11, i32 0, i32 %9)
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %6
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%19 = tail call i32 @free(i8* %11)
br label %147
20: ; preds = %6
%21 = load i32, i32* @SEEK_END
%22 = tail call i32 @fseek(i32* %15, i64 0, i32 %21)
%23 = tail call i32 @ftell(i32* %15)
%24 = load i32, i32* @SEEK_SET
%25 = tail call i32 @fseek(i32* %15, i64 0, i32 %24)
%26 = icmp sgt i32 %9, %23
br i1 %26, label %27, label %31
27: ; preds = %20
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
%29 = tail call i32 @free(i8* %11)
%30 = tail call i32 @fclose(i32* %15)
br label %147
31: ; preds = %20
%32 = tail call i32 @fread(i8* %11, i32 1, i32 %9, i32* %15)
%33 = icmp eq i32 %32, %9
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%36 = tail call i32 @free(i8* %11)
%37 = tail call i32 @fclose(i32* %15)
br label %147
38: ; preds = %31
%39 = tail call i32 @fclose(i32* %15)
%40 = add i32 %9, -16
%41 = icmp sgt i32 %9, 16
br i1 %41, label %42, label %126
42: ; preds = %38
%43 = getelementptr inbounds i8, i8* %11, i64 16
%44 = add i32 %9, -17
%45 = zext i32 %44 to i64
%46 = add nuw nsw i64 %45, 1
%47 = icmp ult i32 %44, 7
br i1 %47, label %112, label %48
48: ; preds = %42
%49 = and i64 %46, 8589934584
%50 = trunc i64 %49 to i32
%51 = getelementptr i8, i8* %43, i64 %49
%52 = add nsw i64 %49, -8
%53 = lshr exact i64 %52, 3
%54 = add nuw nsw i64 %53, 1
%55 = and i64 %54, 1
%56 = icmp eq i64 %52, 0
br i1 %56, label %88, label %57
57: ; preds = %48
%58 = and i64 %54, 4611686018427387902
br label %59
59: ; preds = %59, %57
%60 = phi i64 [ 0, %57 ], [ %85, %59 ]
%61 = phi <4 x i32> [ zeroinitializer, %57 ], [ %83, %59 ]
%62 = phi <4 x i32> [ zeroinitializer, %57 ], [ %84, %59 ]
%63 = phi i64 [ 0, %57 ], [ %86, %59 ]
%64 = getelementptr i8, i8* %43, i64 %60
%65 = bitcast i8* %64 to <4 x i8>*
%66 = load <4 x i8>, <4 x i8>* %65
%67 = getelementptr i8, i8* %64, i64 4
%68 = bitcast i8* %67 to <4 x i8>*
%69 = load <4 x i8>, <4 x i8>* %68
%70 = zext <4 x i8> %66 to <4 x i32>
%71 = zext <4 x i8> %69 to <4 x i32>
%72 = add <4 x i32> %61, %70
%73 = add <4 x i32> %62, %71
%74 = or i64 %60, 8
%75 = getelementptr i8, i8* %43, i64 %74
%76 = bitcast i8* %75 to <4 x i8>*
%77 = load <4 x i8>, <4 x i8>* %76
%78 = getelementptr i8, i8* %75, i64 4
%79 = bitcast i8* %78 to <4 x i8>*
%80 = load <4 x i8>, <4 x i8>* %79
%81 = zext <4 x i8> %77 to <4 x i32>
%82 = zext <4 x i8> %80 to <4 x i32>
%83 = add <4 x i32> %72, %81
%84 = add <4 x i32> %73, %82
%85 = add nuw i64 %60, 16
%86 = add i64 %63, 2
%87 = icmp eq i64 %86, %58
br i1 %87, label %88, label %59
88: ; preds = %59, %48
%89 = phi <4 x i32> [ undef, %48 ], [ %83, %59 ]
%90 = phi <4 x i32> [ undef, %48 ], [ %84, %59 ]
%91 = phi i64 [ 0, %48 ], [ %85, %59 ]
%92 = phi <4 x i32> [ zeroinitializer, %48 ], [ %83, %59 ]
%93 = phi <4 x i32> [ zeroinitializer, %48 ], [ %84, %59 ]
%94 = icmp eq i64 %55, 0
br i1 %94, label %106, label %95
95: ; preds = %88
%96 = getelementptr i8, i8* %43, i64 %91
%97 = bitcast i8* %96 to <4 x i8>*
%98 = load <4 x i8>, <4 x i8>* %97
%99 = getelementptr i8, i8* %96, i64 4
%100 = bitcast i8* %99 to <4 x i8>*
%101 = load <4 x i8>, <4 x i8>* %100
%102 = zext <4 x i8> %98 to <4 x i32>
%103 = zext <4 x i8> %101 to <4 x i32>
%104 = add <4 x i32> %92, %102
%105 = add <4 x i32> %93, %103
br label %106
106: ; preds = %88, %95
%107 = phi <4 x i32> [ %89, %88 ], [ %104, %95 ]
%108 = phi <4 x i32> [ %90, %88 ], [ %105, %95 ]
%109 = add <4 x i32> %108, %107
%110 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %109)
%111 = icmp eq i64 %46, %49
br i1 %111, label %126, label %112
112: ; preds = %42, %106
%113 = phi i32 [ 0, %42 ], [ %50, %106 ]
%114 = phi i32 [ 0, %42 ], [ %110, %106 ]
%115 = phi i8* [ %43, %42 ], [ %51, %106 ]
br label %116
116: ; preds = %112, %116
%117 = phi i32 [ %124, %116 ], [ %113, %112 ]
%118 = phi i32 [ %123, %116 ], [ %114, %112 ]
%119 = phi i8* [ %120, %116 ], [ %115, %112 ]
%120 = getelementptr inbounds i8, i8* %119, i64 1
%121 = load i8, i8* %119
%122 = zext i8 %121 to i32
%123 = add i32 %118, %122
%124 = add nuw nsw i32 %117, 1
%125 = icmp eq i32 %124, %40
br i1 %125, label %126, label %116
126: ; preds = %116, %106, %38
%127 = phi i32 [ 0, %38 ], [ %110, %106 ], [ %123, %116 ]
%128 = getelementptr inbounds i8, i8* %11, i64 8
%129 = bitcast i8* %128 to i32*
store i32 %127, i32* %129
%130 = getelementptr inbounds i8*, i8** %1, i64 2
%131 = load i8*, i8** %130
%132 = tail call i32* @fopen(i8* %131, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%133 = icmp eq i32* %132, null
br i1 %133, label %134, label %137
134: ; preds = %126
%135 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.8, i64 0, i64 0))
%136 = tail call i32 @free(i8* %11)
br label %147
137: ; preds = %126
%138 = tail call i32 @fwrite(i8* %11, i32 1, i32 %9, i32* %132)
%139 = icmp eq i32 %138, %9
br i1 %139, label %144, label %140
140: ; preds = %137
%141 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%142 = tail call i32 @free(i8* %11)
%143 = tail call i32 @fclose(i32* %132)
br label %147
144: ; preds = %137
%145 = tail call i32 @free(i8* %11)
%146 = tail call i32 @fclose(i32* %132)
br label %147
147: ; preds = %144, %140, %134, %34, %27, %17, %4
%148 = phi i32 [ -1, %4 ], [ -1, %17 ], [ -1, %27 ], [ -1, %34 ], [ -1, %134 ], [ -1, %140 ], [ 0, %144 ]
ret i32 %148
}