LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/util.c
// Function: je_buferror
int
buferror(int err, char *buf, size_t buflen)
{

#ifdef _WIN32
	FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
	    (LPSTR)buf, (DWORD)buflen, NULL);
	return (0);
#elif defined(__GLIBC__) && defined(_GNU_SOURCE)
	char *b = strerror_r(err, buf, buflen);
	if (b != buf) {
		strncpy(buf, b, buflen);
		buf[buflen-1] = '\0';
	}
	return (0);
#else
	return (strerror_r(err, buf, buflen));
#endif
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
callq 0xb360
cmpq %r14, %rax
je 0x35f80
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0xb0a0
movb $0x0, -0x1(%r14,%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/util.c
// Function: je_malloc_cprintf
void
malloc_cprintf(void (*write_cb)(void *, const char *), void *cbopaque,
    const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	malloc_vcprintf(write_cb, cbopaque, format, ap);
	va_end(ap);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10d0, %rsp           # imm = 0x10D0
movq %rsi, %rbx
leaq 0x20(%rsp), %rsi
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x36e8c
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rsi, 0x10(%rcx)
leaq 0x10f0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
movq 0x16625(%rip), %rax     # 0x4d4d8
testq %rax, %rax
leaq -0xf89(%rip), %r15      # 0x35f34
cmovneq %rax, %r15
testq %rdi, %rdi
cmoveq %rdi, %rbx
cmovneq %rdi, %r15
leaq 0xd0(%rsp), %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
callq 0x3612e
movq %rbx, %rdi
movq %r14, %rsi
callq *%r15
addq $0x10d0, %rsp           # imm = 0x10D0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/util.c
// Function: je_malloc_printf
void
malloc_printf(const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	malloc_vcprintf(NULL, NULL, format, ap);
	va_end(ap);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x36f58
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0x10f0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
movq 0x16559(%rip), %rax     # 0x4d4d8
testq %rax, %rax
leaq -0x1055(%rip), %r14     # 0x35f34
cmovneq %rax, %r14
leaq 0xd0(%rsp), %rbx
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
movq %r10, %rdx
callq 0x3612e
xorl %edi, %edi
movq %rbx, %rsi
callq *%r14
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/witness.c
// Function: je_witness_lock_error
void
witness_lock_error(const witness_list_t *witnesses, const witness_t *witness)
{
	witness_t *w;

	malloc_printf("<jemalloc>: Lock rank order reversal:");
	ql_foreach(w, witnesses, link) {
		malloc_printf(" %s(%u)", w->name, w->rank);
	}
	malloc_printf(" %s(%u)\n", witness->name, witness->rank);
	abort();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x79b2(%rip), %rdi      # 0x3e98a
xorl %eax, %eax
callq 0x36ef7
movq (%r14), %r12
testq %r12, %r12
je 0x37013
leaq 0x79c2(%rip), %r15      # 0x3e9b0
movq (%r12), %rsi
movl 0x8(%r12), %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x36ef7
movq 0x18(%r12), %r12
cmpq (%r14), %r12
jne 0x3700e
xorl %r12d, %r12d
testq %r12, %r12
jne 0x36fee
movq (%rbx), %rsi
movl 0x8(%rbx), %edx
leaq 0x79ae(%rip), %rdi      # 0x3e9ce
xorl %eax, %eax
callq 0x36ef7
callq 0xb070
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/witness.c
// Function: je_witness_lockless_error
void
witness_lockless_error(const witness_list_t *witnesses)
{
	witness_t *w;

	malloc_printf("<jemalloc>: Should not own any locks:");
	ql_foreach(w, witnesses, link) {
		malloc_printf(" %s(%u)", w->name, w->rank);
	}
	malloc_printf("\n");
	abort();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x798b(%rip), %rdi      # 0x3e9fa
xorl %eax, %eax
callq 0x36ef7
movq (%rbx), %r15
testq %r15, %r15
je 0x370a7
leaq 0x792b(%rip), %r14      # 0x3e9b0
movq (%r15), %rsi
movl 0x8(%r15), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x36ef7
movq 0x18(%r15), %r15
cmpq (%rbx), %r15
jne 0x370a2
xorl %r15d, %r15d
testq %r15, %r15
jne 0x37085
leaq 0x2696(%rip), %rdi      # 0x39744
xorl %eax, %eax
callq 0x36ef7
callq 0xb070
// File: /workspace/github_c_makefile_star2_O1/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 0x15ede(%rip), %r12     # 0x4d0d0
movq (%r12), %rax
notq %rax
andq %rbx, %rax
cmpq %rax, %rbx
je 0x372a1
movq (%rax), %r15
movq (%r12), %rax
notq %rax
andq %rbx, %rax
movq %rbx, %rcx
subq %rax, %rcx
je 0x372b1
shrq $0xc, %rcx
leaq 0x15d97(%rip), %rdx     # 0x4cfc0
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 0x372d4
movl %ecx, %eax
leaq 0x43f2(%rip), %rcx      # 0x3b640
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 0x372be
shrq $0xc, %r8
leaq 0x15d45(%rip), %rax     # 0x4cfc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
movq %r14, %rdi
movq %rbx, %rcx
jne 0x372e8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xdf6b
movq %rbx, %rdi
callq 0x2e39f
movq %rax, %r15
jmp 0x37208
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e4e2
jmp 0x37252
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x11227
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x37252
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xdfd3
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/ckh.c
// Function: je_ckh_iter
bool
ckh_iter(ckh_t *ckh, size_t *tabind, void **key, void **data)
{
	size_t i, ncells;

	for (i = *tabind, ncells = (ZU(1) << (ckh->lg_curbuckets +
	    LG_CKH_BUCKET_CELLS)); i < ncells; i++) {
		if (ckh->tab[i].key != NULL) {
			if (key != NULL)
				*key = (void *)ckh->tab[i].key;
			if (data != NULL)
				*data = (void *)ckh->tab[i].data;
			*tabind = i + 1;
			return (false);
		}
	}

	return (true);
}

// Assembly:
movq %rcx, %r8
movq (%rsi), %r9
movl 0x14(%rdi), %ecx
addl $0x2, %ecx
movq %r9, %rax
shrq %cl, %rax
testq %rax, %rax
setne %al
je 0x37318
retq
pushq %rbx
movq 0x28(%rdi), %r10
movq %r9, %rbx
shlq $0x4, %rbx
movq (%r10,%rbx), %r11
testq %r11, %r11
jne 0x37351
addq %rbx, %r10
addq $0x10, %r10
incq %r9
movq %r9, %rax
shrq %cl, %rax
testq %rax, %rax
setne %al
jne 0x37377
movq (%r10), %r11
addq $0x10, %r10
testq %r11, %r11
je 0x37334
testq %rdx, %rdx
je 0x37359
movq %r11, (%rdx)
testq %r8, %r8
je 0x37371
movq 0x28(%rdi), %rcx
movq %r9, %rdx
shlq $0x4, %rdx
movq 0x8(%rcx,%rdx), %rcx
movq %rcx, (%r8)
incq %r9
movq %r9, (%rsi)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/ckh.c
// Function: je_ckh_search
bool
ckh_search(ckh_t *ckh, const void *searchkey, void **key, void **data)
{
	size_t cell;

	assert(ckh != NULL);

	cell = ckh_isearch(ckh, searchkey);
	if (cell != SIZE_T_MAX) {
		if (key != NULL)
			*key = (void *)ckh->tab[cell].key;
		if (data != NULL)
			*data = (void *)ckh->tab[cell].data;
		return (false);
	}

	return (true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r15
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r14
leaq 0x10(%rsp), %r13
movq %rsi, %rdi
movq %r13, %rsi
callq *0x18(%r14)
movb 0x14(%r14), %cl
movq $-0x1, %rbp
shlq %cl, %rbp
notq %rbp
andq (%r13), %rbp
leaq (,%rbp,4), %r13
shlq $0x6, %rbp
xorl %ebx, %ebx
movq 0x28(%r14), %rax
movq (%rax,%rbp), %rsi
testq %rsi, %rsi
je 0x37bfc
movq %r12, %rdi
callq *0x20(%r14)
testb %al, %al
jne 0x37c12
incq %rbx
addq $0x10, %rbp
cmpq $0x4, %rbx
jne 0x37be4
movq $-0x1, %r13
jmp 0x37c15
addq %rbx, %r13
cmpq $-0x1, %r13
jne 0x37c70
movb 0x14(%r14), %cl
movq $-0x1, %rbp
shlq %cl, %rbp
notq %rbp
andq 0x18(%rsp), %rbp
leaq (,%rbp,4), %r13
shlq $0x6, %rbp
xorl %ebx, %ebx
movq 0x28(%r14), %rax
movq (%rax,%rbp), %rsi
testq %rsi, %rsi
je 0x37c57
movq %r12, %rdi
callq *0x20(%r14)
testb %al, %al
jne 0x37c6d
incq %rbx
addq $0x10, %rbp
cmpq $0x4, %rbx
jne 0x37c3f
movq $-0x1, %r13
jmp 0x37c70
addq %rbx, %r13
cmpq $-0x1, %r13
je 0x37caa
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0x37c92
movq 0x28(%r14), %rax
movq %r13, %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rax
movq %rax, (%rdx)
testq %r15, %r15
je 0x37caa
movq 0x28(%r14), %rax
movq %r13, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
movq %rax, (%r15)
cmpq $-0x1, %r13
sete %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/ckh.c
// Function: je_ckh_pointer_hash
void
ckh_pointer_hash(const void *key, size_t r_hash[2])
{
	union {
		const void	*v;
		size_t		i;
	} u;

	assert(sizeof(u.v) == sizeof(u.i));
	u.v = key;
	hash(&u.i, sizeof(u.i), 0xd983396eU, r_hash);
}

// Assembly:
movabsq $-0x783c846eeebdac2b, %rax # imm = 0x87C37B91114253D5
imulq %rdi, %rax
movabsq $-0x775ed61580000000, %rcx # imm = 0x88A129EA80000000
imulq %rdi, %rcx
shrq $0x21, %rax
orq %rcx, %rax
movabsq $0x4cf5ad432745937f, %rcx # imm = 0x4CF5AD432745937F
imulq %rax, %rcx
movl $0xd9833966, %eax       # imm = 0xD9833966
xorq %rax, %rcx
addq %rcx, %rax
movabsq $0x1b30672cc, %rdx      # imm = 0x1B30672CC
addq %rcx, %rdx
movq %rax, %rcx
shrq $0x21, %rcx
xorq %rax, %rcx
movabsq $-0xae502812aa7333, %rax # imm = 0xFF51AFD7ED558CCD
imulq %rax, %rcx
movq %rcx, %rdi
shrq $0x21, %rdi
xorq %rcx, %rdi
movabsq $-0x3b314601e57a13ad, %rcx # imm = 0xC4CEB9FE1A85EC53
imulq %rcx, %rdi
movq %rdi, %r8
shrq $0x21, %r8
xorq %rdi, %r8
movq %rdx, %rdi
shrq $0x21, %rdi
xorq %rdx, %rdi
imulq %rax, %rdi
movq %rdi, %rax
shrq $0x21, %rax
xorq %rdi, %rax
imulq %rcx, %rax
movq %rax, %rcx
shrq $0x21, %rcx
xorq %rax, %rcx
addq %rcx, %r8
addq %r8, %rcx
movq %r8, (%rsi)
movq %rcx, 0x8(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xb10(%rip), %rdi       # 0x2041
callq 0x1030
leaq 0xb1c(%rip), %rdi       # 0x2059
callq 0x1030
leaq 0xb2a(%rip), %rdi       # 0x2073
callq 0x1030
leaq 0xb3d(%rip), %rdi       # 0x2092
popq %rax
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x4, %edi
callq 0x1070
movq %rax, %rbx
testl %ebp, %ebp
jne 0x123c
leaq 0x2ea1(%rip), %rdi      # 0x4068
movl $0x1, %esi
callq 0x1040
testl %eax, %eax
leaq 0xe2d(%rip), %rax       # 0x2007
leaq 0xe23(%rip), %r14       # 0x2004
cmoveq %rax, %r14
leaq 0x2e84(%rip), %rdi      # 0x4070
movl $0x1, %esi
callq 0x1040
testl %eax, %eax
leaq 0xe1b(%rip), %r15       # 0x201a
cmovneq %r14, %r15
movq %rsp, %rdi
movl $0x1, %esi
callq 0x1040
testl %eax, %eax
leaq 0xe13(%rip), %r14       # 0x202c
cmovneq %r15, %r14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1040
testl %eax, %eax
leaq 0xe0f(%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_O1/yurrriq[P]knrc/src/fahrcels.c
// Function: print_header
void print_header(char lhs[], char rhs[])
{
    printf("| %s | %s |\n", lhs, rhs);
    putchar('|');
    for (size_t i = 0; i < strlen(lhs) + 2; ++i)
        putchar('-');
    putchar('+');
    for (size_t i = 0; i < strlen(rhs) + 2; ++i)
        putchar('-');
    puts("|");
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xeb1(%rip), %rdi       # 0x2030
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1060
movl $0x7c, %edi
callq 0x1030
movq %r14, %rdi
callq 0x1050
cmpq $-0x2, %rax
je 0x11c5
xorl %r15d, %r15d
movl $0x2d, %edi
callq 0x1030
incq %r15
movq %r14, %rdi
callq 0x1050
addq $0x2, %rax
cmpq %rax, %r15
jb 0x11a7
movl $0x2b, %edi
callq 0x1030
movq %rbx, %rdi
callq 0x1050
cmpq $-0x2, %rax
je 0x11fe
xorl %r14d, %r14d
movl $0x2d, %edi
callq 0x1030
incq %r14
movq %rbx, %rdi
callq 0x1050
addq $0x2, %rax
cmpq %rax, %r14
jb 0x11e0
leaq 0xe38(%rip), %rdi       # 0x203d
popq %rbx
popq %r14
popq %r15
jmp 0x1040
// File: /workspace/github_c_makefile_star2_O1/yurrriq[P]knrc/src/fahrcels.c
// Function: main
int main()
{
    fahrcels();
    puts("\n");
    celsfahr();

    return 0;
}

// Assembly:
pushq %rax
callq 0x127c
leaq 0xd83(%rip), %rdi       # 0x2062
callq 0x1040
callq 0x120f
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1aa5(%rip), %rdi      # 0x515b
callq 0x30c0
leaq 0x1aa6(%rip), %r15      # 0x5168
leaq 0x1a86(%rip), %r14      # 0x514f
xorl %r12d, %r12d
movslq (%r12,%r15), %rsi
addq %r15, %rsi
movq (%rbx,%r12,2), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x3130
addq $0x4, %r12
cmpq $0x48, %r12
jne 0x36cc
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3080
// File: /workspace/github_c_makefile_star2_O1/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 0x3732
leaq 0x1a92(%rip), %rdi      # 0x51b0
movq %rax, %rsi
xorl %eax, %eax
callq 0x3130
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x37e8
movq %rsi, %r15
movq %rax, %rcx
shlq $0x4, %rcx
leaq 0x51cd(%rip), %rbx      # 0x8910
movq 0x8(%rcx,%rbx), %rsi
testb %dl, %dl
je 0x37d5
movq %rdi, %r14
addq %rcx, %rbx
leaq 0x1a70(%rip), %rdi      # 0x51cd
xorl %eax, %eax
callq 0x3130
movl (%rbx), %r13d
cmpq $0x6, %r13
ja 0x37f9
movq %r15, (%rsp)
testq %r13, %r13
je 0x37bf
shlq $0x3, %r13
leaq 0x26eb(%rip), %rbp      # 0x5e70
leaq 0x1ad6(%rip), %r15      # 0x5262
leaq 0x1ac8(%rip), %r12      # 0x525b
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x37a4
movq %r12, %rdi
xorl %eax, %eax
callq 0x3130
movq (%rbx,%rbp), %rax
movq (%r14,%rax,8), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x3130
addq $0x8, %rbx
cmpq %rbx, %r13
jne 0x3795
leaq 0x1a98(%rip), %rdi      # 0x525e
xorl %ebp, %ebp
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x3130
jmp 0x37e8
leaq 0x19e0(%rip), %rdi      # 0x51bc
xorl %ebp, %ebp
movq %rax, %rdx
xorl %eax, %eax
callq 0x3130
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19d1(%rip), %rdi      # 0x51d1
leaq 0x1a06(%rip), %rsi      # 0x520d
leaq 0x1a14(%rip), %rcx      # 0x5222
movl $0x185, %edx            # imm = 0x185
callq 0x3160
// File: /workspace/github_c_makefile_star2_O1/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 0x3100
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31d0
callq 0x3090
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x2, (%rcx)
jne 0x389b
movq %rbx, %rdi
movl $0x1fc, %esi            # imm = 0x1FC
callq 0x30b0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x3120
movq %rax, %rdx
shlq $0x20, %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rdx, %rsi
sarq $0x20, %rsi
xorl %ecx, %ecx
cmpb $0x2f, (%rbx,%rsi)
je 0x38fa
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0xff, %eax
jg 0x38fa
movq %rdx, %rax
sarq $0x20, %rax
movb $0x2f, (%rbx,%rax)
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rdx, %rax
sarq $0x20, %rax
movb $0x0, (%rbx,%rax)
xorl %ecx, %ecx
movl %ecx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x30e0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x394c
movq %r14, %rdi
callq 0x3120
movq %rax, %r15
movq %rbx, %rdi
callq 0x3120
movq %rax, %rcx
addl %r15d, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ebp, %ecx
jge 0x394c
movslq %ebp, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3180
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x3200
movq 0x8(%rbx), %rdi
callq 0x3200
movq 0x10(%rbx), %rdi
callq 0x3200
movq 0x20(%rbx), %rdi
callq 0x3200
movq 0x18(%rbx), %rdi
callq 0x3200
movq (%rbx), %rdi
callq 0x30f0
movq 0x8(%rbx), %rdi
callq 0x30f0
movq 0x10(%rbx), %rdi
callq 0x30f0
movq 0x20(%rbx), %rdi
callq 0x30f0
movq 0x18(%rbx), %rdi
popq %rbx
jmp 0x30f0
// File: /workspace/github_c_makefile_star2_O1/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 0x3a33
xorl %ebx, %ebx
jmp 0x3ac6
movl $0x40, %edi
callq 0x31f0
testq %rax, %rax
je 0x3ad4
movq %rax, %rbx
leaq 0x24ca(%rip), %rsi      # 0x5f1a
movq %rsp, %r14
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
movq %rax, %rcx
callq 0x3030
leaq 0x10(%rbx), %rcx
leaq 0x24b7(%rip), %rsi      # 0x5f25
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
leaq 0x20(%rbx), %rcx
leaq 0x24a7(%rip), %rsi      # 0x5f2d
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
leaq 0x18(%rbx), %rcx
leaq 0x2497(%rip), %rsi      # 0x5f35
movq %r14, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x3030
movq %rbx, %rcx
addq $0x28, %rcx
leaq 0x2484(%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
callq 0x3290
// File: /workspace/github_c_makefile_star2_O1/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
xorl %esi, %esi
movl $0x2, %edx
callq 0x3220
movq 0x8(%rbx), %rdi
callq 0x31b0
movq %rax, %r15
movq %rax, %r14
shrq $0x5, %r14
movq %rax, %rdi
callq 0x31f0
movq 0x38(%rbx), %rcx
movq %rax, 0x18(%rcx)
movq %r15, 0x20(%rcx)
movq 0x8(%rbx), %rdi
callq 0x3140
leaq 0x241e(%rip), %rdi      # 0x5f46
movq %r14, %rsi
xorl %eax, %eax
callq 0x3130
movq 0x8(%rbx), %rcx
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rdi
movl $0x20, %esi
movq %r14, %rdx
callq 0x30d0
cmpq %r14, %rax
jne 0x3b5f
movl $0xa, %edi
popq %rbx
popq %r14
popq %r15
jmp 0x3080
callq 0x32b5
// File: /workspace/github_c_makefile_star2_O1/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 0x20(%rax), %rcx
cmpq $0x20, %rcx
jb 0x3b88
movq 0x18(%rax), %rax
shrq $0x5, %rcx
cmpq %rdi, (%rax)
je 0x3b8a
addq $0x20, %rax
decq %rcx
jne 0x3b7a
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x3bff
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x8(%rsp), %r14
movq $0x0, (%r14)
movq (%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %r15
decq %rsi
imulq %r15, %rsi
xorl %edx, %edx
callq 0x3220
movq (%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x30d0
movq (%r14), %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x32da
// File: /workspace/github_c_makefile_star2_O1/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 0x3c51
movq %rsi, %rbx
movq %rsp, %r14
movq $0x0, (%r14)
movq 0x18(%rsi), %rax
leaq -0x4(,%rdi,4), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x3220
movq 0x18(%rbx), %rcx
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x30d0
movq (%r14), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x32ff
// File: /workspace/github_c_makefile_star2_O1/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 0x30f0
movq (%rbx), %rdi
callq 0x30f0
movq 0x10(%rbx), %rdi
callq 0x30f0
movq 0x20(%rbx), %rdi
callq 0x30f0
movq 0x18(%rbx), %rdi
callq 0x30f0
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x424e
callq 0x30f0
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_O1/melynx[P]peekaboo/libpeekaboo/libpeekaboo.c
// Function: free_peekaboo_insn
void free_peekaboo_insn(peekaboo_insn_t *insn_ptr)
{
	if (insn_ptr != NULL)
	{
		if (insn_ptr->regfile != NULL)
		{
			free(insn_ptr->regfile);
			insn_ptr->regfile = NULL;
		}
		free(insn_ptr);
		insn_ptr = NULL;
	}
}

// Assembly:
testq %rdi, %rdi
je 0x44e2
pushq %rbx
movq %rdi, %rbx
movq 0x130(%rdi), %rdi
testq %rdi, %rdi
je 0x44d9
callq 0x3070
movq $0x0, 0x130(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x3070
retq
// File: /workspace/github_c_makefile_star2_O1/sadistech[P]nesromtool2/./src/subcommands/chr.c
// Function: subcommand_chr_replace.cold.1
chr_output_format parse_chr_output_format(char *format) {
  if (strcmp(format, "raw") == 0) {
    return raw_format;
  } else if (strcmp(format, "png") == 0) {
    return png_format;
  }

  return null_format;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rdx
movq 0x98b7(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x60b4(%rip), %rsi      # 0x87ff
xorl %eax, %eax
callq 0x21f0
movq %r14, %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2040
pushq $0x1
popq %rdi
callq 0x2330
// File: /workspace/github_c_makefile_star2_O1/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 0x2c4c
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
callq 0x23b0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/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, %r12
movl $0x10, %edi
callq 0x2240
movq %rax, %r15
movq %rsp, %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x2180
movl $0x1, %esi
movl $0x10, %edx
movq %r15, %rdi
movq %r12, %rcx
callq 0x20c0
testq %rax, %rax
je 0x2cf3
movq %r15, %rdi
callq 0x2d91
testb %al, %al
jne 0x2ccf
leaq 0x4390(%rip), %rsi      # 0x7044
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2320
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2c0a
movq %r15, %rdi
callq 0x2daa
testb %al, %al
jne 0x2d05
movzbl 0x4(%r15), %edx
leaq 0x437b(%rip), %rsi      # 0x7062
movq %r14, %rdi
xorl %eax, %eax
callq 0x2320
jmp 0x2cfa
leaq 0x4329(%rip), %r14      # 0x7023
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c0a
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x10, %edi
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_O1/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:
xorl %eax, %eax
movl $0x7, %ecx
xorl %edx, %edx
movsbl (%rdi,%rax), %r8d
movzbl 0x8(%rdi,%rax), %r9d
xorl %r10d, %r10d
btl %ecx, %r8d
setb %r10b
xorl %r8d, %r8d
btl %ecx, %r9d
setb %r8b
leal (%r10,%r8,2), %r8d
movb %r8b, (%rsi,%rdx)
incq %rdx
decl %ecx
cmpq $0x8, %rdx
jne 0x2e11
incq %rax
addq $0x8, %rsi
cmpq $0x8, %rax
jne 0x2e0a
retq
// File: /workspace/github_c_makefile_star2_O1/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
movb (%rsi,%rax), %cl
movb 0x8(%rsi,%rax), %dl
xorl %r8d, %r8d
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
cmpq $0x8, %r8
jne 0x2e87
incq %rax
addq $0x8, %rdi
cmpq $0x8, %rax
jne 0x2e7d
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0xff, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20c0
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x10, %edi
callq 0x2240
movl $0x0, (%rax)
movq $0x0, 0x8(%rax)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x10, %edi
callq 0x2240
movq %r14, (%rax)
movq %rbx, 0x8(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %r14
movq %rdi, %rbx
movl $0x10, %edi
callq 0x2240
movq %r14, (%rax)
movq $0x0, 0x8(%rax)
incl (%rbx)
testl %ebp, %ebp
je 0x35d7
movq %rbx, %rcx
movq 0x8(%rcx), %rcx
decl %ebp
jne 0x35c1
movq 0x8(%rcx), %rdx
movq %rax, 0x8(%rcx)
movq %rdx, 0x8(%rax)
jmp 0x35e3
movq 0x8(%rbx), %rcx
movq %rcx, 0x8(%rax)
movq %rax, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x360e
leal 0x1(%rsi), %edx
movq %rcx, %rax
decl %edx
je 0x3610
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x3601
xorl %eax, %eax
testq %rax, %rax
je 0x362e
decl (%rdi)
testl %esi, %esi
je 0x3631
decl %esi
je 0x3625
movq 0x8(%rcx), %rcx
jmp 0x361b
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
retq
xorl %eax, %eax
retq
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x36b0
movq (%r14), %rdi
testq %rdi, %rdi
je 0x369c
callq 0x2040
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x2040
movq %r15, %r14
testq %r15, %r15
jne 0x368f
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2040
// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %r14
movq %rdi, %rbx
movl $0x10, %edi
callq 0x2240
movq %r14, (%rax)
movq $0x0, 0x8(%rax)
incl (%rbx)
testl %ebp, %ebp
je 0x3774
movq %rbx, %rcx
movq 0x8(%rcx), %rcx
decl %ebp
jne 0x375e
movq 0x8(%rcx), %rdx
movq %rax, 0x8(%rcx)
movq %rdx, 0x8(%rax)
jmp 0x3780
movq 0x8(%rbx), %rcx
movq %rcx, 0x8(%rax)
movq %rax, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x37ab
leal 0x1(%rsi), %edx
movq %rcx, %rax
decl %edx
je 0x37ad
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x379e
xorl %eax, %eax
testq %rax, %rax
je 0x37cb
decl (%rdi)
testl %esi, %esi
je 0x37ce
decl %esi
je 0x37c2
movq 0x8(%rcx), %rcx
jmp 0x37b8
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
retq
xorl %eax, %eax
retq
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x384d
movq (%r14), %rdi
testq %rdi, %rdi
je 0x3839
callq 0x2040
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x2040
movq %r15, %r14
testq %r15, %r15
jne 0x382c
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2040
// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movl $0x118, %edi            # imm = 0x118
callq 0x2240
movq %rax, %rbx
movl $0x10, %edi
callq 0x2240
movq %rax, (%rbx)
movl $0x10, %edi
callq 0x2240
xorl %r14d, %r14d
movl %r14d, (%rax)
movq %r14, 0x8(%rax)
movq %rax, 0x8(%rbx)
movl $0x10, %edi
callq 0x2240
movl %r14d, (%rax)
movq %r14, 0x8(%rax)
movq %rax, 0x10(%rbx)
leaq 0x18(%rbx), %rdi
movl $0xff, %edx
xorl %esi, %esi
callq 0x2180
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
movq %rdi, %r14
callq 0x385a
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2280
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x2d39
cmpl $0x1, %eax
jne 0x39f4
movq (%rbx), %rax
cmpb $0x0, 0x4(%rax)
je 0x3976
xorl %ebp, %ebp
movl $0x4000, %edi           # imm = 0x4000
callq 0x2240
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x2dd0
movl %eax, %r15d
cmpl $0x1, %eax
jne 0x394f
movq 0x8(%rbx), %rdi
movl (%rdi), %edx
movq %r12, %rsi
callq 0x3597
jmp 0x395f
movq %rbx, %rdi
callq 0x38c0
movq %r12, %rdi
callq 0x2040
cmpl $0x1, %r15d
jne 0x39fc
incl %ebp
movq (%rbx), %rax
movzbl 0x4(%rax), %eax
cmpl %eax, %ebp
jb 0x391d
movq (%rbx), %r15
cmpb $0x0, 0x5(%r15)
je 0x39e0
xorl %ebp, %ebp
movl $0x1, %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0x21c0
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %rax, %rcx
callq 0x340d
movl %eax, %r15d
cmpl $0x1, %eax
jne 0x39bc
movq 0x10(%rbx), %rdi
movl (%rdi), %edx
movq %r12, %rsi
callq 0x3734
jmp 0x39cc
movq %rbx, %rdi
callq 0x38c0
movq %r12, %rdi
callq 0x2040
cmpl $0x1, %r15d
jne 0x39fc
incl %ebp
movq (%rbx), %r15
movzbl 0x5(%r15), %eax
cmpl %eax, %ebp
jb 0x3982
movq %rbx, %rdx
addq $0x18, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3498
jmp 0x39fe
movq %rbx, %rdi
callq 0x38c0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x3a2c
movq 0x8(%rcx), %rcx
incb %al
jmp 0x3a1f
movq (%r14), %rdi
movb %al, 0x4(%rdi)
movq 0x10(%r14), %rax
movq 0x8(%rax), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x3a49
movq 0x8(%rcx), %rcx
incb %al
jmp 0x3a3c
movb %al, 0x5(%rdi)
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2340
movq 0x8(%r14), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x3a86
movq (%r15), %rdi
movl $0x4000, %esi           # imm = 0x4000
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2340
movq 0x8(%r15), %r15
jmp 0x3a66
movq 0x10(%r14), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x3aae
movq (%r15), %rdi
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2340
movq 0x8(%r15), %r15
jmp 0x3a8e
cmpb $0x0, 0x18(%r14)
je 0x3ace
addq $0x18, %r14
movl $0xff, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2340
movb $0x1, %al
popq %rbx
popq %r14
popq %r15
retq
nop