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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
size_t fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ int2le(int, unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int rkw_crc32(unsigned char *, int);
int /*<<< orphan*/ stderr;
int rkw_encode(char *iname, char *oname, unsigned long modelnum) {
  size_t len;
  int length;
  int rkwlength;
  FILE *file;
  uint32_t binary_crc, header_crc;
  unsigned char *outbuf;
  file = fopen(iname, "rb");
  if (!file) {
    perror(iname);
    return -1;
  }
  fseek(file, 0, SEEK_END);
  length = ftell(file);
  fseek(file, 0, SEEK_SET);
  rkwlength = (length + 0x2c + 4);
  outbuf = malloc(rkwlength);
  if (!outbuf) {
    printf("out of memory!\n");
    fclose(file);
    return -1;
  }
  memset(outbuf, 0, rkwlength);
  int2le(0x4c44524b, outbuf);
  int2le(0x2c, outbuf + 0x04);
  int2le(0x60000000, outbuf + 0x08);
  int2le(0x60000000, outbuf + 0x0c);
  int2le(0x60000000 + length, outbuf + 0x10);
  int2le(0x6035a5e4, outbuf + 0x14);
  int2le(modelnum, outbuf + 0x18);
  int2le(0, outbuf + 0x1c);
  int2le(0x60000000, outbuf + 0x20);
  int2le(0xe0000000, outbuf + 0x24);
  header_crc = rkw_crc32(outbuf, 0x2c - 4);
  int2le(header_crc, outbuf + 0x28);
  len = fread(outbuf + 0x2c, 1, length, file);
  if (len < (size_t)length) {
    perror(iname);
    free(outbuf);
    fclose(file);
    return -2;
  }
  fclose(file);
  binary_crc = rkw_crc32(outbuf + 0x2c, length);
  int2le(binary_crc, outbuf + rkwlength - 4);
  file = fopen(oname, "wb");
  if (!file) {
    perror(oname);
    free(outbuf);
    return -3;
  }
  len = fwrite(outbuf, 1, rkwlength, file);
  if (len < (size_t)length) {
    perror(oname);
    fclose(file);
    free(outbuf);
    return -4;
  }
  fclose(file);
  free(outbuf);
  fprintf(stderr, "File encoded successfully\n");
  return 0;
}


x86 assembly (clang, -O0):
<rkw_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1228 <rkw_encode+0x48>
mov    -0x10(%rbp),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c5 <rkw_encode+0x2e5>
mov    -0x38(%rbp),%rdi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2d7d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x2c(%rbp),%eax
add    $0x2c,%eax
add    $0x4,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12a0 <rkw_encode+0xc0>
lea    0xd7d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c5 <rkw_encode+0x2e5>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x48(%rbp),%rsi
mov    $0x4c44524b,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2c,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x8,%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0xc,%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
mov    -0x2c(%rbp),%edi
add    $0x60000000,%edi
mov    -0x48(%rbp),%rsi
add    $0x10,%rsi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x14,%rsi
mov    $0x6035a5e4,%edi
call   10f0 <int2le@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
mov    -0x48(%rbp),%rsi
add    $0x18,%rsi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x1c,%rsi
xor    %edi,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x20,%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rsi
add    $0x24,%rsi
mov    $0xe0000000,%edi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rdi
mov    $0x28,%esi
call   1050 <rkw_crc32@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x48(%rbp),%rsi
add    $0x28,%rsi
call   10f0 <int2le@plt>
mov    -0x48(%rbp),%rdi
add    $0x2c,%rdi
mov    -0x2c(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
jae    13d6 <rkw_encode+0x1f6>
mov    -0x10(%rbp),%rdi
call   10e0 <perror@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    14c5 <rkw_encode+0x2e5>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
add    $0x2c,%rdi
mov    -0x2c(%rbp),%esi
call   1050 <rkw_crc32@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x48(%rbp),%rsi
movslq -0x30(%rbp),%rax
add    %rax,%rsi
add    $0xfffffffffffffffc,%rsi
call   10f0 <int2le@plt>
mov    -0x18(%rbp),%rdi
lea    0xbff(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1446 <rkw_encode+0x266>
mov    -0x18(%rbp),%rdi
call   10e0 <perror@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    14c5 <rkw_encode+0x2e5>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rax
jae    1497 <rkw_encode+0x2b7>
mov    -0x18(%rbp),%rdi
call   10e0 <perror@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    14c5 <rkw_encode+0x2e5>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
lea    0xb5d(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rkw_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe02(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13e6 <rkw_encode+0x206>
mov    %rax,%r15
mov    %rbx,0x10(%rsp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r15,%rdi
call   10a0 <ftell@plt>
mov    %eax,%r12d
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
lea    0x30(%r12),%r13d
mov    %r13d,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13be <rkw_encode+0x1de>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   1080 <memset@plt>
mov    $0x4c44524b,%edi
mov    %rbx,%rsi
call   10f0 <int2le@plt>
lea    0x4(%rbx),%rsi
mov    $0x2c,%edi
call   10f0 <int2le@plt>
lea    0x8(%rbx),%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
lea    0xc(%rbx),%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
lea    0x60000000(%r12),%edi
60
lea    0x10(%rbx),%rsi
call   10f0 <int2le@plt>
lea    0x14(%rbx),%rsi
mov    $0x6035a5e4,%edi
call   10f0 <int2le@plt>
lea    0x18(%rbx),%rsi
mov    %r14d,%edi
call   10f0 <int2le@plt>
lea    0x1c(%rbx),%rsi
xor    %edi,%edi
call   10f0 <int2le@plt>
lea    0x20(%rbx),%rsi
mov    $0x60000000,%edi
call   10f0 <int2le@plt>
lea    0x24(%rbx),%rsi
mov    $0xe0000000,%edi
call   10f0 <int2le@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1060 <rkw_crc32@plt>
lea    0x28(%rbx),%rsi
mov    %eax,%edi
call   10f0 <int2le@plt>
lea    0x2c(%rbx),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
movslq %r12d,%r14
cmp    %r14,%rax
jb     13f0 <rkw_encode+0x210>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
call   1060 <rkw_crc32@plt>
movslq %r13d,%rcx
lea    (%rbx,%rcx,1),%rsi
add    $0xfffffffffffffffc,%rsi
mov    %eax,%edi
call   10f0 <int2le@plt>
lea    0xca3(%rip),%rsi
mov    0x10(%rsp),%r15
mov    %r15,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1411 <rkw_encode+0x231>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %rax,%rcx
call   1100 <fwrite@plt>
cmp    %r14,%rax
jb     1428 <rkw_encode+0x248>
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xc51(%rip),%rsi
call   1090 <fprintf@plt>
xor    %eax,%eax
jmp    13d7 <rkw_encode+0x1f7>
lea    0xc5c(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   10e0 <perror@plt>
jmp    13d2 <rkw_encode+0x1f2>
mov    0x8(%rsp),%rdi
call   10e0 <perror@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0xfffffffe,%eax
jmp    13d7 <rkw_encode+0x1f7>
mov    %r15,%rdi
call   10e0 <perror@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffffd,%eax
jmp    13d7 <rkw_encode+0x1f7>
mov    %r15,%rdi
call   10e0 <perror@plt>
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffffc,%eax
jmp    13d7 <rkw_encode+0x1f7>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [16 x i8] c"out of memory!\0A\00"
@.str.2 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"File encoded successfully\0A\00"
define i32 @rkw_encode(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%15 = load i8*, i8** %5
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %11
%17 = load i32*, i32** %11
%18 = icmp ne i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = call i32 @perror(i8* %20)
store i32 -1, i32* %4
br label %147
22: ; preds = %3
%23 = load i32*, i32** %11
%24 = load i32, i32* @SEEK_END
%25 = call i32 @fseek(i32* %23, i32 0, i32 %24)
%26 = load i32*, i32** %11
%27 = call i32 @ftell(i32* %26)
store i32 %27, i32* %9
%28 = load i32*, i32** %11
%29 = load i32, i32* @SEEK_SET
%30 = call i32 @fseek(i32* %28, i32 0, i32 %29)
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 44
%33 = add nsw i32 %32, 4
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %14
%36 = load i8*, i8** %14
%37 = icmp ne i8* %36, null
br i1 %37, label %42, label %38
38: ; preds = %22
%39 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32*, i32** %11
%41 = call i32 @fclose(i32* %40)
store i32 -1, i32* %4
br label %147
42: ; preds = %22
%43 = load i8*, i8** %14
%44 = load i32, i32* %10
%45 = call i32 @memset(i8* %43, i32 0, i32 %44)
%46 = load i8*, i8** %14
%47 = call i32 @int2le(i32 1279545931, i8* %46)
%48 = load i8*, i8** %14
%49 = getelementptr inbounds i8, i8* %48, i64 4
%50 = call i32 @int2le(i32 44, i8* %49)
%51 = load i8*, i8** %14
%52 = getelementptr inbounds i8, i8* %51, i64 8
%53 = call i32 @int2le(i32 1610612736, i8* %52)
%54 = load i8*, i8** %14
%55 = getelementptr inbounds i8, i8* %54, i64 12
%56 = call i32 @int2le(i32 1610612736, i8* %55)
%57 = load i32, i32* %9
%58 = add nsw i32 1610612736, %57
%59 = load i8*, i8** %14
%60 = getelementptr inbounds i8, i8* %59, i64 16
%61 = call i32 @int2le(i32 %58, i8* %60)
%62 = load i8*, i8** %14
%63 = getelementptr inbounds i8, i8* %62, i64 20
%64 = call i32 @int2le(i32 1614128612, i8* %63)
%65 = load i64, i64* %7
%66 = trunc i64 %65 to i32
%67 = load i8*, i8** %14
%68 = getelementptr inbounds i8, i8* %67, i64 24
%69 = call i32 @int2le(i32 %66, i8* %68)
%70 = load i8*, i8** %14
%71 = getelementptr inbounds i8, i8* %70, i64 28
%72 = call i32 @int2le(i32 0, i8* %71)
%73 = load i8*, i8** %14
%74 = getelementptr inbounds i8, i8* %73, i64 32
%75 = call i32 @int2le(i32 1610612736, i8* %74)
%76 = load i8*, i8** %14
%77 = getelementptr inbounds i8, i8* %76, i64 36
%78 = call i32 @int2le(i32 -536870912, i8* %77)
%79 = load i8*, i8** %14
%80 = call i32 @rkw_crc32(i8* %79, i32 40)
store i32 %80, i32* %13
%81 = load i32, i32* %13
%82 = load i8*, i8** %14
%83 = getelementptr inbounds i8, i8* %82, i64 40
%84 = call i32 @int2le(i32 %81, i8* %83)
%85 = load i8*, i8** %14
%86 = getelementptr inbounds i8, i8* %85, i64 44
%87 = load i32, i32* %9
%88 = load i32*, i32** %11
%89 = call i64 @fread(i8* %86, i32 1, i32 %87, i32* %88)
store i64 %89, i64* %8
%90 = load i64, i64* %8
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = icmp ult i64 %90, %92
br i1 %93, label %94, label %101
94: ; preds = %42
%95 = load i8*, i8** %5
%96 = call i32 @perror(i8* %95)
%97 = load i8*, i8** %14
%98 = call i32 @free(i8* %97)
%99 = load i32*, i32** %11
%100 = call i32 @fclose(i32* %99)
store i32 -2, i32* %4
br label %147
101: ; preds = %42
%102 = load i32*, i32** %11
%103 = call i32 @fclose(i32* %102)
%104 = load i8*, i8** %14
%105 = getelementptr inbounds i8, i8* %104, i64 44
%106 = load i32, i32* %9
%107 = call i32 @rkw_crc32(i8* %105, i32 %106)
store i32 %107, i32* %12
%108 = load i32, i32* %12
%109 = load i8*, i8** %14
%110 = load i32, i32* %10
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = getelementptr inbounds i8, i8* %112, i64 -4
%114 = call i32 @int2le(i32 %108, i8* %113)
%115 = load i8*, i8** %6
%116 = call i32* @fopen(i8* %115, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %116, i32** %11
%117 = load i32*, i32** %11
%118 = icmp ne i32* %117, null
br i1 %118, label %124, label %119
119: ; preds = %101
%120 = load i8*, i8** %6
%121 = call i32 @perror(i8* %120)
%122 = load i8*, i8** %14
%123 = call i32 @free(i8* %122)
store i32 -3, i32* %4
br label %147
124: ; preds = %101
%125 = load i8*, i8** %14
%126 = load i32, i32* %10
%127 = load i32*, i32** %11
%128 = call i64 @fwrite(i8* %125, i32 1, i32 %126, i32* %127)
store i64 %128, i64* %8
%129 = load i64, i64* %8
%130 = load i32, i32* %9
%131 = sext i32 %130 to i64
%132 = icmp ult i64 %129, %131
br i1 %132, label %133, label %140
133: ; preds = %124
%134 = load i8*, i8** %6
%135 = call i32 @perror(i8* %134)
%136 = load i32*, i32** %11
%137 = call i32 @fclose(i32* %136)
%138 = load i8*, i8** %14
%139 = call i32 @free(i8* %138)
store i32 -4, i32* %4
br label %147
140: ; preds = %124
%141 = load i32*, i32** %11
%142 = call i32 @fclose(i32* %141)
%143 = load i8*, i8** %14
%144 = call i32 @free(i8* %143)
%145 = load i32, i32* @stderr
%146 = call i32 @fprintf(i32 %145, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %147
147: ; preds = %140, %133, %119, %94, %38, %19
%148 = load i32, i32* %4
ret i32 %148
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"File encoded successfully\0A\00"
@str = [15 x i8] c"out of memory!\00"
define i32 @rkw_encode(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @perror(i8* %0)
br label %78
8: ; preds = %3
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %4, i32 0, i32 %9)
%11 = tail call i32 @ftell(i32* %4)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @fseek(i32* %4, i32 0, i32 %12)
%14 = add nsw i32 %11, 48
%15 = tail call i8* @malloc(i32 %14)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %8
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @fclose(i32* %4)
br label %78
20: ; preds = %8
%21 = tail call i32 @memset(i8* %15, i32 0, i32 %14)
%22 = tail call i32 @int2le(i32 1279545931, i8* %15)
%23 = getelementptr inbounds i8, i8* %15, i64 4
%24 = tail call i32 @int2le(i32 44, i8* %23)
%25 = getelementptr inbounds i8, i8* %15, i64 8
%26 = tail call i32 @int2le(i32 1610612736, i8* %25)
%27 = getelementptr inbounds i8, i8* %15, i64 12
%28 = tail call i32 @int2le(i32 1610612736, i8* %27)
%29 = add nsw i32 %11, 1610612736
%30 = getelementptr inbounds i8, i8* %15, i64 16
%31 = tail call i32 @int2le(i32 %29, i8* %30)
%32 = getelementptr inbounds i8, i8* %15, i64 20
%33 = tail call i32 @int2le(i32 1614128612, i8* %32)
%34 = trunc i64 %2 to i32
%35 = getelementptr inbounds i8, i8* %15, i64 24
%36 = tail call i32 @int2le(i32 %34, i8* %35)
%37 = getelementptr inbounds i8, i8* %15, i64 28
%38 = tail call i32 @int2le(i32 0, i8* %37)
%39 = getelementptr inbounds i8, i8* %15, i64 32
%40 = tail call i32 @int2le(i32 1610612736, i8* %39)
%41 = getelementptr inbounds i8, i8* %15, i64 36
%42 = tail call i32 @int2le(i32 -536870912, i8* %41)
%43 = tail call i32 @rkw_crc32(i8* %15, i32 40)
%44 = getelementptr inbounds i8, i8* %15, i64 40
%45 = tail call i32 @int2le(i32 %43, i8* %44)
%46 = getelementptr inbounds i8, i8* %15, i64 44
%47 = tail call i64 @fread(i8* %46, i32 1, i32 %11, i32* %4)
%48 = sext i32 %11 to i64
%49 = icmp ult i64 %47, %48
br i1 %49, label %50, label %54
50: ; preds = %20
%51 = tail call i32 @perror(i8* %0)
%52 = tail call i32 @free(i8* %15)
%53 = tail call i32 @fclose(i32* %4)
br label %78
54: ; preds = %20
%55 = tail call i32 @fclose(i32* %4)
%56 = tail call i32 @rkw_crc32(i8* %46, i32 %11)
%57 = sext i32 %14 to i64
%58 = getelementptr inbounds i8, i8* %15, i64 %57
%59 = getelementptr inbounds i8, i8* %58, i64 -4
%60 = tail call i32 @int2le(i32 %56, i8* %59)
%61 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %66
63: ; preds = %54
%64 = tail call i32 @perror(i8* %1)
%65 = tail call i32 @free(i8* %15)
br label %78
66: ; preds = %54
%67 = tail call i64 @fwrite(i8* %15, i32 1, i32 %14, i32* %61)
%68 = icmp ult i64 %67, %48
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = tail call i32 @perror(i8* %1)
%71 = tail call i32 @fclose(i32* %61)
%72 = tail call i32 @free(i8* %15)
br label %78
73: ; preds = %66
%74 = tail call i32 @fclose(i32* %61)
%75 = tail call i32 @free(i8* %15)
%76 = load i32, i32* @stderr
%77 = tail call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %73, %69, %63, %50, %17, %6
%79 = phi i32 [ -2, %50 ], [ -4, %69 ], [ 0, %73 ], [ -3, %63 ], [ -1, %17 ], [ -1, %6 ]
ret i32 %79
}