#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*/ FILE;

/* Variables and functions */
size_t atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  size_t payloadChunkSize = 0, extraChunkSize = 0;
  size_t bytes;
  char *filearg;
  char *filename;
  char *buffer;
  FILE *nb, *payload, *extra;
  printf("NBSplit 2.1rc2\n");
  if (argc < 3) {
    printf("Usage: %s -hermes|-kaiser|-titan|-wizard|-athena|-sp\n"
           "|-data <number> -extra <number> <filename.nb>\n"
           "Generates <filename.nb.payload> and <filename.nb.extra> from "
           "<filename.nb>\n"
           "<filename.nb> will NOT get overwritten.\n",
           argv[0]);
    return 1;
  }
  if (!strcmp(argv[1], "-wizard") || !strcmp(argv[1], "-athena")) {
    printf("Wizard and Athena ROMs do not contain extra bytes.\n"
           "You need not run %s. Just copy <filename.nb> to "
           "<filename.nb.payload>\n",
           argv[0]);
    return 0;
  }
  if (argc > 5 && !strcmp(argv[1], "-data") && !strcmp(argv[3], "-extra")) {
    payloadChunkSize = atoi(argv[2]);
    extraChunkSize = atoi(argv[4]);
  }
  if (!strcmp(argv[1], "-hermes") || !strcmp(argv[1], "-sp")) {
    payloadChunkSize = 0x200;
    extraChunkSize = 0x08;
  }
  if (!strcmp(argv[1], "-titan") || !strcmp(argv[1], "-kaiser")) {
    payloadChunkSize = 0x800;
    extraChunkSize = 0x08;
  }
  if (payloadChunkSize == 0) {
    printf("Wrong or missing parameters.\n");
    printf("Usage: %s -hermes|-kaiser|-titan|-acer|-wizard|-athena|-sp\n"
           "|-data <number> -extra <number> <filename.nb>\n"
           "Generates <filename.nb.payload> and <filename.nb.extra> from "
           "<filename.nb>\n"
           "<filename.nb> will NOT get overwritten.\n",
           argv[0]);
    return 1;
  }
  filearg = argv[argc - 1];
  filename =
      (char *)malloc(strlen(filearg) + strlen(".payload") + strlen(".extra"));
  if (!filename) {
    printf("Error allocating memory\n");
    return 1;
  }
  if (NULL == (nb = fopen(filearg, "rb"))) {
    printf("Could not open input file %s\n", filearg);
    free(filename);
    return 1;
  }
  sprintf(filename, "%s%s", filearg, ".payload");
  if (NULL == (payload = fopen(filename, "w+b"))) {
    printf("Could not open output file %s\n", filename);
    free(filename);
    fclose(nb);
    return 1;
  }
  sprintf(filename, "%s%s", filearg, ".extra");
  if (NULL == (extra = fopen(filename, "w+b"))) {
    printf("Could not open output file %s\n", filename);
    free(filename);
    fclose(payload);
    fclose(nb);
    return 1;
  }
  free(filename);
  printf("Using data chunk size = 0x%x and extra chunk size = 0x%x\n"
         "on file %s\n",
         payloadChunkSize, extraChunkSize, filearg);
  buffer = (char *)malloc(payloadChunkSize + extraChunkSize);
  do {
    bytes = fread(buffer, 1, payloadChunkSize, nb);
    if (bytes != fwrite(buffer, 1, bytes, payload)) {
      printf("Error writing to payload file. Generated files are unusable!\n");
      free(buffer);
      fclose(nb);
      fclose(payload);
      fclose(extra);
      return 1;
    }
    if (bytes != payloadChunkSize)
      break;
    bytes = fread(buffer, 1, extraChunkSize, nb);
    if (bytes != fwrite(buffer, 1, bytes, extra)) {
      printf("Error writing to extra file. Generated files are unusable!\n");
      free(buffer);
      fclose(nb);
      fclose(payload);
      fclose(extra);
      return 1;
    }
    if (bytes != extraChunkSize)
      break;
  } while (1);
  free(buffer);
  fclose(nb);
  fclose(payload);
  fclose(extra);
  printf("Done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jge    1212 <main+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xec6(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     124c <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb1(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    126d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16fd <main+0x54d>
cmpl   $0x5,-0x8(%rbp)
jle    12d3 <main+0x123>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeeb(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12d3 <main+0x123>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xed4(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12d3 <main+0x123>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10b0 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     130d <main+0x15d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    131d <main+0x16d>
movq   $0x200,-0x18(%rbp)
movq   $0x8,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     1357 <main+0x1a7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe48(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1367 <main+0x1b7>
movq   $0x800,-0x18(%rbp)
movq   $0x8,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13a1 <main+0x1f1>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x68(%rbp)
lea    0xeca(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
lea    0xeb9(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
add    %rax,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    141e <main+0x26e>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x30(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x48(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1467 <main+0x2b7>
mov    -0x30(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe68(%rip),%rsi
lea    0xe17(%rip),%rcx
call   10c0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x50(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    14d4 <main+0x324>
mov    -0x38(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xdfb(%rip),%rsi
lea    0xdb3(%rip),%rcx
call   10c0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x58(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    154a <main+0x39a>
mov    -0x38(%rbp),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
add    -0x20(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
cmp    %rcx,%rax
je     1604 <main+0x454>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1617 <main+0x467>
jmp    16c4 <main+0x514>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
je     169d <main+0x4ed>
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    16fd <main+0x54d>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     16b0 <main+0x500>
jmp    16c4 <main+0x514>
jmp    16b5 <main+0x505>
mov    $0x1,%al
test   $0x1,%al
jne    157e <main+0x3ce>
jmp    16c4 <main+0x514>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    %edi,%ebx
lea    0x112a(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%ebx
jg     1200 <main+0x40>
mov    (%r12),%rsi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%ebx
jmp    1476 <main+0x2b6>
mov    0x8(%r12),%r13
lea    0xecb(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1462 <main+0x2a2>
lea    0xebc(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1462 <main+0x2a2>
cmp    $0x6,%ebx
jb     1264 <main+0xa4>
lea    0xf22(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    1264 <main+0xa4>
mov    0x18(%r12),%rdi
lea    0xf10(%rip),%rsi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1517 <main+0x357>
xor    %ebp,%ebp
xor    %r14d,%r14d
lea    0xefe(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     128f <main+0xcf>
lea    0xef3(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
jne    129a <main+0xda>
mov    $0x200,%r14d
mov    $0x8,%ebp
lea    0xed9(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
mov    $0x8,%ecx
mov    %rcx,0x10(%rsp)
mov    $0x800,%r15d
test   %eax,%eax
je     12e1 <main+0x121>
lea    0xebd(%rip),%rsi
mov    %r13,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     12e1 <main+0x121>
mov    %r14,%r15
mov    %rbp,0x10(%rsp)
test   %r14,%r14
je     14ba <main+0x2fa>
add    $0xffffffff,%ebx
mov    (%r12,%rbx,8),%r13
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0xe(%rax),%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1487 <main+0x2c7>
mov    %rax,%rbp
lea    0xf6a(%rip),%rsi
mov    %r13,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     149a <main+0x2da>
mov    %rax,%r14
lea    0xf70(%rip),%rsi
lea    0xf38(%rip),%rcx
mov    %rbp,%rdi
mov    %r13,%rdx
call   10d0 <sprintf@plt>
lea    0xf5c(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14d6 <main+0x316>
mov    %rax,%r12
lea    0xf3c(%rip),%rsi
lea    0xf0d(%rip),%rcx
mov    %rbp,%rdi
mov    %r13,%rdx
call   10d0 <sprintf@plt>
lea    0xf28(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     14f1 <main+0x331>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xf26(%rip),%rdi
mov    %r15,%rsi
mov    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    %rdx,%r13
xor    %eax,%eax
call   1080 <printf@plt>
lea    (%r15,%r13,1),%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <fread@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
cmp    %rax,%rbx
jne    1536 <main+0x376>
cmp    %r15,%rbx
jne    1430 <main+0x270>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
mov    %r14,%rcx
call   1050 <fread@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    0x8(%rsp),%rcx
call   10e0 <fwrite@plt>
cmp    %rax,%rbx
jne    153f <main+0x37f>
cmp    %r13,%rbx
je     13c0 <main+0x200>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    1476 <main+0x2b6>
mov    (%r12),%rsi
lea    0xc7a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    1476 <main+0x2b6>
lea    0xdd8(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x1,%ebx
jmp    1476 <main+0x2b6>
lea    0xee8(%rip),%rdi
call   1040 <puts@plt>
mov    (%r12),%rsi
lea    0xcb8(%rip),%rdi
jmp    11ef <main+0x2f>
lea    0xdc3(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    1512 <main+0x352>
lea    0xda8(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
jmp    1568 <main+0x3a8>
mov    0x10(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%r14
mov    0x20(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%rbp
jmp    1269 <main+0xa9>
lea    0xe2f(%rip),%rdi
jmp    1546 <main+0x386>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    $0x1,%ebx
jmp    1476 <main+0x2b6>

LLVM IR (-O0):
@.str = [16 x i8] c"NBSplit 2.1rc2\0A\00"
@.str.1 = [215 x i8] c"Usage: %s -hermes|-kaiser|-titan|-wizard|-athena|-sp\0A|-data <number> -extra <number> <filename.nb>\0AGenerates <filename.nb.payload> and <filename.nb.extra> from <filename.nb>\0A<filename.nb> will NOT get overwritten.\0A\00"
@.str.2 = [8 x i8] c"-wizard\00"
@.str.3 = [8 x i8] c"-athena\00"
@.str.4 = [122 x i8] c"Wizard and Athena ROMs do not contain extra bytes.\0AYou need not run %s. Just copy <filename.nb> to <filename.nb.payload>\0A\00"
@.str.5 = [6 x i8] c"-data\00"
@.str.6 = [7 x i8] c"-extra\00"
@.str.7 = [8 x i8] c"-hermes\00"
@.str.8 = [4 x i8] c"-sp\00"
@.str.9 = [7 x i8] c"-titan\00"
@.str.10 = [8 x i8] c"-kaiser\00"
@.str.11 = [30 x i8] c"Wrong or missing parameters.\0A\00"
@.str.12 = [221 x i8] c"Usage: %s -hermes|-kaiser|-titan|-acer|-wizard|-athena|-sp\0A|-data <number> -extra <number> <filename.nb>\0AGenerates <filename.nb.payload> and <filename.nb.extra> from <filename.nb>\0A<filename.nb> will NOT get overwritten.\0A\00"
@.str.13 = [9 x i8] c".payload\00"
@.str.14 = [7 x i8] c".extra\00"
@.str.15 = [25 x i8] c"Error allocating memory\0A\00"
@.str.16 = [3 x i8] c"rb\00"
@.str.17 = [30 x i8] c"Could not open input file %s\0A\00"
@.str.18 = [5 x i8] c"%s%s\00"
@.str.19 = [4 x i8] c"w+b\00"
@.str.20 = [31 x i8] c"Could not open output file %s\0A\00"
@.str.21 = [69 x i8] c"Using data chunk size = 0x%x and extra chunk size = 0x%x\0Aon file %s\0A\00"
@.str.22 = [62 x i8] c"Error writing to payload file. Generated files are unusable!\0A\00"
@.str.23 = [60 x i8] c"Error writing to extra file. Generated files are unusable!\0A\00"
@.str.24 = [7 x i8] c"Done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 0, i64* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([215 x i8], [215 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %233
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %29, %23
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str.4, i64 0, i64 0), i8* %38)
store i32 0, i32* %3
br label %233
40: ; preds = %29
%41 = load i32, i32* %4
%42 = icmp sgt i32 %41, 5
br i1 %42, label %43, label %64
43: ; preds = %40
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %64, label %49
49: ; preds = %43
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 @strcmp(i8* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp ne i32 %53, 0
br i1 %54, label %64, label %55
55: ; preds = %49
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
%59 = call i64 @atoi(i8* %58)
store i64 %59, i64* %6
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 4
%62 = load i8*, i8** %61
%63 = call i64 @atoi(i8* %62)
store i64 %63, i64* %7
br label %64
64: ; preds = %55, %49, %43, %40
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %64
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i32 @strcmp(i8* %73, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %77, label %76
76: ; preds = %70, %64
store i64 512, i64* %6
store i64 8, i64* %7
br label %77
77: ; preds = %76, %70
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i32 @strcmp(i8* %80, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %77
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 1
%86 = load i8*, i8** %85
%87 = call i32 @strcmp(i8* %86, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%88 = icmp ne i32 %87, 0
br i1 %88, label %90, label %89
89: ; preds = %83, %77
store i64 2048, i64* %6
store i64 8, i64* %7
br label %90
90: ; preds = %89, %83
%91 = load i64, i64* %6
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %99
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 0
%97 = load i8*, i8** %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([221 x i8], [221 x i8]* @.str.12, i64 0, i64 0), i8* %97)
store i32 1, i32* %3
br label %233
99: ; preds = %90
%100 = load i8**, i8*** %5
%101 = load i32, i32* %4
%102 = sub nsw i32 %101, 1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8*, i8** %100, i64 %103
%105 = load i8*, i8** %104
store i8* %105, i8** %9
%106 = load i8*, i8** %9
%107 = call i64 @strlen(i8* %106)
%108 = call i64 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
%109 = add i64 %107, %108
%110 = call i64 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%111 = add i64 %109, %110
%112 = call i64 @malloc(i64 %111)
%113 = inttoptr i64 %112 to i8*
store i8* %113, i8** %10
%114 = load i8*, i8** %10
%115 = icmp ne i8* %114, null
br i1 %115, label %118, label %116
116: ; preds = %99
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %3
br label %233
118: ; preds = %99
%119 = load i8*, i8** %9
%120 = call i32* @fopen(i8* %119, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
store i32* %120, i32** %12
%121 = icmp eq i32* null, %120
br i1 %121, label %122, label %127
122: ; preds = %118
%123 = load i8*, i8** %9
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.17, i64 0, i64 0), i8* %123)
%125 = load i8*, i8** %10
%126 = call i32 @free(i8* %125)
store i32 1, i32* %3
br label %233
127: ; preds = %118
%128 = load i8*, i8** %10
%129 = load i8*, i8** %9
%130 = call i32 @sprintf(i8* %128, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i8* %129, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
%131 = load i8*, i8** %10
%132 = call i32* @fopen(i8* %131, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
store i32* %132, i32** %13
%133 = icmp eq i32* null, %132
br i1 %133, label %134, label %141
134: ; preds = %127
%135 = load i8*, i8** %10
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* %135)
%137 = load i8*, i8** %10
%138 = call i32 @free(i8* %137)
%139 = load i32*, i32** %12
%140 = call i32 @fclose(i32* %139)
store i32 1, i32* %3
br label %233
141: ; preds = %127
%142 = load i8*, i8** %10
%143 = load i8*, i8** %9
%144 = call i32 @sprintf(i8* %142, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i8* %143, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%145 = load i8*, i8** %10
%146 = call i32* @fopen(i8* %145, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
store i32* %146, i32** %14
%147 = icmp eq i32* null, %146
br i1 %147, label %148, label %157
148: ; preds = %141
%149 = load i8*, i8** %10
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* %149)
%151 = load i8*, i8** %10
%152 = call i32 @free(i8* %151)
%153 = load i32*, i32** %13
%154 = call i32 @fclose(i32* %153)
%155 = load i32*, i32** %12
%156 = call i32 @fclose(i32* %155)
store i32 1, i32* %3
br label %233
157: ; preds = %141
%158 = load i8*, i8** %10
%159 = call i32 @free(i8* %158)
%160 = load i64, i64* %6
%161 = load i64, i64* %7
%162 = load i8*, i8** %9
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.21, i64 0, i64 0), i64 %160, i64 %161, i8* %162)
%164 = load i64, i64* %6
%165 = load i64, i64* %7
%166 = add i64 %164, %165
%167 = call i64 @malloc(i64 %166)
%168 = inttoptr i64 %167 to i8*
store i8* %168, i8** %11
br label %169
169: ; preds = %222, %157
%170 = load i8*, i8** %11
%171 = load i64, i64* %6
%172 = load i32*, i32** %12
%173 = call i64 @fread(i8* %170, i32 1, i64 %171, i32* %172)
store i64 %173, i64* %8
%174 = load i64, i64* %8
%175 = load i8*, i8** %11
%176 = load i64, i64* %8
%177 = load i32*, i32** %13
%178 = call i64 @fwrite(i8* %175, i32 1, i64 %176, i32* %177)
%179 = icmp ne i64 %174, %178
br i1 %179, label %180, label %190
180: ; preds = %169
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.22, i64 0, i64 0))
%182 = load i8*, i8** %11
%183 = call i32 @free(i8* %182)
%184 = load i32*, i32** %12
%185 = call i32 @fclose(i32* %184)
%186 = load i32*, i32** %13
%187 = call i32 @fclose(i32* %186)
%188 = load i32*, i32** %14
%189 = call i32 @fclose(i32* %188)
store i32 1, i32* %3
br label %233
190: ; preds = %169
%191 = load i64, i64* %8
%192 = load i64, i64* %6
%193 = icmp ne i64 %191, %192
br i1 %193, label %194, label %195
194: ; preds = %190
br label %223
195: ; preds = %190
%196 = load i8*, i8** %11
%197 = load i64, i64* %7
%198 = load i32*, i32** %12
%199 = call i64 @fread(i8* %196, i32 1, i64 %197, i32* %198)
store i64 %199, i64* %8
%200 = load i64, i64* %8
%201 = load i8*, i8** %11
%202 = load i64, i64* %8
%203 = load i32*, i32** %14
%204 = call i64 @fwrite(i8* %201, i32 1, i64 %202, i32* %203)
%205 = icmp ne i64 %200, %204
br i1 %205, label %206, label %216
206: ; preds = %195
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.23, i64 0, i64 0))
%208 = load i8*, i8** %11
%209 = call i32 @free(i8* %208)
%210 = load i32*, i32** %12
%211 = call i32 @fclose(i32* %210)
%212 = load i32*, i32** %13
%213 = call i32 @fclose(i32* %212)
%214 = load i32*, i32** %14
%215 = call i32 @fclose(i32* %214)
store i32 1, i32* %3
br label %233
216: ; preds = %195
%217 = load i64, i64* %8
%218 = load i64, i64* %7
%219 = icmp ne i64 %217, %218
br i1 %219, label %220, label %221
220: ; preds = %216
br label %223
221: ; preds = %216
br label %222
222: ; preds = %221
br i1 true, label %169, label %223
223: ; preds = %222, %220, %194
%224 = load i8*, i8** %11
%225 = call i32 @free(i8* %224)
%226 = load i32*, i32** %12
%227 = call i32 @fclose(i32* %226)
%228 = load i32*, i32** %13
%229 = call i32 @fclose(i32* %228)
%230 = load i32*, i32** %14
%231 = call i32 @fclose(i32* %230)
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %3
br label %233
233: ; preds = %223, %206, %180, %148, %134, %122, %116, %93, %35, %18
%234 = load i32, i32* %3
ret i32 %234
}

LLVM IR (-O2):
@.str.1 = [215 x i8] c"Usage: %s -hermes|-kaiser|-titan|-wizard|-athena|-sp\0A|-data <number> -extra <number> <filename.nb>\0AGenerates <filename.nb.payload> and <filename.nb.extra> from <filename.nb>\0A<filename.nb> will NOT get overwritten.\0A\00"
@.str.2 = [8 x i8] c"-wizard\00"
@.str.3 = [8 x i8] c"-athena\00"
@.str.4 = [122 x i8] c"Wizard and Athena ROMs do not contain extra bytes.\0AYou need not run %s. Just copy <filename.nb> to <filename.nb.payload>\0A\00"
@.str.5 = [6 x i8] c"-data\00"
@.str.6 = [7 x i8] c"-extra\00"
@.str.7 = [8 x i8] c"-hermes\00"
@.str.8 = [4 x i8] c"-sp\00"
@.str.9 = [7 x i8] c"-titan\00"
@.str.10 = [8 x i8] c"-kaiser\00"
@.str.12 = [221 x i8] c"Usage: %s -hermes|-kaiser|-titan|-acer|-wizard|-athena|-sp\0A|-data <number> -extra <number> <filename.nb>\0AGenerates <filename.nb.payload> and <filename.nb.extra> from <filename.nb>\0A<filename.nb> will NOT get overwritten.\0A\00"
@.str.13 = [9 x i8] c".payload\00"
@.str.14 = [7 x i8] c".extra\00"
@.str.16 = [3 x i8] c"rb\00"
@.str.17 = [30 x i8] c"Could not open input file %s\0A\00"
@.str.18 = [5 x i8] c"%s%s\00"
@.str.19 = [4 x i8] c"w+b\00"
@.str.20 = [31 x i8] c"Could not open output file %s\0A\00"
@.str.21 = [69 x i8] c"Using data chunk size = 0x%x and extra chunk size = 0x%x\0Aon file %s\0A\00"
@str = [15 x i8] c"NBSplit 2.1rc2\00"
@str.25 = [24 x i8] c"Error allocating memory\00"
@str.26 = [6 x i8] c"Done.\00"
@str.27 = [59 x i8] c"Error writing to extra file. Generated files are unusable!\00"
@str.28 = [61 x i8] c"Error writing to payload file. Generated files are unusable!\00"
@str.29 = [29 x i8] c"Wrong or missing parameters.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([215 x i8], [215 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %132
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %8
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([122 x i8], [122 x i8]* @.str.4, i64 0, i64 0), i8* %17)
br label %132
19: ; preds = %13
%20 = icmp ugt i32 %0, 5
br i1 %20, label %21, label %36
21: ; preds = %19
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32 @strcmp(i8* dereferenceable(1) %26, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = tail call i64 @atoi(i8* %31)
%33 = getelementptr inbounds i8*, i8** %1, i64 4
%34 = load i8*, i8** %33
%35 = tail call i64 @atoi(i8* %34)
br label %36
36: ; preds = %29, %24, %21, %19
%37 = phi i64 [ 0, %21 ], [ 0, %24 ], [ %35, %29 ], [ 0, %19 ]
%38 = phi i64 [ 0, %21 ], [ 0, %24 ], [ %32, %29 ], [ 0, %19 ]
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %36
%42 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41, %36
br label %45
45: ; preds = %44, %41
%46 = phi i64 [ %37, %41 ], [ 8, %44 ]
%47 = phi i64 [ %38, %41 ], [ 512, %44 ]
%48 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%49 = icmp eq i32 %48, 0
br i1 %49, label %59, label %50
50: ; preds = %45
%51 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %50
%54 = icmp eq i64 %47, 0
br i1 %54, label %55, label %59
55: ; preds = %53
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.29, i64 0, i64 0))
%57 = load i8*, i8** %1
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([221 x i8], [221 x i8]* @.str.12, i64 0, i64 0), i8* %57)
br label %132
59: ; preds = %50, %45, %53
%60 = phi i64 [ %47, %53 ], [ 2048, %45 ], [ 2048, %50 ]
%61 = phi i64 [ %46, %53 ], [ 8, %45 ], [ 8, %50 ]
%62 = add nsw i32 %0, -1
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = tail call i64 @strlen(i8* dereferenceable(1) %65)
%67 = add i64 %66, 14
%68 = tail call i64 @malloc(i64 %67)
%69 = inttoptr i64 %68 to i8*
%70 = icmp eq i64 %68, 0
br i1 %70, label %71, label %73
71: ; preds = %59
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.25, i64 0, i64 0))
br label %132
73: ; preds = %59
%74 = tail call i32* @fopen(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.17, i64 0, i64 0), i8* %65)
%78 = tail call i32 @free(i8* %69)
br label %132
79: ; preds = %73
%80 = tail call i32 @sprintf(i8* %69, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i8* %65, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
%81 = tail call i32* @fopen(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %87
83: ; preds = %79
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* %69)
%85 = tail call i32 @free(i8* %69)
%86 = tail call i32 @fclose(i32* %74)
br label %132
87: ; preds = %79
%88 = tail call i32 @sprintf(i8* %69, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i8* %65, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%89 = tail call i32* @fopen(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%90 = icmp eq i32* %89, null
br i1 %90, label %91, label %96
91: ; preds = %87
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.20, i64 0, i64 0), i8* %69)
%93 = tail call i32 @free(i8* %69)
%94 = tail call i32 @fclose(i32* %81)
%95 = tail call i32 @fclose(i32* %74)
br label %132
96: ; preds = %87
%97 = tail call i32 @free(i8* %69)
%98 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.21, i64 0, i64 0), i64 %60, i64 %61, i8* %65)
%99 = add i64 %61, %60
%100 = tail call i64 @malloc(i64 %99)
%101 = inttoptr i64 %100 to i8*
br label %102
102: ; preds = %124, %96
%103 = tail call i64 @fread(i8* %101, i32 1, i64 %60, i32* %74)
%104 = tail call i64 @fwrite(i8* %101, i32 1, i64 %103, i32* %81)
%105 = icmp eq i64 %103, %104
br i1 %105, label %112, label %106
106: ; preds = %102
%107 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.28, i64 0, i64 0))
%108 = tail call i32 @free(i8* %101)
%109 = tail call i32 @fclose(i32* %74)
%110 = tail call i32 @fclose(i32* %81)
%111 = tail call i32 @fclose(i32* %89)
br label %132
112: ; preds = %102
%113 = icmp eq i64 %103, %60
br i1 %113, label %114, label %126
114: ; preds = %112
%115 = tail call i64 @fread(i8* %101, i32 1, i64 %61, i32* %74)
%116 = tail call i64 @fwrite(i8* %101, i32 1, i64 %115, i32* %89)
%117 = icmp eq i64 %115, %116
br i1 %117, label %124, label %118
118: ; preds = %114
%119 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.27, i64 0, i64 0))
%120 = tail call i32 @free(i8* %101)
%121 = tail call i32 @fclose(i32* %74)
%122 = tail call i32 @fclose(i32* %81)
%123 = tail call i32 @fclose(i32* %89)
br label %132
124: ; preds = %114
%125 = icmp eq i64 %115, %61
br i1 %125, label %102, label %126
126: ; preds = %124, %112
%127 = tail call i32 @free(i8* %101)
%128 = tail call i32 @fclose(i32* %74)
%129 = tail call i32 @fclose(i32* %81)
%130 = tail call i32 @fclose(i32* %89)
%131 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.26, i64 0, i64 0))
br label %132
132: ; preds = %126, %118, %106, %91, %83, %76, %71, %55, %16, %5
%133 = phi i32 [ 1, %5 ], [ 1, %55 ], [ 1, %76 ], [ 1, %83 ], [ 1, %91 ], [ 1, %106 ], [ 0, %126 ], [ 1, %118 ], [ 1, %71 ], [ 0, %16 ]
ret i32 %133
}