LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/util.c
// Function: filename_no_ext
char *filename_no_ext(const char *filename) {
  char *newfilename = (char*)calloc(1, strlen(filename + 1));
  strcpy(newfilename, filename);
  char *dot = strrchr(newfilename, '.');

  if (!dot || dot == newfilename) return newfilename;

  *dot = '\0';

  return newfilename;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
incq %rdi
callq 0x2110
movl $0x1, %edi
movq %rax, %rsi
callq 0x21c0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x20a0
movq %rbx, %rdi
movl $0x2e, %esi
callq 0x2160
testq %rax, %rax
sete %cl
cmpq %rbx, %rax
sete %dl
orb %cl, %dl
jne 0x3b4e
movb $0x0, (%rax)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: p_indent
void p_indent(int level, char *str) {
  char *token, *newstr, *tofree;
  char indent_string[256] = "";
  bzero(indent_string, 256);

  tofree = newstr = strdup(str);

  int i = 0;

  for (i = 0; i < level; i++) {
    indent_string[i] = ' ';
    indent_string[i * 2 + 1] = ' ';
  }

  while((token = strsep(&newstr, "\n")) != NULL) {
    printf("%s%s\n", indent_string, token);
  }

  free(tofree);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x10(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2180
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
jle 0x3bc8
movl %ebp, %eax
xorl %ecx, %ecx
movb $0x20, %dl
movb %dl, 0x10(%rsp,%rcx)
movb %dl, 0x11(%rsp,%rcx,2)
incq %rcx
cmpq %rcx, %rax
jne 0x3bb8
leaq 0x34ca(%rip), %rsi      # 0x7099
leaq 0x8(%rsp), %rdi
callq 0x2250
testq %rax, %rax
je 0x3c16
leaq 0x34ee(%rip), %r14      # 0x70d3
leaq 0x10(%rsp), %r15
leaq 0x34a8(%rip), %r12      # 0x7099
leaq 0x8(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2140
movq %r13, %rdi
movq %r12, %rsi
callq 0x2250
testq %rax, %rax
jne 0x3bf6
movq %rbx, %rdi
callq 0x2040
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: p_section
void p_section(char *header, char *usage, struct help_cols *fields, struct help_cols *out_opts) {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(header);

  p_indent(1, usage);

  if (fields) {
    p_header("Fields");
    p_cols(opts, fields);
  }

  if (out_opts) {
    p_header("Options");
    p_cols(opts, out_opts);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %r14
movl $0x1, (%rax)
leaq 0x345f(%rip), %rdi      # 0x70c3
movq %r13, %rsi
xorl %eax, %eax
callq 0x2140
movl $0x1, %edi
movq %r12, %rsi
callq 0x3b77
testq %r15, %r15
je 0x3ca0
leaq 0x343c(%rip), %rdi      # 0x70c3
leaq 0x344b(%rip), %rsi      # 0x70d9
xorl %eax, %eax
callq 0x2140
movq %r14, %rdi
movq %r15, %rsi
callq 0x3cd8
testq %rbx, %rbx
je 0x3cce
leaq 0x3417(%rip), %rdi      # 0x70c3
leaq 0x342d(%rip), %rsi      # 0x70e0
xorl %eax, %eax
callq 0x2140
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3cd8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: p_cols
void p_cols(help_opts *opts, struct help_cols *cols) {
  struct help_cols *t = cols;
  int usage_width = widest_cols_left(cols);
  char indent_string[256] = "";
  bzero(indent_string, 256);
  int i = 0;

  for (i = 0; i < opts->indent; i++) {
    // 2-space indent
    indent_string[i] = ' ';
    indent_string[i * 2 + 1] = ' ';
  }

  char fmt_string[256] = "";

  sprintf(fmt_string, "%s%%-%ds %%s\n", indent_string, usage_width + 2);

  while(t->usage) {
    printf(fmt_string, t->usage, t->desc);
    t = ++cols;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %rbx
movq %rdi, %r15
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x3d21
leaq 0x10(%rbx), %r12
xorl %r14d, %r14d
movl %r14d, %ebp
callq 0x2110
movq %rax, %r14
cmpl %r14d, %ebp
cmovgl %ebp, %r14d
movq (%r12), %rdi
addq $0x10, %r12
testq %rdi, %rdi
jne 0x3cfc
addl $0x2, %r14d
jmp 0x3d27
movl $0x2, %r14d
movq %rsp, %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2180
movl (%r15), %eax
testq %rax, %rax
je 0x3d51
xorl %ecx, %ecx
movb $0x20, %dl
movb %dl, (%rsp,%rcx)
movb %dl, 0x1(%rsp,%rcx,2)
incq %rcx
cmpq %rcx, %rax
jne 0x3d42
leaq 0x100(%rsp), %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x2180
leaq 0x3379(%rip), %rsi      # 0x70e8
movq %rsp, %rdx
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2320
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x3dad
addq $0x10, %rbx
leaq 0x100(%rsp), %r14
movq -0x8(%rbx), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
movq (%rbx), %rsi
addq $0x10, %rbx
testq %rsi, %rsi
jne 0x3d93
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: widest_cols_left
int widest_cols_left(struct help_cols *cols) {
  struct help_cols *t = cols;
  int longest = 0;
  int current = 0;

  while(t->usage) {
    current = strlen(t->usage);
    if (current > longest) {
      longest = current;
    }

    t = ++cols;
  }

  return longest;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3deb
addq $0x10, %rbx
xorl %ebp, %ebp
callq 0x2110
cmpl %eax, %ebp
cmovgl %ebp, %eax
movq (%rbx), %rdi
addq $0x10, %rbx
movl %eax, %ebp
testq %rdi, %rdi
jne 0x3dd1
jmp 0x3ded
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage
void print_usage() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(APPNAME);
  p_indent(1, "A tool for working with NES ROM files in the iNES v1 format");
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " <subcommand> [ <subcommand-args> ... ]");
  p_newline();

  p_header("Subcommands");

  static struct help_cols subcommand_table[] = {
    { "help", "Print the usage for the given subcommand" },
    { "info", "Print an information dump about the given rom" },
    { "prg", "Perform PRG bank actions such as extraction and replacement" },
    { "chr", "Perform CHR bank actions such as extraction and replacement" },
    { "title", "Perform Title metadata actions such as reading and setting" },
    NULL_COL
  };

  p_cols(opts, subcommand_table);

  p_newline();

  printf(
    "For usage information on the above subcommands run `%s help <subcommand>'\n",
    APPNAME
  );

  p_newline();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %r14
movl $0x1, (%rax)
leaq 0x329f(%rip), %r15      # 0x70c3
leaq 0x32d7(%rip), %rbx      # 0x7102
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2140
leaq 0x32c7(%rip), %rsi      # 0x7106
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x32e8(%rip), %rsi      # 0x7142
movq %r15, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x32dd(%rip), %rsi      # 0x7148
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x32ed(%rip), %rsi      # 0x7173
movq %r15, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x8349(%rip), %rsi      # 0xc1e0
movq %r14, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x33d9(%rip), %rdi      # 0x7289
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2140
movl $0xa, %edi
popq %rbx
popq %r14
popq %r15
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_info
void print_usage_info() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(APPNAME " info");
  p_indent(1,
      "Print verbose information about the given ROM file including whether it's valid,\n"
      "the number of PRG and CHR banks, region and mapper information as well as title metadata."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " info <rom>");
  p_newline();
}

// Assembly:
pushq %rbx
leaq 0x31f2(%rip), %rbx      # 0x70c3
leaq 0x33fc(%rip), %rsi      # 0x72d4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x33f4(%rip), %rsi      # 0x72dd
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x323e(%rip), %rsi      # 0x7142
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3473(%rip), %rsi      # 0x7388
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
popq %rbx
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_prg
void print_usage_prg() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(APPNAME " prg");
  p_indent(1, "Perform PRG bank action such as extraction and replacement");
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " prg <action> [ <action-args> ... ]");
  p_newline();

  p_header("Actions");

  static struct help_cols action_cols[] = {
    "extract", "Extract the given PRG bank index to a raw PRG bank",
    "replace", "Replace a PRG bank index with the given PRG bank",
    NULL_COL
  };

  p_cols(opts, action_cols);

  p_newline();

  printf("For additional usage information for the above actions run `%s prg <action> --help`\n", APPNAME);

  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x3176(%rip), %r14      # 0x70c3
leaq 0x3443(%rip), %rsi      # 0x7397
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x343a(%rip), %rsi      # 0x739f
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x31c2(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3449(%rip), %rsi      # 0x73da
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x3455(%rip), %rsi      # 0x7401
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x8283(%rip), %rsi      # 0xc240
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x3497(%rip), %rdi      # 0x746d
leaq 0x3125(%rip), %rsi      # 0x7102
xorl %eax, %eax
callq 0x2140
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_prg_extract
void print_usage_prg_extract() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to extract from",
    "<bank-index>", "The zero-based index of the PRG bank to extract",
    "<outflie>", "The output file.",
    NULL_COL
  };

  p_header(APPNAME " prg extract");
  p_indent(1,
    "Extract a PRG bank to a separate file."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " prg extract <rom> [ <options> ... ] <bank-index> <outfile>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x30ab(%rip), %r14      # 0x70c3
leaq 0x3544(%rip), %rsi      # 0x7563
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3543(%rip), %rsi      # 0x7573
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x30f7(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x353e(%rip), %rsi      # 0x759a
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x3562(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x8208(%rip), %rsi      # 0xc290
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x303f(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x81be(%rip), %rsi      # 0xc270
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_prg_replace
void print_usage_prg_replace() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    "-o | --outfile <path>", "When replacing the bank, write the updated ROM file to this path rather than clobbering the source ROM",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to extract from",
    "<bank-index>", "The zero-based index of the bank to replace",
    "<prgbank>", "The source PRG bank file; a raw PRG bank",
    NULL_COL
  };

  p_header(APPNAME " prg replace");
  p_indent(1,
      "Replace a PRG bank in a ROM file with the given bank file"
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " prg replace <rom> [ <options> ... ] <bank-index> <prgbank>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2fd5(%rip), %r14      # 0x70c3
leaq 0x35c0(%rip), %rsi      # 0x76b5
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x35bf(%rip), %rsi      # 0x76c5
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x3021(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x35cd(%rip), %rsi      # 0x76ff
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x348c(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x81a2(%rip), %rsi      # 0xc300
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2f69(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x8148(%rip), %rsi      # 0xc2d0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_chr
void print_usage_chr() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(APPNAME " chr");
  p_indent(1, "Perform CHR bank action such as extraction and replacement");
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " chr <action> [ <action-args> ... ]");
  p_newline();

  p_header("Actions");

  static struct help_cols action_cols[] = {
    { "extract", "Extract the given CHR to either a raw CHR bank or a PNG file" },
    { "replace", "Replace a CHR bank with the given PNG or raw CHR bank" },
    NULL_COL
  };

  p_cols(opts, action_cols);

  p_newline();

  printf("For additional usage information for the above actions run `%s chr <action> --help`\n", APPNAME);

  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2eff(%rip), %r14      # 0x70c3
leaq 0x3573(%rip), %rsi      # 0x773e
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x356a(%rip), %rsi      # 0x7746
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2f4b(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3579(%rip), %rsi      # 0x7781
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x31de(%rip), %rsi      # 0x7401
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x810c(%rip), %rsi      # 0xc340
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x35ce(%rip), %rdi      # 0x781b
leaq 0x2eae(%rip), %rsi      # 0x7102
xorl %eax, %eax
callq 0x2140
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_chr_extract
void print_usage_chr_extract() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    "-f | --format <format>", "Export to the selected format: raw or png",
    "-w | --width <width>", "Applicable only for PNG output: The number of tiles wide the final image should be (default: 16)",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to extract from",
    "<bank-index>", "The zero-based index of the CHR bank to extract",
    "<outflie>", "The output file",
    NULL_COL
  };

  p_header(APPNAME " chr extract");
  p_indent(1,
      "Extract a CHR bank from a ROM file to either a raw CHR bank file or a PNG bitmap\n"
      "The format is determined by either the file extension of the output file or\n"
      "the value of the -f or --format flag"
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " chr extract <rom> [ <options> ... ] <bank-index> <outfile>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2e34(%rip), %r14      # 0x70c3
leaq 0x36d1(%rip), %rsi      # 0x7967
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x36d0(%rip), %rsi      # 0x7977
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2e80(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3766(%rip), %rsi      # 0x7a39
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x32eb(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x80b1(%rip), %rsi      # 0xc3b0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2dc8(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x8047(%rip), %rsi      # 0xc370
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_chr_replace
void print_usage_chr_replace() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    "-f | --format <format>", "Import from the selected format: raw or png; If not passed, the format will be guessed from the file extension of the sourcefile",
    "-o | --outfile <path>", "When replacing the bank, write the updated ROM file to this path rather than clobbering the source ROM",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to replace the CHR bank",
    "<bank-index>", "The zero-based index of the bank to replace",
    "<sourcefile>", "The source CHR bank file; either a raw CHR bank or a png bitmap",
    NULL_COL
  };

  p_header(APPNAME " chr replace");
  p_indent(1,
      "Replace a CHR bank in a ROM file with the given bank or png image."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " chr replace <rom> [ <options> ... ] <bank-index> <chrbank>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();

  p_header("Notes");
  p_indent(1,
      "When importing a PNG file, the file MUST contain 256 8x8 pixel tiles and\n"
      "be in indexed color mode. Only the colors 0-3 of the file's pallete will\n"
      "be used when importing into the ROM."
  );
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %r14
movl $0x1, (%rax)
leaq 0x2d5e(%rip), %rbx      # 0x70c3
leaq 0x3812(%rip), %rsi      # 0x7b7e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3811(%rip), %rsi      # 0x7b8e
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2daa(%rip), %rsi      # 0x7142
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3828(%rip), %rsi      # 0x7bd1
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x3215(%rip), %rsi      # 0x75d9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x805b(%rip), %rsi      # 0xc430
movq %r14, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2cf2(%rip), %rsi      # 0x70e0
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7ff1(%rip), %rsi      # 0xc3f0
movq %r14, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x37f8(%rip), %rsi      # 0x7c10
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x37ed(%rip), %rsi      # 0x7c16
movl $0x1, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3b77
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_title
void print_usage_title() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  p_header(APPNAME " title");
  p_indent(1,
      "Perform actions related to the title metadata in an NES ROM such as setting,\n"
      "getting and removing the metadata. Title metadata is stored at the end of\n"
      "the ROM file and is not consistently supported by emulators, however should\n"
      "not affect the playability of the file itself."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " title <action> [ <action-args> ... ]");
  p_newline();

  p_header("Actions");

  static struct help_cols action_cols[] = {
    { "get", "Read the title metadata from the given ROM and output to STDOUT" },
    { "set", "Set the title to the provided string value" },
    { "remove", "Remove the title metadata entirely from the given ROM file" },
    NULL_COL
  };

  p_cols(opts, action_cols);

  p_newline();

  printf("For additional usage information for the above actions run `%s title <action> --help`\n", APPNAME);

  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2c66(%rip), %r14      # 0x70c3
leaq 0x3869(%rip), %rsi      # 0x7ccd
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3862(%rip), %rsi      # 0x7cd7
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2cb2(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3948(%rip), %rsi      # 0x7de9
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2f45(%rip), %rsi      # 0x7401
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7fa3(%rip), %rsi      # 0xc470
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x39d2(%rip), %rdi      # 0x7eb8
leaq 0x2c15(%rip), %rsi      # 0x7102
xorl %eax, %eax
callq 0x2140
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_title_get
void print_usage_title_get() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to read the title",
    NULL_COL
  };

  p_header(APPNAME " title get");
  p_indent(1,
      "Read the title metadata (if there is any) and output to STDOUT.\n"
      "If there is no title metadata, nothing will be output."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " title get <rom>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2b9b(%rip), %r14      # 0x70c3
leaq 0x3a12(%rip), %rsi      # 0x7f41
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a0f(%rip), %rsi      # 0x7f4f
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2be7(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a5a(%rip), %rsi      # 0x7fc6
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x3052(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7f38(%rip), %rsi      # 0xc4d0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2b2f(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7eee(%rip), %rsi      # 0xc4b0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_title_set
void print_usage_title_set() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the ROM file to set the title on",
    "<title>", "The new title to set (max: 256 chars)",
    NULL_COL
  };

  p_header(APPNAME " title set");
  p_indent(1,
      "Set the title metadata on the given ROM. Titles can be a maximum of 256 chars.\n"
      "If the title is an empty string, then remove the title entirely."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " title set <rom> <title>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2ac5(%rip), %r14      # 0x70c3
leaq 0x3a28(%rip), %rsi      # 0x802d
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a25(%rip), %rsi      # 0x803b
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2b11(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a89(%rip), %rsi      # 0x80cb
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2f7c(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7ea2(%rip), %rsi      # 0xc510
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2a59(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7e58(%rip), %rsi      # 0xc4f0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_title_remove
void print_usage_title_remove() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<rom>", "The path to the source ROM file to remove the title",
    NULL_COL
  };

  p_header(APPNAME " title remove");
  p_indent(1,
      "Remove the title metadata from the given ROM file."
  );
  p_newline();

  p_header("Usage");
  p_indent(1, APPNAME " title remove <rom>");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x29ef(%rip), %r14      # 0x70c3
leaq 0x3a40(%rip), %rsi      # 0x811b
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a40(%rip), %rsi      # 0x812c
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2a3b(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3a47(%rip), %rsi      # 0x815f
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2ea6(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7e1c(%rip), %rsi      # 0xc560
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x2983(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7dd2(%rip), %rsi      # 0xc540
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_chr2png
void print_usage_chr2png() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    "-w | --width=<width>", "Set the width (in tiles) of the output PNG",
    "-o | --outdir=<outdir>", "Set the output directory for the output PNG files (default is to output to same directory as source file)",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<chrfile>", "A raw CHR bank file; possibly exported from a ROM, for example",
    NULL_COL
  };

  p_header("chr2png");
  p_indent(1,
      "Convert stand-alone CHR bank files into indexed 4-color raster PNG files"
  );
  p_newline();

  p_header("Usage");
  p_indent(1, "chr2png [ <options> ... ] <chrfile> [ <chrfile> ... ]");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2919(%rip), %r14      # 0x70c3
leaq 0x3acf(%rip), %rsi      # 0x8280
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3ac6(%rip), %rsi      # 0x8288
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2965(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3ae3(%rip), %rsi      # 0x82d1
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2dd0(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7da6(%rip), %rsi      # 0xc5c0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x28ad(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7d3c(%rip), %rsi      # 0xc580
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/help.c
// Function: print_usage_png2chr
void print_usage_png2chr() {
  help_opts *opts = HELP_ALLOC_OPTS;
  opts->indent = 1;

  static struct help_cols option_cols[] = {
    "--help", "Display this help",
    "-o | --outdir=<outdir>", "Set the output directory for the output PNG files (default is to output to same directory as source file)",
    "-s | --size=<size>", "Set the number of tiles in the target CHR file. This can be an integer value (from 1 up to 512) or 'table' for 256 or 'chr' for 512.",
    NULL_COL
  };

  static struct help_cols arg_cols[] = {
    "<pngfile>", "An indexed color raster PNG file",
    NULL_COL
  };

  p_header("png2chr");
  p_indent(1,
      "Convert raster PNG files into raw CHR banks. Input files must be indexed color mode\n"
      "and only the first 4 colors in the palette will be used"
  );
  p_newline();

  p_header("Usage");
  p_indent(1, "png2chr [ <options> ... ] <pngfile> [ <pngfile> ... ]");
  p_newline();

  p_header("Arguments");
  p_cols(opts, arg_cols);
  p_newline();

  p_header("Options");
  p_cols(opts, option_cols);
  p_newline();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, %rbx
movl $0x1, (%rax)
leaq 0x2843(%rip), %r14      # 0x70c3
leaq 0x3b43(%rip), %rsi      # 0x83ca
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3b3a(%rip), %rsi      # 0x83d2
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x288f(%rip), %rsi      # 0x7142
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x3b9a(%rip), %rsi      # 0x845e
movl $0x1, %edi
callq 0x3b77
movl $0xa, %edi
callq 0x2050
leaq 0x2cfa(%rip), %rsi      # 0x75d9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7d30(%rip), %rsi      # 0xc620
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
callq 0x2050
leaq 0x27d7(%rip), %rsi      # 0x70e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
leaq 0x7cc6(%rip), %rsi      # 0xc5e0
movq %rbx, %rdi
callq 0x3cd8
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
nop
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands.c
// Function: is_subcommand
bool is_subcommand(char *subcommand, ...) {
  va_list aliases;

  va_start(aliases, subcommand);

  char *alias = va_arg(aliases, char*);

  while(alias) {
    if (strcmp(alias, subcommand) == 0) {
      va_end(aliases);
      return true;
    }

    alias = va_arg(aliases, char*);
  }

  va_end(aliases);

  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x499a
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
movl $0x8, %ecx
cmpq $0x28, %rcx
ja 0x49d7
movl $0x8, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x49e5
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdi
testq %rdi, %rdi
setne %bpl
je 0x4a48
movq 0x10(%rsp), %r14
movq %rbx, %rsi
callq 0x21d0
testl %eax, %eax
je 0x4a48
movq 0x8(%rsp), %rcx
movl (%rsp), %r15d
cmpl $0x28, %r15d
ja 0x4a24
movq %rcx, %r12
movl %r15d, %ecx
addq %r14, %rcx
addl $0x8, %r15d
movl %r15d, (%rsp)
jmp 0x4a2d
leaq 0x8(%rcx), %r12
movq %r12, 0x8(%rsp)
movq (%rcx), %rdi
testq %rdi, %rdi
setne %bpl
je 0x4a48
movq %rbx, %rsi
callq 0x21d0
movq %r12, %rcx
testl %eax, %eax
jne 0x4a0b
movl %ebp, %eax
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/prg.c
// Function: subcommand_prg
void subcommand_prg(int argc, char **argv) {
  char *action = *(argv++);

  if (strcmp(action, "extract") == 0) {
    SUBCOMMAND(prg, extract);
  } else if (strcmp(action, "replace") == 0) {
    SUBCOMMAND(prg, replace);
  } else if (strcmp(action, "--help") == 0) {
    print_usage_prg();
    exit(EXIT_SUCCESS);
  } else {
    fprintf(stderr, "Invalid action: %s\n", action);
    exit(EXIT_FAILURE);
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movl %edi, %ebp
movq (%rsi), %rbx
addq $0x8, %r14
leaq 0x25f1(%rip), %rsi      # 0x756b
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
je 0x4fb1
leaq 0x2730(%rip), %rsi      # 0x76bd
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x4fc5
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x4dbb
movq %rax, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x5146
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x4c64
movq %rax, %rdi
callq 0x4fee
leaq 0x24f6(%rip), %rsi      # 0x74c2
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x4fe6
xorl %eax, %eax
callq 0x3f2a
xorl %edi, %edi
callq 0x2330
movq %rbx, %rdi
callq 0x2528
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/prg.c
// Function: subcommand_prg_extract
void subcommand_prg_extract(prg_opts *opts) {
  // now we're ready to write this stuff out.
  FILE *ifile = fopen(opts->romfile_path, "r");
  if (!ifile) {
    fprintf(stderr, "Failed to open file: %s\n", opts->romfile_path);
    exit(EXIT_FAILURE);
  }

  nrt_header *header = NRT_HEADER_ALLOC;
  nrt_header_extract(ifile, header);

  if (! nrt_validate_header(header)) {
    fprintf(stderr, "Rom file does not look valid: %s\n", opts->romfile_path);
    fclose(ifile);
    free(header);
    free(opts);
    exit(EXIT_FAILURE);
  }

  free(header);

  nrt_prgbank *prg = NRT_PRG_ALLOC;
  if (!nrt_extract_prg(ifile, opts->bank_index, prg)) {
    fprintf(stderr, "Failed to read PRG bank %d from %s\n", opts->bank_index, opts->romfile_path);
    fclose(ifile);
    free(prg);
    free(opts);
    exit(EXIT_FAILURE);
  }

  fclose(ifile);

  // ok, now let's write out the PRG
  FILE *ofile = fopen(opts->outfile_path, "w");

  if (!ofile) {
    perror("Failed to open file for writing");
    exit(EXIT_FAILURE);
  }

  if (opts->format == prg_raw_format) {
    // just write out the data to the file.

    fwrite(prg, NRT_PRG_BANK_SIZE, 1, ofile);

    fclose(ofile);
    free(prg);
  }

  free(opts);
  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x2747(%rip), %rsi      # 0x7744
callq 0x22c0
testq %rax, %rax
jne 0x5027
movq 0x6fea(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x3683(%rip), %rsi      # 0x869b
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21f0
jmp 0x50ce
movq %rax, %r14
movl $0x10, %edi
callq 0x2240
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x2d39
movq %r15, %rdi
callq 0x2d68
testb %al, %al
je 0x509b
movq %r15, %rdi
callq 0x2040
movl $0x4000, %edi           # imm = 0x4000
callq 0x2240
movq %rax, %r15
movl 0x404(%rbx), %esi
movq %r14, %rdi
movq %rax, %rdx
callq 0x2dd0
testl %eax, %eax
jne 0x50d8
movq 0x6f79(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movl 0x404(%rbx), %edx
leaq 0x3647(%rip), %rsi      # 0x86d6
movq %rbx, %rcx
xorl %eax, %eax
callq 0x21f0
jmp 0x50b6
movq 0x6f56(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x3608(%rip), %rsi      # 0x86b4
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21f0
movq %r14, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
movl $0x1, %edi
callq 0x2330
movq %r14, %rdi
callq 0x2100
leaq 0x808(%rbx), %rdi
leaq 0x3526(%rip), %rsi      # 0x8614
callq 0x22c0
testq %rax, %rax
jne 0x5106
leaq 0x35fb(%rip), %rdi      # 0x86fa
callq 0x22d0
jmp 0x50ce
cmpl $0x1, 0x400(%rbx)
jne 0x5137
movq %rax, %r14
movl $0x4000, %esi           # imm = 0x4000
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rcx
callq 0x2340
movq %r14, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
xorl %edi, %edi
callq 0x2330
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/prg.c
// Function: subcommand_prg_replace
void subcommand_prg_replace(prg_opts *opts) {
  nrt_prgbank *prg_bank = NRT_PRG_ALLOC;

  if (opts->format == prg_raw_format) {
    // it's a raw file, so let's read that in.
    FILE *ifile = fopen(opts->sourcefile_path, "r");
    if (!ifile) {
      perror("Failed to open source file");
      free(prg_bank);
      free(opts);
      exit(EXIT_FAILURE);
    }

    // read in the data.
    if (fread(prg_bank, NRT_PRG_BANK_SIZE, 1, ifile) != 1) {
      perror("Failed to read prg bank from file");
      fclose(ifile);
      free(prg_bank);
      free(opts);
      exit(EXIT_FAILURE);
    }

    fclose(ifile);
  } else {
    fprintf(stderr, "Unsupported format: %d\n", opts->format);
  }

  static char tempfile_path[] = "/tmp/nrt-rom.XXXXXX";

  // ok, let's read in the rom file, and replace the chr
  FILE *romfile = fopen(opts->romfile_path, "r");

  if (!romfile) {
    perror("Failed to open rom file for reading");
    exit(EXIT_FAILURE);
  }

  nrt_rom *rom = nrt_read_rom_from_file(romfile);
  fclose(romfile);

  nrt_prg_listitem *bank_listitem = nrt_prg_listitem_at(rom->prgs, opts->bank_index);
  free(bank_listitem->prg);
  bank_listitem->prg = prg_bank;

  int fd = mkstemp(tempfile_path);
  FILE *tempfile = fdopen(fd, "w");

  nrt_rom_write_to_file(rom, tempfile);

  fclose(tempfile);
  nrt_rom_free(rom);

  rename(tempfile_path, opts->outfile_path);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x4000, %edi           # imm = 0x4000
callq 0x2240
movq %rax, %r14
movl 0x400(%rbx), %edx
cmpl $0x1, %edx
jne 0x5257
leaq 0x408(%rbx), %rdi
leaq 0x25c9(%rip), %rsi      # 0x7744
callq 0x22c0
testq %rax, %rax
je 0x5279
movq %rax, %r15
movl $0x4000, %esi           # imm = 0x4000
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rcx
callq 0x20c0
movq %r15, %rdi
cmpq $0x1, %rax
jne 0x5284
callq 0x2100
leaq 0x258a(%rip), %rsi      # 0x7744
movq %rbx, %rdi
callq 0x22c0
testq %rax, %rax
je 0x5274
movq %rax, %r12
movq %rax, %rdi
callq 0x38df
movq %rax, %r15
movq %r12, %rdi
callq 0x2100
movq 0x8(%r15), %rdi
movl 0x404(%rbx), %esi
callq 0x363a
movq %rax, %r12
movq (%rax), %rdi
callq 0x2040
movq %r14, (%r12)
leaq 0x751a(%rip), %r14      # 0xc720
movq %r14, %rdi
callq 0x2270
leaq 0x33ff(%rip), %rsi      # 0x8614
movl %eax, %edi
callq 0x2290
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x3a0a
movq %r12, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x38c0
addq $0x808, %rbx            # imm = 0x808
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x22e0
movq 0x6d9a(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x34ef(%rip), %rsi      # 0x8757
xorl %eax, %eax
callq 0x21f0
jmp 0x51b3
callq 0x2586
movq %r14, %rdi
movq %rbx, %rsi
callq 0x259b
movq %r14, %rsi
movq %rbx, %rdx
callq 0x254c
nop
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/chr.c
// Function: filename_to_chr_output_format
chr_output_format filename_to_chr_output_format(char *filename) {
  // figure out the format if it's not passed
  const char *ext = filename_ext(filename);

  if (strcmp(ext, "chr") == 0) {
    return raw_format;
  } else if (strcmp(ext, "png") == 0) {
    return png_format;
  }

  return null_format;
}

// Assembly:
pushq %rbx
callq 0x3ad8
movq %rax, %rbx
leaq 0x246b(%rip), %rsi      # 0x7742
movq %rax, %rdi
callq 0x21d0
testl %eax, %eax
je 0x52ff
leaq 0x25c3(%rip), %rsi      # 0x78ad
movq %rbx, %rdi
callq 0x21d0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
addl %eax, %eax
jmp 0x5304
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/chr.c
// Function: subcommand_chr
void subcommand_chr(int argc, char **argv) {
  char *action = *(argv++);

  if (strcmp(action, "extract") == 0) {
    SUBCOMMAND(chr, extract);
  } else if (strcmp(action, "replace") == 0) {
    SUBCOMMAND(chr, replace);
  } else if (strcmp(action, "--help") == 0) {
    print_usage_chr();
    exit(EXIT_SUCCESS);
  } else {
    fprintf(stderr, "Invalid action: %s\n", action);
    exit(EXIT_FAILURE);
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movl %edi, %ebp
movq (%rsi), %rbx
addq $0x8, %r14
leaq 0x1f56(%rip), %rsi      # 0x756b
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
je 0x564c
leaq 0x2095(%rip), %rsi      # 0x76bd
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x5660
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x547a
movq %rax, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x5844
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x5306
movq %rax, %rdi
callq 0x5689
leaq 0x1e5b(%rip), %rsi      # 0x74c2
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x5681
xorl %eax, %eax
callq 0x41a1
xorl %edi, %edi
callq 0x2330
movq %rbx, %rdi
callq 0x2709
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title_set_parse
title_opts* subcommand_title_set_parse(int argc, char **argv) {
  title_opts *opts = (title_opts*)calloc(1, sizeof(title_opts));

  static struct option longopts[] = {
    { "help", no_argument, NULL, 'h' },
    { "outfile", required_argument, NULL, 'o' },
    { NULL, 0, NULL, 0 }
  };

  if (strcmp(argv[0], "--help") == 0) {
    print_usage_title_set();
    exit(EXIT_SUCCESS);
  }

  strcpy(opts->romfile_path, argv[0]); // don't shift the args

  int ch;

  while ((ch = getopt_long(argc, argv, "o:h", longopts, NULL)) != -1) {
    switch (ch) {
      case 'h':
        print_usage_title_set();
        exit(EXIT_SUCCESS);
        break;

      case 'o':
        strcpy(opts->outfile_path, optarg);

        break;
      case 0:
        break;
      default:
        fprintf(stderr, "Invalid argument: -%c\n", ch);
        exit(EXIT_FAILURE);
    }
  }

  argc -= optind;
  argv += optind;

  // read in the title from the CLI. make sure that it doesn't go over the max length.

  char *title = argv[0];

  if (strnlen(title, NRT_TITLE_MAX_LENGTH + 1) > NRT_TITLE_MAX_LENGTH) {
    fprintf(stderr, "Title cannot be more than %d characters.\n", NRT_TITLE_MAX_LENGTH);
    free(opts);
    exit(EXIT_FAILURE);
  }

  strncpy(opts->title, title, NRT_TITLE_MAX_LENGTH);

  // if the user didn't specify an outfile, then we want the outfile to be
  // the same as the romfile.
  if (strlen(opts->outfile_path) == 0) {
    strcpy(opts->outfile_path, opts->romfile_path);
  }

  return opts;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movl %edi, %ebp
movl $0x1, %edi
movl $0x8ff, %esi            # imm = 0x8FF
callq 0x21c0
movq %rax, %rbx
movq (%r15), %r14
leaq 0x1aa2(%rip), %rsi      # 0x74c2
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5af9
movq %rbx, %rdi
movq %r14, %rsi
callq 0x20a0
movq %rbx, (%rsp)
leaq 0x4ff(%rbx), %r14
leaq 0x2de2(%rip), %r12      # 0x882f
leaq 0x6e0c(%rip), %r13      # 0xc860
movq 0x6575(%rip), %rbx      # 0xbfd0
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2130
cmpl $0x67, %eax
jg 0x5a79
testl %eax, %eax
je 0x5a5b
jmp 0x5a8b
cmpl $0x6f, %eax
jne 0x5af4
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x20a0
jmp 0x5a5b
cmpl $-0x1, %eax
jne 0x5b07
movq 0x6531(%rip), %rax      # 0xbfc8
movslq (%rax), %rax
movq (%r15,%rax,8), %r15
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
callq 0x2190
cmpq $0x100, %rax            # imm = 0x100
movq (%rsp), %rbx
jae 0x5b0e
movq %rbx, %rdi
addq $0x400, %rdi            # imm = 0x400
movl $0xff, %edx
movq %r15, %rsi
callq 0x2070
cmpb $0x0, 0x4ff(%rbx)
jne 0x5ae2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20a0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %eax
jne 0x5b07
xorl %eax, %eax
callq 0x45db
xorl %edi, %edi
callq 0x2330
movl %eax, %edi
callq 0x27d0
movq %rbx, %rdi
callq 0x279f
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title_get_parse
title_opts* subcommand_title_get_parse(int argc, char **argv) {
  title_opts *opts = (title_opts*)calloc(1, sizeof(title_opts));

  static struct option longopts[] = {
    { "help", no_argument, NULL, 'h' },
    { NULL, 0, NULL, 0 }
  };

  if (strcmp(argv[0], "--help") == 0) {
    print_usage_title_get();
    exit(EXIT_SUCCESS);
  }

  strcpy(opts->romfile_path, argv[0]); // don't shift the args

  int ch;

  while ((ch = getopt_long(argc, argv, "h", longopts, NULL)) != -1) {
    switch (ch) {
      case 'h':
        print_usage_title_get();
        exit(EXIT_SUCCESS);
        break;

      case 0:
        break;
      default:
        fprintf(stderr, "Invalid argument: -%c\n", ch);
        exit(EXIT_FAILURE);
    }
  }

  argc -= optind;
  argv += optind;

  return opts;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movl $0x1, %edi
movl $0x8ff, %esi            # imm = 0x8FF
callq 0x21c0
movq %rax, %r14
movq (%rbx), %r15
leaq 0x1983(%rip), %rsi      # 0x74c2
movq %r15, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5b91
movq %r14, %rdi
movq %r15, %rsi
callq 0x20a0
leaq 0x2cd4(%rip), %r15      # 0x8831
leaq 0x6d5c(%rip), %r12      # 0xc8c0
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2130
testl %eax, %eax
je 0x5b64
cmpl $-0x1, %eax
jne 0x5b8c
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %eax
jne 0x5b9f
xorl %eax, %eax
callq 0x4505
xorl %edi, %edi
callq 0x2330
movl %eax, %edi
callq 0x27f3