LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/json.c
// Function: codepoint_to_utf8
static size_t codepoint_to_utf8(long cp, char buf[4])
{
	if (cp <= 0x7F) {
		buf[0] = cp;
		return 1;
	} else if (cp <= 0x7FF) {
		buf[0] = 0xC0 | (cp >> 6);
		buf[1] = 0x80 | (cp & 0x3F);
		return 2;
	} else if (cp <= 0xFFFF) {
		buf[0] = 0xE0 | (cp >> 12);
		buf[1] = 0x80 | ((cp >> 6) & 0x3F);
		buf[2] = 0x80 | (cp & 0x3F);
		return 3;
	} else {
		buf[0] = 0xF0 | (cp >> 18);
		buf[1] = 0x80 | ((cp >> 12) & 0x3F);
		buf[2] = 0x80 | ((cp >> 6) & 0x3F);
		buf[3] = 0x80 | (cp & 0x3F);
		return 4;
	}
}

// Assembly:
cmpq $0x7f, %rdi
jg 0x6134
movb %dil, (%rsi)
pushq $0x1
jmp 0x61af
movl %edi, %eax
cmpq $0x7ff, %rdi            # imm = 0x7FF
ja 0x6156
shrl $0x6, %eax
orb $-0x40, %al
movb %al, (%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x1(%rsi)
pushq $0x2
jmp 0x61af
cmpq $0xffff, %rdi           # imm = 0xFFFF
ja 0x6182
shrl $0xc, %eax
orb $-0x20, %al
movb %al, (%rsi)
movl %edi, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x1(%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x2(%rsi)
pushq $0x3
jmp 0x61af
shrl $0x12, %eax
orb $-0x10, %al
movb %al, (%rsi)
movl %edi, %eax
shrl $0xc, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x1(%rsi)
movl %edi, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x2(%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x3(%rsi)
pushq $0x4
popq %rax
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_init
void loader_init(struct loader *ldr, const char *root)
{
	ldr->txtrs_dir = mid_cat(root, DIRSEP, "textures");
	table_init(&ldr->txtrs, 16);
	ldr->ents_dir = mid_cat(root, DIRSEP, "ents");
	table_init(&ldr->ents, 16);
	ldr->maps_dir = mid_cat(root, DIRSEP, "maps");
	table_init(&ldr->maps, 16);
	color_map_init(&ldr->colors);
	// Default background pixel:
	color_map_add_pair(&ldr->colors, pixel(PC_BLACK, PC_BLACK));
	ldr->log = NULL;
	ldr->empty_txtr = NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x5269(%rip), %rdx      # 0xb619
pushq $0x2f
popq %rbp
movq %rsi, %rdi
movl %ebp, %esi
callq 0xa595
movq %rax, 0x20(%rbx)
leaq 0x8(%rbx), %rdi
pushq $0x10
popq %r15
movq %r15, %rsi
callq 0x9e28
leaq 0x524a(%rip), %rdx      # 0xb622
movq %r14, %rdi
movl %ebp, %esi
callq 0xa595
movq %rax, 0x40(%rbx)
leaq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x9e28
leaq 0x522e(%rip), %rdx      # 0xb627
movq %r14, %rdi
movl %ebp, %esi
callq 0xa595
movq %rax, 0x60(%rbx)
leaq 0x48(%rbx), %rdi
movq %r15, %rsi
callq 0x9e28
leaq 0x68(%rbx), %r14
movq %r14, %rdi
callq 0xa138
movq %r14, %rdi
xorl %esi, %esi
callq 0xa14f
andq $0x0, 0xb0(%rbx)
andq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_map_path
char *loader_map_path(const struct loader *ldr, const char *name)
{
	size_t cap = 10;
	struct string buf;
	string_init(&buf, cap);
	string_pushz(&buf, &cap, ldr->maps_dir);
	string_pushc(&buf, &cap, DIRSEP);
	string_pushz(&buf, &cap, name);
	string_pushn(&buf, &cap, ".json", 6);
	string_shrink_to_fit(&buf);
	return buf.text;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r12
movq %rsp, %r14
movq $0xa, (%r14)
leaq 0x8(%rsp), %rbx
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x9d70
movq 0x60(%r12), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9dd5
pushq $0x2f
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9e18
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x9dd5
leaq 0x5263(%rip), %rdx      # 0xb701
pushq $0x6
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9dae
movq %rbx, %rdi
callq 0x9d98
movq 0x8(%rbx), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loadj
static void **loadj(table *tab, const char *root, const char *name, FILE **file,
	struct logger *log)
{
	char *fname = mid_cat(name, '.', "json");
	void **loaded = load(tab, root, fname, file, log);
	if (!*file) free(fname);
	return loaded;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %rax
movq %rsi, %r12
movq %rdi, %r13
leaq 0x5205(%rip), %rdx      # 0xb702
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0xa595
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x65a1
movq %rax, %r14
cmpq $0x0, (%r15)
jne 0x6530
movq %rbx, %rdi
callq 0x2580
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_texture
d3d_texture **loader_texture(struct loader *ldr, const char *name, FILE **file)
{
	char *fname = str_dup(name);
	d3d_texture **loaded = (d3d_texture **)load(&ldr->txtrs, ldr->txtrs_dir,
		fname, file, ldr->log);
	if (!*file) free(fname);
	return loaded;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0xa554
movq %rax, %rbx
leaq 0x8(%r14), %rdi
movq 0x20(%r14), %rsi
movq 0xb0(%r14), %r8
movq %rax, %rdx
movq %r15, %rcx
callq 0x65a1
movq %rax, %r14
cmpq $0x0, (%r15)
jne 0x6598
movq %rbx, %rdi
callq 0x2580
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: load
static void **load(table *tab, const char *root, const char *name, FILE **file,
	struct logger *log)
{
	void **item = table_get(tab, name);
	*file = NULL;
	if (!item) {
		char *path = mid_cat(root, DIRSEP, name);
		*file = fopen(path, "r");
		if (*file) {
			logger_printf(log, LOGGER_INFO, "Loading %s\n", path);
			table_add(tab, name, NULL);
			item = table_get(tab, name);
		} else {
			logger_printf(log, LOGGER_ERROR,
				"Cannot load %s\n", path);
		}
		free(path);
	}
	return item;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rdx, %rsi
callq 0x9f6a
movq %rax, %rbp
andq $0x0, (%r13)
testq %rax, %rax
jne 0x664e
pushq $0x2f
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0xa595
movq %rax, %rbx
leaq 0x4e90(%rip), %rsi      # 0xb478
movq %rax, %rdi
callq 0x2160
movq %rax, (%r13)
testq %rax, %rax
je 0x662d
leaq 0x5075(%rip), %rdx      # 0xb675
pushq $0x1
popq %rsi
movq %r12, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x691c
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x9e46
movq %r15, %rdi
movq %r14, %rsi
callq 0x9f6a
movq %rax, %rbp
jmp 0x6646
leaq 0x504d(%rip), %rdx      # 0xb681
xorl %ebp, %ebp
pushq $0x4
popq %rsi
movq %r12, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x691c
movq %rbx, %rdi
callq 0x2580
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_empty_texture
const d3d_texture *loader_empty_texture(struct loader *ldr)
{
	if (!ldr->empty_txtr)
		ldr->empty_txtr = assert_alloc(d3d_new_texture(1, 1,
			TRANSPARENT_PIXEL));
	return ldr->empty_txtr;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x6669
retq
pushq %rbx
movq %rdi, %rbx
pushq $0x1
popq %rdi
movq %rdi, %rsi
movl $0xff, %edx
callq 0x2901
movq %rax, %rdi
callq 0xa922
movq %rax, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_print_summary
void loader_print_summary(struct loader *ldr)
{
	logger_printf(ldr->log, LOGGER_INFO,
		"Load summary: %lu maps, %lu entity types, %lu textures, "
		"%lu color pairs\n",
		(unsigned long)table_count(&ldr->maps),
		(unsigned long)table_count(&ldr->ents),
		(unsigned long)table_count(&ldr->txtrs),
		(unsigned long)color_map_count_pairs(&ldr->colors));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movq 0xb0(%rdi), %rbx
addq $0x48, %rdi
callq 0x9ff0
movq %rax, %r15
leaq 0x28(%r14), %rdi
callq 0x9ff0
movq %rax, %r12
leaq 0x8(%r14), %rdi
callq 0x9ff0
movq %rax, %r13
addq $0x68, %r14
movq %r14, %rdi
callq 0xa1e8
movq %rax, (%rsp)
leaq 0x4f50(%rip), %rdx      # 0xb62c
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %r15, %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x691c
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/loader.c
// Function: loader_free
void loader_free(struct loader *ldr)
{
	const char *key;
	void **val;
	d3d_free_texture(ldr->empty_txtr);
	TABLE_FOR_EACH(&ldr->txtrs, key, val) {
		free((char *)key);
		d3d_free_texture(*val);
	}
	table_free(&ldr->txtrs);
	free(ldr->txtrs_dir);
	TABLE_FOR_EACH(&ldr->ents, key, val) {
		free((char *)key);
		ent_type_free(*val);
	}
	table_free(&ldr->ents);
	free(ldr->ents_dir);
	TABLE_FOR_EACH(&ldr->maps, key, val) {
		free((char *)key);
		map_free(*val);
	}
	table_free(&ldr->maps);
	free(ldr->maps_dir);
	color_map_destroy(&ldr->colors);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x37ed
leaq 0x8(%rbx), %r14
pushq $0x8
popq %r15
xorl %r12d, %r12d
cmpq (%r14), %r12
jae 0x6761
movq 0x18(%rbx), %r13
movq -0x8(%r13,%r15), %rdi
callq 0x2580
movq (%r13,%r15), %rdi
callq 0x37ed
incq %r12
addq $0x10, %r15
jmp 0x673b
movq %r14, %rdi
callq 0x9ff4
movq 0x20(%rbx), %rdi
callq 0x2580
leaq 0x28(%rbx), %r14
pushq $0x8
popq %r15
xorl %r12d, %r12d
cmpq (%r14), %r12
jae 0x67a3
movq 0x38(%rbx), %r13
movq -0x8(%r13,%r15), %rdi
callq 0x2580
movq (%r13,%r15), %rdi
callq 0x4564
incq %r12
addq $0x10, %r15
jmp 0x677d
movq %r14, %rdi
callq 0x9ff4
movq 0x40(%rbx), %rdi
callq 0x2580
leaq 0x48(%rbx), %r14
pushq $0x8
popq %r15
xorl %r12d, %r12d
cmpq (%r14), %r12
jae 0x67e5
movq 0x58(%rbx), %r13
movq -0x8(%r13,%r15), %rdi
callq 0x2580
movq (%r13,%r15), %rdi
callq 0x7fa6
incq %r12
addq $0x10, %r15
jmp 0x67bf
movq %r14, %rdi
callq 0x9ff4
movq 0x60(%rbx), %rdi
callq 0x2580
addq $0x68, %rbx
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xa1fe
nop
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/logger.c
// Function: logger_set_output
void logger_set_output(struct logger *log, int which, FILE *dest, bool do_free)
{
	if (!log) return;
	if ((which & LOGGER_ALL) == LOGGER_ALL) {
		log->do_free &= ~LOGGER_ALL;
		log->flags &= ~LOGGER_ALL;
		log->info = log->warning = log->error = dest;
		if (dest) {
			log->flags |= LOGGER_ALL;
			if (do_free) log->do_free |= LOGGER_ALL;
		}
	} else {
		int mode = get_mode(which);
		log->do_free &= ~mode;
		*get_filep(log, mode) = dest;
		if (dest) {
			log->flags |= mode;
			if (do_free) log->do_free |= mode;
		} else {
			log->flags &= ~mode;
		}
	}
}

// Assembly:
testq %rdi, %rdi
je 0x691b
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rdi, %rbx
movl %esi, %eax
notl %eax
testb $0x7, %al
jne 0x68c7
movl (%rbx), %ecx
movl 0x20(%rbx), %eax
movl %eax, %edx
andl $-0x8, %edx
movl %edx, 0x20(%rbx)
movl %ecx, %edx
andl $-0x8, %edx
movl %edx, (%rbx)
movq %r14, 0x18(%rbx)
movq %r14, 0x10(%rbx)
movq %r14, 0x8(%rbx)
testq %r14, %r14
je 0x6917
orl $0x7, %ecx
movl %ecx, (%rbx)
testb %bpl, %bpl
je 0x6917
orl $0x7, %eax
movl %eax, 0x20(%rbx)
jmp 0x6917
movl %esi, %edi
callq 0x6853
movl %eax, %edx
notl %edx
movl 0x20(%rbx), %ecx
movl %ecx, %esi
andl %edx, %esi
xorl %edi, %edi
cmpl $0x2, %eax
sete %dil
leaq 0x8(,%rdi,8), %rdi
cmpl $0x4, %eax
pushq $0x18
popq %r8
cmovneq %rdi, %r8
movl %esi, 0x20(%rbx)
movq %r14, (%rbx,%r8)
movl (%rbx), %esi
testq %r14, %r14
je 0x6913
orl %eax, %esi
movl %esi, (%rbx)
testb %bpl, %bpl
je 0x6917
orl %eax, %ecx
movl %ecx, 0x20(%rbx)
jmp 0x6917
andl %edx, %esi
movl %esi, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/logger.c
// Function: logger_printf
void logger_printf(struct logger *log, int flags, const char *format, ...)
{
	if (!log) return;
	int mode = get_mode(flags);
	if (!(log->flags & mode)) return;
	FILE *file = *get_filep(log, mode);
	fputs(get_prefix(log, mode), file);
	va_list args;
	va_start(args, format);
	vfprintf(file, format, args);
	va_end(args);
	fflush(file);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x6970
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)
testq %rdi, %rdi
je 0x6a06
movq %rdx, %rbx
movq %rdi, %r14
movl %esi, %edi
callq 0x6853
testl %eax, (%r14)
je 0x6a06
xorl %ecx, %ecx
cmpl $0x2, %eax
sete %cl
leaq 0x8(,%rcx,8), %rcx
leaq 0x4cf7(%rip), %rdx      # 0xb699
leaq 0x4ce8(%rip), %rsi      # 0xb691
cmoveq %rdx, %rsi
cmpl $0x4, %eax
pushq $0x18
popq %rax
cmovneq %rcx, %rax
movq (%r14,%rax), %r14
leaq 0x4ce2(%rip), %rdi      # 0xb6a4
cmovneq %rsi, %rdi
movq %r14, %rsi
callq 0x22a0
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rdx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21d0
movq %r14, %rdi
callq 0x2560
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/logger.c
// Function: logger_free
void logger_free(struct logger *log)
{
	if (!log) return;
	// Make sure no files are closed twice.
	FILE *filei = NULL, *filew = NULL, *filee = NULL;
	if ((log->do_free & LOGGER_INFO)
	 && (filei = *get_filep(log, LOGGER_INFO)))
		fclose(filei);
	if ((log->do_free & LOGGER_WARNING)
	 && (filew = *get_filep(log, LOGGER_WARNING))
	 && !(filew == filei && log->do_free & LOGGER_INFO))
		fclose(filew);
	if ((log->do_free & LOGGER_ERROR)
	 && (filee = *get_filep(log, LOGGER_ERROR))
	 && !(filee == filei && log->do_free & LOGGER_INFO)
	 && !(filee == filew && log->do_free & LOGGER_WARNING))
		fclose(filee);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x6a97
movq %rdi, %rbx
movl 0x20(%rdi), %eax
testb $0x1, %al
je 0x6a3b
movq 0x8(%rbx), %r14
testq %r14, %r14
je 0x6a3b
movq %r14, %rdi
callq 0x23f0
movl 0x20(%rbx), %eax
jmp 0x6a3e
xorl %r14d, %r14d
testb $0x2, %al
je 0x6a68
movq 0x10(%rbx), %r15
testq %r15, %r15
je 0x6a68
cmpq %r14, %r15
sete %dl
movq %r14, %rcx
testb %dl, %al
jne 0x6a6a
movq %r15, %rdi
callq 0x23f0
movl 0x20(%rbx), %eax
movq %r15, %rcx
jmp 0x6a6a
xorl %ecx, %ecx
testb $0x4, %al
je 0x6a97
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x6a97
cmpq %r14, %rdi
sete %dl
testb %dl, %al
jne 0x6a97
cmpq %rcx, %rdi
sete %cl
shrb %al
testb %cl, %al
jne 0x6a97
popq %rbx
popq %r14
popq %r15
jmp 0x23f0
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/main.c
// Function: remove_log_dest
static int remove_log_dest(const char *progname, struct logger *log,
	const char *arg)
{
	int which;
	if (!strcasecmp("all", arg)) {
		remove_log_dest(progname, log, "info");
		remove_log_dest(progname, log, "warning");
		remove_log_dest(progname, log, "error");
		return 0;
	} else if (!strcasecmp("info", arg)) {
		which = LOGGER_INFO;
	} else if (!strcasecmp("warning", arg)) {
		which = LOGGER_WARNING;
	} else if (!strcasecmp("error", arg)) {
		which = LOGGER_ERROR;
	} else {
		fprintf(stderr, "%s: Invalid log name: %s\n", progname, arg);
		return -1;
	}
	close_old_file(log, which);
	logger_set_output(log, which, NULL, false);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl $0x0, 0x4(%rsp)
leaq 0x4c4f(%rip), %r12      # 0xbcd8
leaq 0x4c51(%rip), %rbp      # 0xbce1
leaq 0x44d5(%rip), %r13      # 0xb56c
movq %r12, %rdi
movq %r15, %rsi
callq 0x2120
testl %eax, %eax
jne 0x70d1
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x4c29(%rip), %rdx      # 0xbcdc
callq 0x7066
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x7066
movb $0x1, %al
movl %eax, 0x4(%rsp)
movq %r13, %r15
jmp 0x7097
leaq 0x4c04(%rip), %rdi      # 0xbcdc
movq %r15, %rsi
callq 0x2120
testl %eax, %eax
je 0x710e
leaq 0x4bf6(%rip), %rdi      # 0xbce1
movq %r15, %rsi
callq 0x2120
testl %eax, %eax
je 0x7112
leaq 0x446e(%rip), %rdi      # 0xb56c
movq %r15, %rsi
callq 0x2120
testl %eax, %eax
jne 0x714a
pushq $0x4
jmp 0x7114
pushq $0x1
jmp 0x7114
pushq $0x2
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x7185
xorl %r14d, %r14d
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6873
xorl %eax, %eax
testb $0x1, 0x4(%rsp)
cmovel %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9e97(%rip), %rax      # 0x10fe8
movq (%rax), %rdi
leaq 0x4b8e(%rip), %rsi      # 0xbce9
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x24c0
pushq $-0x1
popq %r14
jmp 0x7130
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/map.c
// Function: map_prereq
char *map_prereq(struct loader *ldr, const char *name)
{
	char *path = loader_map_path(ldr, name);
	FILE *file = fopen(path, "r");
	if (!file) {
		free(path);
		return NULL;
	}
	json_reader rdr;
	json_alloc(&rdr, NULL, 1, xmalloc, free, xrealloc);
	char buf[BUFSIZ];
	json_source_file(&rdr, buf, sizeof(buf), file);
	struct json_item item;
	scan_json_key(&rdr, "prereq", &item);
	json_free(&rdr);
	fclose(file);
	free(item.key.bytes);
	free(path);
	return item.type == JSON_STRING ? item.val.str.bytes : NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2090, %rsp           # imm = 0x2090
callq 0x6440
movq %rax, %rbx
leaq 0x3e73(%rip), %rsi      # 0xb478
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x76a1
movq %rax, %r15
leaq 0x31b0(%rip), %rcx      # 0xa7d0
movq 0x9989(%rip), %r8       # 0x10fb0
leaq 0x32c6(%rip), %r9       # 0xa8f4
xorl %r14d, %r14d
leaq 0x30(%rsp), %r12
pushq $0x1
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x515c
leaq 0x90(%rsp), %rsi
movl $0x2000, %edx           # imm = 0x2000
movq %r12, %rdi
movq %r15, %rcx
callq 0x525a
leaq 0x46e6(%rip), %rsi      # 0xbd48
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x50b8
movq %r12, %rdi
callq 0x52d1
movq %r15, %rdi
callq 0x23f0
movq (%r13), %rdi
callq 0x2580
movq %rbx, %rdi
callq 0x2580
cmpl $0x6, 0x10(%r13)
jne 0x76ac
movq 0x20(%rsp), %r14
jmp 0x76ac
movq %rbx, %rdi
callq 0x2580
xorl %r14d, %r14d
movq %r14, %rax
addq $0x2090, %rsp           # imm = 0x2090
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/map.c
// Function: parse_ent_start
static int parse_ent_start(struct map_ent_start *start, struct loader *ldr,
	struct json_node *root)
{
	union json_node_data *got;
	start->frame = 0;
	if ((got = json_map_get(root, "kind", JN_STRING))) {
		struct ent_type *kind = load_ent_type(ldr, got->str);
		if (!kind) goto error_kind;
		start->type = kind;
	} else {
		goto error_kind;
	}
	start->team = TEAM_UNALIGNED;
	if (start->type->team_override != TEAM_INVALID) {
		start->team = start->type->team_override;
	} else if ((got = json_map_get(root, "team", JN_STRING))) {
		enum team team = team_from_str(got->str);
		if (team == TEAM_INVALID) {
			logger_printf(loader_logger(ldr), LOGGER_WARNING,
				"Invalid entity team: \"%s\"\n", got->str);
		} else {
			start->team = team;
		}
	}
	start->pos.x = start->pos.y = 0;
	if ((got = json_map_get(root, "pos", JN_LIST)))
		parse_json_vec(&start->pos, &got->list);
	return 0;

error_kind:
	logger_printf(loader_logger(ldr), LOGGER_ERROR,
		"Entity start specification has no \"kind\" attribute\n");
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
andq $0x0, 0x20(%rdi)
leaq 0x3f31(%rip), %rsi      # 0xbdd4
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x49e4
testq %rax, %rax
je 0x7f05
movq (%rax), %rsi
movq %r15, %rdi
callq 0x40e0
testq %rax, %rax
je 0x7f05
movq %rax, 0x10(%rbx)
movl $0x1, 0x18(%rbx)
movl 0x5c(%rax), %eax
cmpl $-0x1, %eax
je 0x7f2f
movl %eax, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x3f13(%rip), %rsi      # 0xbdf9
pushq $0x3
popq %rdx
movq %r14, %rdi
callq 0x49e4
xorl %ebp, %ebp
testq %rax, %rax
je 0x7f24
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4f6a
jmp 0x7f24
movq %r15, %rdi
callq 0x6705
leaq 0x3ee9(%rip), %rdx      # 0xbdfd
pushq $0x4
popq %rsi
movq %rax, %rdi
xorl %eax, %eax
callq 0x691c
pushq $-0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ea3(%rip), %rsi      # 0xbdd9
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x49e4
testq %rax, %rax
je 0x7ed9
movq %rax, %r12
movq (%rax), %rdi
callq 0xa000
cmpl $-0x1, %eax
jne 0x7ed6
movq %r15, %rdi
callq 0x6705
movq (%r12), %rcx
leaq 0x3e75(%rip), %rdx      # 0xbdde
pushq $0x2
popq %rsi
movq %rax, %rdi
xorl %eax, %eax
callq 0x691c
jmp 0x7ed9
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/map.c
// Function: map_free
void map_free(struct map *map)
{
	if (!map) return;
	free(map->name);
	free(map->prereq);
	d3d_free_board(map->board);
	free(map->walls);
	free(map->blocks);
	free(map->ents);
	free(map);
}

// Assembly:
testq %rdi, %rdi
je 0x7fed
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2580
movq 0x8(%rbx), %rdi
callq 0x2580
movq 0x10(%rbx), %rdi
callq 0x381c
movq 0x18(%rbx), %rdi
callq 0x2580
movq 0x20(%rbx), %rdi
callq 0x2580
movq 0x30(%rbx), %rdi
callq 0x2580
movq %rbx, %rdi
popq %rbx
jmp 0x2580
retq
nop
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_init
int menu_init(struct menu *menu, const char *root_dir, struct screen_area *area,
	struct logger *log)
{
	char *fname = mid_cat(root_dir, DIRSEP, "menu.json");
	FILE *file = fopen(fname, "r");
	if (!file) {
		logger_printf(log, LOGGER_ERROR,
			"Menu file \"%s\" could not be opened\n", fname);
		goto error_fopen;
	}
	struct json_node jtree;
	if (parse_json_tree("menu", file, log, &jtree)) goto error_json_parse;
	menu->root = xmalloc(sizeof(*menu->root));
	if (construct(menu->root, NULL, &jtree, log)) goto error_json_format;
	menu->area = area;
	menu->current = menu->root;
	menu->root_dir = root_dir;
	menu->msg = "";
	menu->lines = NULL;
	menu->n_lines = 0;
	menu->needs_redraw = true;
	free_json_tree(&jtree);
	free(fname);
	return 0;

error_json_format:
	free(menu->root);
	free_json_tree(&jtree);
error_json_parse:
error_fopen:
	free(fname);
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
leaq 0x3e8f(%rip), %rdx      # 0xbea0
pushq $0x2f
popq %rsi
movq %r15, %rdi
callq 0xa595
movq %rax, %rbx
leaq 0x3452(%rip), %rsi      # 0xb478
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x8058
leaq 0x3e94(%rip), %rdi      # 0xbece
leaq 0x8(%rsp), %rcx
movq %rax, %rsi
movq %r13, %rdx
callq 0x4a25
pushq $-0x1
popq %rcx
testl %eax, %eax
je 0x8074
movl %ecx, %ebp
jmp 0x80e1
leaq 0x3e4b(%rip), %rdx      # 0xbeaa
pushq $0x4
popq %rsi
movq %r13, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x691c
pushq $-0x1
popq %rbp
jmp 0x80e1
pushq $0x38
popq %rdi
callq 0xa7d0
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rcx
callq 0x80fa
testl %eax, %eax
je 0x80b0
movq (%r14), %rdi
callq 0x2580
leaq 0x8(%rsp), %rdi
callq 0x4eaf
pushq $-0x1
popq %rax
movl %eax, %ebp
jmp 0x80e1
movq %r12, 0x10(%r14)
movq (%r14), %rax
movq %rax, 0x8(%r14)
movq %r15, 0x18(%r14)
leaq 0x330a(%rip), %rax      # 0xb3d0
movq %rax, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movb $0x1, 0x38(%r14)
leaq 0x8(%rsp), %rdi
callq 0x4eaf
movq %rbx, %rdi
callq 0x2580
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_get_selected
struct menu_item *menu_get_selected(struct menu *menu)
{
	if (!menu->current
	 || menu->current->kind != ITEM_LINKS
	 || (size_t)menu->current->place >= menu->current->n_items)
		return NULL;
	return &menu->current->items[menu->current->place];
}

// Assembly:
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x82b6
cmpl $0x1, 0x10(%rcx)
jne 0x82b6
movslq 0x30(%rcx), %rax
cmpq %rax, 0x28(%rcx)
jbe 0x82b6
imulq $0x38, %rax, %rax
addq 0x20(%rcx), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_scroll
int menu_scroll(struct menu *menu, int amount)
{
	struct menu_item *current = menu->current;
	if (current->kind == ITEM_TEXT) text_n_items(menu, current);
	if (current->n_items <= 0) return 0;
	int last_place = current->place;
	current->place =
		CLAMP(current->place + amount, 0, (int)current->n_items - 1);
	if (current->kind == ITEM_LINKS) {
		int height = menu->area->height - 2;
		if ((int)current->n_items < height) {
			current->frame = 0;
		} else {
			current->frame = CLAMP(current->frame,
				current->place - height + 1, current->place);
		}
	}
	menu->needs_redraw = menu->needs_redraw || current->place != last_place;
	return current->place - last_place;
}

// Assembly:
movq 0x8(%rdi), %rcx
movl 0x10(%rcx), %r8d
cmpl $0x2, %r8d
jne 0x82e8
movq 0x10(%rdi), %rax
movq 0x30(%rdi), %rdx
movslq 0xc(%rax), %rax
addq $-0x3, %rax
subq %rax, %rdx
pushq $0x1
popq %r9
cmovaq %rdx, %r9
movq %r9, 0x28(%rcx)
jmp 0x82ec
movq 0x28(%rcx), %r9
testq %r9, %r9
je 0x834d
movl 0x30(%rcx), %edx
addl %edx, %esi
leal -0x1(%r9), %eax
cmpl %r9d, %esi
cmovll %esi, %eax
xorl %r10d, %r10d
testl %esi, %esi
cmovsl %r10d, %eax
movl %eax, 0x30(%rcx)
cmpl $0x1, %r8d
jne 0x8344
movq 0x10(%rdi), %rsi
movl 0xc(%rsi), %esi
addl $-0x2, %esi
cmpl %r9d, %esi
jg 0x8340
movl 0x34(%rcx), %r8d
movl %eax, %r9d
subl %esi, %r9d
cmpl %eax, %r8d
movl %eax, %r10d
cmovll %r8d, %r10d
leal 0x1(%r9), %esi
cmpl %r9d, %r8d
cmovlel %esi, %r10d
movl %r10d, 0x34(%rcx)
subl %edx, %eax
setne %cl
orb %cl, 0x38(%rdi)
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_enter
enum menu_action menu_enter(struct menu *menu)
{
	struct menu_item *current = menu->current;
	if (!has_items(current)) return ACTION_BLOCKED;
	struct menu_item *into = &current->items[current->place];
	switch (into->kind) {
		FILE *txtfile;
		char *fname;
	case ITEM_INERT:
		return ACTION_BLOCKED;
	case ITEM_LINKS:
		enter(menu, into);
		return ACTION_WENT;
	case ITEM_TEXT:
		fname = mid_cat(menu->root_dir, DIRSEP, into->tag);
		if (!(txtfile = fopen(fname, "r"))
		 || !(menu->lines = read_lines(txtfile, &menu->n_lines))) {
			free(fname);
			menu_set_message(menu, "Failed to read file");
			return ACTION_BLOCKED;
		}
		free(fname);
		text_n_items(menu, into);
		enter(menu, into);
		return ACTION_WENT;
	case ITEM_TAG:
		menu->needs_redraw = true;
		return ACTION_TAG;
	}
	return ACTION_BLOCKED;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x8(%rdi), %rax
movq 0x20(%rax), %r15
xorl %ebp, %ebp
testq %r15, %r15
je 0x842e
cmpq $0x0, 0x28(%rax)
je 0x842e
movq %rdi, %rbx
movslq 0x30(%rax), %rax
imulq $0x38, %rax, %rcx
movl 0x10(%r15,%rcx), %eax
cmpl $0x3, %eax
je 0x840e
addq %rcx, %r15
cmpl $0x2, %eax
je 0x83a0
cmpl $0x1, %eax
je 0x8402
jmp 0x842e
movq 0x18(%rbx), %rdi
movq 0x18(%r15), %rdx
pushq $0x2f
popq %rsi
callq 0xa595
movq %rax, %r14
leaq 0x30be(%rip), %rsi      # 0xb478
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x8417
leaq 0x30(%rbx), %rsi
movq %rax, %rdi
callq 0x9894
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x8417
movq %r14, %rdi
callq 0x2580
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
movslq 0xc(%rax), %rax
addq $-0x3, %rax
subq %rax, %rcx
pushq $0x1
popq %rax
cmovaq %rcx, %rax
movq %rax, 0x28(%r15)
movb $0x1, 0x38(%rbx)
movq %r15, 0x8(%rbx)
pushq $0x1
jmp 0x8414
movb $0x1, 0x38(%rbx)
pushq $0x2
popq %rbp
jmp 0x842e
movq %r14, %rdi
callq 0x2580
movb $0x1, 0x38(%rbx)
leaq 0x3aa9(%rip), %rax      # 0xbed3
movq %rax, 0x20(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_escape
bool menu_escape(struct menu *menu)
{
	if (menu->lines) {
		for (size_t i = 0; i < menu->n_lines; ++i) {
			free(menu->lines[i].text);
		}
		free(menu->lines);
		menu->lines = NULL;
	}
	if (!menu->current->parent) return false;
	menu->needs_redraw = true;
	menu->current = menu->current->parent;
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpq $0x0, 0x28(%rdi)
je 0x8480
pushq $0x8
popq %r14
xorl %r15d, %r15d
movq 0x28(%rbx), %rdi
cmpq 0x30(%rbx), %r15
jae 0x8476
movq (%rdi,%r14), %rdi
callq 0x2580
incq %r15
addq $0x10, %r14
jmp 0x845a
callq 0x2580
andq $0x0, 0x28(%rbx)
movq 0x8(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x8494
movb $0x1, 0x38(%rbx)
movq %rax, 0x8(%rbx)
testq %rax, %rax
setne %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: menu_destroy
void menu_destroy(struct menu *menu)
{
	destroy_item(menu->root);
	free(menu->root);
	if (menu->lines) {
		for (size_t i = 0; i < menu->n_lines; ++i) {
			free(menu->lines[i].text);
		}
		free(menu->lines);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x8762
movq (%rbx), %rdi
callq 0x2580
cmpq $0x0, 0x28(%rbx)
je 0x875c
pushq $0x8
popq %r14
xorl %r15d, %r15d
movq 0x28(%rbx), %rdi
cmpq 0x30(%rbx), %r15
jae 0x8752
movq (%rdi,%r14), %rdi
callq 0x2580
incq %r15
addq $0x10, %r14
jmp 0x8736
popq %rbx
popq %r14
popq %r15
jmp 0x2580
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/menu.c
// Function: destroy_item
static void destroy_item(struct menu_item *item)
{
	if (has_items(item)) {
		for (size_t i = 0; i < item->n_items; ++i) {
			destroy_item(&item->items[i]);
		}
	}
	free(item->items);
	free(item->title);
	free(item->tag);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
testq %rdi, %rdi
je 0x87a0
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x87a2
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x20(%rbx), %rdi
cmpq %rax, %r15
jae 0x87a2
addq %r14, %rdi
callq 0x8762
incq %r15
movq 0x28(%rbx), %rax
addq $0x38, %r14
jmp 0x8782
xorl %edi, %edi
callq 0x2580
movq 0x8(%rbx), %rdi
callq 0x2580
movq 0x18(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2580
nop
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/player.c
// Function: player_init
void player_init(struct player *player, struct map *map)
{
	player->start = &map->player;
	player->body.pos = player->start->pos;
	player->body.radius = player->start->type->width / 2;
	player->body.health = player->start->type->health;
	player->body.damage = player->start->type->damage;
	player->turn_speed = PLAYER_TURN_MULTIPLIER
		* chance_to_fraction(player->start->type->turn_chance);
	double reload_ready =
		1.0 / chance_to_fraction(player->start->type->shoot_chance);
	player->reload_ready = isfinite(reload_ready) ? reload_ready : LONG_MAX;
	player->reload = player->reload_ready;
	player->facing = 0;
}

// Assembly:
leaq 0x38(%rsi), %rax
movq %rax, 0x28(%rdi)
movups 0x38(%rsi), %xmm0
movups %xmm0, (%rdi)
movq 0x48(%rsi), %rax
movsd 0x8(%rax), %xmm0
mulsd 0x1aec(%rip), %xmm0     # 0xb0c0
movsd %xmm0, 0x10(%rdi)
movups 0x60(%rax), %xmm0
movups %xmm0, 0x18(%rdi)
movl 0x44(%rax), %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x2a87(%rip), %xmm1     # 0xc078
mulsd %xmm1, %xmm0
mulsd 0x2a83(%rip), %xmm0     # 0xc080
movsd %xmm0, 0x38(%rdi)
movl 0x48(%rax), %eax
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
movsd 0x1ada(%rip), %xmm0     # 0xb0f0
divsd %xmm2, %xmm0
ucomisd 0x2a66(%rip), %xmm0     # 0xc088
jne 0x962c
movsd 0x1abc(%rip), %xmm0     # 0xb0e8
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rdi)
movq %rax, 0x40(%rdi)
andq $0x0, 0x30(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/player.c
// Function: player_try_shoot
bool player_try_shoot(struct player *player, struct ents *ents)
{
	if (!player_can_shoot(player)) return false;
	player->reload = 0;
	ent_id bullet = ents_add(ents, player->start->type->bullet, TEAM_ALLY,
		&player->body.pos);
	d3d_vec_s *bvel = ents_vel(ents, bullet);
	bvel->x = player->start->type->bullet->speed * cos(player->facing);
	bvel->y = player->start->type->bullet->speed * sin(player->facing);
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %r14
callq 0x9698
movl %eax, %ebx
testb %al, %al
je 0x97fd
andq $0x0, 0x40(%r14)
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rsi
pushq $0x3
popq %rdx
movq %r15, %rdi
movq %r14, %rcx
callq 0x45e5
movq %r15, %rdi
movq %rax, %rsi
callq 0x4838
movq %rax, %r15
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%r14), %xmm0
callq 0x2190
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r15)
movq 0x28(%r14), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%r14), %xmm0
callq 0x2530
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%r15)
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/player.c
// Function: player_collide
void player_collide(struct player *player, struct ents *ents)
{
	if (player_is_dead(player)) return;
	ENTS_FOR_EACH(ents, e) {
		if (teams_can_collide(player->start->team, ents_team(ents, e)))
			bodies_collide(&player->body, ents_body(ents, e));
	}
	player->body.health =
		CLAMP(player->body.health, 0, player->start->type->health);
}

// Assembly:
xorpd %xmm0, %xmm0
ucomisd 0x18(%rdi), %xmm0
jae 0x9893
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %r15d, %r15d
cmpq 0x10(%r14), %r15
jae 0x9864
movq 0x28(%rbx), %rax
movl 0x18(%rax), %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x484d
movl %ebp, %edi
movl %eax, %esi
callq 0xa091
testb %al, %al
je 0x985f
movq %r14, %rdi
movq %r15, %rsi
callq 0x4829
movq %rbx, %rdi
movq %rax, %rsi
callq 0x267c
incq %r15
jmp 0x9824
movsd 0x18(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x9884
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rax
movsd 0x60(%rax), %xmm1
minsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/save-state.c
// Function: save_state_init
int save_state_init(struct save_state *save, FILE *from, struct logger *log)
{
	struct json_node jtree;
	if (parse_json_tree("save_state", from, log, &jtree)) return -1;
	table_init(&save->complete, 5); // This empty table will be populated.
	if (jtree.kind != JN_MAP) goto end;
	union json_node_data *got;
	if ((got = json_map_get(&jtree, "complete", JN_LIST))) {
		struct json_node_data_list *complete = &got->list;
		for (size_t i = 0; i < complete->n_vals; ++i) {
			struct json_node *node = &complete->vals[i];
			if (node->kind == JN_STRING)
				save_state_mark_complete(save, node->d.str);
		}
	} else if ((got = json_map_get(&jtree, "saves", JN_MAP))) {
		// With the old format, merge all the saves' completed levels
		// into one list.
		table *saves = &got->map;
		const char *UNUSED_VAR(key);
		void **val;
		TABLE_FOR_EACH(saves, key, val) {
			if ((got = json_map_get(*val, "complete", JN_LIST))) {
				struct json_node_data_list *complete =
					&got->list;
				for (size_t i = 0; i < complete->n_vals; ++i) {
					struct json_node *node =
						&complete->vals[i];
					if (node->kind == JN_STRING)
						save_state_mark_complete(save,
							node->d.str);
				}
			}
		}
	}
end:
	free_json_tree(&jtree);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x25e8(%rip), %rdi      # 0xc090
leaq 0x8(%rsp), %rcx
callq 0x4a25
testl %eax, %eax
je 0x9abe
pushq $-0x1
popq %rax
jmp 0x9bab
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x9e28
cmpl $0x2, 0x8(%rsp)
jne 0x9b9f
leaq 0x25c0(%rip), %rsi      # 0xc09b
leaq 0x8(%rsp), %rdi
pushq $0x3
popq %rdx
callq 0x49e4
testq %rax, %rax
je 0x9b21
movq %rax, %r14
pushq $0x8
popq %r15
xorl %r12d, %r12d
cmpq (%r14), %r12
jae 0x9b9f
movq 0x8(%r14), %rax
cmpl $0x4, -0x8(%rax,%r15)
jne 0x9b18
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0x9bba
incq %r12
addq $0x20, %r15
jmp 0x9af7
leaq 0x257c(%rip), %rsi      # 0xc0a4
leaq 0x8(%rsp), %rdi
pushq $0x2
popq %rdx
callq 0x49e4
testq %rax, %rax
je 0x9b9f
movq %rax, %r14
xorl %r13d, %r13d
cmpq (%r14), %r13
jae 0x9b9f
movq 0x10(%r14), %rax
movq %r13, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rdi
leaq 0x253f(%rip), %rsi      # 0xc09b
pushq $0x3
popq %rdx
callq 0x49e4
testq %rax, %rax
je 0x9b9a
movq %rax, %r12
pushq $0x8
popq %r15
xorl %ebp, %ebp
cmpq (%r12), %rbp
jae 0x9b9a
movq 0x8(%r12), %rax
cmpl $0x4, -0x8(%rax,%r15)
jne 0x9b91
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0x9bba
incq %rbp
addq $0x20, %r15
jmp 0x9b72
incq %r13
jmp 0x9b40
leaq 0x8(%rsp), %rdi
callq 0x4eaf
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/save-state.c
// Function: save_state_write
int save_state_write(struct save_state *save, FILE *to)
{
	struct string buf;
	size_t cap = 64;
	string_init(&buf, cap);
	string_pushz(&buf, &cap, "{\n \"complete\": ");
	if (table_count(&save->complete) > 0) {
		const char *before = "[";
		const char *key;
		void **UNUSED_VAR(val);
		TABLE_FOR_EACH(&save->complete, key, val) {
			string_pushz(&buf, &cap, before);
			string_pushz(&buf, &cap, "\n  \"");
			escape_text_json(key, &buf, &cap);
			before = "\",";
		}
		string_pushz(&buf, &cap, "\"\n ]\n}");
	} else {
		string_pushz(&buf, &cap, "[]\n}");
	}
	// Try to recover from errors where part of the data was written:
	size_t total_writ = 0;
	do {
		size_t writ = fwrite(buf.text + total_writ, 1,
			buf.len - total_writ, to);
		// Exit if no progress is being made:
		if (!writ) {
			free(buf.text);
			return -1;
		}
		clearerr(to);
		total_writ += writ;
	} while (total_writ < buf.len);
	free(buf.text);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x8(%rsp), %r15
movq $0x40, (%r15)
leaq 0x10(%rsp), %r12
pushq $0x40
popq %rsi
movq %r12, %rdi
callq 0x9d70
leaq 0x2471(%rip), %rdx      # 0xc0aa
movq %r12, %rdi
movq %r15, %rsi
callq 0x9dd5
movq %r14, %rdi
callq 0x9ff0
testq %rax, %rax
je 0x9cc1
movq %rbx, 0x20(%rsp)
leaq 0x245d(%rip), %rdx      # 0xc0ba
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
xorl %ebx, %ebx
cmpq (%r14), %rbx
jae 0x9cb3
movq 0x10(%r14), %rax
movq (%rax,%rbp), %r15
movq %r12, %rdi
movq %r13, %rsi
callq 0x9dd5
movq %r12, %rdi
movq %r13, %rsi
leaq 0x242c(%rip), %rdx      # 0xc0bc
callq 0x9dd5
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4fae
incq %rbx
addq $0x10, %rbp
leaq 0x2410(%rip), %rdx      # 0xc0c1
jmp 0x9c6b
movq 0x20(%rsp), %rbx
leaq 0x2405(%rip), %rdx      # 0xc0c4
jmp 0x9cc8
leaq 0x2403(%rip), %rdx      # 0xc0cb
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x9dd5
xorl %r12d, %r12d
movq (%r14), %rdx
pushq $0x1
popq %r14
pushq $-0x1
popq %rbp
movq 0x18(%rsp), %rdi
addq %r12, %rdi
subq %r12, %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x2470
testq %rax, %rax
je 0x9d1c
movq %rax, %r15
movq %rbx, %rdi
callq 0x2450
addq %r15, %r12
movq 0x10(%rsp), %rdx
cmpq %rdx, %r12
jb 0x9ce7
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
callq 0x2580
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/save-state.c
// Function: save_state_destroy
void save_state_destroy(struct save_state *save)
{
	const char *key;
	void **UNUSED_VAR(val);
	TABLE_FOR_EACH(&save->complete, key, val) {
		free((char *)key);
	}
	table_free(&save->complete);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq (%rbx), %r15
jae 0x9d60
movq 0x10(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2580
incq %r15
addq $0x10, %r14
jmp 0x9d45
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x9ff4
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/table.c
// Function: table_add
int table_add(table *tbl, const char *key, void *val)
{
	struct item *slot;
	GROWE(tbl->items, tbl->len, tbl->cap);
	--tbl->len;
	if (find(tbl, &slot, key)) return -1;
	memmove(slot + 1, slot, (tbl->len - (slot - tbl->items)) * ITEM_SIZE);
	slot->key = key;
	slot->val = val;
	++tbl->len;
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
addq $0x10, %rdi
leaq 0x8(%r14), %rdx
pushq $0x10
popq %rcx
movq %r14, %rsi
callq 0x4954
movq (%r14), %r12
decq %r12
movq %r12, (%r14)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x9ed2
testb %al, %al
je 0x9e91
pushq $-0x1
popq %rax
jmp 0x9ec4
movq 0x8(%rsp), %r13
movq %r13, %rax
subq 0x10(%r14), %rax
leaq 0x10(%r13), %rdi
shrq $0x4, %rax
subq %rax, %r12
shlq $0x4, %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0x22c0
movq %r15, (%r13)
movq %rbx, 0x8(%r13)
incq (%r14)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/table.c
// Function: find
static bool find(table *tbl, struct item **found, const char *key)
{
	long start = 0, end = tbl->len - 1;
	while (start <= end) {
		long mid = (start + end) / 2;
		int cmp = strcmp(key, tbl->items[mid].key);
		if (cmp > 0) {
			start = mid + 1;
		} else if (cmp < 0) {
			end = mid - 1;
		} else {
			*found = &tbl->items[mid];
			return true;
		}
	}
	*found = &tbl->items[start];
	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, (%rsp)
movq %rdi, %r14
movq (%rdi), %rbp
xorl %ebx, %ebx
movq %rbp, %r13
decq %r13
cmpq %r13, %rbx
jg 0x9f29
leaq (%rbx,%r13), %rbp
shrq %rbp
movq 0x10(%r14), %rax
movq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r12
movq (%rax,%rcx), %rsi
movq %r15, %rdi
callq 0x2390
testl %eax, %eax
jle 0x9f25
incq %rbp
movq %rbp, %rbx
jmp 0x9ef2
js 0x9eec
jmp 0x9f34
movq %rbx, %r12
shlq $0x4, %r12
addq 0x10(%r14), %r12
cmpq %r13, %rbx
setle %al
movq (%rsp), %rcx
movq %r12, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/table.c
// Function: table_remove
void *table_remove(table *tbl, const char *key)
{
	struct item *got;
	if (find(tbl, &got, key)) {
		void *val = got->val;
		--tbl->len;
		memmove(got, got + 1,
			(tbl->len - (got - tbl->items)) * ITEM_SIZE);
		return val;
	}
	return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rdx
movq %rdi, %r14
movq %rsp, %rsi
callq 0x9ed2
testb %al, %al
je 0x9fe3
movq (%rsp), %rdi
movq 0x8(%rdi), %rbx
movq (%r14), %rax
leaq -0x1(%rax), %rcx
movq %rcx, (%r14)
leaq 0x10(%rdi), %rsi
movq %rdi, %rcx
subq 0x10(%r14), %rcx
shrq $0x4, %rcx
negq %rcx
leaq (%rax,%rcx), %rdx
decq %rdx
shlq $0x4, %rdx
callq 0x22c0
jmp 0x9fe5
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/team.c
// Function: team_from_str
enum team team_from_str(const char *str)
{
	if (!strcasecmp(str, "GHOST")) {
		return TEAM_GHOST;
	} else if (!strcasecmp(str, "UNALIGNED")) {
		return TEAM_UNALIGNED;
	} else if (!strcasecmp(str, "PLAYER")) {
		return TEAM_PLAYER;
	} else if (!strcasecmp(str, "ALLY")) {
		return TEAM_ALLY;
	} else if (!strcasecmp(str, "ENEMY")) {
		return TEAM_ENEMY;
	} else if (!strcasecmp(str, "PICKUP")) {
		return TEAM_PICKUP;
	} else {
		return TEAM_INVALID;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x20c5(%rip), %rsi      # 0xc0d0
callq 0x2120
testl %eax, %eax
je 0xa07c
leaq 0x20bb(%rip), %rsi      # 0xc0d6
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa080
leaq 0x20b2(%rip), %rsi      # 0xc0e0
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa084
leaq 0x20a6(%rip), %rsi      # 0xc0e7
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa088
leaq 0x2098(%rip), %rsi      # 0xc0ec
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa08c
leaq 0x208b(%rip), %rsi      # 0xc0f2
movq %rbx, %rdi
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
orl $0x5, %eax
jmp 0xa08f
xorl %eax, %eax
jmp 0xa08f
pushq $0x1
jmp 0xa08e
pushq $0x2
jmp 0xa08e
pushq $0x3
jmp 0xa08e
pushq $0x4
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/ticker.c
// Function: tick
void tick(struct ticker *tkr)
{
	struct timeval now;
	gettimeofday(&now, NULL);
	long elapsed = (long)now.tv_usec - (long)tkr->last_tick.tv_usec;
	if (elapsed < 0) elapsed += 1000000;
	long delay = tkr->interval - elapsed;
	if (delay > 0) {
		struct timespec delay_ts =
			{ .tv_sec = 0, .tv_nsec = delay * 1000 };
		nanosleep(&delay_ts, NULL);
	}
	gettimeofday(&tkr->last_tick, NULL);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2130
movq 0x8(%r14), %rax
subq 0x8(%rbx), %rax
leaq 0xf4240(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
movq 0x10(%rbx), %rax
subq %rcx, %rax
jle 0xa125
leaq 0x8(%rsp), %rdi
andq $0x0, (%rdi)
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x23b0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2130
addq $0x28, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: color_map_add_pair
int color_map_add_pair(struct color_map *map, d3d_pixel pix)
{
	if (pix >= sizeof(map->pixel2pair)) return 0;
	if (map->pixel2pair[pix] == 0) {
		if (map->pair_num >= COLOR_PAIRS - 1) return 0;
		++map->pair_num;
		map->pixel2pair[pix] = map->pair_num;
	}
	return map->pixel2pair[pix];
}

// Assembly:
xorl %eax, %eax
cmpb $0x3f, %sil
ja 0xa17f
movzbl %sil, %edx
movb 0x4(%rdi,%rdx), %cl
testb %cl, %cl
jne 0xa17c
movl (%rdi), %ecx
movq 0x6e24(%rip), %rsi      # 0x10f90
movl (%rsi), %esi
decl %esi
cmpl %esi, %ecx
jge 0xa17f
incl %ecx
movl %ecx, (%rdi)
movb %cl, 0x4(%rdi,%rdx)
movsbl %cl, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: color_map_apply
int color_map_apply(struct color_map *map)
{
	static const short colors[] = {
		COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
		COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
	};
	int ret = 0;
	for (d3d_pixel p = 0; p < sizeof(map->pixel2pair); ++p) {
		int pair = map->pixel2pair[p];
		if (pair > 0) {
			int fg = colors[pixel_fg(p)];
			int bg = colors[pixel_bg(p)];
			if (init_pair(pair, fg, bg) == ERR) {
				map->pixel2pair[p] = 0;
				ret = -1;
			}
		}
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
leaq 0x1fab(%rip), %r15      # 0xc140
pushq $-0x1
popq %r12
xorl %ebp, %ebp
cmpq $0x40, %r14
je 0xa1dd
movsbl 0x4(%rbx,%r14), %eax
testw %ax, %ax
jle 0xa1d8
movl %r14d, %ecx
shrl $0x3, %ecx
movswl (%r15,%rcx,2), %esi
movl %r14d, %ecx
andl $0x7, %ecx
movswl (%r15,%rcx,2), %edx
movswl %ax, %edi
callq 0x21b0
cmpl $-0x1, %eax
jne 0xa1d8
movb $0x0, 0x4(%rbx,%r14)
movl %r12d, %ebp
incq %r14
jmp 0xa19b
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq