LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/ckh.c
// Function: je_ckh_delete
void
ckh_delete(tsd_t *tsd, ckh_t *ckh)
{

	assert(ckh != NULL);

#ifdef CKH_VERBOSE
	malloc_printf(
	    "%s(%p): ngrows: %"FMTu64", nshrinks: %"FMTu64","
	    " nshrinkfails: %"FMTu64", ninserts: %"FMTu64","
	    " nrelocs: %"FMTu64"\n", __func__, ckh,
	    (unsigned long long)ckh->ngrows,
	    (unsigned long long)ckh->nshrinks,
	    (unsigned long long)ckh->nshrinkfails,
	    (unsigned long long)ckh->ninserts,
	    (unsigned long long)ckh->nrelocs);
#endif

	idalloctm(tsd_tsdn(tsd), ckh->tab, NULL, true, true);
	if (config_debug)
		memset(ckh, JEMALLOC_FREE_JUNK, sizeof(ckh_t));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x28(%rsi), %rbx
leaq 0x16832(%rip), %r12     # 0x490d0
movq (%r12), %rax
notq %rax
andq %rbx, %rax
cmpq %rax, %rbx
je 0x32946
movq (%rax), %r15
cmpq %rax, %rbx
je 0x32960
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x166f2(%rip), %rdx     # 0x48fc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x32983
movl %ecx, %eax
leaq 0x394d(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%r15)
movq (%r12), %rdx
notq %rdx
andq %rbx, %rdx
movq %rbx, %r8
subq %rdx, %r8
je 0x3296d
shrq $0xc, %r8
leaq 0x166a0(%rip), %rax     # 0x48fc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
movq %r14, %rdi
movq %rbx, %rcx
jne 0x32997
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1ca94
movq %rbx, %rdi
callq 0x28ce3
movq %rax, %r15
movq (%r12), %rax
notq %rax
andq %rbx, %rax
jmp 0x328b4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x292e1
jmp 0x328f7
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x28fb2
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x328f7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1cc1f
// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/ckh.c
// Function: ckh_try_bucket_insert
JEMALLOC_INLINE_C bool
ckh_try_bucket_insert(ckh_t *ckh, size_t bucket, const void *key,
    const void *data)
{
	ckhc_t *cell;
	unsigned offset, i;

	/*
	 * Cycle through the cells in the bucket, starting at a random position.
	 * The randomness avoids worst-case search overhead as buckets fill up.
	 */
	offset = (unsigned)prng_lg_range_u64(&ckh->prng_state,
	    LG_CKH_BUCKET_CELLS);
	for (i = 0; i < (ZU(1) << LG_CKH_BUCKET_CELLS); i++) {
		cell = &ckh->tab[(bucket << LG_CKH_BUCKET_CELLS) +
		    ((i + offset) & ((ZU(1) << LG_CKH_BUCKET_CELLS) - 1))];
		if (cell->key == NULL) {
			cell->key = key;
			cell->data = data;
			ckh->count++;
			return (false);
		}
	}

	return (true);
}

// Assembly:
movabsq $0x5851f42d4c957f2d, %r8 # imm = 0x5851F42D4C957F2D
imulq (%rdi), %r8
movabsq $0x14057b7ef767814f, %rax # imm = 0x14057B7EF767814F
addq %r8, %rax
movq %rax, (%rdi)
shrq $0x3e, %rax
movq 0x28(%rdi), %r8
shlq $0x2, %rsi
xorl %r11d, %r11d
movl %r11d, %r9d
cmpl $0x4, %r11d
je 0x33a01
leal (%rax,%r9), %r10d
andl $0x3, %r10d
orq %rsi, %r10
shlq $0x4, %r10
leal 0x1(%r9), %r11d
cmpq $0x0, (%r8,%r10)
jne 0x339d0
addq %r10, %r8
movq %rdx, (%r8)
movq %rcx, 0x8(%r8)
incq 0x8(%rdi)
cmpl $0x4, %r9d
setae %al
retq
// File: /workspace/github_c_makefile_star2_O2/keiranrowan[P]tiny-core/./src/wc.c
// Function: help
void help() {
	printf("wc [-w|-c|-l] [FILE]...\n");
	printf("    -w = Print word count\n");
	printf("    -c = Print character count\n");
	printf("    -l = Print line count\n");
}

// Assembly:
pushq %rax
leaq 0xb95(%rip), %rdi       # 0x2030
callq 0x1030
leaq 0xba1(%rip), %rdi       # 0x2048
callq 0x1030
leaq 0xbaf(%rip), %rdi       # 0x2062
callq 0x1030
leaq 0xbc2(%rip), %rdi       # 0x2081
popq %rax
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O2/openshmem-org[P]openshmem-examples/c/addr-accessible.c
// Function: main
int
main(void)
{
    long local_target;
    int *shm_target;
    int me;

    shmem_init();
    me = shmem_my_pe();

    shm_target = (int *) shmem_malloc(sizeof(int));

    if (me == 0) {
        char *msg = "OK";

        if (! check_it(&global_target)) {    /* long global: yes */
            msg = "FAIL (global long)";
        }
        if (! check_it(&static_target)) {    /* static int global: yes */
            msg = "FAIL (static int)";
        }
        if (! check_it(&local_target)) {  /* main() stack: no */
            msg = "FAIL (stack variable)";
        }
        if (! check_it(shm_target)) {    /* shmem_malloc: yes */
            msg = "FAIL (shmem_malloc)";
        }

        puts(msg);

    }

    shmem_free(shm_target);

    shmem_finalize();

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x1080
callq 0x1060
movl %eax, %ebp
pushq $0x4
popq %rdi
callq 0x1070
movq %rax, %rbx
testl %ebp, %ebp
jne 0x1226
leaq 0x2ea3(%rip), %rdi      # 0x4068
callq 0x1240
testl %eax, %eax
leaq 0xe34(%rip), %rax       # 0x2007
leaq 0xe2a(%rip), %r14       # 0x2004
cmoveq %rax, %r14
leaq 0x2e8b(%rip), %rdi      # 0x4070
callq 0x1240
testl %eax, %eax
leaq 0xe27(%rip), %r15       # 0x201a
cmovneq %r14, %r15
movq %rsp, %rdi
callq 0x1240
testl %eax, %eax
leaq 0xe24(%rip), %r14       # 0x202c
cmovneq %r15, %r14
movq %rbx, %rdi
callq 0x1240
testl %eax, %eax
leaq 0xe25(%rip), %rdi       # 0x2042
cmovneq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1090
callq 0x1050
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/arch/amd64.c
// Function: amd64_regfile_pp
void amd64_regfile_pp(regfile_amd64_t *regfile)
{
	printf("\tRegisters:\n");
	char *gpr_string[] = {"rdi",
	                     "rsi",
	                     "rsp",
	                     "rbp",
	                     "rbx",
	                     "rdx",
	                     "rcx",
	                     "rax",
	                     "r8 ",
	                     "r9 ",
	                     "r10",
	                     "r11",
	                     "r12",
	                     "r13",
	                     "r14",
	                     "r15",
	                     "rflags",
	                     "rip"};

	for (int x=0; x<18; x++)
	{
		printf("\t  %s: %" PRIx64 "\n", gpr_string[x], ((uint64_t *)&(regfile->gpr))[x]);
	}
	printf("\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1d91(%rip), %rdi      # 0x515b
callq 0x30d0
leaq 0x1d92(%rip), %r15      # 0x5168
leaq 0x1d72(%rip), %r14      # 0x514f
xorl %r12d, %r12d
cmpq $0x48, %r12
je 0x3401
movslq (%r12,%r15), %rsi
addq %r15, %rsi
movq (%rbx,%r12,2), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x3140
addq $0x4, %r12
jmp 0x33e0
pushq $0xa
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3080
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/arch/amd64_syscall.c
// Function: amd64_syscall_pp
int amd64_syscall_pp(regfile_amd64_t *regfile, uint64_t rvalue, bool print_details)
{
	const uint64_t syscall_id = regfile->gpr.reg_rax;
	if (syscall_id >= sizeof(syscall_infos)/sizeof(struct_syscall_info))
	{
		// Unrecognized syscall ID. Return.
		printf("syscall %lu", syscall_id);
		return -1;
	}
	const struct_syscall_info *syscall_info = &syscall_infos[syscall_id];

	if (!print_details)
	{
		// Just print what syscall is this. Job done!
		printf("syscall %s (%lu)", syscall_info->sys_name, syscall_id);
		return 0;
	}
	
	// Print arguments and rvalue.
	printf("%s(", syscall_info->sys_name);
	assert(syscall_info->nargs <= sizeof(args_offset)/sizeof(uint64_t));
	unsigned int arg_idx;
	for (arg_idx = 0; arg_idx < syscall_info->nargs; arg_idx++)
	{
		if (arg_idx != 0) printf(", ");
		printf("0x%lx", ((uint64_t *)&regfile->gpr)[args_offset[arg_idx]]);
	}
	printf(") = 0x%lx", rvalue);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x38(%rdi), %rax
cmpq $0x14f, %rax            # imm = 0x14F
jb 0x3444
leaq 0x1d7e(%rip), %rdi      # 0x51b0
movq %rax, %rsi
xorl %eax, %eax
callq 0x3140
pushq $-0x1
popq %rbp
jmp 0x34f3
movq %rsi, %r8
movq %rax, %rcx
shlq $0x4, %rcx
leaq 0x54bb(%rip), %rbx      # 0x8910
movq 0x8(%rcx,%rbx), %rsi
testb %dl, %dl
je 0x34ca
movq %rdi, %r14
movq %r8, (%rsp)
addq %rcx, %rbx
leaq 0x1d5e(%rip), %rdi      # 0x51cd
xorl %eax, %eax
callq 0x3140
movl (%rbx), %r13d
cmpq $0x6, %r13
ja 0x3504
shlq $0x3, %r13
leaq 0x29e2(%rip), %rbp      # 0x5e70
leaq 0x1dcd(%rip), %r15      # 0x5262
leaq 0x1dbf(%rip), %r12      # 0x525b
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x34df
testq %rbx, %rbx
je 0x34b2
movq %r12, %rdi
xorl %eax, %eax
callq 0x3140
movq (%rbx,%rbp), %rax
movq (%r14,%rax,8), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x3140
addq $0x8, %rbx
jmp 0x349e
leaq 0x1ceb(%rip), %rdi      # 0x51bc
xorl %ebp, %ebp
movq %rax, %rdx
xorl %eax, %eax
callq 0x3140
jmp 0x34f3
leaq 0x1d78(%rip), %rdi      # 0x525e
xorl %ebp, %ebp
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3140
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cc6(%rip), %rdi      # 0x51d1
leaq 0x1cfb(%rip), %rsi      # 0x520d
leaq 0x1d09(%rip), %rcx      # 0x5222
movl $0x185, %edx            # imm = 0x185
callq 0x3170
nop
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: create_folder
int create_folder(char *name, char *output, uint32_t max_size)
{
	DIR *dir = opendir(name);
	char *resolved_name = realpath(name, output);
	if (errno == ENOENT)
		mkdir(name, S_IRWXU|S_IRWXG|S_IROTH);
	else
		return -1;
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3110
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31f0
callq 0x3090
cmpl $0x2, (%rax)
jne 0x35a5
movq %rbx, %rdi
movl $0x1fc, %esi            # imm = 0x1FC
callq 0x30c0
xorl %eax, %eax
jmp 0x35a8
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: term_dir
int term_dir(char *path, int size)
{
	int path_len = strlen(path);
	// check if directory terminates with '/'
	if (path[path_len-1] != '/')
	{
		if (path_len > MAX_PATH-1) return -1;

		path[path_len] = '/';
		path[path_len+1] = 0;
	}
	return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x3130
movq %rax, %rcx
movq %rax, %rdx
shlq $0x20, %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rdx, %rsi
sarq $0x20, %rsi
xorl %eax, %eax
cmpb $0x2f, (%rbx,%rsi)
je 0x3609
cmpl $0xff, %ecx
jle 0x35e9
pushq $-0x1
popq %rax
jmp 0x3609
movq %rdx, %rcx
sarq $0x20, %rcx
movb $0x2f, (%rbx,%rcx)
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rdx, %rcx
sarq $0x20, %rcx
movb $0x0, (%rbx,%rcx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: join_path
int join_path(char *dir_path, char *filename, int size)
{
	if (!term_dir(dir_path, size))
	{
		int dir_len;
		int file_len;

		dir_len = strlen(dir_path);
		file_len = strlen(filename);

		if (dir_len + file_len >= size) return -1;
		strncat(dir_path, filename, size);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0x30f0
xorl %ebx, %ebx
testl %eax, %eax
jne 0x3653
movq %r15, %rdi
callq 0x3130
movq %rax, %r12
movq %r14, %rdi
callq 0x3130
addl %r12d, %eax
cmpl %ebp, %eax
jge 0x3650
movslq %ebp, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3190
jmp 0x3653
pushq $-0x1
popq %rbx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: create_trace_file
int create_trace_file(char *dir_path, char *filename, int size, FILE **output)
{
	char path[MAX_PATH];

	strncpy(path, dir_path, MAX_PATH);
	if (join_path(path, filename, size)) return -1;
	*output = fopen(path, "wb");
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rsi
movq %rsp, %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
callq 0x30a0
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x3180
testl %eax, %eax
je 0x369c
pushq $-0x1
popq %rax
jmp 0x36b0
leaq 0x2845(%rip), %rsi      # 0x5ee8
movq %rsp, %rdi
callq 0x3270
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: close_trace
void close_trace(peekaboo_trace_t *trace_ptr)
{
	fflush(trace_ptr->insn_trace);
	fflush(trace_ptr->bytes_map);
	fflush(trace_ptr->regfile);
	fflush(trace_ptr->memfile);
	fflush(trace_ptr->memrefs);
	//fflush(trace_ptr->metafile);

	fclose(trace_ptr->insn_trace);
	fclose(trace_ptr->bytes_map);
	fclose(trace_ptr->regfile);
	fclose(trace_ptr->memfile);
	fclose(trace_ptr->memrefs);
	//fclose(trace_ptr->metafile);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3220
movq 0x8(%rbx), %rdi
callq 0x3220
movq 0x10(%rbx), %rdi
callq 0x3220
movq 0x20(%rbx), %rdi
callq 0x3220
movq 0x18(%rbx), %rdi
callq 0x3220
movq (%rbx), %rdi
callq 0x3100
movq 0x8(%rbx), %rdi
callq 0x3100
movq 0x10(%rbx), %rdi
callq 0x3100
movq 0x20(%rbx), %rdi
callq 0x3100
movq 0x18(%rbx), %rdi
popq %rbx
jmp 0x3100
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: create_trace
peekaboo_trace_t *create_trace(char *name)
{
	char dir_path[MAX_PATH];
	peekaboo_trace_t *trace_ptr;

	if (create_folder(name, dir_path, MAX_PATH)) 
	{
		return NULL;
	}

	trace_ptr = (peekaboo_trace_t *)malloc(sizeof(peekaboo_trace_t));
	if (!trace_ptr) PEEKABOO_DIE("libpeekaboo: Unable to malloc trace instance.\n");

	create_trace_file(dir_path, "insn.trace", MAX_PATH, &trace_ptr->insn_trace);
	create_trace_file(dir_path, "regfile", MAX_PATH, &trace_ptr->regfile);
	create_trace_file(dir_path, "memfile", MAX_PATH, &trace_ptr->memfile);
	create_trace_file(dir_path, "memrefs", MAX_PATH, &trace_ptr->memrefs);
	create_trace_file(dir_path, "metafile", MAX_PATH, &trace_ptr->metafile);

	/* Since version 2, insn.bytemap is shared by all threads. So we do not create
	 * here.
	 */
	//create_trace_file(dir_path, "insn.bytemap", MAX_PATH, &trace_ptr->bytes_map);


	return trace_ptr;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsp, %rsi
callq 0x3060
testl %eax, %eax
je 0x3738
xorl %ebx, %ebx
jmp 0x37c9
pushq $0x40
popq %rdi
callq 0x3210
testq %rax, %rax
je 0x37d7
movq %rax, %rbx
leaq 0x27c7(%rip), %rsi      # 0x5f1a
movq %rsp, %r14
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
movq %rax, %rcx
callq 0x3030
leaq 0x10(%rbx), %rcx
leaq 0x27b4(%rip), %rsi      # 0x5f25
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
leaq 0x20(%rbx), %rcx
leaq 0x27a4(%rip), %rsi      # 0x5f2d
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
leaq 0x18(%rbx), %rcx
leaq 0x2794(%rip), %rsi      # 0x5f35
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
movq %rbx, %rcx
addq $0x28, %rcx
leaq 0x2781(%rip), %rsi      # 0x5f3d
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
retq
movq 0x6812(%rip), %rax      # 0x9ff0
movq (%rax), %rcx
leaq 0x2703(%rip), %rdi      # 0x5eeb
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3280
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: load_bytes_map
void load_bytes_map(peekaboo_trace_t *trace)
{
	fseek(trace->bytes_map, 0, SEEK_END);
	size_t bytesmap_size = ftell(trace->bytes_map);
	size_t num_maps = bytesmap_size / sizeof(bytes_map_t);

	trace->internal->bytes_map_buf = malloc(bytesmap_size);
	trace->internal->bytes_map_size = bytesmap_size;

	rewind(trace->bytes_map);
	printf("Found %lu instructions in bytemap...\n", num_maps);
	if (fread(trace->internal->bytes_map_buf, sizeof(bytes_map_t), num_maps, trace->bytes_map) != num_maps)
	{
		PEEKABOO_DIE("libpeekaboo: BYTES MAP READ ERROR!\n");
	}
	printf("\n");
	return ;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x3240
movq 0x8(%rbx), %rdi
callq 0x31d0
movq %rax, %r15
movq %rax, %r14
shrq $0x5, %r14
movq %rax, %rdi
callq 0x3210
movq 0x38(%rbx), %rcx
movq %rax, 0x18(%rcx)
movq %r15, 0x20(%rcx)
movq 0x8(%rbx), %rdi
callq 0x3150
leaq 0x26fe(%rip), %rdi      # 0x5f46
movq %r14, %rsi
xorl %eax, %eax
callq 0x3140
movq 0x8(%rbx), %rcx
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rdi
pushq $0x20
popq %rsi
movq %r14, %rdx
callq 0x30e0
cmpq %r14, %rax
jne 0x387b
pushq $0xa
popq %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3080
movq 0x676e(%rip), %rax      # 0x9ff0
movq (%rax), %rcx
leaq 0x26e0(%rip), %rdi      # 0x5f6c
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3280
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: find_bytes_map
bytes_map_t *find_bytes_map(uint64_t pc, peekaboo_trace_t *trace)
{
	bytes_map_t *bytes_map_buf = trace->internal->bytes_map_buf;
	size_t map_size = trace->internal->bytes_map_size;
	size_t num_maps = map_size / sizeof(bytes_map_t);
	int x;
	for (x=0; x<num_maps; x++)
	{
		if ((bytes_map_buf+x)->pc == pc)
			return bytes_map_buf+x;
	}

	return NULL;
}

// Assembly:
movq 0x38(%rsi), %rax
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rdx
shrq $0x5, %rdx
incq %rdx
addq $-0x20, %rcx
decq %rdx
je 0x38c9
leaq 0x20(%rcx), %rax
cmpq %rdi, 0x20(%rcx)
movq %rax, %rcx
jne 0x38b6
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: get_addr
uint64_t get_addr(size_t id, peekaboo_trace_t *trace)
{
	if (!id) PEEKABOO_DIE("libpeekaboo: Error. Instruction index 0 is not accepted.\n");

	uint64_t addr = 0;
	size_t ptr_size = get_ptr_size(trace);

	fseek(trace->insn_trace, (id-1) * ptr_size, SEEK_SET);
	size_t fread_bytes = fread(&addr, ptr_size, 1, trace->insn_trace);
	return addr;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x393b
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x8(%rsp), %r14
andq $0x0, (%r14)
movq (%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %r15
decq %rsi
imulq %r15, %rsi
xorl %edx, %edx
callq 0x3240
movq (%rbx), %rcx
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x30e0
movq (%r14), %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x66ae(%rip), %rax      # 0x9ff0
movq (%rax), %rcx
leaq 0x2644(%rip), %rdi      # 0x5f90
pushq $0x39
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3280
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: get_num_mem
size_t get_num_mem(size_t id, peekaboo_trace_t *trace)
{
	if (!id) PEEKABOO_DIE("libpeekaboo: Error. Instruction index 0 is not accepted.\n");

	size_t num_mem = 0;
	fseek(trace->memrefs, (id-1) * sizeof(memref_t), SEEK_SET);
	size_t fread_bytes = fread(&num_mem, sizeof(memref_t), 1, trace->memrefs);
	return num_mem;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x39a5
movq %rsi, %rbx
movq %rsp, %r14
andq $0x0, (%r14)
movq 0x18(%rsi), %rax
leaq -0x4(,%rdi,4), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x3240
movq 0x18(%rbx), %rcx
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x30e0
movq (%r14), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x6644(%rip), %rax      # 0x9ff0
movq (%rax), %rcx
leaq 0x25da(%rip), %rdi      # 0x5f90
pushq $0x39
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3280
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: free_peekaboo_trace
void free_peekaboo_trace(peekaboo_trace_t *trace_ptr)
{
	fclose(trace_ptr->bytes_map);
	fclose(trace_ptr->insn_trace);
	fclose(trace_ptr->regfile);
	fclose(trace_ptr->memfile);
	fclose(trace_ptr->memrefs);
	if (trace_ptr->memrefs_offsets)	fclose(trace_ptr->memrefs_offsets);
	free(trace_ptr->internal->bytes_map_buf);
	free(trace_ptr->internal);
	free(trace_ptr);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x3100
movq (%rbx), %rdi
callq 0x3100
movq 0x10(%rbx), %rdi
callq 0x3100
movq 0x20(%rbx), %rdi
callq 0x3100
movq 0x18(%rbx), %rdi
callq 0x3100
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x4019
callq 0x3100
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x3070
movq 0x38(%rbx), %rdi
callq 0x3070
movq %rbx, %rdi
popq %rbx
jmp 0x3070
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: write_metadata
void write_metadata(peekaboo_trace_t *trace_ptr, enum ARCH arch, uint32_t version)
{
	metadata_hdr_t metadata;
	metadata.arch = arch;
	metadata.version = version;
	if (arch == ARCH_AMD64)
	{
		#ifdef _STORE_SIMD
			metadata.storage_options.amd64.has_simd = 1;
		#else
			metadata.storage_options.amd64.has_simd = 0;
		#endif
		#ifdef _STORE_FXSAVE
			metadata.storage_options.amd64.has_fxsave = 1;
		#else
			metadata.storage_options.amd64.has_fxsave = 0;
		#endif
	}
	fwrite(&metadata, sizeof(metadata_hdr_t), 1, trace_ptr->metafile);
	fflush(trace_ptr->metafile);
	fclose(trace_ptr->metafile);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl %esi, (%rsp)
movl %edx, 0x4(%rsp)
cmpl $0x3, %esi
jne 0x405b
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%rsp)
movq 0x28(%rbx), %rcx
movq %rsp, %rdi
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
movq 0x28(%rbx), %rdi
callq 0x3220
movq 0x28(%rbx), %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x3100
// File: /workspace/github_c_makefile_star2_O2/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: regfile_pp
void regfile_pp(peekaboo_insn_t *insn)
{
	switch (insn->arch)
	{
		case ARCH_AMD64:
			amd64_regfile_pp(insn->regfile);
			break;
		case ARCH_AARCH64:
			aarch64_regfile_pp(insn->regfile);
			break;
		case ARCH_X86:
			x86_regfile_pp(insn->regfile);
			break;
		default:
			PEEKABOO_DIE("libpeekaboo: Unsupported Architecture!\n");
			break;
	}
}

// Assembly:
movl 0x128(%rdi), %eax
cmpl $0x1, %eax
je 0x428a
cmpl $0x2, %eax
je 0x427e
cmpl $0x3, %eax
jne 0x4296
movq 0x130(%rdi), %rdi
jmp 0x3120
movq 0x130(%rdi), %rdi
jmp 0x3200
movq 0x130(%rdi), %rdi
jmp 0x3040
pushq %rax
movq 0x5d52(%rip), %rax      # 0x9ff0
movq (%rax), %rcx
leaq 0x1fcd(%rip), %rdi      # 0x6275
pushq $0x27
popq %rsi
pushq $0x1
popq %rdx
callq 0x3290
pushq $0x1
popq %rdi
callq 0x3280
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/error.c
// Function: nrt_append_error
void nrt_append_error(nrt_error *error, char *msg) {
  if (error->count >= NRT_MAX_ERRORS) {
    fprintf(stderr, "Cannot add additional errors.\n");
    exit(EXIT_FAILURE);
  }

  int len = strlen(msg);

  error->errors[error->count] = (char*)malloc(len + 1);
  strcpy(error->errors[error->count], msg);
  error->count++;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq (%rdi), %r15
cmpq $0x10, %r15
jge 0x24e9
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2110
incl %eax
movslq %eax, %rdi
callq 0x2240
movq %rax, 0x8(%rbx,%r15,8)
movq %rax, %rdi
movq %r14, %rsi
callq 0x20a0
leal 0x1(%r15), %eax
movl %eax, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
movq 0x8b08(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x3b0a(%rip), %rdi      # 0x6004
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
pushq $0x1
popq %rdi
callq 0x2330
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/util.c
// Function: nrt_validate_file
void nrt_validate_file(FILE *rom, nrt_error *error) {
  nrt_header *header = NRT_HEADER_ALLOC;
  char msg[256] = "";

  if (! fread(header, 1, sizeof(nrt_header), rom) ) {
    nrt_append_error(error, "Failed to read header from file.");
    return;
  }

  if (! nrt_validate_header_magic_word(header)) {
    sprintf(msg, "Magic word does not match: %s", header->magic_word);
    nrt_append_error(error, msg);
  }

  if (! nrt_validate_header_prg_count(header)) {
    sprintf(msg, "PRG count is invalid: %d", header->prg_count);
    nrt_append_error(error, msg);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r15
pushq $0x10
popq %r12
movq %r12, %rdi
callq 0x2240
movq %rax, %r14
movq %rsp, %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2180
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x20c0
testq %rax, %rax
je 0x25c5
movq %r14, %rdi
callq 0x264f
testb %al, %al
jne 0x2586
leaq 0x3ad9(%rip), %rsi      # 0x6044
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2320
movq %rbx, %rdi
movq %r15, %rsi
callq 0x24a7
movq %r14, %rdi
callq 0x2666
testb %al, %al
jne 0x25b6
movzbl 0x4(%r14), %edx
leaq 0x3ac4(%rip), %rsi      # 0x6062
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2320
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24a7
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x3a57(%rip), %rsi      # 0x6023
movq %rbx, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x24a7
nop
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/header.c
// Function: nrt_header_create
nrt_header* nrt_header_create(int prg_count, int chr_count) {
  nrt_header* header = NRT_HEADER_ALLOC;

  memcpy(header->magic_word, NRT_MAGIC_WORD, NRT_MAGIC_WORD_SIZE);

  header->prg_count = prg_count;
  header->chr_count = chr_count;

  return header;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
pushq $0x10
popq %rdi
callq 0x2240
movl $0x1a53454e, (%rax)     # imm = 0x1A53454E
movb %bpl, 0x4(%rax)
movb %bl, 0x5(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/tile.c
// Function: nrt_tile_to_bitmap
void nrt_tile_to_bitmap(nrt_tile *tile, nrt_tile_bitmap *bitmap) {
  int i, j;

  // iterate over each byte (row of pixels)
  for (i = 0; i < NRT_TILE_CHANNEL_SIZE; i++) {
    // now, let's iterate over the bits in the row and write the pixels
    for (j = 0; j < 8; j++) {
      int pixel_offset = (i * NRT_TILE_WIDTH_PX) + j;
      bitmap->pixels[pixel_offset] = nrt_get_tile_pixel(i, j, tile);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
cmpq $0x8, %r15
je 0x2700
xorl %r12d, %r12d
cmpq $0x8, %r12
je 0x26f7
movl %r15d, %edi
movl %r12d, %esi
movq %r14, %rdx
callq 0x270c
movb %al, (%rbx,%r12)
incq %r12
jmp 0x26da
incq %r15
addq $0x8, %rbx
jmp 0x26d1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/tile.c
// Function: nrt_bitmap_to_tile
void nrt_bitmap_to_tile(nrt_tile_bitmap *bitmap, nrt_tile *tile) {
  // iterate over the bitmap pixels
  int x, y;
  int pixel;

  for (y = 0; y < NRT_TILE_HEIGHT_PX; y++) {
    for (x = 0; x < NRT_TILE_WIDTH_PX; x++) {
      // shift the current byte over first
      tile->chan_a[y] <<= 1;
      tile->chan_b[y] <<= 1;

      // write the bit to each channel
      pixel = bitmap->pixels[x + (y * NRT_TILE_WIDTH_PX)];
      tile->chan_a[y] += pixel & 1;
      tile->chan_b[y] += pixel >> 1 & 1;
    }
  }
}

// Assembly:
xorl %eax, %eax
cmpq $0x8, %rax
je 0x2784
movb (%rsi,%rax), %cl
movb 0x8(%rsi,%rax), %dl
xorl %r8d, %r8d
cmpq $0x8, %r8
je 0x277b
addb %cl, %cl
movb %cl, (%rsi,%rax)
addb %dl, %dl
movb %dl, 0x8(%rsi,%rax)
movb (%rdi,%r8), %r9b
movl %r9d, %r10d
andb $0x1, %r10b
orb %r10b, %cl
movb %cl, (%rsi,%rax)
shrb %r9b
andb $0x1, %r9b
orb %r9b, %dl
movb %dl, 0x8(%rsi,%rax)
incq %r8
jmp 0x2746
incq %rax
addq $0x8, %rdi
jmp 0x2736
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt/title.c
// Function: nrt_read_title_from_file
int nrt_read_title_from_file(FILE* rom, nrt_header* header, char* buf) {
  // first seek to end of file
  int offset = NRT_HEADER_SIZE + (header->prg_count * NRT_PRG_BANK_SIZE) + (header->chr_count * NRT_CHR_BANK_SIZE);

  fseek(rom, offset, SEEK_SET);

  return fread(buf, NRT_TITLE_MAX_LENGTH, 1, rom);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movzbl 0x4(%rsi), %eax
shll $0xe, %eax
movzbl 0x5(%rsi), %ecx
shll $0xd, %ecx
leaq (%rcx,%rax), %rsi
addq $0x10, %rsi
xorl %edx, %edx
callq 0x2280
pushq $0x1
popq %rdx
movl $0xff, %esi
movq %rbx, %rdi
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20c0
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_prg_list_create
nrt_prg_list* nrt_prg_list_create(void)
{
  nrt_prg_list* list = (nrt_prg_list*)malloc(sizeof(nrt_prg_list));
  list->count = 0;
  list->list = NULL;

  return list;
}

// Assembly:
pushq %rax
pushq $0x10
popq %rdi
callq 0x2240
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_prg_listitem_create
nrt_prg_listitem* nrt_prg_listitem_create(nrt_prgbank* prg, nrt_prg_listitem* next)
{
  nrt_prg_listitem *list = NRT_PRG_LISTITEM_ALLOC;
  list->prg = prg;
  list->next = next;

  return list;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x10
popq %rdi
callq 0x2240
movq %r14, (%rax)
movq %rbx, 0x8(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_prg_list_insert
nrt_prg_list* nrt_prg_list_insert(nrt_prg_list* list, nrt_prgbank* prg, int index)
{
  // initialize our new listitem.
  nrt_prg_listitem *new_item = nrt_prg_listitem_create(prg, NULL);

  list->count++;

  // we're prepending, so this is super-simple
  if ( index == 0 ) {
    new_item->next = list->list;
    list->list = new_item;
    return list;
  }

  nrt_prg_listitem *before = nrt_prg_listitem_at(list, index - 1);
  nrt_prg_listitem *after = before->next;

  before->next = new_item;
  new_item->next = after;

  return list;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x2daf
incl (%rbx)
movq %rax, %r14
movq %rbx, %rax
testl %ebp, %ebp
je 0x2e02
decl %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2e59
movq 0x8(%rax), %rcx
movq %r14, 0x8(%rax)
movq %rcx, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_prg_list_delete
nrt_prg_listitem* nrt_prg_list_delete(nrt_prg_list* list, int index)
{
  // first get the item in question
  nrt_prg_listitem* item = nrt_prg_listitem_at(list, index);

  // if we didn't get anything, just return null and don't do anything.
  if (!item) {
    return NULL;
  }

  // next, if index is zero, we need to basically just shift everyting over and we're done.
  if (index == 0) {
    list->count--;
    list->list = item->next;
    return item;
  }

  // otherwise, we need to surgically remove the item.
  // get the previous item, set previous->next to item->next
  list->count--;
  nrt_prg_listitem* prev = nrt_prg_listitem_at(list, index - 1);
  prev->next = item->next;

  return item;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
callq 0x2e59
movq %rax, %rbx
testq %rax, %rax
je 0x2e51
decl (%r14)
testl %ebp, %ebp
je 0x2e49
decl %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2e59
movq %rax, %r14
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_prg_list_free
void nrt_prg_list_free(nrt_prg_list *list) {
  nrt_prg_listitem *l = list->list;
  nrt_prg_listitem *next = l->next;

  while (l) {
    if (l->prg) {
      free(l->prg);
    }

    next = l->next;
    free(l);

    l = next;
  }

  free(list);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
testq %r14, %r14
je 0x2ec0
movq (%r14), %rdi
callq 0x2040
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x2040
movq %r15, %r14
jmp 0x2ea2
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2040
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_chr_list_insert
nrt_chr_list* nrt_chr_list_insert(nrt_chr_list* list, nrt_chrbank* chr, int index)
{
  // initialize our new listitem.
  nrt_chr_listitem *new_item = nrt_chr_listitem_create(chr, NULL);

  list->count++;

  // we're prepending, so this is super-simple
  if ( index == 0 ) {
    new_item->next = list->list;
    list->list = new_item;
    return list;
  }

  nrt_chr_listitem *before = nrt_chr_listitem_at(list, index - 1);
  nrt_chr_listitem *after = before->next;

  before->next = new_item;
  new_item->next = after;

  return list;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %rbx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x2ee0
incl (%rbx)
movq %rax, %r14
movq %rbx, %rax
testl %ebp, %ebp
je 0x2f33
decl %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2f8a
movq 0x8(%rax), %rcx
movq %r14, 0x8(%rax)
movq %rcx, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_chr_list_delete
nrt_chr_listitem* nrt_chr_list_delete(nrt_chr_list* list, int index)
{
  // first get the item in question
  nrt_chr_listitem* item = nrt_chr_listitem_at(list, index);

  // if we didn't get anything, just return null and don't do anything.
  if (!item) {
    return NULL;
  }

  // next, if index is zero, we need to basically just shift everyting over and we're done.
  if (index == 0) {
    list->count--;
    list->list = item->next;
    return item;
  }

  // otherwise, we need to surgically remove the item.
  // get the previous item, set previous->next to item->next
  list->count--;
  nrt_chr_listitem* prev = nrt_chr_listitem_at(list, index - 1);
  prev->next = item->next;

  return item;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
callq 0x2f8a
movq %rax, %rbx
testq %rax, %rax
je 0x2f82
decl (%r14)
testl %ebp, %ebp
je 0x2f7a
decl %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x2f8a
movq %rax, %r14
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_chr_list_free
void nrt_chr_list_free(nrt_chr_list *list) {
  nrt_chr_listitem *l = list->list;
  nrt_chr_listitem *next = l->next;

  while (l) {
    if (l->chr) {
      free(l->chr);
    }

    next = l->next;
    free(l);

    l = next;
  }

  free(list);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
testq %r14, %r14
je 0x2ff1
movq (%r14), %rdi
callq 0x2040
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x2040
movq %r15, %r14
jmp 0x2fd3
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2040
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_rom_create
nrt_rom* nrt_rom_create(void) {
  nrt_rom* rom = NRT_ROM_ALLOC;

  rom->header = NRT_HEADER_ALLOC;
  rom->prgs = nrt_prg_list_create();
  rom->chrs = nrt_chr_list_create();

  bzero(rom->title, NRT_TITLE_MAX_LENGTH);

  return rom;
}

// Assembly:
pushq %rbx
movl $0x118, %edi            # imm = 0x118
callq 0x2240
movq %rax, %rbx
pushq $0x10
popq %rdi
callq 0x2240
movq %rax, (%rbx)
callq 0x2d9c
movq %rax, 0x8(%rbx)
callq 0x2ecd
movq %rax, 0x10(%rbx)
leaq 0x18(%rbx), %rdi
movl $0xff, %edx
xorl %esi, %esi
callq 0x2180
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_read_rom_from_file
nrt_rom* nrt_read_rom_from_file(FILE* romfile) {
  nrt_rom* rom = nrt_rom_create();

  fseek(romfile, 0, SEEK_SET);

  if (nrt_header_extract(romfile, rom->header) != 1) {
    nrt_rom_free(rom);
    return NULL;
  }

  int i;
  for (i = 0; i < rom->header->prg_count; i++) {
    nrt_prgbank* prg = NRT_PRG_ALLOC;

    if (nrt_extract_prg(romfile, i, prg) != 1) {
      nrt_rom_free(rom);
      free(prg);
      return NULL;
    }

    nrt_prg_list_append(rom->prgs, prg);
  }

  for (i = 0; i < rom->header->chr_count; i++) {
    nrt_chrbank* chr = NRT_CHR_ALLOC;

    if (nrt_extract_chr(romfile, rom->header, i, chr) != 1) {
      nrt_rom_free(rom);
      free(chr);
      return NULL;
    }

    nrt_chr_list_append(rom->chrs, chr);
  }

  nrt_read_title_from_file(romfile, rom->header, rom->title);

  return rom;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x2ffe
movq %rax, %rbx
xorl %r12d, %r12d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2280
movq (%rbx), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2607
cmpl $0x1, %eax
jne 0x30d0
movzbl 0x4(%r15), %eax
cmpl %eax, %r12d
jae 0x30da
movl $0x4000, %edi           # imm = 0x4000
callq 0x2240
movq %rax, %r13
movq %r14, %rdi
movl %r12d, %esi
movq %rax, %rdx
callq 0x268c
cmpl $0x1, %eax
jne 0x311e
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x2e16
incl %r12d
jmp 0x3095
movq %rbx, %rdi
callq 0x303e
jmp 0x312e
xorl %ebp, %ebp
pushq $0x1
popq %r12
movzbl 0x5(%r15), %eax
cmpl %eax, %ebp
jae 0x3142
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdi
callq 0x21c0
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %rax, %rcx
callq 0x2c91
cmpl $0x1, %eax
jne 0x311e
movq 0x10(%rbx), %rdi
movq %r13, %rsi
callq 0x2f47
incl %ebp
jmp 0x30e0
movq %rbx, %rdi
callq 0x303e
movq %r13, %rdi
callq 0x2040
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdx
addq $0x18, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2d18
jmp 0x3130
// File: /workspace/github_c_makefile_star2_O2/sadistech[P]nesromtool2/./src/nrt.c
// Function: nrt_rom_write_to_file
bool nrt_rom_write_to_file(nrt_rom *rom, FILE *outfile) {
  int i;

  rom->header->prg_count = nrt_prg_listitem_count(rom->prgs->list);
  rom->header->chr_count = nrt_chr_listitem_count(rom->chrs->list);

  fwrite(rom->header, NRT_HEADER_SIZE, 1, outfile);

  nrt_prg_listitem *prg_listitem = rom->prgs->list;
  while (prg_listitem) {
    fwrite(prg_listitem->prg, NRT_PRG_BANK_SIZE, 1, outfile);
    prg_listitem = prg_listitem->next;
  }

  nrt_chr_listitem *chr_listitem = rom->chrs->list;
  while (chr_listitem) {
    fwrite(chr_listitem->chr, NRT_CHR_BANK_SIZE, 1, outfile);
    chr_listitem = chr_listitem->next;
  }

  // only write the title if it has one.
  if (strlen(rom->title) > 0) {
    fwrite(rom->title, NRT_TITLE_MAX_LENGTH, 1, outfile);
  }

  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rdi
callq 0x2e86
movq (%r14), %r12
movb %al, 0x4(%r12)
movq 0x10(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x2fb7
movb %al, 0x5(%r12)
pushq $0x10
popq %rsi
pushq $0x1
popq %r15
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2340
movq 0x8(%r14), %r12
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x31c4
movq (%r12), %rdi
movl $0x4000, %esi           # imm = 0x4000
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2340
jmp 0x31a4
movq 0x10(%r14), %r12
pushq $0x1
popq %r15
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x31ec
movq (%r12), %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r15, %rdx
movq %rbx, %rcx
callq 0x2340
jmp 0x31cc
cmpb $0x0, 0x18(%r14)
je 0x320a
addq $0x18, %r14
pushq $0x1
popq %rdx
movl $0xff, %esi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2340
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rdi
movq %rax, %rsi
callq 0x21c0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x20a0
pushq $0x2e
popq %rsi
movq %rbx, %rdi
callq 0x2160
testq %rax, %rax
sete %cl
cmpq %rbx, %rax
sete %dl
orb %cl, %dl
jne 0x3288
movb $0x0, (%rax)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x10(%rsp), %rdi
xorl %r15d, %r15d
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2180
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
movq %rax, 0x8(%rsp)
testl %r14d, %r14d
cmovlel %r15d, %r14d
movb $0x20, %al
cmpq %r15, %r14
je 0x3304
movb %al, 0x10(%rsp,%r15)
movb %al, 0x11(%rsp,%r15,2)
incq %r15
jmp 0x32f0
leaq 0x2d8e(%rip), %r14      # 0x6099
leaq 0x8(%rsp), %r15
leaq 0x2dbc(%rip), %r12      # 0x60d3
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r14, %rsi
callq 0x2250
testq %rax, %rax
je 0x333e
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2140
jmp 0x331c
movq %rbx, %rdi
callq 0x2040
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x4
popq %rdi
pushq $0x1
popq %rsi
callq 0x21c0
movq %rax, %r14
movl $0x1, (%rax)
movq %r13, %rdi
callq 0x3294
pushq $0x1
popq %rdi
movq %r12, %rsi
callq 0x32ad
testq %r15, %r15
je 0x33af
leaq 0x2d3a(%rip), %rdi      # 0x60d9
callq 0x3294
movq %r14, %rdi
movq %r15, %rsi
callq 0x33de
testq %rbx, %rbx
je 0x33d4
leaq 0x2d25(%rip), %rdi      # 0x60e0
callq 0x3294
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x33de
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x347f
movl %eax, %ebp
movq %rsp, %rdi
xorl %r15d, %r15d
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x2180
movl (%r14), %eax
movb $0x20, %cl
cmpq %r15, %rax
je 0x3425
movb %cl, (%rsp,%r15)
movb %cl, 0x1(%rsp,%r15,2)
incq %r15
jmp 0x3412
leaq 0x100(%rsp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x2180
addl $0x2, %ebp
leaq 0x2ca2(%rip), %rsi      # 0x60e8
movq %rsp, %rdx
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2320
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x3471
movq 0x8(%rbx), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2140
addq $0x10, %rbx
jmp 0x3455
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
xorl %ebp, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x34a1
callq 0x2110
cmpl %eax, %ebp
cmovgl %ebp, %eax
addq $0x10, %rbx
movl %eax, %ebp
jmp 0x3487
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r14
pushq %rbx
pushq $0x4
popq %rdi
pushq $0x1
popq %rsi
callq 0x21c0
movq %rax, %r14
movl $0x1, (%rax)
leaq 0x2c2d(%rip), %rbx      # 0x6102
movq %rbx, %rdi
callq 0x3294
leaq 0x2c22(%rip), %rsi      # 0x6106
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x32ad
callq 0x32a5
leaq 0x2c48(%rip), %rdi      # 0x6142
callq 0x3294
leaq 0x2c42(%rip), %rsi      # 0x6148
movl %ebp, %edi
callq 0x32ad
callq 0x32a5
leaq 0x2c5a(%rip), %rdi      # 0x6173
callq 0x3294
leaq 0x7cbb(%rip), %rsi      # 0xb1e0
movq %r14, %rdi
callq 0x33de
callq 0x32a5
leaq 0x2d50(%rip), %rdi      # 0x6289
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2140
popq %rbx
popq %r14
popq %rbp
jmp 0x32a5
// File: /workspace/github_c_makefile_star2_O2/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 0x2d80(%rip), %rdi      # 0x62d4
callq 0x3294
leaq 0x2d7d(%rip), %rsi      # 0x62dd
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0x32ad
callq 0x32a5
leaq 0x2bcc(%rip), %rdi      # 0x6142
callq 0x3294
leaq 0x2e06(%rip), %rsi      # 0x6388
movl %ebx, %edi
callq 0x32ad
popq %rbx
jmp 0x32a5