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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(unsigned char *, char *);
int /*<<< orphan*/ truncate(char *, unsigned long);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("You must specify exactly one argument: the *.bin file to convert "
           "to *.trx\n");
  } else {
    char *fileName = argv[1];
    FILE *adjFile = fopen(fileName, "rb+");
    if (adjFile != NULL) {
      fpos_t start_pos;
      unsigned char hdr_test[5];
      int offset;
      int read_test;
      int val = fgetpos(adjFile, &start_pos);
      read_test = fread(hdr_test, 1, 4, adjFile);
      read_test = read_test == 4 ? 4 : 0;
      hdr_test[4] = '\0';
      offset = 0;
      while (read_test > 0 && strcmp(hdr_test, "HDR0") != 0) {
        unsigned char next;
        read_test = fread(&next, 1, 1, adjFile);
        if (read_test > 0) {
          hdr_test[0] = hdr_test[1];
          hdr_test[1] = hdr_test[2];
          hdr_test[2] = hdr_test[3];
          hdr_test[3] = next;
        }
        offset++;
      }
      if (read_test > 0 && offset > 0) {
        unsigned long new_length = 0;
        unsigned char buffer[4096];
        int buffer_length = 4096;
        unsigned long adjIndex = 0;
        fseek(adjFile, offset, SEEK_SET);
        while (buffer_length == 4096) {
          buffer_length = fread(buffer, 1, 4096, adjFile);
          new_length = new_length + buffer_length;
          fseek(adjFile, -1 * (buffer_length + offset), SEEK_CUR);
          fwrite(buffer, 1, buffer_length, adjFile);
          if (buffer_length == 4096) {
            fseek(adjFile, offset, SEEK_CUR);
          }
        }
        fclose(adjFile);
        truncate(fileName, new_length);
      } else {
        fclose(adjFile);
        if (offset > 0) {
          fprintf(stderr, "ERROR: Invalid bin/trx file, no header found\n");
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d4 <main+0x34>
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
jmp    1410 <main+0x270>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     140b <main+0x26b>
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <fgetpos@plt>
mov    %eax,-0x38(%rbp)
lea    -0x29(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edx
xor    %eax,%eax
mov    $0x4,%ecx
cmp    $0x4,%edx
cmove  %ecx,%eax
mov    %eax,-0x34(%rbp)
movb   $0x0,-0x25(%rbp)
movl   $0x0,-0x30(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x1061(%rbp)
jle    1276 <main+0xd6>
lea    -0x29(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1061(%rbp)
mov    -0x1061(%rbp),%al
test   $0x1,%al
jne    1289 <main+0xe9>
jmp    12d0 <main+0x130>
mov    -0x20(%rbp),%rcx
lea    -0x39(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    12c2 <main+0x122>
mov    -0x28(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x27(%rbp),%al
mov    %al,-0x28(%rbp)
mov    -0x26(%rbp),%al
mov    %al,-0x27(%rbp)
mov    -0x39(%rbp),%al
mov    %al,-0x26(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1247 <main+0xa7>
cmpl   $0x0,-0x34(%rbp)
jle    13d9 <main+0x239>
cmpl   $0x0,-0x30(%rbp)
jle    13d9 <main+0x239>
movq   $0x0,-0x48(%rbp)
movl   $0x1000,-0x1054(%rbp)
movq   $0x0,-0x1060(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
cmpl   $0x1000,-0x1054(%rbp)
jne    13be <main+0x21e>
lea    -0x1050(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x1054(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x1054(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x1054(%rbp),%eax
add    -0x30(%rbp),%eax
imul   $0xffffffff,%eax,%esi
mov    0x2c76(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x1054(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
cmpl   $0x1000,-0x1054(%rbp)
jne    13b9 <main+0x219>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    0x2c36(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
jmp    1316 <main+0x176>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1090 <truncate@plt>
jmp    1406 <main+0x266>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1401 <main+0x261>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xc58(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1406 <main+0x266>
jmp    140b <main+0x26b>
jmp    1410 <main+0x270>
xor    %eax,%eax
add    $0x1070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
cmp    $0x2,%edi
jne    136b <main+0x1cb>
mov    0x8(%rsi),%rbx
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     138b <main+0x1eb>
mov    %rax,%r15
lea    0x1c(%rsp),%rsi
mov    %rax,%rdi
call   1060 <fgetpos@plt>
lea    0xb(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movb   $0x0,0xf(%rsp)
cmp    $0x4,%eax
jne    1383 <main+0x1e3>
mov    %eax,%r12d
lea    0xdef(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
mov    %rbx,0x10(%rsp)
je     1379 <main+0x1d9>
xor    %ebx,%ebx
lea    0x20(%rsp),%r13
lea    0xdc9(%rip),%rbp
lea    0xb(%rsp),%r14
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jle    139f <main+0x1ff>
movzwl 0xc(%rsp),%eax
mov    %ax,0xb(%rsp)
movzbl 0xe(%rsp),%eax
mov    %al,0xd(%rsp)
movzbl 0x20(%rsp),%eax
mov    %al,0xe(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0xa0>
test   %ebx,%ebx
je     1383 <main+0x1e3>
mov    0x2d35(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   10a0 <fseek@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movslq %eax,%r12
lea    (%rbx,%r12,1),%esi
neg    %esi
mov    0x2d17(%rip),%r13
mov    0x0(%r13),%edx
mov    %r15,%rdi
call   10a0 <fseek@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
cmp    $0x1000,%r12d
jne    1354 <main+0x1b4>
lea    0x20(%rsp),%r14
xchg   %ax,%ax
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   10a0 <fseek@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movslq %eax,%rbp
add    %rbp,%r12
lea    (%rbx,%rbp,1),%esi
neg    %esi
mov    0x0(%r13),%edx
mov    %r15,%rdi
call   10a0 <fseek@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
cmp    $0x1000,%ebp
je     1300 <main+0x160>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1090 <truncate@plt>
jmp    138b <main+0x1eb>
lea    0xcc5(%rip),%rdi
call   1030 <puts@plt>
jmp    138b <main+0x1eb>
xor    %ebx,%ebx
test   %ebx,%ebx
jne    1294 <main+0xf4>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   1050 <fclose@plt>
cmp    $0x4,%r12d
jne    138b <main+0x1eb>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
lea    0xc4c(%rip),%rsi
call   1080 <fprintf@plt>
jmp    138b <main+0x1eb>

LLVM IR (-O0):
@.str = [75 x i8] c"You must specify exactly one argument: the *.bin file to convert to *.trx\0A\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [5 x i8] c"HDR0\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
@stderr = global i32 0
@.str.3 = [46 x i8] c"ERROR: Invalid bin/trx file, no header found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [5 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i64
%15 = alloca [4096 x i8]
%16 = alloca i32
%17 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
br label %128
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %7
%28 = load i32*, i32** %7
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %127
30: ; preds = %22
%31 = load i32*, i32** %7
%32 = call i32 @fgetpos(i32* %31, i32* %8)
store i32 %32, i32* %12
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%34 = load i32*, i32** %7
%35 = call i32 @fread(i8* %33, i32 1, i32 4, i32* %34)
store i32 %35, i32* %11
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, 4
%38 = zext i1 %37 to i64
%39 = select i1 %37, i32 4, i32 0
store i32 %39, i32* %11
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 4
store i8 0, i8* %40
store i32 0, i32* %10
br label %41
41: ; preds = %67, %30
%42 = load i32, i32* %11
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br label %48
48: ; preds = %44, %41
%49 = phi i1 [ false, %41 ], [ %47, %44 ]
br i1 %49, label %50, label %70
50: ; preds = %48
%51 = load i32*, i32** %7
%52 = call i32 @fread(i8* %13, i32 1, i32 1, i32* %51)
store i32 %52, i32* %11
%53 = load i32, i32* %11
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %67
55: ; preds = %50
%56 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 1
%57 = load i8, i8* %56
%58 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
store i8 %57, i8* %58
%59 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 2
%60 = load i8, i8* %59
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 1
store i8 %60, i8* %61
%62 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 3
%63 = load i8, i8* %62
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 2
store i8 %63, i8* %64
%65 = load i8, i8* %13
%66 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 3
store i8 %65, i8* %66
br label %67
67: ; preds = %55, %50
%68 = load i32, i32* %10
%69 = add nsw i32 %68, 1
store i32 %69, i32* %10
br label %41
70: ; preds = %48
%71 = load i32, i32* %11
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %117
73: ; preds = %70
%74 = load i32, i32* %10
%75 = icmp sgt i32 %74, 0
br i1 %75, label %76, label %117
76: ; preds = %73
store i64 0, i64* %14
store i32 4096, i32* %16
store i64 0, i64* %17
%77 = load i32*, i32** %7
%78 = load i32, i32* %10
%79 = load i32, i32* @SEEK_SET
%80 = call i32 @fseek(i32* %77, i32 %78, i32 %79)
br label %81
81: ; preds = %110, %76
%82 = load i32, i32* %16
%83 = icmp eq i32 %82, 4096
br i1 %83, label %84, label %111
84: ; preds = %81
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%86 = load i32*, i32** %7
%87 = call i32 @fread(i8* %85, i32 1, i32 4096, i32* %86)
store i32 %87, i32* %16
%88 = load i64, i64* %14
%89 = load i32, i32* %16
%90 = sext i32 %89 to i64
%91 = add i64 %88, %90
store i64 %91, i64* %14
%92 = load i32*, i32** %7
%93 = load i32, i32* %16
%94 = load i32, i32* %10
%95 = add nsw i32 %93, %94
%96 = mul nsw i32 -1, %95
%97 = load i32, i32* @SEEK_CUR
%98 = call i32 @fseek(i32* %92, i32 %96, i32 %97)
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%100 = load i32, i32* %16
%101 = load i32*, i32** %7
%102 = call i32 @fwrite(i8* %99, i32 1, i32 %100, i32* %101)
%103 = load i32, i32* %16
%104 = icmp eq i32 %103, 4096
br i1 %104, label %105, label %110
105: ; preds = %84
%106 = load i32*, i32** %7
%107 = load i32, i32* %10
%108 = load i32, i32* @SEEK_CUR
%109 = call i32 @fseek(i32* %106, i32 %107, i32 %108)
br label %110
110: ; preds = %105, %84
br label %81
111: ; preds = %81
%112 = load i32*, i32** %7
%113 = call i32 @fclose(i32* %112)
%114 = load i8*, i8** %6
%115 = load i64, i64* %14
%116 = call i32 @truncate(i8* %114, i64 %115)
br label %126
117: ; preds = %73, %70
%118 = load i32*, i32** %7
%119 = call i32 @fclose(i32* %118)
%120 = load i32, i32* %10
%121 = icmp sgt i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i32, i32* @stderr
%124 = call i32 @fprintf(i32 %123, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %125
125: ; preds = %122, %117
br label %126
126: ; preds = %125, %111
br label %127
127: ; preds = %126, %22
br label %128
128: ; preds = %127, %20
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [5 x i8] c"HDR0\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
@stderr = global i32 0
@.str.3 = [46 x i8] c"ERROR: Invalid bin/trx file, no header found\0A\00"
@str = [74 x i8] c"You must specify exactly one argument: the *.bin file to convert to *.trx\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca i8
%6 = alloca [4096 x i8]
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
br label %82
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %82, label %15
15: ; preds = %10
%16 = bitcast i32* %3 to i8*
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%18 = call i32 @fgetpos(i32* %13, i32* %3)
%19 = call i32 @fread(i8* %17, i32 1, i32 4, i32* %13)
%20 = icmp eq i32 %19, 4
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 4
store i8 0, i8* %21
br i1 %20, label %24, label %22
22: ; preds = %15
%23 = call i32 @fclose(i32* %13)
br label %81
24: ; preds = %15
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 2
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 3
%28 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %44, label %32
30: ; preds = %32
%31 = call i32 @fclose(i32* %13)
br i1 %20, label %78, label %81
32: ; preds = %24, %36
%33 = phi i32 [ %41, %36 ], [ 0, %24 ]
%34 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %13)
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %30
36: ; preds = %32
%37 = load i8, i8* %25
store i8 %37, i8* %17
%38 = load i8, i8* %26
store i8 %38, i8* %25
%39 = load i8, i8* %27
store i8 %39, i8* %26
%40 = load i8, i8* %5
store i8 %40, i8* %27
%41 = add nuw nsw i32 %33, 1
%42 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %32
44: ; preds = %36, %24
%45 = phi i32 [ 0, %24 ], [ %41, %36 ]
%46 = icmp eq i32 %45, 0
br i1 %46, label %76, label %47
47: ; preds = %44
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%49 = load i32, i32* @SEEK_SET
%50 = call i32 @fseek(i32* %13, i32 %45, i32 %49)
%51 = call i32 @fread(i8* %48, i32 1, i32 4096, i32* %13)
%52 = sext i32 %51 to i64
%53 = add nsw i32 %45, %51
%54 = sub nsw i32 0, %53
%55 = load i32, i32* @SEEK_CUR
%56 = call i32 @fseek(i32* %13, i32 %54, i32 %55)
%57 = call i32 @fwrite(i8* %48, i32 1, i32 %51, i32* %13)
%58 = icmp eq i32 %51, 4096
br i1 %58, label %59, label %72
59: ; preds = %47, %59
%60 = phi i64 [ %65, %59 ], [ %52, %47 ]
%61 = load i32, i32* @SEEK_CUR
%62 = call i32 @fseek(i32* %13, i32 %45, i32 %61)
%63 = call i32 @fread(i8* %48, i32 1, i32 4096, i32* %13)
%64 = sext i32 %63 to i64
%65 = add i64 %60, %64
%66 = add nsw i32 %45, %63
%67 = sub nsw i32 0, %66
%68 = load i32, i32* @SEEK_CUR
%69 = call i32 @fseek(i32* %13, i32 %67, i32 %68)
%70 = call i32 @fwrite(i8* %48, i32 1, i32 %63, i32* %13)
%71 = icmp eq i32 %63, 4096
br i1 %71, label %59, label %72
72: ; preds = %59, %47
%73 = phi i64 [ %52, %47 ], [ %65, %59 ]
%74 = call i32 @fclose(i32* %13)
%75 = call i32 @truncate(i8* %12, i64 %73)
br label %81
76: ; preds = %44
%77 = call i32 @fclose(i32* %13)
br label %81
78: ; preds = %30
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %22, %76, %30, %78, %72
br label %82
82: ; preds = %10, %81, %8
ret i32 0
}