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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int fwrite(unsigned char *, long, int, int /*<<< orphan*/ *);
unsigned char *malloc(long);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  long f_size;
  long blocks;
  long out_size;
  FILE *in, *out;
  unsigned char header[16];
  unsigned char *buf;
  if (argc != 3) {
    printf("Usage:   lpc18xx_bootheader [in-file] [out-file]\n");
    return 1;
  }
  in = fopen(argv[1], "rb");
  if (!in) {
    printf("Cannot open input file: %s\n", argv[1]);
    return 2;
  }
  fseek(in, 0, SEEK_END);
  f_size = ftell(in);
  rewind(in);
  blocks = (f_size + 511) / 512;
  out_size = blocks * 512;
  if (blocks >> 16) {
    printf("Number of blocks is too large: %ld\n", blocks);
    return 3;
  }
  buf = malloc(out_size);
  if (!buf) {
    printf("Could not allocate %ld bytes of memory\n", f_size);
    return 4;
  }
  if (fread(buf, f_size, 1, in) != 1) {
    printf("Could not read file contents: %s\n", argv[1]);
    return 5;
  }
  fclose(in);
  memset(buf + f_size, 0, out_size - f_size);
  memset(header, 0, sizeof(header));
  header[0] = 0x1A;
  header[0] |= (3 << 6);
  header[1] = 0x3F;
  header[2] = blocks & 0xFF;
  header[3] = (blocks >> 8) & 0xFF;
  header[12] = 0xFF;
  header[13] = 0xFF;
  header[14] = 0xFF;
  header[15] = 0xFF;
  out = fopen(argv[2], "wb");
  if (!out) {
    printf("Cannot open output file: %s\n", argv[2]);
    return 6;
  }
  if (fwrite(header, sizeof(header), 1, out) != 1) {
    printf("Could not write header to file: %s\n", argv[2]);
    return 7;
  }
  if (fwrite(buf, out_size, 1, out) != 1) {
    printf("Could not write image data to file: %s\n", argv[2]);
    return 8;
  }
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11da <main+0x3a>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    121f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x30(%rbp),%rdi
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x18(%rbp),%rax
add    $0x1ff,%rax
mov    $0x200,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x9,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sar    $0x10,%rax
cmp    $0x0,%rax
je     129d <main+0xfd>
mov    -0x20(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x28(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12d3 <main+0x133>
mov    -0x18(%rbp),%rsi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x58(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1314 <main+0x174>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x5,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x58(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
movb   $0x1a,-0x50(%rbp)
movzbl -0x50(%rbp),%eax
or     $0xc0,%eax
mov    %al,-0x50(%rbp)
movb   $0x3f,-0x4f(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x4e(%rbp)
mov    -0x20(%rbp),%rax
sar    $0x8,%rax
and    $0xff,%rax
mov    %al,-0x4d(%rbp)
movb   $0xff,-0x44(%rbp)
movb   $0xff,-0x43(%rbp)
movb   $0xff,-0x42(%rbp)
movb   $0xff,-0x41(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd28(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13cd <main+0x22d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x6,-0x4(%rbp)
jmp    1460 <main+0x2c0>
lea    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x10,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
cmp    $0x1,%eax
je     140f <main+0x26f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x7,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   10c0 <fwrite@plt>
cmp    $0x1,%eax
je     1450 <main+0x2b0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x8,-0x4(%rbp)
jmp    1460 <main+0x2c0>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    1317 <main+0x167>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe2b(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     132d <main+0x17d>
mov    %rax,%rbx
mov    0x2dfb(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbx,%rdi
call   1090 <ftell@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1070 <rewind@plt>
lea    0x1ff(%r13),%rax
lea    0x3fe(%r13),%r12
test   %rax,%rax
cmovns %rax,%r12
mov    %r12,%rsi
sar    $0x9,%rsi
cmp    $0x10000,%rsi
jae    1349 <main+0x199>
mov    %rsi,%rbp
and    $0xfffffffffffffe00,%r12
mov    %r12,%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     135e <main+0x1ae>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1376 <main+0x1c6>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
add    %r13,%rdi
mov    %r12d,%edx
sub    %r13d,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
movw   $0x3fda,(%rsp)
mov    %rbp,%rax
mov    %al,0x2(%rsp)
mov    %ah,0x3(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
mov    0x10(%r14),%rdi
lea    0xdd0(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     138f <main+0x1df>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
jne    13a8 <main+0x1f8>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
cmp    $0x1,%eax
jne    13c1 <main+0x211>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    13d8 <main+0x228>
lea    0xddb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    13d8 <main+0x228>
mov    0x8(%r14),%rsi
lea    0xccb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%eax
jmp    13d8 <main+0x228>
lea    0xccf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x3,%eax
jmp    13d8 <main+0x228>
lea    0xcde(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x4,%eax
jmp    13d8 <main+0x228>
mov    0x8(%r14),%rsi
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x5,%eax
jmp    13d8 <main+0x228>
mov    0x10(%r14),%rsi
lea    0xcf6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x6,%eax
jmp    13d8 <main+0x228>
mov    0x10(%r14),%rsi
lea    0xcfa(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x7,%eax
jmp    13d8 <main+0x228>
mov    0x10(%r14),%rsi
lea    0xd05(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x8,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Usage: lpc18xx_bootheader [in-file] [out-file]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [28 x i8] c"Cannot open input file: %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [36 x i8] c"Number of blocks is too large: %ld\0A\00"
@.str.4 = [40 x i8] c"Could not allocate %ld bytes of memory\0A\00"
@.str.5 = [34 x i8] c"Could not read file contents: %s\0A\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [29 x i8] c"Cannot open output file: %s\0A\00"
@.str.8 = [36 x i8] c"Could not write header to file: %s\0A\00"
@.str.9 = [40 x i8] c"Could not write image data to file: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [16 x i8]
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %135
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %9
%22 = load i32*, i32** %9
%23 = icmp ne i32* %22, null
br i1 %23, label %29, label %24
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 2, i32* %3
br label %135
29: ; preds = %17
%30 = load i32*, i32** %9
%31 = load i32, i32* @SEEK_END
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = load i32*, i32** %9
%34 = call i64 @ftell(i32* %33)
store i64 %34, i64* %6
%35 = load i32*, i32** %9
%36 = call i32 @rewind(i32* %35)
%37 = load i64, i64* %6
%38 = add nsw i64 %37, 511
%39 = sdiv i64 %38, 512
store i64 %39, i64* %7
%40 = load i64, i64* %7
%41 = mul nsw i64 %40, 512
store i64 %41, i64* %8
%42 = load i64, i64* %7
%43 = ashr i64 %42, 16
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %29
%46 = load i64, i64* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 %46)
store i32 3, i32* %3
br label %135
48: ; preds = %29
%49 = load i64, i64* %8
%50 = call i8* @malloc(i64 %49)
store i8* %50, i8** %12
%51 = load i8*, i8** %12
%52 = icmp ne i8* %51, null
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = load i64, i64* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i64 %54)
store i32 4, i32* %3
br label %135
56: ; preds = %48
%57 = load i8*, i8** %12
%58 = load i64, i64* %6
%59 = load i32*, i32** %9
%60 = call i32 @fread(i8* %57, i64 %58, i32 1, i32* %59)
%61 = icmp ne i32 %60, 1
br i1 %61, label %62, label %67
62: ; preds = %56
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = load i8*, i8** %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %65)
store i32 5, i32* %3
br label %135
67: ; preds = %56
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
%70 = load i8*, i8** %12
%71 = load i64, i64* %6
%72 = getelementptr inbounds i8, i8* %70, i64 %71
%73 = load i64, i64* %8
%74 = load i64, i64* %6
%75 = sub nsw i64 %73, %74
%76 = trunc i64 %75 to i32
%77 = call i32 @memset(i8* %72, i32 0, i32 %76)
%78 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%79 = call i32 @memset(i8* %78, i32 0, i32 16)
%80 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
store i8 26, i8* %80
%81 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = or i32 %83, 192
%85 = trunc i32 %84 to i8
store i8 %85, i8* %81
%86 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 1
store i8 63, i8* %86
%87 = load i64, i64* %7
%88 = and i64 %87, 255
%89 = trunc i64 %88 to i8
%90 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 2
store i8 %89, i8* %90
%91 = load i64, i64* %7
%92 = ashr i64 %91, 8
%93 = and i64 %92, 255
%94 = trunc i64 %93 to i8
%95 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 3
store i8 %94, i8* %95
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 12
store i8 -1, i8* %96
%97 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 13
store i8 -1, i8* %97
%98 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 14
store i8 -1, i8* %98
%99 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 15
store i8 -1, i8* %99
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 2
%102 = load i8*, i8** %101
%103 = call i32* @fopen(i8* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %103, i32** %10
%104 = load i32*, i32** %10
%105 = icmp ne i32* %104, null
br i1 %105, label %111, label %106
106: ; preds = %67
%107 = load i8**, i8*** %5
%108 = getelementptr inbounds i8*, i8** %107, i64 2
%109 = load i8*, i8** %108
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %109)
store i32 6, i32* %3
br label %135
111: ; preds = %67
%112 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%113 = load i32*, i32** %10
%114 = call i32 @fwrite(i8* %112, i64 16, i32 1, i32* %113)
%115 = icmp ne i32 %114, 1
br i1 %115, label %116, label %121
116: ; preds = %111
%117 = load i8**, i8*** %5
%118 = getelementptr inbounds i8*, i8** %117, i64 2
%119 = load i8*, i8** %118
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %119)
store i32 7, i32* %3
br label %135
121: ; preds = %111
%122 = load i8*, i8** %12
%123 = load i64, i64* %8
%124 = load i32*, i32** %10
%125 = call i32 @fwrite(i8* %122, i64 %123, i32 1, i32* %124)
%126 = icmp ne i32 %125, 1
br i1 %126, label %127, label %132
127: ; preds = %121
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 2
%130 = load i8*, i8** %129
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i8* %130)
store i32 8, i32* %3
br label %135
132: ; preds = %121
%133 = load i32*, i32** %10
%134 = call i32 @fclose(i32* %133)
store i32 0, i32* %3
br label %135
135: ; preds = %132, %127, %116, %106, %62, %53, %45, %24, %15
%136 = load i32, i32* %3
ret i32 %136
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [28 x i8] c"Cannot open input file: %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [36 x i8] c"Number of blocks is too large: %ld\0A\00"
@.str.4 = [40 x i8] c"Could not allocate %ld bytes of memory\0A\00"
@.str.5 = [34 x i8] c"Could not read file contents: %s\0A\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [29 x i8] c"Cannot open output file: %s\0A\00"
@.str.8 = [36 x i8] c"Could not write header to file: %s\0A\00"
@.str.9 = [40 x i8] c"Could not write image data to file: %s\0A\00"
@str = [49 x i8] c"Usage: lpc18xx_bootheader [in-file] [out-file]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %74
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %74
16: ; preds = %8
%17 = load i32, i32* @SEEK_END
%18 = tail call i32 @fseek(i32* %11, i32 0, i32 %17)
%19 = tail call i64 @ftell(i32* %11)
%20 = tail call i32 @rewind(i32* %11)
%21 = add nsw i64 %19, 511
%22 = sdiv i64 %21, 512
%23 = shl nsw i64 %22, 9
%24 = icmp ult i64 %22, 65536
br i1 %24, label %27, label %25
25: ; preds = %16
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 %22)
br label %74
27: ; preds = %16
%28 = tail call i8* @malloc(i64 %23)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i64 %19)
br label %74
32: ; preds = %27
%33 = tail call i32 @fread(i8* %28, i64 %19, i32 1, i32* %11)
%34 = icmp eq i32 %33, 1
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i8*, i8** %9
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %74
38: ; preds = %32
%39 = tail call i32 @fclose(i32* %11)
%40 = getelementptr inbounds i8, i8* %28, i64 %19
%41 = sub nsw i64 %23, %19
%42 = trunc i64 %41 to i32
%43 = tail call i32 @memset(i8* %40, i32 0, i32 %42)
%44 = call i32 @memset(i8* %4, i32 0, i32 16)
store i8 -38, i8* %4
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 1
store i8 63, i8* %45
%46 = trunc i64 %22 to i8
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 2
store i8 %46, i8* %47
%48 = lshr i64 %22, 8
%49 = trunc i64 %48 to i8
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 3
store i8 %49, i8* %50
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 12
%52 = getelementptr inbounds i8*, i8** %1, i64 2
%53 = bitcast i8* %51 to i32*
store i32 -1, i32* %53
%54 = load i8*, i8** %52
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %60
57: ; preds = %38
%58 = load i8*, i8** %52
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %58)
br label %74
60: ; preds = %38
%61 = call i32 @fwrite(i8* %4, i64 16, i32 1, i32* %55)
%62 = icmp eq i32 %61, 1
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i8*, i8** %52
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %64)
br label %74
66: ; preds = %60
%67 = call i32 @fwrite(i8* %28, i64 %23, i32 1, i32* %55)
%68 = icmp eq i32 %67, 1
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i8*, i8** %52
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i8* %70)
br label %74
72: ; preds = %66
%73 = call i32 @fclose(i32* %55)
br label %74
74: ; preds = %72, %69, %63, %57, %35, %30, %25, %13, %6
%75 = phi i32 [ 1, %6 ], [ 3, %25 ], [ 5, %35 ], [ 7, %63 ], [ 8, %69 ], [ 0, %72 ], [ 6, %57 ], [ 4, %30 ], [ 2, %13 ]
ret i32 %75
}