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

/* Variables and functions */
int /*<<< orphan*/ _IONBF;
int fclose(int /*<<< orphan*/ *);
int ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
size_t fwrite(int *, int, int, int /*<<< orphan*/ *);
char *malloc(size_t);
scalar_t__ setvbuf(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr,
            "Usage: %s FileName1 [FileName2...]\n"
            "Extracts anything resembling wave (RIFF) files and all data "
            "stored after that from provided resource files,\n"
            "places extracted files in the same directory where input files "
            "are stored.\n"
            "Version r4\n",
            argv[0]);
    return -1;
  }
  static uint32_t riffMark =
      ((('R') & 0xff) << 0 * 8) | ((('I') & 0xff) << 1 * 8) |
      ((('F') & 0xff) << 2 * 8) | ((('F') & 0xff) << 3 * 8);
  for (size_t i = 1; i < (size_t)argc; ++i) {
    FILE *file = fopen(argv[i], "rb");
    if (file == NULL) {
      fprintf(stderr, "%s: Error opening file.\n", argv[i]);
      continue;
    }
    if (setvbuf(file, NULL, _IONBF, 0)) {
      fprintf(stderr, "%s: Error using file?!\n", argv[i]);
      fclose(file);
      continue;
    }
    uint8_t aborting = 0;
    static uint8_t readFile[4096 + 3];
    *(uint32_t *)readFile = ~riffMark;
    size_t outNameLength = strlen(argv[i]) + 5 + 16 + 1;
    char *outName = malloc(outNameLength);
    if (outName == NULL) {
      fprintf(stderr, "Error allocating memory?!\nAborting.\n");
      aborting = 1;
      goto cleanup;
    }
    size_t offset = -3;
    FILE *fileWriter = NULL;
    while (1) {
      size_t ioStatus = fread(readFile + 3, 1, 4096, file);
      uint8_t *writeFile = readFile, *inspectPointer = readFile,
              *inspectEnd = readFile + ioStatus;
      if (ioStatus == 0) {
        if (fileWriter) {
          fwrite(readFile, 3, 1, fileWriter);
        }
        if (ferror(file)) {
          fprintf(stderr, "%s: Error reading from a file.\n", argv[i]);
        }
        break;
      }
      for (; inspectPointer < inspectEnd; ++inspectPointer) {
        if (*(uint32_t *)inspectPointer == riffMark) {
          if (fileWriter) {
            ioStatus =
                fwrite(writeFile, inspectPointer - writeFile, 1, fileWriter);
            if ((ioStatus == 0) | (fclose(fileWriter) != 0)) {
              fprintf(stderr, "%s: Error writing to a file.\nAborting.\n",
                      outName);
              aborting = 1;
              goto cleanup;
            }
            fprintf(stdout, "%s\n", outName);
          }
          offset += inspectPointer - writeFile;
          snprintf(outName, outNameLength, "%s_%08lx.wav", argv[i], offset);
          writeFile = inspectPointer;
          fileWriter = fopen(outName, "wb");
          if (fileWriter == NULL) {
            fprintf(stderr, "%s: Error creating file.\nAborting.\n", outName);
            aborting = 1;
            goto cleanup;
          }
          inspectPointer += 3;
        }
      }
      if (fileWriter) {
        ioStatus = fwrite(writeFile, inspectPointer - writeFile, 1, fileWriter);
        if (ioStatus == 0) {
          break;
        }
      }
      offset += inspectPointer - writeFile;
      readFile[0] = inspectEnd[0], readFile[1] = inspectEnd[1],
      readFile[2] = inspectEnd[2];
    }
    if (fileWriter && (ferror(fileWriter) | fclose(fileWriter))) {
      fprintf(stderr, "%s: Error writing to a file.\nAborting.\n", outName);
      aborting = 1;
      goto cleanup;
    }
    fprintf(stdout, "%s\n", outName);
  cleanup:
    free(outName);
    fclose(file);
    if (aborting)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11fa <main+0x4a>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16ac <main+0x4fc>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    16a5 <main+0x4f5>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xec0(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1262 <main+0xb2>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1694 <main+0x4e4>
mov    -0x20(%rbp),%rdi
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10b0 <setvbuf@plt>
cmp    $0x0,%rax
je     12b5 <main+0x105>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
jmp    1694 <main+0x4e4>
movl   $0x0,-0x24(%rbp)
movsbl 0x2db5(%rip),%eax
xor    $0xffffffff,%eax
mov    %al,0x2dd4(%rip)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <strlen@plt>
add    $0x5,%eax
add    $0x10,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1327 <main+0x177>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1667 <main+0x4b7>
movq   $0xfffffffffffffffd,-0x40(%rbp)
ff
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rcx
lea    0x2d5e(%rip),%rdi
add    $0xc,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1050 <fread@plt>
mov    %rax,-0x50(%rbp)
lea    0x2d40(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0x2d35(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rcx
lea    0x2d26(%rip),%rax
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13ef <main+0x23f>
cmpq   $0x0,-0x48(%rbp)
je     13b5 <main+0x205>
mov    -0x48(%rbp),%rcx
lea    0x2cfa(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%eax
je     13ea <main+0x23a>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15f5 <main+0x445>
jmp    13f4 <main+0x244>
mov    -0x60(%rbp),%rax
cmp    -0x68(%rbp),%rax
jae    156c <main+0x3bc>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
movsbl 0x2c68(%rip),%ecx
cmp    %ecx,%eax
jne    1556 <main+0x3a6>
cmpq   $0x0,-0x48(%rbp)
je     14c1 <main+0x311>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,%esi
mov    -0x48(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <fclose@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    $0x0,%ecx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     14a6 <main+0x2f6>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1667 <main+0x4b7>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xccd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x40(%rbp),%r8
lea    0xc94(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xc89(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    154a <main+0x39a>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1667 <main+0x4b7>
mov    -0x60(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x60(%rbp)
jmp    155b <main+0x3ab>
mov    -0x60(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x60(%rbp)
jmp    13f4 <main+0x244>
cmpq   $0x0,-0x48(%rbp)
je     15b3 <main+0x403>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,%esi
mov    -0x48(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    15ae <main+0x3fe>
jmp    15f5 <main+0x445>
jmp    15b3 <main+0x403>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x2aca(%rip)
mov    -0x68(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,0x2ac1(%rip)
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,0x2ab8(%rip)
jmp    1337 <main+0x187>
cmpq   $0x0,-0x48(%rbp)
je     164c <main+0x49c>
mov    -0x48(%rbp),%rdi
call   1040 <ferror@plt>
mov    %eax,-0x70(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <fclose@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
or     %ecx,%eax
cmp    $0x0,%eax
je     164c <main+0x49c>
mov    0x29ac(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xb26(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1667 <main+0x4b7>
mov    0x297d(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xb27(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x24(%rbp)
je     168f <main+0x4df>
movl   $0x1,-0x4(%rbp)
jmp    16ac <main+0x4fc>
jmp    1694 <main+0x4e4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1202 <main+0x52>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jge    11ea <main+0x3a>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe27(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    15b5 <main+0x405>
mov    %edi,%r15d
mov    $0x1,%ebp
lea    0xeed(%rip),%r13
mov    0x2dd8(%rip),%r12
jmp    1233 <main+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edi
mov    (%rbx,%rbp,8),%rdx
lea    0xeca(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
add    $0x1,%rbp
cmp    %r15,%rbp
je     15c4 <main+0x414>
mov    (%rbx,%rbp,8),%rdi
mov    %r13,%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1210 <main+0x60>
mov    %rax,%r14
mov    0x2d9a(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
xor    %ecx,%ecx
call   10b0 <setvbuf@plt>
test   %rax,%rax
je     1290 <main+0xe0>
mov    (%r12),%edi
mov    (%rbx,%rbp,8),%rdx
lea    0xe92(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
jmp    1226 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0xad,0x2e09(%rip)
mov    (%rbx,%rbp,8),%rdi
call   1070 <strlen@plt>
add    $0x16,%eax
movslq %eax,%rdi
mov    %rdi,0x30(%rsp)
call   10a0 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     15c8 <main+0x418>
mov    %rbp,0x28(%rsp)
lea    0x2de2(%rip),%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
mov    $0x1,%bpl
test   %rax,%rax
je     14b0 <main+0x300>
mov    %r15,0x20(%rsp)
mov    %rbx,0x18(%rsp)
mov    $0xfffffffffffffffd,%r12
xor    %r13d,%r13d
mov    %r14,0x10(%rsp)
lea    0x2d98(%rip),%rbp
lea    0x0(,%rax,4),%r14
add    %rbp,%r14
test   %rax,%rax
mov    0x8(%rsp),%rbx
jle    1400 <main+0x250>
mov    %rbp,%rdi
jmp    1340 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%r15
add    $0x4,%rbp
cmp    %r14,%rbp
jae    1406 <main+0x256>
cmpb   $0x52,0x0(%rbp)
jne    1330 <main+0x180>
mov    %rbp,%r15
sub    %rdi,%r15
test   %r13,%r13
je     13a0 <main+0x1f0>
mov    %r15,%rsi
shr    $0x2,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1060 <fclose@plt>
test   %rbx,%rbx
je     157f <main+0x3cf>
test   %eax,%eax
jne    157f <main+0x3cf>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
sar    $0x2,%r15
add    %r12,%r15
mov    0x18(%rsp),%rax
mov    0x28(%rsp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    %rbx,%rdi
mov    0x30(%rsp),%rsi
lea    0xdc7(%rip),%rdx
mov    %r15,%r8
call   1080 <snprintf@plt>
mov    %rbx,%rdi
lea    0xdc2(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     156d <main+0x3bd>
mov    %rax,%r13
mov    %rbp,%rdi
add    $0xc,%rbp
mov    %r15,%r12
jmp    1333 <main+0x183>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%r15
mov    %rbp,%rdi
sub    %rdi,%rbp
test   %r13,%r13
je     142b <main+0x27b>
mov    %rbp,%rsi
shr    $0x2,%rsi
mov    $0x1,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
test   %rax,%rax
je     1539 <main+0x389>
sar    $0x2,%rbp
add    %r15,%rbp
mov    (%r14),%eax
mov    %eax,0x2c65(%rip)
mov    0x4(%r14),%eax
mov    %eax,0x2c5f(%rip)
mov    0x8(%r14),%eax
mov    %eax,0x2c59(%rip)
lea    0x2c56(%rip),%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    0x10(%rsp),%r14
mov    %r14,%rcx
call   1050 <fread@plt>
mov    %rbp,%r12
test   %rax,%rax
jne    1301 <main+0x151>
test   %r13,%r13
je     1551 <main+0x3a1>
lea    0x2c17(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
mov    0x18(%rsp),%rbx
mov    0x2b31(%rip),%r12
xor    %ebp,%ebp
mov    0x20(%rsp),%r15
jmp    14b3 <main+0x303>
xor    %r13d,%r13d
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %eax,%eax
je     14da <main+0x32a>
mov    (%r12),%edi
mov    0x28(%rsp),%rax
mov    (%rbx,%rax,8),%rdx
lea    0xc6c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
test   %bpl,%bpl
jne    14f9 <main+0x349>
mov    %r13,%rdi
call   1040 <ferror@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1060 <fclose@plt>
or     %ebp,%eax
jne    15dc <main+0x42c>
mov    0x2ad0(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x28(%rsp),%rbp
lea    0xbb2(%rip),%r13
jmp    1226 <main+0x76>
mov    0x10(%rsp),%r14
mov    0x18(%rsp),%rbx
mov    0x2a8e(%rip),%r12
mov    0x20(%rsp),%r15
jmp    14df <main+0x32f>
xor    %r13d,%r13d
mov    0x18(%rsp),%rbx
mov    0x2a78(%rip),%r12
mov    0x20(%rsp),%r15
mov    $0x1,%bpl
jmp    14b3 <main+0x303>
mov    0x2a64(%rip),%rax
mov    (%rax),%edi
lea    0xc1e(%rip),%rsi
jmp    1594 <main+0x3e4>
mov    0x2a52(%rip),%rax
mov    (%rax),%edi
lea    0xbd0(%rip),%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    15b5 <main+0x405>
mov    (%r12),%edi
lea    0xb47(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    15f3 <main+0x443>
mov    (%r12),%edi
lea    0xb78(%rip),%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
jmp    15ab <main+0x3fb>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [230 x i8] c"Usage: %s FileName1 [FileName2...]\0AExtracts anything resembling wave (RIFF) files and all data stored after that from provided resource files,\0Aplaces extracted files in the same directory where input files are stored.\0AVersion r4\0A\00"
@main.riffMark = internal global i8 82
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [25 x i8] c"%s: Error opening file.\0A\00"
@_IONBF = global i32 0
@.str.3 = [24 x i8] c"%s: Error using file?!\0A\00"
@main.readFile = internal global [4099 x i32] zeroinitializer
@.str.4 = [37 x i8] c"Error allocating memory?!\0AAborting.\0A\00"
@.str.5 = [32 x i8] c"%s: Error reading from a file.\0A\00"
@.str.6 = [40 x i8] c"%s: Error writing to a file.\0AAborting.\0A\00"
@stdout = global i32 0
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [13 x i8] c"%s_%08lx.wav\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [36 x i8] c"%s: Error creating file.\0AAborting.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32*
%13 = alloca i64
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([230 x i8], [230 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 -1, i32* %3
br label %251
25: ; preds = %2
store i64 1, i64* %6
br label %26
26: ; preds = %247, %25
%27 = load i64, i64* %6
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = icmp ult i64 %27, %29
br i1 %30, label %31, label %250
31: ; preds = %26
%32 = load i8**, i8*** %5
%33 = load i64, i64* %6
%34 = getelementptr inbounds i8*, i8** %32, i64 %33
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %7
%37 = load i32*, i32** %7
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %46
39: ; preds = %31
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = load i64, i64* %6
%43 = getelementptr inbounds i8*, i8** %41, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %247
46: ; preds = %31
%47 = load i32*, i32** %7
%48 = load i32, i32* @_IONBF
%49 = call i64 @setvbuf(i32* %47, i32* null, i32 %48, i32 0)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %46
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = load i64, i64* %6
%55 = getelementptr inbounds i8*, i8** %53, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = load i32*, i32** %7
%59 = call i32 @fclose(i32* %58)
br label %247
60: ; preds = %46
store i32 0, i32* %8
%61 = load i8, i8* @main.riffMark
%62 = sext i8 %61 to i32
%63 = xor i32 %62, -1
%64 = trunc i32 %63 to i8
store i8 %64, i8* bitcast ([4099 x i32]* @main.readFile to i8*)
%65 = load i8**, i8*** %5
%66 = load i64, i64* %6
%67 = getelementptr inbounds i8*, i8** %65, i64 %66
%68 = load i8*, i8** %67
%69 = call i32 @strlen(i8* %68)
%70 = add nsw i32 %69, 5
%71 = add nsw i32 %70, 16
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
store i64 %73, i64* %9
%74 = load i64, i64* %9
%75 = call i8* @malloc(i64 %74)
store i8* %75, i8** %10
%76 = load i8*, i8** %10
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %81
78: ; preds = %60
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %8
br label %238
81: ; preds = %60
store i64 -3, i64* %11
store i32* null, i32** %12
br label %82
82: ; preds = %81, %202
%83 = load i32*, i32** %7
%84 = call i64 @fread(i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 3), i32 1, i32 4096, i32* %83)
store i64 %84, i64* %13
store i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), i32** %14
store i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), i32** %15
%85 = load i64, i64* %13
%86 = getelementptr inbounds i32, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), i64 %85
store i32* %86, i32** %16
%87 = load i64, i64* %13
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %107
89: ; preds = %82
%90 = load i32*, i32** %12
%91 = icmp ne i32* %90, null
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i32*, i32** %12
%94 = call i64 @fwrite(i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), i32 3, i32 1, i32* %93)
br label %95
95: ; preds = %92, %89
%96 = load i32*, i32** %7
%97 = call i32 @ferror(i32* %96)
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %106
99: ; preds = %95
%100 = load i32, i32* @stderr
%101 = load i8**, i8*** %5
%102 = load i64, i64* %6
%103 = getelementptr inbounds i8*, i8** %101, i64 %102
%104 = load i8*, i8** %103
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %104)
br label %106
106: ; preds = %99, %95
br label %220
107: ; preds = %82
br label %108
108: ; preds = %181, %107
%109 = load i32*, i32** %15
%110 = load i32*, i32** %16
%111 = icmp ult i32* %109, %110
br i1 %111, label %112, label %184
112: ; preds = %108
%113 = load i32*, i32** %15
%114 = bitcast i32* %113 to i8*
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = load i8, i8* @main.riffMark
%118 = sext i8 %117 to i32
%119 = icmp eq i32 %116, %118
br i1 %119, label %120, label %180
120: ; preds = %112
%121 = load i32*, i32** %12
%122 = icmp ne i32* %121, null
br i1 %122, label %123, label %151
123: ; preds = %120
%124 = load i32*, i32** %14
%125 = load i32*, i32** %15
%126 = load i32*, i32** %14
%127 = ptrtoint i32* %125 to i64
%128 = ptrtoint i32* %126 to i64
%129 = sub i64 %127, %128
%130 = sdiv exact i64 %129, 4
%131 = trunc i64 %130 to i32
%132 = load i32*, i32** %12
%133 = call i64 @fwrite(i32* %124, i32 %131, i32 1, i32* %132)
store i64 %133, i64* %13
%134 = load i64, i64* %13
%135 = icmp eq i64 %134, 0
%136 = zext i1 %135 to i32
%137 = load i32*, i32** %12
%138 = call i32 @fclose(i32* %137)
%139 = icmp ne i32 %138, 0
%140 = zext i1 %139 to i32
%141 = or i32 %136, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %147
143: ; preds = %123
%144 = load i32, i32* @stderr
%145 = load i8*, i8** %10
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %145)
store i32 1, i32* %8
br label %238
147: ; preds = %123
%148 = load i32, i32* @stdout
%149 = load i8*, i8** %10
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %149)
br label %151
151: ; preds = %147, %120
%152 = load i32*, i32** %15
%153 = load i32*, i32** %14
%154 = ptrtoint i32* %152 to i64
%155 = ptrtoint i32* %153 to i64
%156 = sub i64 %154, %155
%157 = sdiv exact i64 %156, 4
%158 = load i64, i64* %11
%159 = add i64 %158, %157
store i64 %159, i64* %11
%160 = load i8*, i8** %10
%161 = load i64, i64* %9
%162 = load i8**, i8*** %5
%163 = load i64, i64* %6
%164 = getelementptr inbounds i8*, i8** %162, i64 %163
%165 = load i8*, i8** %164
%166 = load i64, i64* %11
%167 = call i32 @snprintf(i8* %160, i64 %161, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %165, i64 %166)
%168 = load i32*, i32** %15
store i32* %168, i32** %14
%169 = load i8*, i8** %10
%170 = call i32* @fopen(i8* %169, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %170, i32** %12
%171 = load i32*, i32** %12
%172 = icmp eq i32* %171, null
br i1 %172, label %173, label %177
173: ; preds = %151
%174 = load i32, i32* @stderr
%175 = load i8*, i8** %10
%176 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i8* %175)
store i32 1, i32* %8
br label %238
177: ; preds = %151
%178 = load i32*, i32** %15
%179 = getelementptr inbounds i32, i32* %178, i64 3
store i32* %179, i32** %15
br label %180
180: ; preds = %177, %112
br label %181
181: ; preds = %180
%182 = load i32*, i32** %15
%183 = getelementptr inbounds i32, i32* %182, i32 1
store i32* %183, i32** %15
br label %108
184: ; preds = %108
%185 = load i32*, i32** %12
%186 = icmp ne i32* %185, null
br i1 %186, label %187, label %202
187: ; preds = %184
%188 = load i32*, i32** %14
%189 = load i32*, i32** %15
%190 = load i32*, i32** %14
%191 = ptrtoint i32* %189 to i64
%192 = ptrtoint i32* %190 to i64
%193 = sub i64 %191, %192
%194 = sdiv exact i64 %193, 4
%195 = trunc i64 %194 to i32
%196 = load i32*, i32** %12
%197 = call i64 @fwrite(i32* %188, i32 %195, i32 1, i32* %196)
store i64 %197, i64* %13
%198 = load i64, i64* %13
%199 = icmp eq i64 %198, 0
br i1 %199, label %200, label %201
200: ; preds = %187
br label %220
201: ; preds = %187
br label %202
202: ; preds = %201, %184
%203 = load i32*, i32** %15
%204 = load i32*, i32** %14
%205 = ptrtoint i32* %203 to i64
%206 = ptrtoint i32* %204 to i64
%207 = sub i64 %205, %206
%208 = sdiv exact i64 %207, 4
%209 = load i64, i64* %11
%210 = add i64 %209, %208
store i64 %210, i64* %11
%211 = load i32*, i32** %16
%212 = getelementptr inbounds i32, i32* %211, i64 0
%213 = load i32, i32* %212
store i32 %213, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0)
%214 = load i32*, i32** %16
%215 = getelementptr inbounds i32, i32* %214, i64 1
%216 = load i32, i32* %215
store i32 %216, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 1)
%217 = load i32*, i32** %16
%218 = getelementptr inbounds i32, i32* %217, i64 2
%219 = load i32, i32* %218
store i32 %219, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 2)
br label %82
220: ; preds = %200, %106
%221 = load i32*, i32** %12
%222 = icmp ne i32* %221, null
br i1 %222, label %223, label %234
223: ; preds = %220
%224 = load i32*, i32** %12
%225 = call i32 @ferror(i32* %224)
%226 = load i32*, i32** %12
%227 = call i32 @fclose(i32* %226)
%228 = or i32 %225, %227
%229 = icmp ne i32 %228, 0
br i1 %229, label %230, label %234
230: ; preds = %223
%231 = load i32, i32* @stderr
%232 = load i8*, i8** %10
%233 = call i32 (i32, i8*, ...) @fprintf(i32 %231, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %232)
store i32 1, i32* %8
br label %238
234: ; preds = %223, %220
%235 = load i32, i32* @stdout
%236 = load i8*, i8** %10
%237 = call i32 (i32, i8*, ...) @fprintf(i32 %235, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %236)
br label %238
238: ; preds = %234, %230, %173, %143, %78
%239 = load i8*, i8** %10
%240 = call i32 @free(i8* %239)
%241 = load i32*, i32** %7
%242 = call i32 @fclose(i32* %241)
%243 = load i32, i32* %8
%244 = icmp ne i32 %243, 0
br i1 %244, label %245, label %246
245: ; preds = %238
store i32 1, i32* %3
br label %251
246: ; preds = %238
br label %247
247: ; preds = %246, %51, %39
%248 = load i64, i64* %6
%249 = add i64 %248, 1
store i64 %249, i64* %6
br label %26
250: ; preds = %26
store i32 0, i32* %3
br label %251
251: ; preds = %250, %245, %19
%252 = load i32, i32* %3
ret i32 %252
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [230 x i8] c"Usage: %s FileName1 [FileName2...]\0AExtracts anything resembling wave (RIFF) files and all data stored after that from provided resource files,\0Aplaces extracted files in the same directory where input files are stored.\0AVersion r4\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [25 x i8] c"%s: Error opening file.\0A\00"
@_IONBF = global i32 0
@.str.3 = [24 x i8] c"%s: Error using file?!\0A\00"
@main.readFile = internal global [4099 x i32] zeroinitializer
@.str.4 = [37 x i8] c"Error allocating memory?!\0AAborting.\0A\00"
@.str.5 = [32 x i8] c"%s: Error reading from a file.\0A\00"
@.str.6 = [40 x i8] c"%s: Error writing to a file.\0AAborting.\0A\00"
@stdout = global i32 0
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [13 x i8] c"%s_%08lx.wav\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [36 x i8] c"%s: Error creating file.\0AAborting.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([230 x i8], [230 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %156
10: ; preds = %4, %153
%11 = phi i64 [ %154, %153 ], [ 1, %4 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %153
20: ; preds = %10
%21 = load i32, i32* @_IONBF
%22 = tail call i64 @setvbuf(i32* %14, i32* null, i32 %21, i32 0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %12
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = tail call i32 @fclose(i32* %14)
br label %153
29: ; preds = %20
store i8 -83, i8* bitcast ([4099 x i32]* @main.readFile to i8*)
%30 = load i8*, i8** %12
%31 = tail call i32 @strlen(i8* %30)
%32 = add nsw i32 %31, 22
%33 = sext i32 %32 to i64
%34 = tail call i8* @malloc(i64 %33)
%35 = icmp eq i8* %34, null
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = tail call i64 @fread(i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 3), i32 1, i32 4096, i32* %14)
%38 = icmp eq i64 %37, 0
br i1 %38, label %52, label %42
39: ; preds = %29
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %150
42: ; preds = %36, %125
%43 = phi i64 [ %133, %125 ], [ %37, %36 ]
%44 = phi i32* [ %113, %125 ], [ null, %36 ]
%45 = phi i64 [ %127, %125 ], [ -3, %36 ]
%46 = getelementptr inbounds [4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 %43
%47 = icmp sgt i64 %43, 0
br i1 %47, label %61, label %111
48: ; preds = %125
%49 = icmp eq i32* %113, null
br i1 %49, label %52, label %50
50: ; preds = %48
%51 = tail call i64 @fwrite(i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), i32 3, i32 1, i32* %113)
br label %52
52: ; preds = %36, %50, %48
%53 = phi i1 [ false, %50 ], [ true, %48 ], [ true, %36 ]
%54 = phi i32* [ %113, %50 ], [ null, %48 ], [ null, %36 ]
%55 = tail call i32 @ferror(i32* %14)
%56 = icmp eq i32 %55, 0
br i1 %56, label %135, label %57
57: ; preds = %52
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %12
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %59)
br label %135
61: ; preds = %42, %104
%62 = phi i32* [ %109, %104 ], [ getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), %42 ]
%63 = phi i32* [ %107, %104 ], [ getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), %42 ]
%64 = phi i32* [ %106, %104 ], [ %44, %42 ]
%65 = phi i64 [ %105, %104 ], [ %45, %42 ]
%66 = bitcast i32* %62 to i8*
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 82
br i1 %68, label %69, label %104
69: ; preds = %61
%70 = icmp eq i32* %64, null
%71 = ptrtoint i32* %62 to i64
%72 = ptrtoint i32* %63 to i64
%73 = sub i64 %71, %72
br i1 %70, label %90, label %74
74: ; preds = %69
%75 = lshr exact i64 %73, 2
%76 = trunc i64 %75 to i32
%77 = tail call i64 @fwrite(i32* %63, i32 %76, i32 1, i32* %64)
%78 = icmp eq i64 %77, 0
%79 = tail call i32 @fclose(i32* %64)
%80 = icmp ne i32 %79, 0
%81 = or i1 %78, %80
br i1 %81, label %82, label %87
82: ; preds = %74
%83 = load i32, i32* @stderr
%84 = tail call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%85 = tail call i32 @free(i8* %34)
%86 = tail call i32 @fclose(i32* %14)
br label %156
87: ; preds = %74
%88 = load i32, i32* @stdout
%89 = tail call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %34)
br label %90
90: ; preds = %69, %87
%91 = ashr exact i64 %73, 2
%92 = add i64 %91, %65
%93 = load i8*, i8** %12
%94 = tail call i32 @snprintf(i8* %34, i64 %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %93, i64 %92)
%95 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%96 = icmp eq i32* %95, null
br i1 %96, label %97, label %102
97: ; preds = %90
%98 = load i32, i32* @stderr
%99 = tail call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0), i8* %34)
%100 = tail call i32 @free(i8* %34)
%101 = tail call i32 @fclose(i32* %14)
br label %156
102: ; preds = %90
%103 = getelementptr inbounds i32, i32* %62, i64 3
br label %104
104: ; preds = %61, %102
%105 = phi i64 [ %92, %102 ], [ %65, %61 ]
%106 = phi i32* [ %95, %102 ], [ %64, %61 ]
%107 = phi i32* [ %62, %102 ], [ %63, %61 ]
%108 = phi i32* [ %103, %102 ], [ %62, %61 ]
%109 = getelementptr inbounds i32, i32* %108, i64 1
%110 = icmp ult i32* %109, %46
br i1 %110, label %61, label %111
111: ; preds = %104, %42
%112 = phi i64 [ %45, %42 ], [ %105, %104 ]
%113 = phi i32* [ %44, %42 ], [ %106, %104 ]
%114 = phi i32* [ getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), %42 ], [ %107, %104 ]
%115 = phi i32* [ getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0), %42 ], [ %109, %104 ]
%116 = icmp eq i32* %113, null
%117 = ptrtoint i32* %115 to i64
%118 = ptrtoint i32* %114 to i64
%119 = sub i64 %117, %118
br i1 %116, label %125, label %120
120: ; preds = %111
%121 = lshr exact i64 %119, 2
%122 = trunc i64 %121 to i32
%123 = tail call i64 @fwrite(i32* %114, i32 %122, i32 1, i32* %113)
%124 = icmp eq i64 %123, 0
br i1 %124, label %136, label %125
125: ; preds = %111, %120
%126 = ashr exact i64 %119, 2
%127 = add i64 %126, %112
%128 = load i32, i32* %46
store i32 %128, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 0)
%129 = getelementptr inbounds i32, i32* %46, i64 1
%130 = load i32, i32* %129
store i32 %130, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 1)
%131 = getelementptr inbounds i32, i32* %46, i64 2
%132 = load i32, i32* %131
store i32 %132, i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 2)
%133 = tail call i64 @fread(i32* getelementptr inbounds ([4099 x i32], [4099 x i32]* @main.readFile, i64 0, i64 3), i32 1, i32 4096, i32* %14)
%134 = icmp eq i64 %133, 0
br i1 %134, label %48, label %42
135: ; preds = %57, %52
br i1 %53, label %145, label %136
136: ; preds = %120, %135
%137 = phi i32* [ %54, %135 ], [ %113, %120 ]
%138 = tail call i32 @ferror(i32* %137)
%139 = tail call i32 @fclose(i32* %137)
%140 = or i32 %139, %138
%141 = icmp eq i32 %140, 0
br i1 %141, label %145, label %142
142: ; preds = %136
%143 = load i32, i32* @stderr
%144 = tail call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %34)
br label %150
145: ; preds = %136, %135
%146 = load i32, i32* @stdout
%147 = tail call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %34)
%148 = tail call i32 @free(i8* %34)
%149 = tail call i32 @fclose(i32* %14)
br label %153
150: ; preds = %142, %39
%151 = tail call i32 @free(i8* %34)
%152 = tail call i32 @fclose(i32* %14)
br label %156
153: ; preds = %145, %16, %24
%154 = add nuw i64 %11, 1
%155 = icmp eq i64 %154, %5
br i1 %155, label %156, label %10
156: ; preds = %153, %97, %82, %150, %6
%157 = phi i32 [ -1, %6 ], [ 1, %150 ], [ 1, %97 ], [ 1, %82 ], [ 0, %153 ]
ret i32 %157
}