// File: /workspace/github_c_makefile_star2_O0/sadistech[P]nesromtool2/./src/subcommands/info.c
// Function: subcommand_info
void subcommand_info(int argc, char **argv) {
  info_opts *opts = subcommand_info_parse(argc, argv);

  FILE *romfile = fopen(opts->romfile_path, "r");

  if (!romfile) {
    perror("Failed to read in rom file");
    free(opts);
    exit(EXIT_FAILURE);
  }

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

  if (!nrt_validate_header(rom->header)) {
    printf(
      "Path: %s\n"
      "Valid: FAIL\n",
      opts->romfile_path
    );
    exit(EXIT_FAILURE);
  }

  printf(
    "Path: %s\n"
    "Valid: OK\n"
    "PRG Banks: %d\n"
    "CHR Banks: %d\n"
    "\n"
    "Mapper lower nybble: %d\n"
    "Ignore mirroring control: %d\n"
    "Trainer present: %d\n"
    "Persistent memory: %d\n"
    "Mirror mode: %d\n"
    "\n"
    "Mapper upper nybble: %d\n"
    "Flag format: %d\n"
    "Playchoice: %d\n"
    "VS Unisystem: %d\n"
    "\n"
    "PRG RAM Size: %d\n"
    "\n"
    "TV System: %d\n"
    "\n"
    "Bus conflicts: %d\n"
    "PRG RAM absent: %d\n"
    "TV System (2): %d\n"
    "\n"
    "Title: %s\n",
    opts->romfile_path,
    rom->prgs->count,
    rom->chrs->count,

    rom->header->mapper_nybble_lower,
    rom->header->ignore_mirroring_control,
    rom->header->trainer_present,
    rom->header->persistent_memory,
    rom->header->mirror_mode,

    rom->header->mapper_nybble_upper,
    rom->header->flag_format,
    rom->header->playchoice,
    rom->header->vs_unisystem,

    rom->header->prg_ram_size,

    rom->header->tv_system,

    rom->header->bus_conflicts,
    rom->header->prg_ram_absent,
    rom->header->tv_system_2,

    rom->title
  );

  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edi, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
callq 0x4c50
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x3a4e(%rip), %rsi      # 0x8744
callq 0x22a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x4d25
leaq 0x4787(%rip), %rdi      # 0x9494
callq 0x22b0
movq -0x40(%rbp), %rdi
callq 0x2040
movl $0x1, %edi
callq 0x2310
movq -0x48(%rbp), %rdi
callq 0x39b0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x20e0
movq -0x50(%rbp), %rax
movq (%rax), %rdi
callq 0x26d0
testb $0x1, %al
jne 0x4d67
movq -0x40(%rbp), %rsi
leaq 0x4759(%rip), %rdi      # 0x94af
movb $0x0, %al
callq 0x2120
movl $0x1, %edi
callq 0x2310
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %edx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movq -0x50(%rbp), %rax
movq (%rax), %rax
movw 0x6(%rax), %ax
andw $0xf, %ax
movzbl %al, %r8d
movq -0x50(%rbp), %rax
movq (%rax), %rax
movw 0x6(%rax), %ax
shrw $0x4, %ax
andw $0x1, %ax
movzbl %al, %r9d
movq -0x50(%rbp), %rax
movq (%rax), %rax
movw 0x6(%rax), %ax
shrw $0x5, %ax
andw $0x1, %ax
movzbl %al, %eax
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0x6, %di
andw $0x1, %di
movzbl %dil, %edi
movl %edi, -0x68(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0x7, %di
andw $0x1, %di
movzbl %dil, %edi
movl %edi, -0x64(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0x8, %di
andw $0xf, %di
movzbl %dil, %edi
movl %edi, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0xc, %di
andw $0x3, %di
movzbl %dil, %edi
movl %edi, -0x5c(%rbp)
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0xe, %di
andw $0x1, %di
movzbl %dil, %r13d
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x6(%rdi), %di
shrw $0xf, %di
movzbl %dil, %r12d
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movzbl 0x8(%rdi), %r15d
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x9(%rdi), %di
shrw $0x7, %di
andw $0x1, %di
movzbl %dil, %r14d
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x9(%rdi), %di
shrw $0xa, %di
andw $0x1, %di
movzbl %dil, %ebx
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x9(%rdi), %di
shrw $0xb, %di
andw $0x1, %di
movzbl %dil, %r11d
movq -0x50(%rbp), %rdi
movq (%rdi), %rdi
movw 0x9(%rdi), %di
shrw $0xe, %di
movzbl %dil, %r10d
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x58(%rbp)
leaq 0x45fd(%rip), %rdi      # 0x94c5
movl %eax, (%rsp)
movl -0x68(%rbp), %eax
movl %eax, 0x8(%rsp)
movl -0x64(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x60(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0x5c(%rbp), %eax
movl %eax, 0x20(%rsp)
movq -0x58(%rbp), %rax
movl %r13d, 0x28(%rsp)
movl %r12d, 0x30(%rsp)
movl %r15d, 0x38(%rsp)
movl %r14d, 0x40(%rsp)
movl %ebx, 0x48(%rsp)
movl %r11d, 0x50(%rsp)
movl %r10d, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movb $0x0, %al
callq 0x2120
xorl %edi, %edi
callq 0x2310