LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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 0x51f5
leaq 0x408(%rbx), %rdi
leaq 0x262b(%rip), %rsi      # 0x7744
callq 0x22c0
testq %rax, %rax
je 0x5217
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 0x5222
callq 0x2100
leaq 0x25ec(%rip), %rsi      # 0x7744
movq %rbx, %rdi
callq 0x22c0
testq %rax, %rax
je 0x5212
movq %rax, %r12
movq %rax, %rdi
callq 0x38d1
movq %rax, %r15
movq %r12, %rdi
callq 0x2100
movq 0x8(%r15), %rdi
movl 0x404(%rbx), %esi
callq 0x363c
movq %rax, %r12
movq (%rax), %rdi
callq 0x2040
movq %r14, (%r12)
leaq 0x757c(%rip), %r14      # 0xc720
movq %r14, %rdi
callq 0x2270
leaq 0x3461(%rip), %rsi      # 0x8614
movl %eax, %edi
callq 0x2290
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x39d1
movq %r12, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x38b2
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 0x6dfc(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x3551(%rip), %rsi      # 0x8757
xorl %eax, %eax
callq 0x21f0
jmp 0x5151
callq 0x2586
movq %r14, %rdi
movq %rbx, %rsi
callq 0x259b
movq %r14, %rsi
movq %rbx, %rdx
callq 0x254c
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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 0x3aa0
movq %rax, %rbx
leaq 0x24cb(%rip), %rsi      # 0x7742
movq %rax, %rdi
callq 0x21d0
testl %eax, %eax
je 0x529f
leaq 0x2623(%rip), %rsi      # 0x78ad
movq %rbx, %rdi
callq 0x21d0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
addl %eax, %eax
jmp 0x52a4
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x1fc1(%rip), %rsi      # 0x756b
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
je 0x55e1
leaq 0x2100(%rip), %rsi      # 0x76bd
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x55f5
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x5415
movq %rax, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x57d9
decl %ebp
movl %ebp, %edi
movq %r14, %rsi
callq 0x52a6
movq %rax, %rdi
callq 0x561e
leaq 0x1ec6(%rip), %rsi      # 0x74c2
movq %rbx, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x5616
xorl %eax, %eax
callq 0x4169
xorl %edi, %edi
callq 0x2330
movq %rbx, %rdi
callq 0x2709
// File: /workspace/github_c_makefile_star2_O3/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 0x1b0e(%rip), %rsi      # 0x74c2
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5a8d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x20a0
movq %rbx, (%rsp)
leaq 0x4ff(%rbx), %r14
leaq 0x2e4e(%rip), %r12      # 0x882f
leaq 0x6e78(%rip), %r13      # 0xc860
movq 0x65e1(%rip), %rbx      # 0xbfd0
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2130
cmpl $0x67, %eax
jg 0x5a0d
testl %eax, %eax
je 0x59ef
jmp 0x5a1f
cmpl $0x6f, %eax
jne 0x5a88
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x20a0
jmp 0x59ef
cmpl $-0x1, %eax
jne 0x5a9b
movq 0x659d(%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 0x5aa2
movq %rbx, %rdi
addq $0x400, %rdi            # imm = 0x400
movl $0xff, %edx
movq %r15, %rsi
callq 0x2070
cmpb $0x0, 0x4ff(%rbx)
jne 0x5a76
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 0x5a9b
xorl %eax, %eax
callq 0x45a3
xorl %edi, %edi
callq 0x2330
movl %eax, %edi
callq 0x27d0
movq %rbx, %rdi
callq 0x279f
// File: /workspace/github_c_makefile_star2_O3/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 0x19ef(%rip), %rsi      # 0x74c2
movq %r15, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5b25
movq %r14, %rdi
movq %r15, %rsi
callq 0x20a0
leaq 0x2d40(%rip), %r15      # 0x8831
leaq 0x6dc8(%rip), %r12      # 0xc8c0
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x2130
testl %eax, %eax
je 0x5af8
cmpl $-0x1, %eax
jne 0x5b20
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %eax
jne 0x5b33
xorl %eax, %eax
callq 0x44cd
xorl %edi, %edi
callq 0x2330
movl %eax, %edi
callq 0x27f3
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title_remove_parse
title_opts* subcommand_title_remove_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_remove();
    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_remove();
        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;

  return opts;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movl $0x1, %edi
movl $0x8ff, %esi            # imm = 0x8FF
callq 0x21c0
movq %rax, %r14
movq (%rbx), %r15
leaq 0x195c(%rip), %rsi      # 0x74c2
movq %r15, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5bed
movq %r14, %rdi
movq %r15, %rsi
callq 0x20a0
movq %r14, (%rsp)
movq %r14, %r15
addq $0x4ff, %r15            # imm = 0x4FF
leaq 0x2c9d(%rip), %r12      # 0x882f
leaq 0x6d67(%rip), %r13      # 0xc900
movq 0x6430(%rip), %r14      # 0xbfd0
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2130
cmpl $0x67, %eax
jg 0x5bbe
testl %eax, %eax
je 0x5ba0
jmp 0x5bd0
cmpl $0x6f, %eax
jne 0x5be8
movq (%r14), %rsi
movq %r15, %rdi
callq 0x20a0
jmp 0x5ba0
cmpl $-0x1, %eax
jne 0x5bfb
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %eax
jne 0x5bfb
xorl %eax, %eax
callq 0x4679
xorl %edi, %edi
callq 0x2330
movl %eax, %edi
callq 0x2816
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title
void subcommand_title(int argc, char **argv) {
  char *action = *(argv++);

  if (strcmp(action, "set") == 0) {
    SUBCOMMAND(title, set);
  } else if (strcmp(action, "get") == 0) {
    SUBCOMMAND(title, get);
  } else if (strcmp(action, "remove") == 0) {
    SUBCOMMAND(title, remove);
  } else if (strcmp(action, "--help") == 0) {
    print_usage_title();
    exit(EXIT_SUCCESS);
  } else {
    fprintf(stderr, "Invalid action: %s\n", action);
    exit(EXIT_FAILURE);
  }

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movq (%rsi), %r14
addq $0x8, %rbx
leaq 0x241e(%rip), %rsi      # 0x8037
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5c6f
leaq 0x231f(%rip), %rsi      # 0x7f4b
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
je 0x5c8a
leaq 0x24e6(%rip), %rsi      # 0x8125
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x5c9e
decl %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x5b3a
movq %rax, %rbx
leaq 0x400(%rax), %rdi
movl $0xff, %edx
xorl %esi, %esi
callq 0x2180
jmp 0x5c7e
decl %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x5988
movq %rax, %rbx
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x5cc7
decl %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x5aaa
movq %rax, %rdi
callq 0x5d7c
leaq 0x181d(%rip), %rsi      # 0x74c2
movq %r14, %rdi
callq 0x21d0
testl %eax, %eax
jne 0x5cbf
xorl %eax, %eax
callq 0x4402
xorl %edi, %edi
callq 0x2330
movq %r14, %rdi
callq 0x2839
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title_set
void subcommand_title_set(title_opts *opts) {
  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);

  // first we want to zero out the entire title in our in-memory rom
  // then strcpy() the new title in there
  bzero(rom->title, NRT_TITLE_MAX_LENGTH);
  strcpy(rom->title, opts->title);

  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
leaq 0x1a6b(%rip), %rsi      # 0x7744
callq 0x22c0
testq %rax, %rax
je 0x5d77
movq %rax, %r15
movq %rax, %rdi
callq 0x38d1
movq %rax, %r14
movq %r15, %rdi
callq 0x2100
leaq 0x18(%r14), %r15
movl $0xff, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x2180
leaq 0x400(%rbx), %rsi
movq %r15, %rdi
callq 0x20a0
leaq 0x6c3a(%rip), %r15      # 0xc960
movq %r15, %rdi
callq 0x2270
leaq 0x28df(%rip), %rsi      # 0x8614
movl %eax, %edi
callq 0x2290
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
callq 0x39d1
movq %r12, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x38b2
addq $0x4ff, %rbx            # imm = 0x4FF
movq %r15, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x22e0
callq 0x285d
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/subcommands/title.c
// Function: subcommand_title_get
void subcommand_title_get(title_opts *opts) {
  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);

  if (strnlen(rom->title, NRT_TITLE_MAX_LENGTH) == 0) {
    printf("<no-title>\n");
    nrt_rom_free(rom);
    free(opts);
    exit(EXIT_SUCCESS);
  }

  printf("%s\n", rom->title);
  nrt_rom_free(rom);
  free(opts);

  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x19b9(%rip), %rsi      # 0x7744
callq 0x22c0
testq %rax, %rax
jne 0x5dab
leaq 0x29d3(%rip), %rdi      # 0x876f
callq 0x22d0
movl $0x1, %edi
callq 0x2330
movq %rax, %r15
movq %rax, %rdi
callq 0x38d1
movq %rax, %r14
movq %r15, %rdi
callq 0x2100
cmpb $0x0, 0x18(%r14)
jne 0x5dd1
leaq 0x2a8e(%rip), %rdi      # 0x885d
jmp 0x5dd8
movq %r14, %rdi
addq $0x18, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x38b2
movq %rbx, %rdi
callq 0x2040
xorl %edi, %edi
callq 0x2330
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/chr2png_main.c
// Function: validate_outdir
void validate_outdir(char *outdir) {
  // first, let's make sure the opts->outdir exists and is a directory before we get started
  // (assuming that it's specified)
  if (outdir[0] != '\0') {
    struct stat *outdir_stat = (struct stat*)malloc(sizeof(struct stat));

    if (stat(outdir, outdir_stat) != 0) {
      free(outdir_stat);
      perror(outdir);
      exit(EXIT_FAILURE);
    }

    if (!(outdir_stat->st_mode & S_IFDIR)) {
      free(outdir_stat);
      fprintf(stderr, "Output directory must be a directory.\n");
      exit(EXIT_FAILURE);
    }

    free(outdir_stat);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpb $0x0, (%rdi)
je 0x6480
movq %rdi, %rbx
movl $0x90, %edi
callq 0x2240
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2200
testl %eax, %eax
jne 0x6488
movl 0x18(%r14), %ebx
movq %r14, %rdi
callq 0x2040
btl $0xe, %ebx
jae 0x6493
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a0c
callq 0x2a25
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/chr2png_main.c
// Function: validate_chrfile
void validate_chrfile(char *filepath) {
  struct stat *filestat = (struct stat*)malloc(sizeof(struct stat));

  if (stat(filepath, filestat) != 0) {
    free(filestat);
    perror(filepath);
    exit(EXIT_FAILURE);
  }

  if (!(filestat->st_mode & S_IFREG)) {
    free(filestat);
    fprintf(stderr, "CHR file must be a regular file.\n");
    exit(EXIT_FAILURE);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x90, %edi
callq 0x2240
movq %rax, %rbx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2200
testl %eax, %eax
jne 0x64c9
testb $-0x80, 0x19(%rbx)
je 0x64d4
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a4a
movq %rbx, %rdi
callq 0x2a63
// File: /workspace/github_c_makefile_star2_O3/sadistech[P]nesromtool2/./src/chr2png_main.c
// Function: chr_tile_count
int chr_tile_count(char *chrfile) {
  struct stat *chrfile_stat = (struct stat*)malloc(sizeof(struct stat));

  if (stat(chrfile, chrfile_stat) != 0) {
    free(chrfile_stat);
    perror(chrfile);
    exit(EXIT_FAILURE);
  }

  int size = chrfile_stat->st_size;
  free(chrfile_stat);

  // the file must be a size that's a multiple of 16 (the size of a tile in CHR memory)
  if (size % NRT_TILE_SIZE != 0) {
    fprintf(stderr, "File is the wrong size. It is %d bytes and must be a multiple of %d.\n", size, NRT_TILE_SIZE);
    exit(EXIT_FAILURE);
  }

  return size / NRT_TILE_SIZE;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x90, %edi
callq 0x2240
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2200
testl %eax, %eax
jne 0x656a
movl 0x30(%r14), %ebx
movq %r14, %rdi
callq 0x2040
testb $0xf, %bl
jne 0x6575
sarl $0x4, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2acb
movl %ebx, %edi
callq 0x2ae4
// File: /workspace/github_c_makefile_star2_O3/openshmem-org[P]openshmem-examples/c/fip.c
// Function: main
int
main(void)
{
    float *f;
    int me;

    shmem_init();
    me = shmem_my_pe();

    f = (float *) shmem_malloc(sizeof(*f));

    *f = PI;
    shmem_barrier_all();

    if (me == 0) {
        shmem_float_p(f, E, 1);
    }

    shmem_barrier_all();

    if (me == 1) {
        printf("PE %d: %f, %s\n",
               me, *f, (fabsf(*f - E) < epsilon) ? "OK" : "FAIL");
    }

    shmem_free(f);

    shmem_finalize();

    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
callq 0x1090
callq 0x1060
movl %eax, %ebp
movl $0x4, %edi
callq 0x1070
movq %rax, %rbx
movl $0x40490fdb, (%rax)     # imm = 0x40490FDB
callq 0x1080
testl %ebp, %ebp
je 0x122a
callq 0x1080
cmpl $0x1, %ebp
jne 0x1244
movss (%rbx), %xmm1
cvtss2sd %xmm1, %xmm0
addss 0xe13(%rip), %xmm1      # 0x2004
andps 0xe18(%rip), %xmm1      # 0x2010
movss 0xe08(%rip), %xmm2      # 0x2008
ucomiss %xmm1, %xmm2
leaq 0xe25(%rip), %rax       # 0x202f
leaq 0xe21(%rip), %rdx       # 0x2032
cmovaq %rax, %rdx
leaq 0xe04(%rip), %rdi       # 0x2020
movl $0x1, %esi
movb $0x1, %al
callq 0x1030
jmp 0x1244
movss 0xdda(%rip), %xmm0      # 0x200c
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1040
callq 0x1080
movq %rbx, %rdi
callq 0x10a0
callq 0x1050
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/evilwombat[P]gopro-fw-tools/h4-section-patch.c
// Function: read_file
unsigned char *read_file(const char *fname, unsigned int *out_size)
{
	unsigned char *buf;
	struct stat st;
	int size, ret;
	FILE *fd;

	ret = stat(fname, &st);
	if (ret) {
		printf("Error: Could not stat %s\n", fname);
		return NULL;
	}

	size = st.st_size;
	if (size <= 0) {
		printf("Bad file size of %s: %d\n", fname, size);
		return NULL;
	}

	fd = fopen(fname, "rb");
	if (!fd) {
		printf("Error opening file %s\n", fname);
		return NULL;
	}
		
	buf = malloc(size);
	if (!buf) {
		printf("Could not allocate %d bytes\n", size);
		fclose(fd);
		return NULL;
	}

	ret = fread(buf, size, 1, fd);
	
	if (ret != 1) {
		printf("Error reading file %s: %d\n", fname, ret);
		free(buf);
		fclose(fd);
		return NULL;
	}

	*out_size = size;
	fclose(fd);
	
	return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r13
movq %rdi, %r14
leaq 0x8(%rsp), %rsi
callq 0x10b0
testl %eax, %eax
je 0x1259
leaq 0xddc(%rip), %rdi       # 0x2014
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x1080
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rsp), %r12
testl %r12d, %r12d
jle 0x12b1
leaq 0xddd(%rip), %rsi       # 0x2047
movq %r14, %rdi
callq 0x10e0
testq %rax, %rax
je 0x12cc
movq %rax, %r15
movl %r12d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %rbp, %rdi
callq 0x10d0
testq %rax, %rax
je 0x12d8
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rcx
callq 0x1060
cmpl $0x1, %eax
jne 0x12f8
movl %r12d, (%r13)
jmp 0x12eb
leaq 0xd76(%rip), %rdi       # 0x202e
xorl %ebx, %ebx
movq %r14, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1080
jmp 0x1244
leaq 0xd77(%rip), %rdi       # 0x204a
jmp 0x1238
leaq 0xd82(%rip), %rdi       # 0x2061
xorl %ebx, %ebx
movl %r12d, %esi
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
callq 0x1070
jmp 0x1244
leaq 0xd7f(%rip), %rdi       # 0x207e
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1070
xorl %ebx, %ebx
jmp 0x1244
// File: /workspace/github_c_makefile_star2_O3/evilwombat[P]gopro-fw-tools/h4-section-patch.c
// Function: print_sections
void print_sections(struct section_info *sections, int num_sections)
{
	int i;
	printf("Section\t\t  Offset\t  Length\t     CRC\n");
	printf("========================================================\n");
	for (i = 0; i < num_sections; i++) {
		printf("section_%d\t%8d\t%8d\t%08x (%s)\n",
		       i, sections[i].offset, sections[i].length, sections[i].header_crc,
			(sections[i].header_crc == sections[i].actual_crc) ? "OK" : "MISMATCH!"
		);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x125d(%rip), %rdi      # 0x2596
callq 0x1050
leaq 0x1275(%rip), %rdi      # 0x25ba
callq 0x1050
testl %ebp, %ebp
jle 0x139b
movl %ebp, %r12d
addq $0x1c, %rbx
leaq 0xd5b(%rip), %r13       # 0x20b7
leaq 0xd57(%rip), %rbp       # 0x20ba
leaq 0xd2f(%rip), %r14       # 0x2099
xorl %r15d, %r15d
movl -0x1c(%rbx), %r8d
movq %r13, %r9
cmpl -0x18(%rbx), %r8d
je 0x137d
movq %rbp, %r9
movl -0x4(%rbx), %edx
movl (%rbx), %ecx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1080
incq %r15
addq $0x20, %rbx
cmpq %r15, %r12
jne 0x136d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/evilwombat[P]gopro-fw-tools/h4-section-patch.c
// Function: get_global_crc
unsigned int get_global_crc(unsigned char *buf, int size)
{
	if (size < GLOBAL_HEADER_SIZE) {
		printf("Invalid firmware size: %d\n", size);
		return 0;
	}
	
	return crc32(buf + GLOBAL_HEADER_SIZE, size - GLOBAL_HEADER_SIZE);
}

// Assembly:
pushq %rbx
cmpl $0xdf, %esi
jg 0x13c5
leaq 0xd0a(%rip), %rdi       # 0x20c4
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1080
jmp 0x13da
addq $0xe0, %rdi
addl $0xffffff20, %esi       # imm = 0xFFFFFF20
callq 0x1bf4
movq %rax, %rbx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/evilwombat[P]gopro-fw-tools/h4-section-patch.c
// Function: save_file
static int save_file(const char *output_name, int size, unsigned char *buf)
{
	FILE *ofd;
	int ret;
	ofd = fopen(output_name, "wb+");
	if (!ofd) {
		printf("Could not write to %s\n", output_name);
		return -1;
	}
	ret = fwrite(buf, size, 1, ofd);
	fclose(ofd);

	return ret == 1 ? 0 : -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
leaq 0x9df(%rip), %rsi       # 0x257b
callq 0x10e0
testq %rax, %rax
je 0x1bd3
movq %rax, %r14
movslq %ebp, %rsi
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x1100
movq %rax, %rbx
movq %r14, %rdi
callq 0x1070
xorl %eax, %eax
cmpl $0x1, %ebx
setne %al
negl %eax
jmp 0x1be9
leaq 0x9a5(%rip), %rdi       # 0x257f
movq %r15, %rsi
xorl %eax, %eax
callq 0x1080
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: strdump
void
strdump(void)
{
	size_t i;
	uint c;

	fprintf(stderr, "ESC%c", strescseq.type);
	for (i = 0; i < strescseq.len; i++) {
		c = strescseq.buf[i] & 0xff;
		if (c == '\0') {
			putc('\n', stderr);
			return;
		} else if (isprint(c)) {
			putc(c, stderr);
		} else if (c == '\n') {
			fprintf(stderr, "(\\n)");
		} else if (c == '\r') {
			fprintf(stderr, "(\\r)");
		} else if (c == 0x1b) {
			fprintf(stderr, "(\\e)");
		} else {
			fprintf(stderr, "(%02x)", c);
		}
	}
	fprintf(stderr, "ESC\\\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x1260e(%rip), %r12     # 0x18ff0
movq (%r12), %rdi
movsbl 0x16cab(%rip), %edx     # 0x1d698
leaq 0xbfdc(%rip), %rsi      # 0x129d0
xorl %eax, %eax
callq 0x68d0
cmpq $0x0, 0x16cad(%rip)     # 0x1d6b0
je 0x6ab6
pushq $0x4
popq %r14
pushq $0x1
popq %r15
leaq 0xbfcd(%rip), %rbp      # 0x129e5
xorl %r13d, %r13d
movq 0x16c7e(%rip), %rax     # 0x1d6a0
movzbl (%rax,%r13), %ebx
testl %ebx, %ebx
je 0x6a9c
callq 0x63b0
movq (%rax), %rax
testb $0x40, 0x1(%rax,%rbx,2)
movq (%r12), %rcx
je 0x6a56
movl %ebx, %edi
movq %rcx, %rsi
callq 0x6510
incq %r13
cmpq 0x16c5e(%rip), %r13     # 0x1d6b0
jb 0x6a1b
jmp 0x6ab6
cmpl $0x1b, %ebx
je 0x6a77
cmpl $0xd, %ebx
je 0x6a6e
cmpl $0xa, %ebx
jne 0x6a8b
leaq 0xbf6a(%rip), %rdi      # 0x129d6
jmp 0x6a7e
leaq 0xbf66(%rip), %rdi      # 0x129db
jmp 0x6a7e
leaq 0xbf62(%rip), %rdi      # 0x129e0
movq %r14, %rsi
movq %r15, %rdx
callq 0x6860
jmp 0x6a48
movq %rcx, %rdi
movq %rbp, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x68d0
jmp 0x6a48
movq (%r12), %rsi
pushq $0xa
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6510
movq (%r12), %rcx
leaq 0xbf2b(%rip), %rdi      # 0x129ec
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6860
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: tinsync
int
tinsync(uint timeout)
{
    struct timespec now;
    if (su && !clock_gettime(CLOCK_MONOTONIC, &now)
           && TIMEDIFF(now, sutv) >= timeout)
        su = 0;
    return su;
}

// Assembly:
cmpb $0x1, 0x135bd(%rip)     # 0x1a4c0
jne 0x6f6d
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movq %rsp, %rsi
movl $0x1, %edi
callq 0x6130
testl %eax, %eax
jne 0x6f68
movq (%rsp), %rax
subq 0x135a0(%rip), %rax     # 0x1a4c8
movq 0x8(%rsp), %rcx
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
cvtsi2sd %rax, %xmm0
subq 0x13590(%rip), %rcx     # 0x1a4d0
cvtsi2sd %rcx, %xmm1
divsd 0xb0bb(%rip), %xmm1     # 0x12008
addsd %xmm0, %xmm1
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd %xmm0, %xmm1
jb 0x6f68
movb $0x0, 0x13558(%rip)     # 0x1a4c0
addq $0x10, %rsp
popq %rbx
movzbl 0x1354c(%rip), %eax     # 0x1a4c0
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: utf8encode
size_t
utf8encode(Rune u, char *c)
{
    size_t len, i;

    len = utf8validate(&u, 0);
    if (len > UTF_SIZ)
        return 0;

    for (i = len - 1; i != 0; --i) {
        c[i] = utf8encodebyte(u, 0);
        u >>= 6;
    }
    c[0] = utf8encodebyte(u, len);

    return len;
}

// Assembly:
movl %edi, %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl $0xd800, %eax           # imm = 0xD800
movl $0xfffd, %eax           # imm = 0xFFFD
movl %edi, %ecx
cmovel %eax, %ecx
cmpl $0x110000, %edi         # imm = 0x110000
cmovael %eax, %ecx
xorl %eax, %eax
leaq 0xb41b(%rip), %rdx      # 0x124d0
movq %rax, %rdi
incq %rax
cmpl 0x4(%rdx,%rdi,4), %ecx
ja 0x70b5
cmpq $0x4, %rax
jbe 0x70ca
xorl %eax, %eax
retq
cmpq $0x1, %rax
je 0x70ea
leaq -0x1(%rax), %rdx
movl %ecx, %edi
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, (%rsi,%rdx)
shrl $0x6, %ecx
decq %rdx
jne 0x70d4
leaq 0xb3ab(%rip), %rdx      # 0x1249c
leaq 0xb3a9(%rip), %rdi      # 0x124a1
movzbl (%rax,%rdi), %edi
notl %edi
andl %ecx, %edi
orb (%rax,%rdx), %dil
movb %dil, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: selstart
void
selstart(int col, int row, int snap)
{
    selclear();
    sel.mode = SEL_EMPTY;
    sel.type = SEL_REGULAR;
    sel.alt = IS_SET(MODE_ALTSCREEN);
    sel.snap = snap;
    sel.oe.x = sel.ob.x = col;
    sel.oe.y = sel.ob.y = row;
    selnormalize();

    if (sel.snap != 0)
        sel.mode = SEL_READY;
    tsetdirt(sel.nb.y, sel.ne.y);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %r14d
movl %esi, %ebx
movl %edi, %ebp
cmpl $-0x1, 0x133c1(%rip)    # 0x1a4f4
je 0x715a
movl $0x0, 0x13399(%rip)     # 0x1a4d8
movl $0xffffffff, 0x133ab(%rip) # imm = 0xFFFFFFFF
movl 0x13399(%rip), %edi     # 0x1a4e8
movl 0x1339b(%rip), %esi     # 0x1a4f0
callq 0x72f4
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x1336d(%rip)     # 0x1a4d8
movl 0x1438b(%rip), %eax     # 0x1b4fc
shrl $0x2, %eax
andl $0x1, %eax
movl %eax, 0x13387(%rip)     # 0x1a504
movl %r14d, 0x1335c(%rip)    # 0x1a4e0
movl %ebp, 0x1336a(%rip)     # 0x1a4f4
movl %ebp, 0x1336c(%rip)     # 0x1a4fc
movl %ebx, 0x13362(%rip)     # 0x1a4f8
movl %ebx, 0x13364(%rip)     # 0x1a500
callq 0x71f8
cmpl $0x0, 0x13338(%rip)     # 0x1a4e0
je 0x71b4
movl $0x2, 0x13324(%rip)     # 0x1a4d8
movl 0x1332e(%rip), %edi     # 0x1a4e8
movl 0x13330(%rip), %esi     # 0x1a4f0
popq %rbx
popq %r14
popq %rbp
jmp 0x72f4
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: selclear
void
selclear(void)
{
    if (sel.ob.x == -1)
        return;
    sel.mode = SEL_IDLE;
    sel.ob.x = -1;
    tsetdirt(sel.nb.y, sel.ne.y);
}

// Assembly:
cmpl $-0x1, 0x13324(%rip)    # 0x1a4f4
je 0x71f7
movl $0x0, 0x132fc(%rip)     # 0x1a4d8
movl $0xffffffff, 0x1330e(%rip) # imm = 0xFFFFFFFF
movl 0x132fc(%rip), %edi     # 0x1a4e8
movl 0x132fe(%rip), %esi     # 0x1a4f0
jmp 0x72f4
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: selextend
void
selextend(int col, int row, int type, int done)
{
    int oldey, oldex, oldsby, oldsey, oldtype;

    if (sel.mode == SEL_IDLE)
        return;
    if (done && sel.mode == SEL_EMPTY) {
        selclear();
        return;
    }

    oldey = sel.oe.y;
    oldex = sel.oe.x;
    oldsby = sel.nb.y;
    oldsey = sel.ne.y;
    oldtype = sel.type;

    sel.oe.x = col;
    sel.oe.y = row;
    selnormalize();
    sel.type = type;

    if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY)
        tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));

    sel.mode = done ? SEL_IDLE : SEL_READY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl 0x1309c(%rip), %eax     # 0x1a4d8
testl %eax, %eax
je 0x752a
movl %ecx, %ebx
testl %ecx, %ecx
sete %cl
cmpl $0x1, %eax
setne %al
orb %cl, %al
jne 0x7493
cmpl $-0x1, 0x13098(%rip)    # 0x1a4f4
je 0x752a
movl $0x0, 0x1306c(%rip)     # 0x1a4d8
movl $0xffffffff, 0x1307e(%rip) # imm = 0xFFFFFFFF
movl 0x1306c(%rip), %edi     # 0x1a4e8
movl 0x1306e(%rip), %esi     # 0x1a4f0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x72f4
movl %edx, %ebp
movl 0x1304c(%rip), %r14d    # 0x1a4e8
movl 0x1304d(%rip), %r15d    # 0x1a4f0
movl 0x13032(%rip), %r12d    # 0x1a4dc
movsd 0x1304a(%rip), %xmm0    # 0x1a4fc
movaps %xmm0, (%rsp)
movl %edi, 0x13040(%rip)     # 0x1a4fc
movl %esi, 0x1303e(%rip)     # 0x1a500
callq 0x71f8
movl %ebp, 0x1300f(%rip)     # 0x1a4dc
movq 0x13027(%rip), %xmm0    # 0x1a4fc
pcmpeqd (%rsp), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movmskpd %xmm0, %eax
cmpl $0x3, %eax
jne 0x74f6
cmpl %ebp, %r12d
jne 0x74f6
cmpl $0x1, 0x12fe4(%rip)     # 0x1a4d8
jne 0x751b
movl 0x12fec(%rip), %eax     # 0x1a4e8
cmpl %r14d, %eax
cmovll %eax, %r14d
movl 0x12fe7(%rip), %eax     # 0x1a4f0
cmpl %r15d, %eax
cmovgl %eax, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x72f4
xorl %eax, %eax
testl %ebx, %ebx
sete %al
addl %eax, %eax
movl %eax, 0x12fae(%rip)     # 0x1a4d8
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: tlinelen
int
tlinelen(int y)
{
    int i = term.col;

    if (TLINE(y)[i - 1].mode & ATTR_WRAP)
        return i;

    while (i > 0 && TLINE(y)[i - 1].u == ' ')
        --i;

    return i;
}

// Assembly:
movl 0x12cd0(%rip), %eax     # 0x1a50c
movslq %eax, %r8
movl 0x13c7f(%rip), %ecx     # 0x1b4c4
movl %edi, %esi
leaq 0x12cba(%rip), %rdx     # 0x1a508
subl %ecx, %esi
jge 0x7892
movl 0x13c67(%rip), %r9d     # 0x1b4c0
addl %esi, %r9d
addl $0x1f5, %r9d            # imm = 0x1F5
movslq %r9d, %r9
imulq $0x10624dd3, %r9, %r10  # imm = 0x10624DD3
movq %r10, %r11
shrq $0x3f, %r11
sarq $0x25, %r10
addl %r11d, %r10d
imull $0x1f4, %r10d, %r10d    # imm = 0x1F4
subl %r10d, %r9d
movslq %r9d, %r9
leaq (%rdx,%r9,8), %r9
addq $0x18, %r9
jmp 0x78a0
movslq %esi, %r9
shlq $0x3, %r9
addq 0x12c70(%rip), %r9      # 0x1a510
movq (%r9), %r9
movq %r8, %r10
shlq $0x4, %r10
testb $0x1, -0xb(%r9,%r10)
sete %r9b
testl %r8d, %r8d
setg %r8b
andb %r9b, %r8b
cmpb $0x1, %r8b
jne 0x7931
movslq %esi, %r8
shlq $0x3, %r8
addq 0x12c3e(%rip), %r8      # 0x1a510
movl 0x13be7(%rip), %r9d     # 0x1b4c0
addl %r9d, %esi
addl $0x1f5, %esi            # imm = 0x1F5
movslq %esi, %rsi
imulq $0x10624dd3, %rsi, %r9  # imm = 0x10624DD3
movq %r9, %r10
shrq $0x3f, %r10
sarq $0x25, %r9
addl %r10d, %r9d
imull $0x1f4, %r9d, %r9d      # imm = 0x1F4
subl %r9d, %esi
cmpl %ecx, %edi
movslq %esi, %rcx
leaq 0x18(%rdx,%rcx,8), %rcx
cmovgeq %r8, %rcx
movq (%rcx), %rcx
addq $-0x10, %rcx
movl %eax, %edx
shlq $0x4, %rdx
cmpl $0x20, (%rcx,%rdx)
jne 0x7931
leal -0x1(%rax), %edx
cmpl $0x1, %eax
movl %edx, %eax
jg 0x7919
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: ttyread
size_t
ttyread(void)
{
	static char buf[BUFSIZ];
	static int buflen = 0;
	int ret, written;

	/* append read bytes to unprocessed bytes */
	ret = twrite_aborted ? 1 : read(cmdfd, buf+buflen, LEN(buf)-buflen);

	switch (ret) {
	case 0:
		exit(0);
	case -1:
		die("couldn't read from shell: %s\n", strerror(errno));
	default:
		buflen += twrite_aborted ? 0 : ret;
		written = twrite(buf, buflen, 0);
		buflen -= written;
		/* keep any incomplete UTF-8 byte sequence for the next call */
		if (buflen > 0)
			memmove(buf, buf + written, buflen);
		return ret;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpb $0x0, 0x136fd(%rip)     # 0x1b528
je 0x7e36
movl $0x1, %ebx
xorl %esi, %esi
jmp 0x7e72
movl 0x136e4(%rip), %edi     # 0x1b520
movslq 0x156ed(%rip), %rax     # 0x1d530
leaq 0x136e6(%rip), %rsi     # 0x1b530
addq %rax, %rsi
movl $0x2000, %edx           # imm = 0x2000
subq %rax, %rdx
callq 0x61e0
cmpl $-0x1, %eax
je 0x7eba
testl %eax, %eax
je 0x7ed7
xorl %esi, %esi
cmpb $0x0, 0x136bc(%rip)     # 0x1b528
cmovel %eax, %esi
movslq %eax, %rbx
addl 0x156b8(%rip), %esi     # 0x1d530
movl %esi, 0x156b2(%rip)     # 0x1d530
leaq 0x136ab(%rip), %r14     # 0x1b530
movq %r14, %rdi
xorl %edx, %edx
callq 0x7ede
movl 0x1569b(%rip), %ecx     # 0x1d530
subl %eax, %ecx
movl %ecx, 0x15693(%rip)     # 0x1d530
jle 0x7eaf
movslq %eax, %rsi
addq %r14, %rsi
movl %ecx, %edx
movq %r14, %rdi
callq 0x6530
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x65c0
movl (%rax), %edi
callq 0x6470
leaq 0xa7cd(%rip), %rdi      # 0x1269a
movq %rax, %rsi
xorl %eax, %eax
callq 0x6f9f
xorl %edi, %edi
callq 0x6190
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: twrite
int
twrite(const char *buf, int buflen, int show_ctrl)
{
	int charsize;
	Rune u;
	int n;

	int su0 = su;
	twrite_aborted = 0;

	for (n = 0; n < buflen; n += charsize) {
		if (IS_SET(MODE_UTF8)) {
			/* process a complete utf8 char */
			charsize = utf8decode(buf + n, &u, buflen - n);
			if (charsize == 0)
				break;
		} else {
			u = buf[n] & 0xFF;
			charsize = 1;
		}
		if (su0 && !su) {
			twrite_aborted = 1;
			break;  // ESU - allow rendering before a new BSU
		}
		if (show_ctrl && ISCONTROL(u)) {
			if (u & 0x80) {
				u &= 0x7f;
				tputc('^');
				tputc('[');
			} else if (u != '\n' && u != '\r' && u != '\t') {
				u ^= 0x40;
				tputc('^');
			}
		}
		tputc(u);
	}
	return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
movb 0x125cc(%rip), %bpl     # 0x1a4c0
movb $0x0, 0x1362d(%rip)     # 0x1b528
testl %esi, %esi
jle 0x7fe2
movl %esi, %r14d
movq %rdi, %r15
xorb $0x1, %bpl
xorl %ebx, %ebx
movslq %ebx, %rdi
addq %r15, %rdi
testb $0x40, 0x135e0(%rip)    # 0x1b4fc
jne 0x7f2c
movzbl (%rdi), %eax
movl %eax, (%rsp)
movl $0x1, %r13d
jmp 0x7f48
movl %r14d, %eax
subl %ebx, %eax
movslq %eax, %rdx
movq %rsp, %rsi
callq 0xa256
movq %rax, %r13
testl %r13d, %r13d
je 0x7fed
movb 0x12572(%rip), %al      # 0x1a4c0
orb %bpl, %al
testb $0x1, %al
je 0x7fe6
movl (%rsp), %r12d
cmpl $0x0, 0x4(%rsp)
je 0x7fcc
cmpl $0x20, %r12d
setae %al
cmpl $0x7f, %r12d
setne %cl
movl %r12d, %edx
andl $-0x20, %edx
cmpl $0x80, %edx
setne %dl
andb %cl, %dl
testb %al, %dl
jne 0x7fcc
cmpl $0x80, %r12d
jae 0x7fb0
cmpl $0xd, %r12d
ja 0x7fa1
movl $0x2600, %eax           # imm = 0x2600
btl %r12d, %eax
jb 0x7fcc
xorl $0x40, %r12d
movl %r12d, (%rsp)
movl $0x5e, %edi
jmp 0x7fc7
andl $0x7f, %r12d
movl %r12d, (%rsp)
movl $0x5e, %edi
callq 0xa85b
movl $0x5b, %edi
callq 0xa85b
movl %r12d, %edi
callq 0xa85b
addl %r13d, %ebx
cmpl %r14d, %ebx
jl 0x7f0f
jmp 0x7fed
xorl %ebx, %ebx
jmp 0x7fed
movb $0x1, 0x1353b(%rip)     # 0x1b528
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: selscroll
void
selscroll(int orig, int n)
{
	if (sel.ob.x == -1 || sel.alt != IS_SET(MODE_ALTSCREEN))
		return;

	if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) {
		selclear();
	} else if (BETWEEN(sel.nb.y, orig, term.bot)) {
		sel.ob.y += n;
		sel.oe.y += n;
		if (sel.ob.y < term.top || sel.ob.y > term.bot ||
		    sel.oe.y < term.top || sel.oe.y > term.bot) {
			selclear();
		} else {
			selnormalize();
		}
	}
}

// Assembly:
cmpl $-0x1, 0x11971(%rip)    # 0x1a4f4
je 0x8c36
movl 0x11975(%rip), %eax     # 0x1a504
btl $0x2, 0x12965(%rip)     # 0x1b4fc
sbbl $0x0, %eax
jne 0x8c36
movl %edi, %ecx
movl 0x11940(%rip), %edi     # 0x1a4e8
cmpl %ecx, %edi
setge %al
movl 0x12945(%rip), %edx     # 0x1b4f8
cmpl %edx, %edi
setle %r8b
andb %al, %r8b
movl 0x1192e(%rip), %eax     # 0x1a4f0
cmpl %ecx, %eax
setl %cl
cmpl %edx, %eax
setg %r9b
orb %cl, %r9b
cmpb %r9b, %r8b
je 0x8c1b
testb %r8b, %r8b
je 0x8c36
movl 0x11918(%rip), %ecx     # 0x1a4f8
addl %esi, %ecx
movl %ecx, 0x11910(%rip)     # 0x1a4f8
addl 0x11912(%rip), %esi     # 0x1a500
movl %esi, 0x1190c(%rip)     # 0x1a500
movl 0x128f9(%rip), %r8d     # 0x1b4f4
cmpl %r8d, %ecx
jl 0x8c1b
cmpl %edx, %ecx
setg %cl
cmpl %r8d, %esi
setl %r8b
cmpl %edx, %esi
setg %dl
orb %cl, %dl
orb %r8b, %dl
cmpb $0x1, %dl
jne 0x8c37
movl $0x0, 0x118b3(%rip)     # 0x1a4d8
movl $0xffffffff, 0x118c5(%rip) # imm = 0xFFFFFFFF
movl %eax, %esi
jmp 0x72f4
retq
jmp 0x71f8
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: osc4_color_response
void
osc4_color_response(int num)
{
	int n;
	char buf[32];
	unsigned char r, g, b;

	if (xgetcolor(num, &r, &g, &b)) {
		fprintf(stderr, "erresc: failed to fetch osc4 color %d\n", num);
		return;
	}

	n = snprintf(buf, sizeof buf, "\033]4;%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
		     num, r, r, g, g, b, b);

	ttywrite(buf, n, 1);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
leaq 0xf(%rsp), %rsi
leaq 0xe(%rsp), %rdx
leaq 0xd(%rsp), %rcx
callq 0xd242
testl %eax, %eax
jne 0x8e06
movzbl 0xf(%rsp), %r8d
movzbl 0xe(%rsp), %r10d
movzbl 0xd(%rsp), %r11d
leaq 0x9937(%rip), %rdx      # 0x12700
leaq 0x10(%rsp), %r14
movl $0x20, %esi
movq %r14, %rdi
movl %ebx, %ecx
movl %r8d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r11
pushq %r10
pushq %r10
callq 0x60b0
addq $0x20, %rsp
movslq %eax, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x7ffe
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq 0x101e3(%rip), %rax     # 0x18ff0
movq (%rax), %rdi
leaq 0x98c2(%rip), %rsi      # 0x126d9
movl %ebx, %edx
xorl %eax, %eax
callq 0x68d0
jmp 0x8dfe
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: osc_color_response
void
osc_color_response(int index, int num)
{
	int n;
	char buf[32];
	unsigned char r, g, b;

	if (xgetcolor(index, &r, &g, &b)) {
		fprintf(stderr, "erresc: failed to fetch osc color %d\n", index);
		return;
	}

	n = snprintf(buf, sizeof buf, "\033]%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
		     num, r, r, g, g, b, b);

	ttywrite(buf, n, 1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movl %esi, %ebx
movl %edi, %ebp
leaq 0xf(%rsp), %rsi
leaq 0xe(%rsp), %rdx
leaq 0xd(%rsp), %rcx
callq 0xd242
testl %eax, %eax
jne 0x8e9d
movzbl 0xf(%rsp), %r8d
movzbl 0xe(%rsp), %r10d
movzbl 0xd(%rsp), %r11d
leaq 0x98ee(%rip), %rdx      # 0x1274d
leaq 0x10(%rsp), %r14
movl $0x20, %esi
movq %r14, %rdi
movl %ebx, %ecx
movl %r8d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r11
pushq %r10
pushq %r10
callq 0x60b0
addq $0x20, %rsp
movslq %eax, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x7ffe
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x1014c(%rip), %rax     # 0x18ff0
movq (%rax), %rdi
leaq 0x9879(%rip), %rsi      # 0x12727
movl %ebp, %edx
xorl %eax, %eax
callq 0x68d0
jmp 0x8e94
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: drawregion
void
drawregion(int x1, int y1, int x2, int y2)
{
	int y;

	for (y = y1; y < y2; y++) {
		if (!term.dirty[y])
			continue;

		term.dirty[y] = 0;
		xdrawline(TLINE(y), x1, y, x2);
	}
}

// Assembly:
cmpl %edx, %edi
jge 0x9a8b
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movl %esi, %ebp
movslq %edi, %r14
movq 0x11ae0(%rip), %rax     # 0x1b4c8
leaq (,%r14,8), %r15
leaq 0x10b11(%rip), %r12     # 0x1a508
cmpl $0x0, (%rax,%r14,4)
je 0x9a73
movl $0x0, (%rax,%r14,4)
movslq 0x11ab7(%rip), %rcx     # 0x1b4c4
cmpq %rcx, %r14
jge 0x9a4c
movl 0x11aa8(%rip), %eax     # 0x1b4c0
subl %ecx, %eax
addl %r14d, %eax
addl $0x1f5, %eax            # imm = 0x1F5
cltq
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x1f4, %ecx, %ecx      # imm = 0x1F4
subl %ecx, %eax
cltq
leaq (%r12,%rax,8), %rax
addq $0x18, %rax
jmp 0x9a5d
movq 0x10abd(%rip), %rax     # 0x1a510
shlq $0x3, %rcx
subq %rcx, %rax
addq %r15, %rax
movq (%rax), %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebp, %ecx
callq 0xd792
movq 0x11a55(%rip), %rax     # 0x1b4c8
incq %r14
addq $0x8, %r15
cmpl %r14d, %ebx
jne 0x99f7
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: select_or_drawcursor
void select_or_drawcursor(int selectsearch_mode, int type) {
	int done = 0;

	if ( selectsearch_mode & 1 ) {
		selextend(term.c.x, term.c.y, type, done);
		xsetsel(getsel());
	}
	else
		xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x],
			    term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
}

// Assembly:
subq $0x28, %rsp
movl %esi, %edx
movl %edi, %eax
movslq 0x113fc(%rip), %rdi     # 0x1b4e0
movslq 0x113f9(%rip), %rsi     # 0x1b4e4
testb $0x1, %al
jne 0xa140
movq 0x1041a(%rip), %rax     # 0x1a510
movq (%rax,%rsi,8), %rcx
movq %rdi, %r10
shlq $0x4, %r10
movslq 0x113e4(%rip), %r8      # 0x1b4ec
movslq 0x113e1(%rip), %r9      # 0x1b4f0
movq (%rax,%r9,8), %rax
movq %r8, %r11
shlq $0x4, %r11
movq (%rcx,%r10), %rdx
movq 0x8(%rcx,%r10), %rcx
movups (%rax,%r11), %xmm0
movaps %xmm0, 0x10(%rsp)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xd2ff
addq $0x28, %rsp
retq
xorl %ecx, %ecx
callq 0x742a
callq 0x75c3
movq %rax, %rdi
addq $0x28, %rsp
jmp 0xcf5e
// File: /workspace/github_c_makefile_star2_O3/mrdotx[P]st/st.c
// Function: search
void search(int selectsearch_mode, Rune *target, int ptarget, int incr, int type, TCursor *cu) {
	Rune *r;
	int i, bound = (term.col * cu->y + cu->x) * (incr > 0) + incr;

	for (i = term.col * term.c.y + term.c.x + incr; i != bound; i += incr) {
		for (r = target; r - target < ptarget; r++) {
			if ( *r == term.line[(i + r - target) / term.col][(i + r - target) % term.col].u ) {
				if ( r - target == ptarget - 1 )     break;
			} else {
				r = NULL;
				break;
			}
		}
		if ( r != NULL )    break;
	}

	if ( i != bound ) {
		term.c.y = i / term.col, term.c.x = i % term.col;
		select_or_drawcursor(selectsearch_mode, type);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r8d, -0xc(%rsp)
movl %edx, %r10d
movl %edi, -0x10(%rsp)
movslq 0x10397(%rip), %r11     # 0x1a50c
movl 0x14(%r9), %eax
imull %r11d, %eax
addl 0x10(%r9), %eax
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %eax
movl 0x11356(%rip), %edx     # 0x1b4e4
imull %r11d, %edx
addl 0x11348(%rip), %edx     # 0x1b4e0
movslq %r10d, %rbx
movq 0x1036e(%rip), %r14     # 0x1a510
leal -0x1(%rbx), %edi
movslq %edi, %r15
movslq %edx, %r9
movslq %ecx, %rcx
movslq %eax, %r12
leaq (,%rcx,4), %rax
movq %rax, -0x8(%rsp)
leaq (,%r9,4), %rax
leaq (%rax,%rcx,4), %rbp
cmpq %r12, %r9
je 0xa24b
addq %rcx, %r9
movq %rsi, %rax
testl %r10d, %r10d
jle 0xa217
xorl %r8d, %r8d
xorl %r13d, %r13d
movl (%rsi,%r8), %edi
leaq (%r8,%rbp), %rax
sarq $0x2, %rax
cqto
idivq %r11
movq (%r14,%rax,8), %rax
shlq $0x4, %rdx
cmpl (%rax,%rdx), %edi
jne 0xa215
cmpq %r15, %r13
je 0xa221
addq $0x4, %r8
movq %r8, %r13
sarq $0x2, %r13
cmpq %rbx, %r13
jl 0xa1e0
jmp 0xa221
xorl %eax, %eax
addq -0x8(%rsp), %rbp
testq %rax, %rax
je 0xa1ca
movl %r9d, %eax
cltd
idivl %r11d
movl %eax, 0x112b6(%rip)     # 0x1b4e4
movl %edx, 0x112ac(%rip)     # 0x1b4e0
movl -0x10(%rsp), %edi
movl -0xc(%rsp), %esi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa0d5
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq