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

/* Variables and functions */
scalar_t__ L_tmpnam;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int fil_sreadU32(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int /*<<< orphan*/ *, size_t, int,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ *, size_t, int,
                          int /*<<< orphan*/ *);
char *malloc(size_t);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ *tmpnam(char *);
int __cole_extract_file(FILE **file, char **filename, uint32_t size,
                        uint32_t pps_start, uint8_t *BDepot, uint8_t *SDepot,
                        FILE *sbfile, FILE *inputfile) {
  FILE *ret;
  uint16_t BlockSize, Offset;
  uint8_t *Depot;
  FILE *infile;
  long FilePos;
  size_t bytes_to_copy;
  uint8_t Block[0x0200];
  *filename = malloc((size_t)(L_tmpnam + 1));
  if (*filename == NULL)
    return 1;
  if (tmpnam(*filename) == NULL) {
    free(*filename);
    return 2;
  };
  ret = fopen(*filename, "w+b");
  *file = ret;
  if (ret == NULL) {
    free(*filename);
    return 3;
  }
  if (size >= 0x1000) {
    Offset = 1;
    BlockSize = 0x0200;
    infile = inputfile;
    Depot = BDepot;
  } else {
    Offset = 0;
    BlockSize = 0x40;
    infile = sbfile;
    Depot = SDepot;
  }
  while (pps_start < (uint32_t)0xfffffffd) {
    FilePos = (long)((pps_start + Offset) * BlockSize);
    if (FilePos < 0) {
      fclose(ret);
      remove(*filename);
      free(*filename);
      return 4;
    }
    bytes_to_copy = ((BlockSize) < (size) ? (BlockSize) : (size));
    if (fseek(infile, FilePos, SEEK_SET)) {
      fclose(ret);
      remove(*filename);
      free(*filename);
      return 4;
    }
    (void)fread(Block, bytes_to_copy, 1, infile);
    if (ferror(infile)) {
      fclose(ret);
      remove(*filename);
      free(*filename);
      return 5;
    }
    (void)fwrite(Block, bytes_to_copy, 1, ret);
    if (ferror(ret)) {
      fclose(ret);
      remove(*filename);
      free(*filename);
      return 6;
    }
    pps_start = fil_sreadU32(Depot + (pps_start * 4));
    size -= ((BlockSize) < (size) ? (BlockSize) : (size));
    if (size == 0)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<__cole_extract_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1210 <__cole_extract_file+0x60>
movl   $0x1,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <tmpnam@plt>
cmp    $0x0,%rax
jne    123e <__cole_extract_file+0x8e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb4(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x38(%rbp)
jne    1283 <__cole_extract_file+0xd3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x3,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
cmpl   $0x1000,-0x1c(%rbp)
jl     12b3 <__cole_extract_file+0x103>
movl   $0x1,-0x40(%rbp)
movl   $0x200,-0x3c(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12d1 <__cole_extract_file+0x121>
movl   $0x0,-0x40(%rbp)
movl   $0x40,-0x3c(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12d6 <__cole_extract_file+0x126>
cmpl   $0xfffffffd,-0x20(%rbp)
jge    14b6 <__cole_extract_file+0x306>
mov    -0x20(%rbp),%eax
add    -0x40(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jge    1328 <__cole_extract_file+0x178>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <remove@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x4,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1342 <__cole_extract_file+0x192>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x864(%rbp)
jmp    134b <__cole_extract_file+0x19b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x864(%rbp)
mov    -0x864(%rbp),%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x2c72(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     13a4 <__cole_extract_file+0x1f4>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <remove@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x4,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
lea    -0x860(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x50(%rbp),%rcx
mov    $0x1,%edx
call   1060 <fread@plt>
mov    -0x50(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     13fd <__cole_extract_file+0x24d>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <remove@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x5,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
lea    -0x860(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     1456 <__cole_extract_file+0x2a6>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <remove@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x6,-0x4(%rbp)
jmp    14bd <__cole_extract_file+0x30d>
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
call   10d0 <fil_sreadU32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    148b <__cole_extract_file+0x2db>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x868(%rbp)
jmp    1494 <__cole_extract_file+0x2e4>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x868(%rbp)
mov    -0x868(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    14b1 <__cole_extract_file+0x301>
jmp    14b6 <__cole_extract_file+0x306>
jmp    12d6 <__cole_extract_file+0x126>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__cole_extract_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
mov    %r9,%r15
mov    %r8,%r13
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    0x2e06(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     133b <__cole_extract_file+0x18b>
mov    %rax,%rdi
call   10c0 <tmpnam@plt>
mov    0x0(%rbp),%rdi
test   %rax,%rax
je     1343 <__cole_extract_file+0x193>
lea    0xdf1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,(%rbx)
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     134b <__cole_extract_file+0x19b>
mov    %r13,%rsi
mov    0x878(%rsp),%r13
xor    %edx,%edx
cmp    $0x1000,%r12d
mov    $0x200,%eax
mov    $0x40,%ebx
cmovge %eax,%ebx
setge  %al
cmovl  0x870(%rsp),%r13
cmovge %rsi,%r15
mov    %r15,0x28(%rsp)
xor    %r15d,%r15d
cmp    $0xfffffffc,%r14d
jg     1382 <__cole_extract_file+0x1d2>
mov    %r12d,%edi
mov    %rbp,0x18(%rsp)
mov    %al,%dl
lea    0x30(%rsp),%r12
mov    %rdx,0x20(%rsp)
mov    %ebx,0x8(%rsp)
lea    (%r14,%rdx,1),%eax
imul   %ebx,%eax
mov    $0x4,%r15d
test   %eax,%eax
js     1361 <__cole_extract_file+0x1b1>
mov    %eax,%esi
cmp    %edi,%ebx
mov    %edi,0xc(%rsp)
mov    %edi,%ebp
cmovl  %ebx,%ebp
mov    0x2d2f(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   1090 <fseek@plt>
test   %rax,%rax
jne    1361 <__cole_extract_file+0x1b1>
movslq %ebp,%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
call   1060 <fread@plt>
mov    %r13,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
jne    1353 <__cole_extract_file+0x1a3>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
jne    135b <__cole_extract_file+0x1ab>
shl    $0x2,%r14d
movslq %r14d,%rax
mov    0x28(%rsp),%rcx
lea    (%rcx,%rax,4),%rdi
call   10d0 <fil_sreadU32@plt>
mov    0xc(%rsp),%edi
sub    %ebp,%edi
je     1336 <__cole_extract_file+0x186>
mov    %eax,%r14d
cmp    $0xfffffffd,%eax
mov    0x20(%rsp),%rdx
mov    0x8(%rsp),%ebx
jl     1280 <__cole_extract_file+0xd0>
xor    %r15d,%r15d
jmp    1382 <__cole_extract_file+0x1d2>
mov    $0x1,%r15d
jmp    1382 <__cole_extract_file+0x1d2>
mov    $0x2,%r15d
jmp    137d <__cole_extract_file+0x1cd>
mov    $0x3,%r15d
jmp    1379 <__cole_extract_file+0x1c9>
mov    $0x5,%r15d
jmp    1361 <__cole_extract_file+0x1b1>
mov    $0x6,%r15d
mov    0x10(%rsp),%rdi
call   1070 <fclose@plt>
mov    0x18(%rsp),%rbp
mov    0x0(%rbp),%rdi
call   1040 <remove@plt>
mov    0x0(%rbp),%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@L_tmpnam = global i64 0
@.str = [4 x i8] c"w+b\00"
@SEEK_SET = global i32 0
define i32 @__cole_extract_file(i32** nocapture writeonly %0, i8** nocapture %1, i32 %2, i32 %3, i32* %4, i32* %5, i32* nocapture %6, i32* nocapture %7) {
%9 = alloca [512 x i32]
%10 = bitcast [512 x i32]* %9 to i8*
%11 = load i64, i64* @L_tmpnam
%12 = add nsw i64 %11, 1
%13 = tail call i8* @malloc(i64 %12)
store i8* %13, i8** %1
%14 = icmp eq i8* %13, null
br i1 %14, label %74, label %15
15: ; preds = %8
%16 = tail call i32* @tmpnam(i8* %13)
%17 = icmp eq i32* %16, null
%18 = load i8*, i8** %1
br i1 %17, label %70, label %19
19: ; preds = %15
%20 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %0
%21 = icmp eq i32* %20, null
br i1 %21, label %67, label %22
22: ; preds = %19
%23 = icmp sgt i32 %2, 4095
%24 = select i1 %23, i32 512, i32 64
%25 = zext i1 %23 to i32
%26 = select i1 %23, i32* %4, i32* %5
%27 = select i1 %23, i32* %7, i32* %6
%28 = icmp slt i32 %3, -3
br i1 %28, label %29, label %74
29: ; preds = %22
%30 = getelementptr inbounds [512 x i32], [512 x i32]* %9, i64 0, i64 0
br label %31
31: ; preds = %29, %53
%32 = phi i32 [ %57, %53 ], [ %3, %29 ]
%33 = phi i32 [ %58, %53 ], [ %2, %29 ]
%34 = add nsw i32 %32, %25
%35 = mul nsw i32 %34, %24
%36 = icmp slt i32 %35, 0
br i1 %36, label %62, label %37
37: ; preds = %31
%38 = zext i32 %35 to i64
%39 = icmp slt i32 %24, %33
%40 = select i1 %39, i32 %24, i32 %33
%41 = sext i32 %40 to i64
%42 = load i32, i32* @SEEK_SET
%43 = tail call i64 @fseek(i32* %27, i64 %38, i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %62
45: ; preds = %37
%46 = call i32 @fread(i32* %30, i64 %41, i32 1, i32* %27)
%47 = tail call i64 @ferror(i32* %27)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %62
49: ; preds = %45
%50 = call i32 @fwrite(i32* %30, i64 %41, i32 1, i32* %20)
%51 = tail call i64 @ferror(i32* %20)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %49
%54 = shl nsw i32 %32, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %26, i64 %55
%57 = tail call i32 @fil_sreadU32(i32* %56)
%58 = sub nsw i32 %33, %40
%59 = icmp ne i32 %58, 0
%60 = icmp slt i32 %57, -3
%61 = select i1 %59, i1 %60, i1 false
br i1 %61, label %31, label %74
62: ; preds = %49, %45, %37, %31
%63 = phi i32 [ 4, %31 ], [ 4, %37 ], [ 5, %45 ], [ 6, %49 ]
%64 = tail call i32 @fclose(i32* %20)
%65 = load i8*, i8** %1
%66 = tail call i32 @remove(i8* %65)
br label %67
67: ; preds = %62, %19
%68 = phi i32 [ 3, %19 ], [ %63, %62 ]
%69 = load i8*, i8** %1
br label %70
70: ; preds = %67, %15
%71 = phi i8* [ %18, %15 ], [ %69, %67 ]
%72 = phi i32 [ 2, %15 ], [ %68, %67 ]
%73 = tail call i32 @free(i8* %71)
br label %74
74: ; preds = %53, %70, %22, %8
%75 = phi i32 [ 1, %8 ], [ 0, %22 ], [ %72, %70 ], [ 0, %53 ]
ret i32 %75
}