#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 */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int fil_sreadU32(int /*<<< orphan*/ *);
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(scalar_t__);
int mkstemp(char *);
int /*<<< orphan*/ remove(char *);
scalar_t__ strlen(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];
  char template_name[] = "rtf2latex-ex-XXXXXX";
  int temp_fd;
  *filename = malloc(strlen(template_name) + 1);
  if (*filename == NULL)
    return 1;
  temp_fd = mkstemp(*filename);
  if (*filename == NULL) {
    free(*filename);
    return 2;
  }
  ret = fdopen(temp_fd, "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    $0x890,%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    0xe10(%rip),%rax
mov    %rax,-0x880(%rbp)
mov    0xe0a(%rip),%rax
mov    %rax,-0x878(%rbp)
mov    0xe05(%rip),%eax
mov    %eax,-0x870(%rbp)
lea    -0x880(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    124d <__cole_extract_file+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    1503 <__cole_extract_file+0x343>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <mkstemp@plt>
mov    %eax,-0x884(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1285 <__cole_extract_file+0xc5>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    1503 <__cole_extract_file+0x343>
mov    -0x884(%rbp),%edi
lea    0xd82(%rip),%rsi
call   10c0 <fdopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x38(%rbp)
jne    12c9 <__cole_extract_file+0x109>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movl   $0x3,-0x4(%rbp)
jmp    1503 <__cole_extract_file+0x343>
cmpl   $0x1000,-0x1c(%rbp)
jl     12f9 <__cole_extract_file+0x139>
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    1317 <__cole_extract_file+0x157>
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    131c <__cole_extract_file+0x15c>
cmpl   $0xfffffffd,-0x20(%rbp)
jge    14fc <__cole_extract_file+0x33c>
mov    -0x20(%rbp),%eax
add    -0x40(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jge    136e <__cole_extract_file+0x1ae>
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    1503 <__cole_extract_file+0x343>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1388 <__cole_extract_file+0x1c8>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x888(%rbp)
jmp    1391 <__cole_extract_file+0x1d1>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x888(%rbp)
mov    -0x888(%rbp),%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x2c34(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
cmp    $0x0,%rax
je     13ea <__cole_extract_file+0x22a>
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    1503 <__cole_extract_file+0x343>
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     1443 <__cole_extract_file+0x283>
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    1503 <__cole_extract_file+0x343>
lea    -0x860(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     149c <__cole_extract_file+0x2dc>
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    1503 <__cole_extract_file+0x343>
mov    -0x48(%rbp),%rdi
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
call   10e0 <fil_sreadU32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14d1 <__cole_extract_file+0x311>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x88c(%rbp)
jmp    14da <__cole_extract_file+0x31a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x88c(%rbp)
mov    -0x88c(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    14f7 <__cole_extract_file+0x337>
jmp    14fc <__cole_extract_file+0x33c>
jmp    131c <__cole_extract_file+0x15c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x890,%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,%r12d
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%r14
mov    $0x14,%edi
call   1080 <malloc@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
je     1337 <__cole_extract_file+0x187>
mov    %rax,%rdi
call   1090 <mkstemp@plt>
cmpq   $0x0,0x0(%rbp)
je     133f <__cole_extract_file+0x18f>
lea    0xdfd(%rip),%rsi
mov    %eax,%edi
call   10b0 <fdopen@plt>
mov    %rax,(%r14)
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1349 <__cole_extract_file+0x199>
mov    0x878(%rsp),%r14
mov    %r13,%rsi
xor    %r13d,%r13d
mov    %ebx,%edi
cmp    $0x1000,%ebx
mov    $0x200,%eax
mov    $0x40,%ebx
cmovge %eax,%ebx
setge  %al
cmovl  0x870(%rsp),%r14
cmovge %rsi,%r15
mov    %r15,0x20(%rsp)
xor    %r15d,%r15d
cmp    $0xfffffffc,%r12d
jg     1380 <__cole_extract_file+0x1d0>
mov    %rbp,0x10(%rsp)
mov    %al,%r13b
mov    %ebx,(%rsp)
mov    %r13,0x18(%rsp)
lea    (%r12,%r13,1),%eax
imul   %ebx,%eax
mov    $0x4,%r15d
test   %eax,%eax
js     135f <__cole_extract_file+0x1af>
mov    %eax,%esi
cmp    %edi,%ebx
mov    %edi,0x4(%rsp)
mov    %edi,%ebp
cmovl  %ebx,%ebp
mov    0x2d47(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    135f <__cole_extract_file+0x1af>
mov    %r12,0x28(%rsp)
movslq %ebp,%r15
lea    0x30(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fread@plt>
mov    %r14,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
jne    1351 <__cole_extract_file+0x1a1>
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    0x8(%rsp),%rbx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
jne    1359 <__cole_extract_file+0x1a9>
mov    0x28(%rsp),%rax
shl    $0x2,%eax
cltq
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,4),%rdi
call   10d0 <fil_sreadU32@plt>
mov    0x4(%rsp),%edi
sub    %ebp,%edi
je     1332 <__cole_extract_file+0x182>
mov    %eax,%r12d
cmp    $0xfffffffd,%eax
mov    0x18(%rsp),%r13
mov    (%rsp),%ebx
jl     1270 <__cole_extract_file+0xc0>
xor    %r15d,%r15d
jmp    1380 <__cole_extract_file+0x1d0>
mov    $0x1,%r15d
jmp    1380 <__cole_extract_file+0x1d0>
mov    $0x2,%r15d
xor    %edi,%edi
jmp    137b <__cole_extract_file+0x1cb>
mov    $0x3,%r15d
jmp    1377 <__cole_extract_file+0x1c7>
mov    $0x5,%r15d
jmp    135f <__cole_extract_file+0x1af>
mov    $0x6,%r15d
mov    0x8(%rsp),%rdi
call   1070 <fclose@plt>
mov    0x10(%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):
@__const.__cole_extract_file.template_name = [20 x i8] c"rtf2latex-ex-XXXXXX\00"
@.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]
%26 = alloca [20 x i8]
%27 = alloca 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
%28 = bitcast [20 x i8]* %26 to i8*
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %26, i64 0, i64 0
%30 = call i64 @strlen(i8* %29)
%31 = add nsw i64 %30, 1
%32 = call i8* @malloc(i64 %31)
%33 = load i8**, i8*** %11
store i8* %32, i8** %33
%34 = load i8**, i8*** %11
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %38
37: ; preds = %8
store i32 1, i32* %9
br label %173
38: ; preds = %8
%39 = load i8**, i8*** %11
%40 = load i8*, i8** %39
%41 = call i32 @mkstemp(i8* %40)
store i32 %41, i32* %27
%42 = load i8**, i8*** %11
%43 = load i8*, i8** %42
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %38
%46 = load i8**, i8*** %11
%47 = load i8*, i8** %46
%48 = call i32 @free(i8* %47)
store i32 2, i32* %9
br label %173
49: ; preds = %38
%50 = load i32, i32* %27
%51 = call i32* @fdopen(i32 %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %51, i32** %18
%52 = load i32*, i32** %18
%53 = load i32**, i32*** %10
store i32* %52, i32** %53
%54 = load i32*, i32** %18
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %60
56: ; preds = %49
%57 = load i8**, i8*** %11
%58 = load i8*, i8** %57
%59 = call i32 @free(i8* %58)
store i32 3, i32* %9
br label %173
60: ; preds = %49
%61 = load i32, i32* %12
%62 = icmp sge i32 %61, 4096
br i1 %62, label %63, label %66
63: ; preds = %60
store i32 1, i32* %20
store i32 512, i32* %19
%64 = load i32*, i32** %17
store i32* %64, i32** %22
%65 = load i32*, i32** %14
store i32* %65, i32** %21
br label %69
66: ; preds = %60
store i32 0, i32* %20
store i32 64, i32* %19
%67 = load i32*, i32** %16
store i32* %67, i32** %22
%68 = load i32*, i32** %15
store i32* %68, i32** %21
br label %69
69: ; preds = %66, %63
br label %70
70: ; preds = %171, %69
%71 = load i32, i32* %13
%72 = icmp slt i32 %71, -3
br i1 %72, label %73, label %172
73: ; preds = %70
%74 = load i32, i32* %13
%75 = load i32, i32* %20
%76 = add nsw i32 %74, %75
%77 = load i32, i32* %19
%78 = mul nsw i32 %76, %77
%79 = sext i32 %78 to i64
store i64 %79, i64* %23
%80 = load i64, i64* %23
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %91
82: ; preds = %73
%83 = load i32*, i32** %18
%84 = call i32 @fclose(i32* %83)
%85 = load i8**, i8*** %11
%86 = load i8*, i8** %85
%87 = call i32 @remove(i8* %86)
%88 = load i8**, i8*** %11
%89 = load i8*, i8** %88
%90 = call i32 @free(i8* %89)
store i32 4, i32* %9
br label %173
91: ; preds = %73
%92 = load i32, i32* %19
%93 = load i32, i32* %12
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %97
95: ; preds = %91
%96 = load i32, i32* %19
br label %99
97: ; preds = %91
%98 = load i32, i32* %12
br label %99
99: ; preds = %97, %95
%100 = phi i32 [ %96, %95 ], [ %98, %97 ]
%101 = sext i32 %100 to i64
store i64 %101, i64* %24
%102 = load i32*, i32** %22
%103 = load i64, i64* %23
%104 = load i32, i32* @SEEK_SET
%105 = call i64 @fseek(i32* %102, i64 %103, i32 %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %116
107: ; preds = %99
%108 = load i32*, i32** %18
%109 = call i32 @fclose(i32* %108)
%110 = load i8**, i8*** %11
%111 = load i8*, i8** %110
%112 = call i32 @remove(i8* %111)
%113 = load i8**, i8*** %11
%114 = load i8*, i8** %113
%115 = call i32 @free(i8* %114)
store i32 4, i32* %9
br label %173
116: ; preds = %99
%117 = getelementptr inbounds [512 x i32], [512 x i32]* %25, i64 0, i64 0
%118 = load i64, i64* %24
%119 = load i32*, i32** %22
%120 = call i32 @fread(i32* %117, i64 %118, i32 1, i32* %119)
%121 = load i32*, i32** %22
%122 = call i64 @ferror(i32* %121)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %133
124: ; preds = %116
%125 = load i32*, i32** %18
%126 = call i32 @fclose(i32* %125)
%127 = load i8**, i8*** %11
%128 = load i8*, i8** %127
%129 = call i32 @remove(i8* %128)
%130 = load i8**, i8*** %11
%131 = load i8*, i8** %130
%132 = call i32 @free(i8* %131)
store i32 5, i32* %9
br label %173
133: ; preds = %116
%134 = getelementptr inbounds [512 x i32], [512 x i32]* %25, i64 0, i64 0
%135 = load i64, i64* %24
%136 = load i32*, i32** %18
%137 = call i32 @fwrite(i32* %134, i64 %135, i32 1, i32* %136)
%138 = load i32*, i32** %18
%139 = call i64 @ferror(i32* %138)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %150
141: ; preds = %133
%142 = load i32*, i32** %18
%143 = call i32 @fclose(i32* %142)
%144 = load i8**, i8*** %11
%145 = load i8*, i8** %144
%146 = call i32 @remove(i8* %145)
%147 = load i8**, i8*** %11
%148 = load i8*, i8** %147
%149 = call i32 @free(i8* %148)
store i32 6, i32* %9
br label %173
150: ; preds = %133
%151 = load i32*, i32** %21
%152 = load i32, i32* %13
%153 = mul nsw i32 %152, 4
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds i32, i32* %151, i64 %154
%156 = call i32 @fil_sreadU32(i32* %155)
store i32 %156, i32* %13
%157 = load i32, i32* %19
%158 = load i32, i32* %12
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %162
160: ; preds = %150
%161 = load i32, i32* %19
br label %164
162: ; preds = %150
%163 = load i32, i32* %12
br label %164
164: ; preds = %162, %160
%165 = phi i32 [ %161, %160 ], [ %163, %162 ]
%166 = load i32, i32* %12
%167 = sub nsw i32 %166, %165
store i32 %167, i32* %12
%168 = load i32, i32* %12
%169 = icmp eq i32 %168, 0
br i1 %169, label %170, label %171
170: ; preds = %164
br label %172
171: ; preds = %164
br label %70
172: ; preds = %170, %70
store i32 0, i32* %9
br label %173
173: ; preds = %172, %141, %124, %107, %82, %56, %45, %37
%174 = load i32, i32* %9
ret i32 %174
}

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