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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ check_flag(char const *, char *, char *);
int copy_file(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
scalar_t__ output_zeros(int /*<<< orphan*/ *, int);
int parse_bytes(char *);
int print_usage(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
size_t strlen(char const *);
int main(int argc, char *argv[]) {
  FILE *write_file = NULL;
  const char *header = NULL;
  const char *output = NULL;
  size_t declared_size = 0;
  size_t total_bytes_written = 0;
  char title[20 + 1] = {
      0,
  };
  if (argc <= 1) {
    return print_usage(argv[0]);
  }
  int i = 1;
  const char *arg;
  while (i < argc) {
    arg = argv[i++];
    if (check_flag(arg, "-b", "--byteswap")) {
      fprintf(stderr, "ERROR: The byteswap option is no longer supported. ");
      fprintf(stderr,
              "Use another tool to convert the output of this program.\n");
      fprintf(stderr,
              "       For example: dd conv=swab if=rom.z64 of=rom.v64\n\n");
      return print_usage(argv[0]);
    }
    if (check_flag(arg, "-h", "--header")) {
      if (header) {
        fprintf(stderr, "ERROR: The header can only be set once\n\n");
        return print_usage(argv[0]);
      }
      if (i >= argc) {
        fprintf(stderr, "ERROR: Expected an argument to header flag\n\n");
        return print_usage(argv[0]);
      }
      header = argv[i++];
      continue;
    }
    if (check_flag(arg, "-o", "--output")) {
      if (output) {
        fprintf(stderr, "ERROR: The output can only be set once\n\n");
        return print_usage(argv[0]);
      }
      if (i >= argc) {
        fprintf(stderr, "ERROR: Expected an argument to output flag\n\n");
        return print_usage(argv[0]);
      }
      output = argv[i++];
      size_t output_len = strlen(output);
      if (output_len < 5 || strcmp(output + output_len - 4, ".z64")) {
        fprintf(stderr,
                "WARNING: The output should have a '.z64' file extension\n");
      }
      continue;
    }
    if (check_flag(arg, "-l", "--size")) {
      if (i >= argc) {
        fprintf(stderr, "ERROR: Expected an argument to size flag\n\n");
        return print_usage(argv[0]);
      }
      ssize_t size = parse_bytes(argv[i++]);
      if (size < 0x100000) {
        fprintf(stderr,
                "ERROR: Invalid size argument; must be at least %d bytes\n\n",
                0x100000);
        return print_usage(argv[0]);
      }
      declared_size = size;
      continue;
    }
    if (check_flag(arg, "-s", "--offset")) {
      if (!header || !output) {
        fprintf(stderr,
                "ERROR: Need header and output flags before offset\n\n");
        return print_usage(argv[0]);
      }
      if (!total_bytes_written || !declared_size) {
        fprintf(stderr, "ERROR: The first file cannot have an offset\n\n");
        return print_usage(argv[0]);
      }
      if (i >= argc) {
        fprintf(stderr, "ERROR: Expected an argument to offset flag\n\n");
        return print_usage(argv[0]);
      }
      ssize_t offset = parse_bytes(argv[i++]);
      if (offset <= 0) {
        fprintf(stderr, "ERROR: Invalid offset argument\n\n");
        return print_usage(argv[0]);
      }
      ssize_t num_zeros = offset - total_bytes_written;
      if (output_zeros(write_file, num_zeros)) {
        fprintf(stderr, "ERROR: Invalid offset %d to seek to in %s!\n", offset,
                output);
        return 1;
      }
      total_bytes_written += num_zeros;
      continue;
    }
    if (check_flag(arg, "-t", "--title")) {
      if (i >= argc) {
        fprintf(stderr, "ERROR: Expected an argument to title flag\n\n");
        return print_usage(argv[0]);
      }
      const char *title_arg = argv[i++];
      size_t title_len = strlen(title_arg);
      if (title_len > 20) {
        fprintf(stderr, "WARNING: Title will be truncated to %d characters\n",
                20);
        title_len = 20;
      }
      memcpy(title, title_arg, title_len);
      continue;
    }
    if (!header || !output || !declared_size) {
      fprintf(stderr,
              "ERROR: Need size, header, and output before first file\n\n");
      return print_usage(argv[0]);
    }
    if (!write_file) {
      write_file = fopen(output, "wb");
      if (!write_file) {
        fprintf(stderr, "ERROR: Cannot open '%s' for writing\n", output);
        return 1;
      }
      ssize_t bytes_copied = copy_file(write_file, header);
      if (bytes_copied != 0x1000) {
        fprintf(stderr, "ERROR: Unable to copy ROM header from '%s' to '%s'\n",
                header, output);
        return 1;
      }
    }
    ssize_t bytes_copied = copy_file(write_file, arg);
    if (bytes_copied < 0) {
      fprintf(stderr, "ERROR: Unable to copy file from '%s' to '%s'\n", arg,
              output);
      return 1;
    }
    total_bytes_written += bytes_copied;
  }
  if (!total_bytes_written) {
    printf("ERROR: No input files, nothing written\n\n");
    return print_usage(argv[0]);
  }
  ssize_t num_zeros = declared_size - total_bytes_written;
  if (output_zeros(write_file, num_zeros)) {
    fprintf(stderr, "ERROR: Couldn't pad %d bytes to %d bytes. ",
            total_bytes_written, declared_size);
    fprintf(stderr, "Increase your size argument to fix this.\n\n");
    return print_usage(argv[0]);
  }
  fseek(write_file, 0x20, SEEK_SET);
  fwrite(title, 1, 20, write_file);
  fclose(write_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1070 <memset@plt>
cmpl   $0x1,-0x8(%rbp)
jg     125f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1919 <main+0x729>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
lea    0xd69(%rip),%rsi
lea    0xd65(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     1306 <main+0x116>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x60(%rbp),%rdi
lea    0xda3(%rip),%rsi
lea    0xd9f(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     13b3 <main+0x1c3>
cmpq   $0x0,-0x20(%rbp)
je     135d <main+0x16d>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1394 <main+0x1a4>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    1266 <main+0x76>
mov    -0x60(%rbp),%rdi
lea    0xd58(%rip),%rsi
lea    0xd54(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     14b1 <main+0x2c1>
cmpq   $0x0,-0x28(%rbp)
je     140a <main+0x21a>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1441 <main+0x251>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x5,-0x68(%rbp)
jb     1495 <main+0x2a5>
mov    -0x28(%rbp),%rdi
add    -0x68(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xcf2(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     14ac <main+0x2bc>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1266 <main+0x76>
mov    -0x60(%rbp),%rdi
lea    0xcfa(%rip),%rsi
lea    0xcf6(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     1571 <main+0x381>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1509 <main+0x319>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
lea    0xcd2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <parse_bytes@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x100000,-0x6c(%rbp)
jge    1564 <main+0x374>
mov    0x2aa5(%rip),%rax
mov    (%rax),%edi
lea    0xca7(%rip),%rsi
mov    $0x100000,%edx
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
movslq -0x6c(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1266 <main+0x76>
mov    -0x60(%rbp),%rdi
lea    0xca9(%rip),%rsi
lea    0xca5(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     16fa <main+0x50a>
cmpq   $0x0,-0x20(%rbp)
je     15a8 <main+0x3b8>
cmpq   $0x0,-0x28(%rbp)
jne    15d3 <main+0x3e3>
mov    0x2a31(%rip),%rax
mov    (%rax),%edi
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
cmpq   $0x0,-0x38(%rbp)
je     15e9 <main+0x3f9>
cmpq   $0x0,-0x30(%rbp)
jne    1614 <main+0x424>
mov    0x29f0(%rip),%rax
mov    (%rax),%edi
lea    0xc6c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     164b <main+0x45b>
mov    0x29b9(%rip),%rax
mov    (%rax),%edi
lea    0xc63(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <parse_bytes@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jg     169e <main+0x4ae>
mov    0x2966(%rip),%rax
mov    (%rax),%edi
lea    0xc3d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
movslq -0x70(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   10c0 <output_zeros@plt>
cmp    $0x0,%rax
je     16e9 <main+0x4f9>
mov    0x291a(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xc0b(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    19f3 <main+0x803>
movslq -0x74(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1266 <main+0x76>
mov    -0x60(%rbp),%rdi
lea    0xc08(%rip),%rsi
lea    0xc04(%rip),%rdx
call   1110 <check_flag@plt>
cmp    $0x0,%rax
je     17ca <main+0x5da>
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1752 <main+0x562>
mov    0x28b2(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x54(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x14,-0x88(%rbp)
14
jbe    17b1 <main+0x5c1>
mov    0x284f(%rip),%rax
mov    (%rax),%edi
lea    0xbaa(%rip),%rsi
mov    $0x14,%edx
mov    $0x0,%al
call   10a0 <fprintf@plt>
movq   $0x14,-0x88(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x88(%rbp),%rdx
call   10b0 <memcpy@plt>
jmp    1266 <main+0x76>
cmpq   $0x0,-0x20(%rbp)
je     17eb <main+0x5fb>
cmpq   $0x0,-0x28(%rbp)
je     17eb <main+0x5fb>
cmpq   $0x0,-0x30(%rbp)
jne    1816 <main+0x626>
mov    0x27ee(%rip),%rax
mov    (%rax),%edi
lea    0xb7c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
cmpq   $0x0,-0x18(%rbp)
jne    18ba <main+0x6ca>
mov    -0x28(%rbp),%rdi
lea    0xb84(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1867 <main+0x677>
mov    0x2799(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xb5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <copy_file@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x1000,-0x8c(%rbp)
je     18b5 <main+0x6c5>
mov    0x274f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xb36(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    19f3 <main+0x803>
jmp    18ba <main+0x6ca>
mov    -0x18(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1030 <copy_file@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x0,-0x90(%rbp)
jge    1905 <main+0x715>
mov    0x26ff(%rip),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xb1a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    19f3 <main+0x803>
movslq -0x90(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1266 <main+0x76>
cmpq   $0x0,-0x38(%rbp)
jne    1944 <main+0x754>
lea    0xb0f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x30(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x94(%rbp),%esi
call   10c0 <output_zeros@plt>
cmp    $0x0,%rax
je     19b5 <main+0x7c5>
mov    0x266e(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xae0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x264f(%rip),%rax
mov    (%rax),%edi
lea    0xaf4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    19f3 <main+0x803>
mov    -0x18(%rbp),%rdi
mov    0x2618(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   10d0 <fseek@plt>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x14,%edx
call   10f0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movq   $0x0,0x4d(%rsp)
cmp    $0x2,%edi
jge    121e <main+0x3e>
mov    0x0(%rbp),%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10f0 <print_usage@plt>
mov    %edi,%ebx
mov    %edi,%r14d
mov    $0x1,%r12d
xor    %edi,%edi
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x30(%rsp)
xor    %r15d,%r15d
mov    %ebx,0xc(%rsp)
mov    %r15,0x18(%rsp)
mov    %rdi,0x20(%rsp)
movslq %r12d,%r15
lea    0x2(%r15),%r12d
lea    0x1(%r15),%rbx
shl    $0x20,%r15
movabs $0x100000000,%rax
add    %rax,%r15
jmp    12a8 <main+0xc8>
nop
lea    0x40(%rsp),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   10a0 <memcpy@plt>
add    $0x2,%r12d
lea    0x2(%rbx),%rax
movabs $0x200000000,%rcx
add    %rcx,%r15
add    $0x1,%rbx
cmp    %r14,%rbx
mov    %rax,%rbx
mov    %r13,%rbp
jge    1614 <main+0x434>
mov    -0x8(%rbp,%rbx,8),%r13
mov    %r13,%rdi
lea    0xd49(%rip),%rsi
lea    0xd45(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
jne    15e2 <main+0x402>
mov    %r13,%rdi
lea    0xdde(%rip),%rsi
lea    0xdda(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
jne    13b0 <main+0x1d0>
mov    %r13,%rdi
lea    0xe21(%rip),%rsi
lea    0xe1d(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
jne    13e9 <main+0x209>
mov    %r13,%rdi
lea    0xea2(%rip),%rsi
lea    0xe9e(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
jne    1462 <main+0x282>
mov    %r13,%rdi
lea    0xef2(%rip),%rsi
lea    0xeee(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
jne    14a1 <main+0x2c1>
mov    %r13,%rdi
lea    0xfbb(%rip),%rsi
lea    0xfb7(%rip),%rdx
call   1100 <check_flag@plt>
test   %rax,%rax
je     1543 <main+0x363>
cmp    %r14,%rbx
jge    1664 <main+0x484>
mov    %rbp,%r13
mov    0x0(%rbp,%rbx,8),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x15,%rax
jb     1270 <main+0x90>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xfaa(%rip),%rsi
mov    $0x14,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x14,%eax
jmp    1270 <main+0x90>
cmpq   $0x0,0x28(%rsp)
jne    16da <main+0x4fa>
lea    -0x1(%r12),%eax
mov    0xc(%rsp),%ebx
cmp    %ebx,%eax
jge    16ec <main+0x50c>
sar    $0x1d,%r15
mov    0x0(%rbp,%r15,1),%rax
mov    %rax,0x28(%rsp)
cmp    %ebx,%r12d
jl     1251 <main+0x71>
jmp    1614 <main+0x434>
cmpq   $0x0,0x10(%rsp)
jne    1701 <main+0x521>
lea    -0x1(%r12),%eax
mov    0xc(%rsp),%ebx
cmp    %ebx,%eax
jge    1716 <main+0x536>
sar    $0x1d,%r15
mov    0x0(%rbp,%r15,1),%rdi
mov    %rdi,0x10(%rsp)
call   1060 <strlen@plt>
cmp    $0x5,%rax
jb     143d <main+0x25d>
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xd45(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1454 <main+0x274>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
lea    0xd30(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
cmp    %ebx,%r12d
jl     1251 <main+0x71>
jmp    1614 <main+0x434>
lea    -0x1(%r12),%eax
mov    0xc(%rsp),%ebx
cmp    %ebx,%eax
jge    172b <main+0x54b>
sar    $0x1d,%r15
mov    0x0(%rbp,%r15,1),%rdi
call   1070 <parse_bytes@plt>
cmp    $0xfffff,%eax
jle    1740 <main+0x560>
mov    %eax,%eax
mov    %rax,0x30(%rsp)
cmp    %ebx,%r12d
jl     1251 <main+0x71>
jmp    1614 <main+0x434>
cmpq   $0x0,0x28(%rsp)
mov    0x30(%rsp),%rax
je     1761 <main+0x581>
cmpq   $0x0,0x10(%rsp)
je     1761 <main+0x581>
cmpq   $0x0,0x18(%rsp)
je     1776 <main+0x596>
test   %rax,%rax
je     1776 <main+0x596>
lea    -0x1(%r12),%eax
cmp    0xc(%rsp),%eax
jge    178b <main+0x5ab>
sar    $0x1d,%r15
mov    0x0(%rbp,%r15,1),%rdi
call   1070 <parse_bytes@plt>
test   %eax,%eax
jle    17b5 <main+0x5d5>
mov    %eax,%r13d
mov    %rbp,0x38(%rsp)
mov    %eax,%ebp
mov    0x18(%rsp),%rbx
sub    %ebx,%ebp
mov    0x20(%rsp),%rdi
mov    %rdi,%r15
mov    %ebp,%esi
call   10b0 <output_zeros@plt>
test   %rax,%rax
jne    17df <main+0x5ff>
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,0x18(%rsp)
mov    0xc(%rsp),%ebx
cmp    %ebx,%r12d
mov    0x38(%rsp),%rbp
jl     1251 <main+0x71>
jmp    1808 <main+0x628>
cmpq   $0x0,0x28(%rsp)
mov    0x30(%rsp),%rax
je     17a0 <main+0x5c0>
cmpq   $0x0,0x10(%rsp)
je     17a0 <main+0x5c0>
test   %rax,%rax
je     17a0 <main+0x5c0>
mov    0x20(%rsp),%rdi
test   %rdi,%rdi
mov    0x18(%rsp),%r15
jne    15b0 <main+0x3d0>
mov    0x10(%rsp),%rdi
lea    0xe2c(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1810 <main+0x630>
mov    %rax,%rdi
mov    0x28(%rsp),%rsi
mov    %rax,%rbx
call   1030 <copy_file@plt>
mov    %rbx,%rdi
cmp    $0x1000,%eax
jne    1836 <main+0x656>
mov    %rdi,0x20(%rsp)
mov    %r13,%rsi
call   1030 <copy_file@plt>
test   %eax,%eax
js     17ca <main+0x5ea>
add    $0xffffffff,%r12d
mov    %eax,%eax
add    %rax,%r15
mov    0xc(%rsp),%ebx
cmp    %ebx,%r12d
mov    0x20(%rsp),%rdi
jl     1247 <main+0x67>
jmp    161e <main+0x43e>
mov    0x29f7(%rip),%rbx
mov    (%rbx),%edi
lea    0xa1c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xa40(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xa69(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%r15
test   %r15,%r15
je     1693 <main+0x4b3>
mov    0x30(%rsp),%rbx
mov    %ebx,%esi
sub    %r15d,%esi
mov    %rdi,%r14
call   10b0 <output_zeros@plt>
test   %rax,%rax
je     16a1 <main+0x4c1>
mov    0x299f(%rip),%r14
mov    (%r14),%edi
lea    0xdef(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%r14),%edi
lea    0xe03(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x2975(%rip),%rax
mov    (%rax),%edi
lea    0xca4(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%rdi
call   10f0 <print_usage@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf6(%rip),%rdi
call   1040 <puts@plt>
jmp    167b <main+0x49b>
mov    0x2930(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x20,%esi
call   10c0 <fseek@plt>
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x14,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1684 <main+0x4a4>
mov    0x28ff(%rip),%rax
mov    (%rax),%edi
lea    0x9d6(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x28ed(%rip),%rax
mov    (%rax),%edi
lea    0x9ed(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x28d8(%rip),%rax
mov    (%rax),%edi
lea    0xa11(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x28c3(%rip),%rax
mov    (%rax),%edi
lea    0xa25(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x28ae(%rip),%rax
mov    (%rax),%edi
lea    0xa85(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x2899(%rip),%rax
mov    (%rax),%edi
lea    0xa9b(%rip),%rsi
mov    $0x100000,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    167b <main+0x49b>
mov    0x2878(%rip),%rax
mov    (%rax),%edi
lea    0xac0(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x2863(%rip),%rax
mov    (%rax),%edi
lea    0xadf(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x284e(%rip),%rax
mov    (%rax),%edi
lea    0xaf8(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x2839(%rip),%rax
mov    (%rax),%edi
lea    0xbc7(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x2824(%rip),%rax
mov    (%rax),%edi
lea    0xafb(%rip),%rsi
jmp    1674 <main+0x494>
mov    0x280f(%rip),%rax
mov    (%rax),%edi
lea    0xc32(%rip),%rsi
mov    %r13,%rdx
jmp    184b <main+0x66b>
mov    0x27fa(%rip),%rax
mov    (%rax),%edi
lea    0xaf2(%rip),%rsi
mov    %r13d,%edx
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    1684 <main+0x4a4>
mov    %r15,%rdi
jmp    1619 <main+0x439>
mov    0x27c9(%rip),%rax
mov    (%rax),%edi
lea    0xb93(%rip),%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    1684 <main+0x4a4>
mov    0x27a3(%rip),%rax
mov    (%rax),%edi
lea    0xb92(%rip),%rsi
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    1684 <main+0x4a4>

LLVM IR (-O0):
@.str = [3 x i8] c"-b\00"
@.str.1 = [11 x i8] c"--byteswap\00"
@stderr = global i32 0
@.str.2 = [52 x i8] c"ERROR: The byteswap option is no longer supported. \00"
@.str.3 = [57 x i8] c"Use another tool to convert the output of this program.\0A\00"
@.str.4 = [57 x i8] c" For example: dd conv=swab if=rom.z64 of=rom.v64\0A\0A\00"
@.str.5 = [3 x i8] c"-h\00"
@.str.6 = [9 x i8] c"--header\00"
@.str.7 = [41 x i8] c"ERROR: The header can only be set once\0A\0A\00"
@.str.8 = [45 x i8] c"ERROR: Expected an argument to header flag\0A\0A\00"
@.str.9 = [3 x i8] c"-o\00"
@.str.10 = [9 x i8] c"--output\00"
@.str.11 = [41 x i8] c"ERROR: The output can only be set once\0A\0A\00"
@.str.12 = [45 x i8] c"ERROR: Expected an argument to output flag\0A\0A\00"
@.str.13 = [5 x i8] c".z64\00"
@.str.14 = [57 x i8] c"WARNING: The output should have a '.z64' file extension\0A\00"
@.str.15 = [3 x i8] c"-l\00"
@.str.16 = [7 x i8] c"--size\00"
@.str.17 = [43 x i8] c"ERROR: Expected an argument to size flag\0A\0A\00"
@.str.18 = [58 x i8] c"ERROR: Invalid size argument; must be at least %d bytes\0A\0A\00"
@.str.19 = [3 x i8] c"-s\00"
@.str.20 = [9 x i8] c"--offset\00"
@.str.21 = [52 x i8] c"ERROR: Need header and output flags before offset\0A\0A\00"
@.str.22 = [46 x i8] c"ERROR: The first file cannot have an offset\0A\0A\00"
@.str.23 = [45 x i8] c"ERROR: Expected an argument to offset flag\0A\0A\00"
@.str.24 = [33 x i8] c"ERROR: Invalid offset argument\0A\0A\00"
@.str.25 = [44 x i8] c"ERROR: Invalid offset %d to seek to in %s!\0A\00"
@.str.26 = [3 x i8] c"-t\00"
@.str.27 = [8 x i8] c"--title\00"
@.str.28 = [44 x i8] c"ERROR: Expected an argument to title flag\0A\0A\00"
@.str.29 = [51 x i8] c"WARNING: Title will be truncated to %d characters\0A\00"
@.str.30 = [57 x i8] c"ERROR: Need size, header, and output before first file\0A\0A\00"
@.str.31 = [3 x i8] c"wb\00"
@.str.32 = [37 x i8] c"ERROR: Cannot open '%s' for writing\0A\00"
@.str.33 = [52 x i8] c"ERROR: Unable to copy ROM header from '%s' to '%s'\0A\00"
@.str.34 = [46 x i8] c"ERROR: Unable to copy file from '%s' to '%s'\0A\00"
@.str.35 = [41 x i8] c"ERROR: No input files, nothing written\0A\0A\00"
@.str.36 = [43 x i8] c"ERROR: Couldn't pad %d bytes to %d bytes. \00"
@.str.37 = [43 x i8] c"Increase your size argument to fix this.\0A\0A\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca [21 x i8]
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i64 0, i64* %9
store i64 0, i64* %10
%23 = bitcast [21 x i8]* %11 to i8*
%24 = load i32, i32* %4
%25 = icmp sle i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @print_usage(i8* %29)
store i32 %30, i32* %3
br label %377
31: ; preds = %2
store i32 1, i32* %12
br label %32
32: ; preds = %334, %278, %244, %168, %135, %82, %31
%33 = load i32, i32* %12
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %339
36: ; preds = %32
%37 = load i8**, i8*** %5
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
store i8* %42, i8** %13
%43 = load i8*, i8** %13
%44 = call i64 @check_flag(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %36
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 @print_usage(i8* %55)
store i32 %56, i32* %3
br label %377
57: ; preds = %36
%58 = load i8*, i8** %13
%59 = call i64 @check_flag(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %89
61: ; preds = %57
%62 = load i8*, i8** %7
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = call i32 @print_usage(i8* %69)
store i32 %70, i32* %3
br label %377
71: ; preds = %61
%72 = load i32, i32* %12
%73 = load i32, i32* %4
%74 = icmp sge i32 %72, %73
br i1 %74, label %75, label %82
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 0
%80 = load i8*, i8** %79
%81 = call i32 @print_usage(i8* %80)
store i32 %81, i32* %3
br label %377
82: ; preds = %71
%83 = load i8**, i8*** %5
%84 = load i32, i32* %12
%85 = add nsw i32 %84, 1
store i32 %85, i32* %12
%86 = sext i32 %84 to i64
%87 = getelementptr inbounds i8*, i8** %83, i64 %86
%88 = load i8*, i8** %87
store i8* %88, i8** %7
br label %32
89: ; preds = %57
%90 = load i8*, i8** %13
%91 = call i64 @check_flag(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %136
93: ; preds = %89
%94 = load i8*, i8** %8
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %103
96: ; preds = %93
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i32 @print_usage(i8* %101)
store i32 %102, i32* %3
br label %377
103: ; preds = %93
%104 = load i32, i32* %12
%105 = load i32, i32* %4
%106 = icmp sge i32 %104, %105
br i1 %106, label %107, label %114
107: ; preds = %103
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = call i32 @print_usage(i8* %112)
store i32 %113, i32* %3
br label %377
114: ; preds = %103
%115 = load i8**, i8*** %5
%116 = load i32, i32* %12
%117 = add nsw i32 %116, 1
store i32 %117, i32* %12
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds i8*, i8** %115, i64 %118
%120 = load i8*, i8** %119
store i8* %120, i8** %8
%121 = load i8*, i8** %8
%122 = call i64 @strlen(i8* %121)
store i64 %122, i64* %14
%123 = load i64, i64* %14
%124 = icmp ult i64 %123, 5
br i1 %124, label %132, label %125
125: ; preds = %114
%126 = load i8*, i8** %8
%127 = load i64, i64* %14
%128 = getelementptr inbounds i8, i8* %126, i64 %127
%129 = getelementptr inbounds i8, i8* %128, i64 -4
%130 = call i64 @strcmp(i8* %129, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%131 = icmp ne i64 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %125, %114
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0))
br label %135
135: ; preds = %132, %125
br label %32
136: ; preds = %89
%137 = load i8*, i8** %13
%138 = call i64 @check_flag(i8* %137, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%139 = icmp ne i64 %138, 0
br i1 %139, label %140, label %171
140: ; preds = %136
%141 = load i32, i32* %12
%142 = load i32, i32* %4
%143 = icmp sge i32 %141, %142
br i1 %143, label %144, label %151
144: ; preds = %140
%145 = load i32, i32* @stderr
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
%147 = load i8**, i8*** %5
%148 = getelementptr inbounds i8*, i8** %147, i64 0
%149 = load i8*, i8** %148
%150 = call i32 @print_usage(i8* %149)
store i32 %150, i32* %3
br label %377
151: ; preds = %140
%152 = load i8**, i8*** %5
%153 = load i32, i32* %12
%154 = add nsw i32 %153, 1
store i32 %154, i32* %12
%155 = sext i32 %153 to i64
%156 = getelementptr inbounds i8*, i8** %152, i64 %155
%157 = load i8*, i8** %156
%158 = call i32 @parse_bytes(i8* %157)
store i32 %158, i32* %15
%159 = load i32, i32* %15
%160 = icmp slt i32 %159, 1048576
br i1 %160, label %161, label %168
161: ; preds = %151
%162 = load i32, i32* @stderr
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.18, i64 0, i64 0), i32 1048576)
%164 = load i8**, i8*** %5
%165 = getelementptr inbounds i8*, i8** %164, i64 0
%166 = load i8*, i8** %165
%167 = call i32 @print_usage(i8* %166)
store i32 %167, i32* %3
br label %377
168: ; preds = %151
%169 = load i32, i32* %15
%170 = sext i32 %169 to i64
store i64 %170, i64* %9
br label %32
171: ; preds = %136
%172 = load i8*, i8** %13
%173 = call i64 @check_flag(i8* %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%174 = icmp ne i64 %173, 0
br i1 %174, label %175, label %249
175: ; preds = %171
%176 = load i8*, i8** %7
%177 = icmp ne i8* %176, null
br i1 %177, label %178, label %181
178: ; preds = %175
%179 = load i8*, i8** %8
%180 = icmp ne i8* %179, null
br i1 %180, label %188, label %181
181: ; preds = %178, %175
%182 = load i32, i32* @stderr
%183 = call i32 (i32, i8*, ...) @fprintf(i32 %182, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0))
%184 = load i8**, i8*** %5
%185 = getelementptr inbounds i8*, i8** %184, i64 0
%186 = load i8*, i8** %185
%187 = call i32 @print_usage(i8* %186)
store i32 %187, i32* %3
br label %377
188: ; preds = %178
%189 = load i64, i64* %10
%190 = icmp ne i64 %189, 0
br i1 %190, label %191, label %194
191: ; preds = %188
%192 = load i64, i64* %9
%193 = icmp ne i64 %192, 0
br i1 %193, label %201, label %194
194: ; preds = %191, %188
%195 = load i32, i32* @stderr
%196 = call i32 (i32, i8*, ...) @fprintf(i32 %195, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0))
%197 = load i8**, i8*** %5
%198 = getelementptr inbounds i8*, i8** %197, i64 0
%199 = load i8*, i8** %198
%200 = call i32 @print_usage(i8* %199)
store i32 %200, i32* %3
br label %377
201: ; preds = %191
%202 = load i32, i32* %12
%203 = load i32, i32* %4
%204 = icmp sge i32 %202, %203
br i1 %204, label %205, label %212
205: ; preds = %201
%206 = load i32, i32* @stderr
%207 = call i32 (i32, i8*, ...) @fprintf(i32 %206, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.23, i64 0, i64 0))
%208 = load i8**, i8*** %5
%209 = getelementptr inbounds i8*, i8** %208, i64 0
%210 = load i8*, i8** %209
%211 = call i32 @print_usage(i8* %210)
store i32 %211, i32* %3
br label %377
212: ; preds = %201
%213 = load i8**, i8*** %5
%214 = load i32, i32* %12
%215 = add nsw i32 %214, 1
store i32 %215, i32* %12
%216 = sext i32 %214 to i64
%217 = getelementptr inbounds i8*, i8** %213, i64 %216
%218 = load i8*, i8** %217
%219 = call i32 @parse_bytes(i8* %218)
store i32 %219, i32* %16
%220 = load i32, i32* %16
%221 = icmp sle i32 %220, 0
br i1 %221, label %222, label %229
222: ; preds = %212
%223 = load i32, i32* @stderr
%224 = call i32 (i32, i8*, ...) @fprintf(i32 %223, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.24, i64 0, i64 0))
%225 = load i8**, i8*** %5
%226 = getelementptr inbounds i8*, i8** %225, i64 0
%227 = load i8*, i8** %226
%228 = call i32 @print_usage(i8* %227)
store i32 %228, i32* %3
br label %377
229: ; preds = %212
%230 = load i32, i32* %16
%231 = sext i32 %230 to i64
%232 = load i64, i64* %10
%233 = sub i64 %231, %232
%234 = trunc i64 %233 to i32
store i32 %234, i32* %17
%235 = load i32*, i32** %6
%236 = load i32, i32* %17
%237 = call i64 @output_zeros(i32* %235, i32 %236)
%238 = icmp ne i64 %237, 0
br i1 %238, label %239, label %244
239: ; preds = %229
%240 = load i32, i32* @stderr
%241 = load i32, i32* %16
%242 = load i8*, i8** %8
%243 = call i32 (i32, i8*, ...) @fprintf(i32 %240, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.25, i64 0, i64 0), i32 %241, i8* %242)
store i32 1, i32* %3
br label %377
244: ; preds = %229
%245 = load i32, i32* %17
%246 = sext i32 %245 to i64
%247 = load i64, i64* %10
%248 = add i64 %247, %246
store i64 %248, i64* %10
br label %32
249: ; preds = %171
%250 = load i8*, i8** %13
%251 = call i64 @check_flag(i8* %250, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i64 0, i64 0))
%252 = icmp ne i64 %251, 0
br i1 %252, label %253, label %283
253: ; preds = %249
%254 = load i32, i32* %12
%255 = load i32, i32* %4
%256 = icmp sge i32 %254, %255
br i1 %256, label %257, label %264
257: ; preds = %253
%258 = load i32, i32* @stderr
%259 = call i32 (i32, i8*, ...) @fprintf(i32 %258, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.28, i64 0, i64 0))
%260 = load i8**, i8*** %5
%261 = getelementptr inbounds i8*, i8** %260, i64 0
%262 = load i8*, i8** %261
%263 = call i32 @print_usage(i8* %262)
store i32 %263, i32* %3
br label %377
264: ; preds = %253
%265 = load i8**, i8*** %5
%266 = load i32, i32* %12
%267 = add nsw i32 %266, 1
store i32 %267, i32* %12
%268 = sext i32 %266 to i64
%269 = getelementptr inbounds i8*, i8** %265, i64 %268
%270 = load i8*, i8** %269
store i8* %270, i8** %18
%271 = load i8*, i8** %18
%272 = call i64 @strlen(i8* %271)
store i64 %272, i64* %19
%273 = load i64, i64* %19
%274 = icmp ugt i64 %273, 20
br i1 %274, label %275, label %278
275: ; preds = %264
%276 = load i32, i32* @stderr
%277 = call i32 (i32, i8*, ...) @fprintf(i32 %276, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.29, i64 0, i64 0), i32 20)
store i64 20, i64* %19
br label %278
278: ; preds = %275, %264
%279 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0, i64 0
%280 = load i8*, i8** %18
%281 = load i64, i64* %19
%282 = call i32 @memcpy(i8* %279, i8* %280, i64 %281)
br label %32
283: ; preds = %249
%284 = load i8*, i8** %7
%285 = icmp ne i8* %284, null
br i1 %285, label %286, label %292
286: ; preds = %283
%287 = load i8*, i8** %8
%288 = icmp ne i8* %287, null
br i1 %288, label %289, label %292
289: ; preds = %286
%290 = load i64, i64* %9
%291 = icmp ne i64 %290, 0
br i1 %291, label %299, label %292
292: ; preds = %289, %286, %283
%293 = load i32, i32* @stderr
%294 = call i32 (i32, i8*, ...) @fprintf(i32 %293, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.30, i64 0, i64 0))
%295 = load i8**, i8*** %5
%296 = getelementptr inbounds i8*, i8** %295, i64 0
%297 = load i8*, i8** %296
%298 = call i32 @print_usage(i8* %297)
store i32 %298, i32* %3
br label %377
299: ; preds = %289
%300 = load i32*, i32** %6
%301 = icmp ne i32* %300, null
br i1 %301, label %323, label %302
302: ; preds = %299
%303 = load i8*, i8** %8
%304 = call i32* @fopen(i8* %303, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.31, i64 0, i64 0))
store i32* %304, i32** %6
%305 = load i32*, i32** %6
%306 = icmp ne i32* %305, null
br i1 %306, label %311, label %307
307: ; preds = %302
%308 = load i32, i32* @stderr
%309 = load i8*, i8** %8
%310 = call i32 (i32, i8*, ...) @fprintf(i32 %308, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.32, i64 0, i64 0), i8* %309)
store i32 1, i32* %3
br label %377
311: ; preds = %302
%312 = load i32*, i32** %6
%313 = load i8*, i8** %7
%314 = call i32 @copy_file(i32* %312, i8* %313)
store i32 %314, i32* %20
%315 = load i32, i32* %20
%316 = icmp ne i32 %315, 4096
br i1 %316, label %317, label %322
317: ; preds = %311
%318 = load i32, i32* @stderr
%319 = load i8*, i8** %7
%320 = load i8*, i8** %8
%321 = call i32 (i32, i8*, ...) @fprintf(i32 %318, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.33, i64 0, i64 0), i8* %319, i8* %320)
store i32 1, i32* %3
br label %377
322: ; preds = %311
br label %323
323: ; preds = %322, %299
%324 = load i32*, i32** %6
%325 = load i8*, i8** %13
%326 = call i32 @copy_file(i32* %324, i8* %325)
store i32 %326, i32* %21
%327 = load i32, i32* %21
%328 = icmp slt i32 %327, 0
br i1 %328, label %329, label %334
329: ; preds = %323
%330 = load i32, i32* @stderr
%331 = load i8*, i8** %13
%332 = load i8*, i8** %8
%333 = call i32 (i32, i8*, ...) @fprintf(i32 %330, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.34, i64 0, i64 0), i8* %331, i8* %332)
store i32 1, i32* %3
br label %377
334: ; preds = %323
%335 = load i32, i32* %21
%336 = sext i32 %335 to i64
%337 = load i64, i64* %10
%338 = add i64 %337, %336
store i64 %338, i64* %10
br label %32
339: ; preds = %32
%340 = load i64, i64* %10
%341 = icmp ne i64 %340, 0
br i1 %341, label %348, label %342
342: ; preds = %339
%343 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.35, i64 0, i64 0))
%344 = load i8**, i8*** %5
%345 = getelementptr inbounds i8*, i8** %344, i64 0
%346 = load i8*, i8** %345
%347 = call i32 @print_usage(i8* %346)
store i32 %347, i32* %3
br label %377
348: ; preds = %339
%349 = load i64, i64* %9
%350 = load i64, i64* %10
%351 = sub i64 %349, %350
%352 = trunc i64 %351 to i32
store i32 %352, i32* %22
%353 = load i32*, i32** %6
%354 = load i32, i32* %22
%355 = call i64 @output_zeros(i32* %353, i32 %354)
%356 = icmp ne i64 %355, 0
br i1 %356, label %357, label %368
357: ; preds = %348
%358 = load i32, i32* @stderr
%359 = load i64, i64* %10
%360 = load i64, i64* %9
%361 = call i32 (i32, i8*, ...) @fprintf(i32 %358, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.36, i64 0, i64 0), i64 %359, i64 %360)
%362 = load i32, i32* @stderr
%363 = call i32 (i32, i8*, ...) @fprintf(i32 %362, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.37, i64 0, i64 0))
%364 = load i8**, i8*** %5
%365 = getelementptr inbounds i8*, i8** %364, i64 0
%366 = load i8*, i8** %365
%367 = call i32 @print_usage(i8* %366)
store i32 %367, i32* %3
br label %377
368: ; preds = %348
%369 = load i32*, i32** %6
%370 = load i32, i32* @SEEK_SET
%371 = call i32 @fseek(i32* %369, i32 32, i32 %370)
%372 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0, i64 0
%373 = load i32*, i32** %6
%374 = call i32 @fwrite(i8* %372, i32 1, i32 20, i32* %373)
%375 = load i32*, i32** %6
%376 = call i32 @fclose(i32* %375)
store i32 0, i32* %3
br label %377
377: ; preds = %368, %357, %342, %329, %317, %307, %292, %257, %239, %222, %205, %194, %181, %161, %144, %107, %96, %75, %64, %46, %26
%378 = load i32, i32* %3
ret i32 %378
}

LLVM IR (-O2):
@.str = [3 x i8] c"-b\00"
@.str.1 = [11 x i8] c"--byteswap\00"
@stderr = global i32 0
@.str.2 = [52 x i8] c"ERROR: The byteswap option is no longer supported. \00"
@.str.3 = [57 x i8] c"Use another tool to convert the output of this program.\0A\00"
@.str.4 = [57 x i8] c" For example: dd conv=swab if=rom.z64 of=rom.v64\0A\0A\00"
@.str.5 = [3 x i8] c"-h\00"
@.str.6 = [9 x i8] c"--header\00"
@.str.7 = [41 x i8] c"ERROR: The header can only be set once\0A\0A\00"
@.str.8 = [45 x i8] c"ERROR: Expected an argument to header flag\0A\0A\00"
@.str.9 = [3 x i8] c"-o\00"
@.str.10 = [9 x i8] c"--output\00"
@.str.11 = [41 x i8] c"ERROR: The output can only be set once\0A\0A\00"
@.str.12 = [45 x i8] c"ERROR: Expected an argument to output flag\0A\0A\00"
@.str.13 = [5 x i8] c".z64\00"
@.str.14 = [57 x i8] c"WARNING: The output should have a '.z64' file extension\0A\00"
@.str.15 = [3 x i8] c"-l\00"
@.str.16 = [7 x i8] c"--size\00"
@.str.17 = [43 x i8] c"ERROR: Expected an argument to size flag\0A\0A\00"
@.str.18 = [58 x i8] c"ERROR: Invalid size argument; must be at least %d bytes\0A\0A\00"
@.str.19 = [3 x i8] c"-s\00"
@.str.20 = [9 x i8] c"--offset\00"
@.str.21 = [52 x i8] c"ERROR: Need header and output flags before offset\0A\0A\00"
@.str.22 = [46 x i8] c"ERROR: The first file cannot have an offset\0A\0A\00"
@.str.23 = [45 x i8] c"ERROR: Expected an argument to offset flag\0A\0A\00"
@.str.24 = [33 x i8] c"ERROR: Invalid offset argument\0A\0A\00"
@.str.25 = [44 x i8] c"ERROR: Invalid offset %d to seek to in %s!\0A\00"
@.str.26 = [3 x i8] c"-t\00"
@.str.27 = [8 x i8] c"--title\00"
@.str.28 = [44 x i8] c"ERROR: Expected an argument to title flag\0A\0A\00"
@.str.29 = [51 x i8] c"WARNING: Title will be truncated to %d characters\0A\00"
@.str.30 = [57 x i8] c"ERROR: Need size, header, and output before first file\0A\0A\00"
@.str.31 = [3 x i8] c"wb\00"
@.str.32 = [37 x i8] c"ERROR: Cannot open '%s' for writing\0A\00"
@.str.33 = [52 x i8] c"ERROR: Unable to copy ROM header from '%s' to '%s'\0A\00"
@.str.34 = [46 x i8] c"ERROR: Unable to copy file from '%s' to '%s'\0A\00"
@.str.36 = [43 x i8] c"ERROR: Couldn't pad %d bytes to %d bytes. \00"
@.str.37 = [43 x i8] c"Increase your size argument to fix this.\0A\0A\00"
@SEEK_SET = global i32 0
@str = [40 x i8] c"ERROR: No input files, nothing written\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [21 x i8]
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %10
8: ; preds = %250
%9 = icmp slt i32 %225, %0
br i1 %9, label %10, label %261
10: ; preds = %6, %8
%11 = phi i32* [ %251, %8 ], [ null, %6 ]
%12 = phi i8* [ %63, %8 ], [ null, %6 ]
%13 = phi i8* [ %105, %8 ], [ null, %6 ]
%14 = phi i64 [ %138, %8 ], [ 0, %6 ]
%15 = phi i64 [ %255, %8 ], [ 0, %6 ]
%16 = phi i32 [ %225, %8 ], [ 1, %6 ]
br label %195
17: ; preds = %2
%18 = load i8*, i8** %1
%19 = tail call i32 @print_usage(i8* %18)
br label %287
20: ; preds = %62, %220
%21 = phi i64 [ %65, %62 ], [ %212, %220 ]
%22 = add nsw i64 %21, 1
%23 = getelementptr inbounds i8*, i8** %1, i64 %21
%24 = load i8*, i8** %23
%25 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%34 = load i8*, i8** %1
%35 = call i32 @print_usage(i8* %34)
br label %287
36: ; preds = %20
%37 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %66, label %39
39: ; preds = %36
%40 = trunc i64 %21 to i32
%41 = icmp eq i8* %63, null
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%45 = load i8*, i8** %1
%46 = call i32 @print_usage(i8* %45)
br label %287
47: ; preds = %39
%48 = trunc i64 %22 to i32
%49 = icmp slt i32 %48, %0
br i1 %49, label %55, label %50
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%53 = load i8*, i8** %1
%54 = call i32 @print_usage(i8* %53)
br label %287
55: ; preds = %47
%56 = add nsw i32 %40, 2
%57 = shl i64 %22, 32
%58 = ashr exact i64 %57, 32
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = icmp slt i32 %56, %0
br i1 %61, label %62, label %261
62: ; preds = %103, %55
%63 = phi i8* [ %104, %103 ], [ %60, %55 ]
%64 = phi i32 [ %106, %103 ], [ %56, %55 ]
%65 = sext i32 %64 to i64
br label %20
66: ; preds = %36
%67 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%68 = icmp eq i64 %67, 0
br i1 %68, label %107, label %69
69: ; preds = %66
%70 = trunc i64 %21 to i32
%71 = icmp eq i8* %105, null
br i1 %71, label %77, label %72
72: ; preds = %69
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%75 = load i8*, i8** %1
%76 = call i32 @print_usage(i8* %75)
br label %287
77: ; preds = %69
%78 = trunc i64 %22 to i32
%79 = icmp slt i32 %78, %0
br i1 %79, label %85, label %80
80: ; preds = %77
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
%83 = load i8*, i8** %1
%84 = call i32 @print_usage(i8* %83)
br label %287
85: ; preds = %77
%86 = add nsw i32 %70, 2
%87 = shl i64 %22, 32
%88 = ashr exact i64 %87, 32
%89 = getelementptr inbounds i8*, i8** %1, i64 %88
%90 = load i8*, i8** %89
%91 = call i64 @strlen(i8* dereferenceable(1) %90)
%92 = icmp ult i64 %91, 5
br i1 %92, label %98, label %93
93: ; preds = %85
%94 = getelementptr inbounds i8, i8* %90, i64 -4
%95 = getelementptr inbounds i8, i8* %94, i64 %91
%96 = call i64 @strcmp(i8* %95, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
br i1 %97, label %101, label %98
98: ; preds = %93, %85
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0))
br label %101
101: ; preds = %98, %93
%102 = icmp slt i32 %86, %0
br i1 %102, label %103, label %261
103: ; preds = %135, %101
%104 = phi i8* [ %136, %135 ], [ %63, %101 ]
%105 = phi i8* [ %137, %135 ], [ %90, %101 ]
%106 = phi i32 [ %139, %135 ], [ %86, %101 ]
br label %62
107: ; preds = %66
%108 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %140, label %110
110: ; preds = %107
%111 = trunc i64 %22 to i32
%112 = icmp slt i32 %111, %0
br i1 %112, label %118, label %113
113: ; preds = %110
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0))
%116 = load i8*, i8** %1
%117 = call i32 @print_usage(i8* %116)
br label %287
118: ; preds = %110
%119 = trunc i64 %21 to i32
%120 = shl i64 %22, 32
%121 = ashr exact i64 %120, 32
%122 = getelementptr inbounds i8*, i8** %1, i64 %121
%123 = load i8*, i8** %122
%124 = call i32 @parse_bytes(i8* %123)
%125 = icmp slt i32 %124, 1048576
%126 = add nsw i32 %119, 2
br i1 %125, label %127, label %132
127: ; preds = %118
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.18, i64 0, i64 0), i32 1048576)
%130 = load i8*, i8** %1
%131 = call i32 @print_usage(i8* %130)
br label %287
132: ; preds = %118
%133 = zext i32 %124 to i64
%134 = icmp slt i32 %126, %0
br i1 %134, label %135, label %259
135: ; preds = %195, %132
%136 = phi i8* [ %196, %195 ], [ %63, %132 ]
%137 = phi i8* [ %197, %195 ], [ %105, %132 ]
%138 = phi i64 [ %198, %195 ], [ %133, %132 ]
%139 = phi i32 [ %200, %195 ], [ %126, %132 ]
br label %103
140: ; preds = %107
%141 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.20, i64 0, i64 0))
%142 = icmp eq i64 %141, 0
br i1 %142, label %201, label %143
143: ; preds = %140
%144 = trunc i64 %21 to i32
%145 = trunc i64 %22 to i32
%146 = icmp ne i8* %63, null
%147 = icmp ne i8* %105, null
%148 = select i1 %146, i1 %147, i1 false
br i1 %148, label %154, label %149
149: ; preds = %143
%150 = load i32, i32* @stderr
%151 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.21, i64 0, i64 0))
%152 = load i8*, i8** %1
%153 = call i32 @print_usage(i8* %152)
br label %287
154: ; preds = %143
%155 = icmp ne i64 %199, 0
%156 = icmp ne i64 %138, 0
%157 = select i1 %155, i1 %156, i1 false
br i1 %157, label %163, label %158
158: ; preds = %154
%159 = load i32, i32* @stderr
%160 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0))
%161 = load i8*, i8** %1
%162 = call i32 @print_usage(i8* %161)
br label %287
163: ; preds = %154
%164 = icmp slt i32 %145, %0
br i1 %164, label %170, label %165
165: ; preds = %163
%166 = load i32, i32* @stderr
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.23, i64 0, i64 0))
%168 = load i8*, i8** %1
%169 = call i32 @print_usage(i8* %168)
br label %287
170: ; preds = %163
%171 = add nsw i32 %144, 2
%172 = shl i64 %22, 32
%173 = ashr exact i64 %172, 32
%174 = getelementptr inbounds i8*, i8** %1, i64 %173
%175 = load i8*, i8** %174
%176 = call i32 @parse_bytes(i8* %175)
%177 = icmp slt i32 %176, 1
br i1 %177, label %178, label %183
178: ; preds = %170
%179 = load i32, i32* @stderr
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %179, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.24, i64 0, i64 0))
%181 = load i8*, i8** %1
%182 = call i32 @print_usage(i8* %181)
br label %287
183: ; preds = %170
%184 = trunc i64 %199 to i32
%185 = sub i32 %176, %184
%186 = call i64 @output_zeros(i32* %11, i32 %185)
%187 = icmp eq i64 %186, 0
%188 = sext i32 %185 to i64
%189 = add i64 %199, %188
br i1 %187, label %193, label %190
190: ; preds = %183
%191 = load i32, i32* @stderr
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %191, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.25, i64 0, i64 0), i32 %176, i8* %105)
br label %287
193: ; preds = %183
%194 = icmp slt i32 %171, %0
br i1 %194, label %195, label %261
195: ; preds = %10, %193
%196 = phi i8* [ %12, %10 ], [ %63, %193 ]
%197 = phi i8* [ %13, %10 ], [ %105, %193 ]
%198 = phi i64 [ %14, %10 ], [ %138, %193 ]
%199 = phi i64 [ %15, %10 ], [ %189, %193 ]
%200 = phi i32 [ %16, %10 ], [ %171, %193 ]
br label %135
201: ; preds = %140
%202 = call i64 @check_flag(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i64 0, i64 0))
%203 = icmp eq i64 %202, 0
br i1 %203, label %224, label %204
204: ; preds = %201
%205 = icmp slt i64 %22, %7
br i1 %205, label %211, label %206
206: ; preds = %204
%207 = load i32, i32* @stderr
%208 = call i32 (i32, i8*, ...) @fprintf(i32 %207, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.28, i64 0, i64 0))
%209 = load i8*, i8** %1
%210 = call i32 @print_usage(i8* %209)
br label %287
211: ; preds = %204
%212 = add i64 %21, 2
%213 = getelementptr inbounds i8*, i8** %1, i64 %22
%214 = load i8*, i8** %213
%215 = call i64 @strlen(i8* dereferenceable(1) %214)
%216 = icmp ugt i64 %215, 20
br i1 %216, label %217, label %220
217: ; preds = %211
%218 = load i32, i32* @stderr
%219 = call i32 (i32, i8*, ...) @fprintf(i32 %218, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.29, i64 0, i64 0), i32 20)
br label %220
220: ; preds = %217, %211
%221 = phi i64 [ 20, %217 ], [ %215, %211 ]
%222 = call i32 @memcpy(i8* %4, i8* %214, i64 %221)
%223 = icmp slt i64 %212, %7
br i1 %223, label %20, label %261
224: ; preds = %201
%225 = trunc i64 %22 to i32
%226 = icmp ne i8* %63, null
%227 = icmp ne i8* %105, null
%228 = select i1 %226, i1 %227, i1 false
%229 = icmp ne i64 %138, 0
%230 = select i1 %228, i1 %229, i1 false
br i1 %230, label %236, label %231
231: ; preds = %224
%232 = load i32, i32* @stderr
%233 = call i32 (i32, i8*, ...) @fprintf(i32 %232, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.30, i64 0, i64 0))
%234 = load i8*, i8** %1
%235 = call i32 @print_usage(i8* %234)
br label %287
236: ; preds = %224
%237 = icmp eq i32* %11, null
br i1 %237, label %238, label %250
238: ; preds = %236
%239 = call i32* @fopen(i8* %105, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.31, i64 0, i64 0))
%240 = icmp eq i32* %239, null
br i1 %240, label %241, label %244
241: ; preds = %238
%242 = load i32, i32* @stderr
%243 = call i32 (i32, i8*, ...) @fprintf(i32 %242, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.32, i64 0, i64 0), i8* %105)
br label %287
244: ; preds = %238
%245 = call i32 @copy_file(i32* %239, i8* %63)
%246 = icmp eq i32 %245, 4096
br i1 %246, label %250, label %247
247: ; preds = %244
%248 = load i32, i32* @stderr
%249 = call i32 (i32, i8*, ...) @fprintf(i32 %248, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.33, i64 0, i64 0), i8* %63, i8* %105)
br label %287
250: ; preds = %244, %236
%251 = phi i32* [ %11, %236 ], [ %239, %244 ]
%252 = call i32 @copy_file(i32* %251, i8* %24)
%253 = icmp slt i32 %252, 0
%254 = zext i32 %252 to i64
%255 = add i64 %199, %254
br i1 %253, label %256, label %8
256: ; preds = %250
%257 = load i32, i32* @stderr
%258 = call i32 (i32, i8*, ...) @fprintf(i32 %257, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.34, i64 0, i64 0), i8* %24, i8* %105)
br label %287
259: ; preds = %132
%260 = zext i32 %124 to i64
br label %261
261: ; preds = %8, %193, %101, %55, %220, %259
%262 = phi i32* [ %11, %259 ], [ %11, %220 ], [ %11, %55 ], [ %11, %101 ], [ %11, %193 ], [ %251, %8 ]
%263 = phi i64 [ %199, %259 ], [ %199, %220 ], [ %199, %55 ], [ %199, %101 ], [ %189, %193 ], [ %255, %8 ]
%264 = phi i64 [ %260, %259 ], [ %138, %220 ], [ %138, %55 ], [ %138, %101 ], [ %138, %193 ], [ %138, %8 ]
%265 = icmp eq i64 %263, 0
br i1 %265, label %266, label %270
266: ; preds = %261
%267 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%268 = load i8*, i8** %1
%269 = call i32 @print_usage(i8* %268)
br label %287
270: ; preds = %261
%271 = sub i64 %264, %263
%272 = trunc i64 %271 to i32
%273 = call i64 @output_zeros(i32* %262, i32 %272)
%274 = icmp eq i64 %273, 0
br i1 %274, label %282, label %275
275: ; preds = %270
%276 = load i32, i32* @stderr
%277 = call i32 (i32, i8*, ...) @fprintf(i32 %276, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.36, i64 0, i64 0), i64 %263, i64 %264)
%278 = load i32, i32* @stderr
%279 = call i32 (i32, i8*, ...) @fprintf(i32 %278, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.37, i64 0, i64 0))
%280 = load i8*, i8** %1
%281 = call i32 @print_usage(i8* %280)
br label %287
282: ; preds = %270
%283 = load i32, i32* @SEEK_SET
%284 = call i32 @fseek(i32* %262, i32 32, i32 %283)
%285 = call i32 @fwrite(i8* %4, i32 1, i32 20, i32* %262)
%286 = call i32 @fclose(i32* %262)
br label %287
287: ; preds = %190, %178, %256, %247, %127, %27, %42, %50, %72, %80, %113, %149, %158, %165, %206, %231, %241, %266, %282, %275, %17
%288 = phi i32 [ %19, %17 ], [ %35, %27 ], [ %46, %42 ], [ %54, %50 ], [ %76, %72 ], [ %84, %80 ], [ %117, %113 ], [ %169, %165 ], [ %162, %158 ], [ %153, %149 ], [ %210, %206 ], [ 1, %247 ], [ 1, %241 ], [ %235, %231 ], [ %269, %266 ], [ %281, %275 ], [ 0, %282 ], [ %131, %127 ], [ 1, %256 ], [ 1, %190 ], [ %182, %178 ]
ret i32 %288
}