LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0x56dc(%rip), %rdi      # 0xcd08
movq %rdx, %rsi
callq 0x2120
movl %eax, %ebp
testl %eax, %eax
jne 0x7689
movl %ebp, 0x4(%rsp)
leaq 0x56c7(%rip), %r13      # 0xcd0c
leaq 0x56c5(%rip), %rbp      # 0xcd11
leaq 0x56b5(%rip), %rbx      # 0xcd08
leaq 0x4f42(%rip), %r12      # 0xc59c
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x7611
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x7611
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2120
testl %eax, %eax
je 0x765a
movl 0x4(%rsp), %ebp
leaq 0x567c(%rip), %rdi      # 0xcd0c
movq %r12, %rsi
callq 0x2120
testl %eax, %eax
je 0x76ed
leaq 0x566e(%rip), %rdi      # 0xcd11
movq %r12, %rsi
callq 0x2120
testl %eax, %eax
je 0x76f4
leaq 0x4ee6(%rip), %rdi      # 0xc59c
movq %r12, %rsi
callq 0x2120
movl $0x4, %ebx
testl %eax, %eax
je 0x76f9
movq 0x991a(%rip), %rax      # 0x10fe8
movq (%rax), %rdi
leaq 0x5641(%rip), %rsi      # 0xcd19
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x24b0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x7714
movl $0x1, %ebx
jmp 0x76f9
movl $0x2, %ebx
movq %r14, %rdi
movl %ebx, %esi
callq 0x772c
xorl %r15d, %r15d
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6d8d
testl %ebp, %ebp
cmovel %ebp, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/map.c
// Function: get_wall_ck
static uint8_t get_wall_ck(const struct map *map, long lx, long ly)
{
	size_t x = (size_t)lx, y = (size_t)ly;
	if (x < d3d_board_width(map->board) && y < d3d_board_height(map->board))
	{
		return *get_wall((struct map *)map, x, y);
	} else {
		return 0;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0x10(%rdi), %rdi
callq 0x3a4e
cmpq %rbx, %rax
jbe 0x7bb1
movq 0x10(%r15), %rdi
callq 0x3a52
cmpq %r14, %rax
jbe 0x7bb1
movq 0x10(%r15), %rdi
movq 0x18(%r15), %r15
callq 0x3a4e
imulq %r14, %rax
addq %r15, %rax
movb (%rbx,%rax), %al
jmp 0x7bb3
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x694a
movq %rax, %rbx
leaq 0x48d0(%rip), %rsi      # 0xc4a8
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x7c76
movq %rax, %r15
leaq 0x348d(%rip), %rcx      # 0xb080
movq 0x93b6(%rip), %r8       # 0x10fb0
leaq 0x35a7(%rip), %r9       # 0xb1a8
xorl %r14d, %r14d
leaq 0x30(%rsp), %r12
movl $0x1, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x550c
leaq 0x90(%rsp), %rsi
movl $0x2000, %edx           # imm = 0x2000
movq %r12, %rdi
movq %r15, %rcx
callq 0x5614
leaq 0x5141(%rip), %rsi      # 0xcd78
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x5467
movq %r12, %rdi
callq 0x5692
movq %r15, %rdi
callq 0x23e0
movq (%r13), %rdi
callq 0x2570
movq %rbx, %rdi
callq 0x2570
cmpl $0x6, 0x10(%r13)
jne 0x7c81
movq 0x20(%rsp), %r14
jmp 0x7c81
movq %rbx, %rdi
callq 0x2570
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_O3/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
movq $0x0, 0x20(%rdi)
leaq 0x4937(%rip), %rsi      # 0xce04
movq %rdx, %rdi
movl $0x4, %edx
callq 0x4cbc
testq %rax, %rax
je 0x8533
movq (%rax), %rsi
movq %r15, %rdi
callq 0x433c
testq %rax, %rax
je 0x8533
movq %rax, 0x10(%rbx)
movl $0x1, 0x18(%rbx)
movl 0x5c(%rax), %eax
cmpl $-0x1, %eax
je 0x8561
movl %eax, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x4917(%rip), %rsi      # 0xce29
movq %r14, %rdi
movl $0x3, %edx
callq 0x4cbc
xorl %ebp, %ebp
testq %rax, %rax
je 0x8556
movq %rbx, %rdi
movq %rax, %rsi
callq 0x52d4
jmp 0x8556
movq %r15, %rdi
callq 0x6c2a
leaq 0x48eb(%rip), %rdx      # 0xce2d
movq %rax, %rdi
movl $0x4, %esi
xorl %eax, %eax
callq 0x6e50
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x48a1(%rip), %rsi      # 0xce09
movq %r14, %rdi
movl $0x4, %edx
callq 0x4cbc
testq %rax, %rax
je 0x8505
movq %rax, %r12
movq (%rax), %rdi
callq 0xa808
cmpl $-0x1, %eax
jne 0x8502
movq %r15, %rdi
callq 0x6c2a
movq (%r12), %rcx
leaq 0x486d(%rip), %rdx      # 0xce0e
movq %rax, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x6e50
jmp 0x8505
// File: /workspace/github_c_makefile_star2_O3/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 0x85fc
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2570
movq 0x8(%rbx), %rdi
callq 0x2570
movq 0x10(%rbx), %rdi
callq 0x3a78
movq 0x18(%rbx), %rdi
callq 0x2570
movq 0x20(%rbx), %rdi
callq 0x2570
movq 0x30(%rbx), %rdi
callq 0x2570
movq %rbx, %rdi
popq %rbx
jmp 0x2570
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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 0x48af(%rip), %rdx      # 0xced0
movq %rsi, %rdi
movl $0x2f, %esi
callq 0xade9
movq %rax, %rbx
leaq 0x3e70(%rip), %rsi      # 0xc4a8
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x869e
leaq 0x48b2(%rip), %rdi      # 0xcefe
leaq 0x8(%rsp), %rcx
movq %rax, %rsi
movq %r13, %rdx
callq 0x4cfd
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x86bc
movl $0x38, %edi
callq 0xb080
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rcx
callq 0x8708
testl %eax, %eax
je 0x86d5
movq (%r14), %rdi
callq 0x2570
leaq 0x8(%rsp), %rdi
callq 0x5215
jmp 0x86b7
leaq 0x4835(%rip), %rdx      # 0xceda
movq %r13, %rdi
movl $0x4, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x6e50
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x2570
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x10(%r14)
movq (%r14), %rax
movq %rax, 0x8(%r14)
movq %r15, 0x18(%r14)
leaq 0x3d15(%rip), %rax      # 0xc400
movq %rax, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movb $0x1, 0x38(%r14)
leaq 0x8(%rsp), %rdi
callq 0x5215
jmp 0x86bc
// File: /workspace/github_c_makefile_star2_O3/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 0x88ea
cmpl $0x1, 0x10(%rcx)
jne 0x88ea
movslq 0x30(%rcx), %rax
cmpq %rax, 0x28(%rcx)
jbe 0x88ea
imulq $0x38, %rax, %rax
addq 0x20(%rcx), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x891e
movq 0x10(%rdi), %rax
movq 0x30(%rdi), %rdx
movslq 0xc(%rax), %rax
addq $-0x3, %rax
subq %rax, %rdx
movl $0x1, %r9d
cmovaq %rdx, %r9
movq %r9, 0x28(%rcx)
jmp 0x8922
movq 0x28(%rcx), %r9
testq %r9, %r9
je 0x8983
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 0x897a
movq 0x10(%rdi), %rsi
movl 0xc(%rsi), %esi
addl $-0x2, %esi
cmpl %r9d, %esi
jg 0x8976
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_O3/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 0x8a6d
cmpq $0x0, 0x28(%rax)
je 0x8a6d
movq %rdi, %rbx
movslq 0x30(%rax), %rax
imulq $0x38, %rax, %rcx
movl 0x10(%r15,%rcx), %eax
cmpl $0x3, %eax
je 0x8a4b
addq %rcx, %r15
cmpl $0x2, %eax
je 0x89d6
cmpl $0x1, %eax
je 0x8a3c
jmp 0x8a6d
movq 0x18(%rbx), %rdi
movq 0x18(%r15), %rdx
movl $0x2f, %esi
callq 0xade9
movq %rax, %r14
leaq 0x3ab6(%rip), %rsi      # 0xc4a8
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x8a56
leaq 0x30(%rbx), %rsi
movq %rax, %rdi
callq 0x9ff0
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x8a56
movq %r14, %rdi
callq 0x2570
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
movslq 0xc(%rax), %rax
addq $-0x3, %rax
subq %rax, %rcx
movl $0x1, %eax
cmovaq %rcx, %rax
movq %rax, 0x28(%r15)
movb $0x1, 0x38(%rbx)
movq %r15, 0x8(%rbx)
movl $0x1, %ebp
jmp 0x8a6d
movb $0x1, 0x38(%rbx)
movl $0x2, %ebp
jmp 0x8a6d
movq %r14, %rdi
callq 0x2570
movb $0x1, 0x38(%rbx)
leaq 0x449a(%rip), %rax      # 0xcf03
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_O3/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
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x8acf
cmpq $0x0, 0x30(%rbx)
je 0x8ac2
movl $0x8, %r14d
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2570
incq %r15
addq $0x10, %r14
cmpq 0x30(%rbx), %r15
jb 0x8aa4
movq 0x28(%rbx), %rdi
callq 0x2570
movq $0x0, 0x28(%rbx)
movq 0x8(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x8ae3
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_O3/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 0x8ddd
movq (%rbx), %rdi
callq 0x2570
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x8dd7
cmpq $0x0, 0x30(%rbx)
je 0x8dcd
movl $0x8, %r14d
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2570
incq %r15
addq $0x10, %r14
cmpq 0x30(%rbx), %r15
jb 0x8daf
movq 0x28(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2570
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x8e1a
cmpq $0x0, 0x28(%rbx)
je 0x8e1c
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x20(%rbx), %rdi
addq %r14, %rdi
callq 0x8ddd
incq %r15
addq $0x38, %r14
cmpq 0x28(%rbx), %r15
jb 0x8dfb
movq 0x20(%rbx), %rdi
jmp 0x8e1c
xorl %edi, %edi
callq 0x2570
movq 0x8(%rbx), %rdi
callq 0x2570
movq 0x18(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2570
// File: /workspace/github_c_makefile_star2_O3/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 0x23d4(%rip), %xmm0     # 0xc0f0
movsd %xmm0, 0x10(%rdi)
movups 0x60(%rax), %xmm0
movups %xmm0, 0x18(%rdi)
movl 0x44(%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd 0x336c(%rip), %xmm1     # 0xd0a8
mulsd %xmm1, %xmm0
mulsd 0x3368(%rip), %xmm0     # 0xd0b0
movsd %xmm0, 0x38(%rdi)
movl 0x48(%rax), %eax
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
movsd 0x23a7(%rip), %xmm0     # 0xc108
divsd %xmm2, %xmm0
ucomisd 0x334b(%rip), %xmm0     # 0xd0b8
jne 0x9d77
movsd 0x2389(%rip), %xmm0     # 0xc100
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rdi)
movq %rax, 0x40(%rdi)
movq $0x0, 0x30(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq 0x28(%rdi), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rsi
testq %rsi, %rsi
je 0x9f4c
movq %rdi, %rbx
movq 0x40(%rdi), %rax
cmpq 0x48(%rdi), %rax
jl 0x9f4c
xorpd %xmm0, %xmm0
ucomisd 0x18(%rbx), %xmm0
jae 0x9f4c
movq $0x0, 0x40(%rbx)
movq %r14, %rdi
movl $0x3, %edx
movq %rbx, %rcx
callq 0x4897
movq %r14, %rdi
movq %rax, %rsi
callq 0x4af8
movq %rax, %r14
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, (%rsp)
movsd 0x30(%rbx), %xmm0
callq 0x2190
mulsd (%rsp), %xmm0
movsd %xmm0, (%r14)
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, (%rsp)
movsd 0x30(%rbx), %xmm0
callq 0x2520
mulsd (%rsp), %xmm0
movsd %xmm0, 0x8(%r14)
movb $0x1, %al
jmp 0x9f4e
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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:
movsd 0x18(%rdi), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0x9fed
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x10(%rsi)
je 0x9fc3
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movl 0x18(%rax), %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x4b15
movl %ebp, %edi
movl %eax, %esi
callq 0xa8a4
testb %al, %al
je 0x9fb5
movq %r14, %rdi
movq %r15, %rsi
callq 0x4ae5
movq %rbx, %rdi
movq %rax, %rsi
callq 0x266c
incq %r15
cmpq 0x10(%r14), %r15
jb 0x9f80
movsd 0x18(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x9fde
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
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x2e74(%rip), %rdi      # 0xd0c0
leaq 0x8(%rsp), %rcx
callq 0x4cfd
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0xa378
movl $0x5, %esi
movq %rbx, %rdi
callq 0xa624
cmpl $0x2, 0x8(%rsp)
jne 0xa36c
leaq 0x2e47(%rip), %rsi      # 0xd0cb
leaq 0x8(%rsp), %rdi
movl $0x3, %edx
callq 0x4cbc
testq %rax, %rax
je 0xa2dc
movq %rax, %r14
movq (%rax), %rax
testq %rax, %rax
je 0xa36c
movl $0x8, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rcx
cmpl $0x4, -0x8(%rcx,%r15)
jne 0xa2cb
movq (%rcx,%r15), %rsi
movq %rbx, %rdi
callq 0xa387
movq (%r14), %rax
incq %r12
addq $0x20, %r15
cmpq %rax, %r12
jb 0xa2b0
jmp 0xa36c
leaq 0x2df1(%rip), %rsi      # 0xd0d4
leaq 0x8(%rsp), %rdi
movl $0x2, %edx
callq 0x4cbc
testq %rax, %rax
je 0xa36c
movq %rax, %r14
cmpq $0x0, (%rax)
je 0xa36c
xorl %r13d, %r13d
movq 0x10(%r14), %rax
movq %r13, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rdi
leaq 0x2db1(%rip), %rsi      # 0xd0cb
movl $0x3, %edx
callq 0x4cbc
testq %rax, %rax
je 0xa364
movq %rax, %r12
movq (%rax), %rax
testq %rax, %rax
je 0xa364
movl $0x8, %ebp
xorl %r15d, %r15d
movq 0x8(%r12), %rcx
cmpl $0x4, -0x8(%rcx,%rbp)
jne 0xa358
movq (%rcx,%rbp), %rsi
movq %rbx, %rdi
callq 0xa387
movq (%r12), %rax
incq %r15
addq $0x20, %rbp
cmpq %rax, %r15
jb 0xa33c
incq %r13
cmpq (%r14), %r13
jb 0xa303
leaq 0x8(%rsp), %rdi
callq 0x5215
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_O3/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
movl $0x40, %esi
movq %r12, %rdi
callq 0xa550
leaq 0x2cd2(%rip), %rdx      # 0xd0da
movq %r12, %rdi
movq %r15, %rsi
callq 0xa5bf
movq %r14, %rdi
callq 0xa7f8
testq %rax, %rax
je 0xa49b
leaq 0x2ccd(%rip), %rdx      # 0xd0f4
cmpq $0x0, (%r14)
je 0xa4a2
movq %rbx, 0x20(%rsp)
leaq 0x2cb1(%rip), %rdx      # 0xd0ea
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %r13
xorl %ebx, %ebx
movq 0x10(%r14), %rax
movq (%rax,%rbp), %r15
movq %r12, %rdi
movq %r13, %rsi
callq 0xa5bf
movq %r12, %rdi
movq %r13, %rsi
leaq 0x2c85(%rip), %rdx      # 0xd0ec
callq 0xa5bf
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x531f
incq %rbx
addq $0x10, %rbp
leaq 0x2c69(%rip), %rdx      # 0xd0f1
cmpq (%r14), %rbx
jb 0xa447
movq 0x20(%rsp), %rbx
leaq 0x2c5b(%rip), %rdx      # 0xd0f4
jmp 0xa4a2
leaq 0x2c59(%rip), %rdx      # 0xd0fb
leaq 0x10(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xa5bf
xorl %r15d, %r15d
movq (%r14), %rdx
movq 0x18(%rsp), %rdi
addq %r15, %rdi
subq %r15, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x2460
testq %rax, %rax
je 0xa4f3
movq %rax, %r14
movq %rbx, %rdi
callq 0x2440
addq %r14, %r15
movq 0x10(%rsp), %rdx
cmpq %rdx, %r15
jb 0xa4ba
xorl %ebx, %ebx
jmp 0xa4f8
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rdi
callq 0x2570
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
cmpq $0x0, (%rdi)
je 0xa540
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2570
incq %r15
addq $0x10, %r14
cmpq (%rbx), %r15
jb 0xa527
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0xa7fc
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/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
movl $0x10, %ecx
movq %r14, %rsi
callq 0x4c2c
movq (%r14), %r12
decq %r12
movq %r12, (%r14)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0xa6d5
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
jne 0xa6c7
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 0x22b0
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_O3/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 %rsi, (%rsp)
movq (%rdi), %r13
movq 0x10(%rdi), %r15
decq %r13
js 0xa72f
movq %rdx, %r14
xorl %r12d, %r12d
leaq (%r12,%r13), %rbp
shrq %rbp
movq %rbp, %rax
shlq $0x4, %rax
leaq (%r15,%rax), %rbx
movq (%r15,%rax), %rsi
movq %r14, %rdi
callq 0x2380
testl %eax, %eax
jle 0xa720
incq %rbp
movq %rbp, %r12
jmp 0xa728
jns 0xa740
decq %rbp
movq %rbp, %r13
cmpq %r13, %r12
jle 0xa6f6
jmp 0xa732
xorl %r12d, %r12d
shlq $0x4, %r12
addq %r12, %r15
xorl %eax, %eax
movq %r15, %rbx
jmp 0xa742
movb $0x1, %al
movq (%rsp), %rcx
movq %rbx, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xa6d5
testb %al, %al
je 0xa7eb
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 0x22b0
jmp 0xa7ed
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x28ed(%rip), %rsi      # 0xd100
callq 0x2120
testl %eax, %eax
je 0xa884
leaq 0x28e3(%rip), %rsi      # 0xd106
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa888
leaq 0x28da(%rip), %rsi      # 0xd110
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa88f
leaq 0x28ce(%rip), %rsi      # 0xd117
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa896
leaq 0x28c0(%rip), %rsi      # 0xd11c
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa89d
leaq 0x28b3(%rip), %rsi      # 0xd122
movq %rbx, %rdi
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
orl $0x5, %eax
jmp 0xa8a2
xorl %eax, %eax
jmp 0xa8a2
movl $0x1, %eax
jmp 0xa8a2
movl $0x2, %eax
jmp 0xa8a2
movl $0x3, %eax
jmp 0xa8a2
movl $0x4, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xa99a
movzbl %sil, %edx
movb 0x4(%rdi,%rdx), %cl
testb %cl, %cl
jne 0xa997
movl (%rdi), %ecx
movq 0x6609(%rip), %rsi      # 0x10f90
movl (%rsi), %esi
decl %esi
cmpl %esi, %ecx
jge 0xa99a
incl %ecx
movl %ecx, (%rdi)
movb %cl, 0x4(%rdi,%rdx)
movsbl %cl, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
leaq 0x27c1(%rip), %r15      # 0xd170
xorl %ebp, %ebp
movsbl 0x4(%rbx,%r14), %eax
testw %ax, %ax
jle 0xa9ea
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 0xa9ea
movb $0x0, 0x4(%rbx,%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incq %r14
cmpq $0x40, %r14
jne 0xa9b1
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: meter_draw
void meter_draw(const struct meter *meter)
{
	int full = meter->width * meter->fraction;
	int i;
	for (i = 0; meter->label[i] && i < full; ++i) {
		mvwaddch(meter->win, meter->y, meter->x + i,
			meter->full_style | meter->label[i]);
	}
	if (i < full) {
		do {
			mvwaddch(meter->win,meter->y, meter->x + i,
				meter->full_style | ' ');
		} while (++i < full);
	} else {
		for (; meter->label[i]; ++i) {
			mvwaddch(meter->win, meter->y, meter->x + i,
				meter->empty_style | meter->label[i]);
		}
	}
	for (; i < meter->width; ++i) {
		mvwaddch(meter->win, meter->y, meter->x + i,
			meter->empty_style | ' ');
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
cvtsi2sdl 0x20(%rdi), %xmm0
mulsd 0x8(%rdi), %xmm0
cvttsd2si %xmm0, %ebp
movq (%rdi), %rax
cmpb $0x0, (%rax)
je 0xaadf
testl %ebp, %ebp
jle 0xaadf
movl %ebp, %r15d
xorl %r12d, %r12d
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r12d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xaa75
movq (%rbx), %rax
movq 0x28(%rbx), %rdi
movsbl (%rax,%r12), %esi
orl 0x10(%rbx), %esi
callq 0x2210
leaq 0x1(%r12), %r14
movq (%rbx), %rax
cmpb $0x0, 0x1(%rax,%r12)
je 0xaa8d
movq %r14, %r12
cmpq %r15, %r14
jb 0xaa4a
cmpq %r15, %r14
jb 0xaae6
movl %r14d, %r15d
cmpb $0x0, (%rax,%r15)
je 0xab3f
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r15d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xaacb
movq (%rbx), %rax
movq 0x28(%rbx), %rdi
movsbl (%rax,%r15), %esi
orl 0x14(%rbx), %esi
callq 0x2210
leaq 0x1(%r15), %r14
movq (%rbx), %rax
cmpb $0x0, 0x1(%rax,%r15)
movq %r14, %r15
jne 0xaaa0
jmp 0xab3f
xorl %r14d, %r14d
testl %ebp, %ebp
jle 0xaa92
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r14d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xab0c
movq 0x28(%rbx), %rdi
movl 0x10(%rbx), %esi
orl $0x20, %esi
callq 0x2210
incl %r14d
cmpl %ebp, %r14d
jl 0xaae6
jmp 0xab3f
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r14d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xab3c
movq 0x28(%rbx), %rdi
movl 0x14(%rbx), %esi
orl $0x20, %esi
callq 0x2210
incl %r14d
cmpl 0x20(%rbx), %r14d
jl 0xab16
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: popup_window
WINDOW *popup_window(const char *text)
{
	int width = 0, height = 0;
	int line_width = 0;
	for (const char *chrp = text; *chrp != '\0'; ++chrp) {
		if (*chrp == '\n') {
			++height;
			line_width = 0;
		} else {
			++line_width;
			if (line_width > width) width = line_width;
		}
	}
	// Simulate a final newline if it's missing:
	if (line_width != 0) ++height;
	// Add one cell of padding to all sides:
	width += 2;
	height += 2;
	// No popups larger than the screen are allowed:
	if (height > LINES || width > COLS) return NULL;
	WINDOW *win = newwin(height, width,
		(LINES - height) / 2, (COLS - width) / 2);
	if (!win) return NULL;
	const char *line = text;
	for (int y = 1; y < height - 1; ++y) {
		const char *nl = strchr(line, '\n');
		// Line length is remaining text length if there's no newline:
		int len = nl ? nl - line : (int)strlen(line);
		// Draw centered line of text:
		mvwaddnstr(win, y, (width - len) / 2, line, len);
		line += len + 1;
	}
	return win;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r15d, %r15d
movq %rdi, %rax
xorl %r13d, %r13d
xorl %ebp, %ebp
movzbl (%rax), %ecx
cmpl $0xa, %ecx
je 0xab82
testl %ecx, %ecx
je 0xab8d
cmpl %ebp, %r15d
leal 0x1(%r15), %ecx
cmovgel %ecx, %ebp
movl %ecx, %r15d
jmp 0xab88
incl %r13d
xorl %r15d, %r15d
incq %rax
jmp 0xab67
cmpl $0x1, %r15d
movl %r13d, %r12d
sbbl $-0x1, %r12d
leal 0x2(%r12), %edi
movq 0x63fc(%rip), %rax      # 0x10fa0
movl (%rax), %eax
subl %edi, %eax
jl 0xac5d
addl $0x2, %ebp
movq 0x6410(%rip), %rcx      # 0x10fc8
movl (%rcx), %esi
subl %ebp, %esi
jl 0xac5d
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %esi, %ecx
shrl $0x1f, %ecx
addl %esi, %ecx
sarl %ecx
movl %ebp, %esi
callq 0x2340
testq %rax, %rax
je 0xac5d
movq %rax, %r14
testl %r12d, %r12d
jle 0xac60
cmpl $0x1, %r15d
sbbl $-0x1, %r13d
incl %r13d
movl $0x1, %r15d
movq %rbx, %rdi
movl $0xa, %esi
callq 0x22c0
testq %rax, %rax
je 0xac13
movq %rax, %r12
subq %rbx, %r12
jmp 0xac1e
movq %rbx, %rdi
callq 0x2200
movslq %eax, %r12
movl %ebp, %eax
subl %r12d, %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movq %r14, %rdi
movl %r15d, %esi
callq 0x2310
cmpl $-0x1, %eax
je 0xac4a
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x2370
incl %r12d
movslq %r12d, %rax
addq %rax, %rbx
incl %r15d
cmpl %r15d, %r13d
jne 0xabf9
jmp 0xac60
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: display_frame
void display_frame(d3d_camera *cam, struct screen_area *area,
	struct color_map *colors)
{
	size_t width = d3d_camera_width(cam);
	if (width > (size_t)area->width) width = (size_t)area->width;
	size_t height = d3d_camera_height(cam);
	if (height > (size_t)area->height) height = (size_t)area->height;
	for (size_t x = 0; x < width; ++x) {
		for (size_t y = 0; y < height; ++y) {
			d3d_pixel pix = *d3d_camera_get(cam, x, y);
			int pair = color_map_get_pair(colors, pix);
			mvaddch((int)y + area->y, (int)x + area->x,
				COLOR_PAIR(pair) | SCENE_FG_CHAR);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
callq 0x39f3
movslq 0x8(%r14), %r12
cmpq %r12, %rax
cmovbq %rax, %r12
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x39f8
movslq 0xc(%r14), %rbx
cmpq %rbx, %rax
cmovbq %rax, %rbx
movq %r12, (%rsp)
testq %r12, %r12
je 0xad34
xorl %r12d, %r12d
testq %rbx, %rbx
je 0xad2b
xorl %r13d, %r13d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x39fd
movzbl (%rax), %eax
movl $0x3a, %ebp
cmpq $0x3f, %rax
ja 0xacf8
movq 0x8(%rsp), %rcx
movzbl 0x4(%rcx,%rax), %eax
shll $0x8, %eax
orl $0x3a, %eax
movzwl %ax, %ebp
movq 0x62d9(%rip), %r15      # 0x10fd8
movq (%r15), %rdi
movl 0x4(%r14), %esi
addl %r13d, %esi
movl (%r14), %edx
addl %r12d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xad23
movq (%r15), %rdi
movl %ebp, %esi
callq 0x2210
incq %r13
cmpq %r13, %rbx
jne 0xacc7
incq %r12
cmpq (%rsp), %r12
jne 0xacbf
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/ui-util.c
// Function: camera_with_dims
d3d_camera *camera_with_dims(int width, int height)
{
	d3d_camera *cam;
	if (width <= 0) width = 1;
	if (height <= 0) height = 1;
	if (width >= height) {
		cam = assert_alloc(d3d_new_camera(CAM_FOV_X,
			CAM_FOV_X / PIXEL_ASPECT * height / width,
			width, height, pixel(PC_BLACK, PC_BLACK)));
	} else {
		cam = assert_alloc(d3d_new_camera(CAM_FOV_X * width / height,
			CAM_FOV_X / PIXEL_ASPECT, width, height,
			pixel(PC_BLACK, PC_BLACK)));
	}
	return cam;
}

// Assembly:
pushq %rax
movl %esi, %eax
cmpl $0x2, %edi
movl $0x1, %esi
cmovll %esi, %edi
cmpl $0x2, %eax
cmovgel %eax, %esi
cmpl %eax, %edi
jge 0xad79
cvtsi2sd %edi, %xmm0
mulsd 0x23f9(%rip), %xmm0     # 0xd160
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
movsd 0x23e1(%rip), %xmm1     # 0xd158
jmp 0xad95
cvtsi2sd %esi, %xmm1
mulsd 0x23d3(%rip), %xmm1     # 0xd158
cvtsi2sd %edi, %xmm0
divsd %xmm0, %xmm1
movsd 0x23cb(%rip), %xmm0     # 0xd160
xorl %edx, %edx
callq 0x26d7
movq %rax, %rdi
popq %rax
jmp 0xb1d6
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/util.c
// Function: ensure_file
int ensure_file(const char *path, bool dir)
{
#ifdef _WIN32
	if (dir) {
		if (_mkdir(path) && errno != EEXIST) return -1;
	} else {
		FILE *f = fopen(path, "a");
		if (!f) return -1;
		fclose(f);
	}
	return 0;
#else
	int fd;
	struct stat st;
	if (stat(path, &st)) {
		fd = dir ? mkdir(path, 0775)
			: open(path, O_RDONLY | O_CREAT, 0664);
	} else {
		if (dir) {
			if (!S_ISDIR(st.st_mode)) {
				errno = EEXIST;
				return -1;
			}
		} else if (!S_ISREG(st.st_mode)) {
			errno = S_ISDIR(st.st_mode) ? EISDIR : EEXIST;
			return -1;
		}
		fd = open(path, O_RDONLY);
	}
	if (fd < 0) return -1;
	close(fd);
	return 0;
#endif /* !defined(_WIN32) */
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
callq 0x24d0
testl %eax, %eax
je 0xae88
movq %rbx, %rdi
testb %bpl, %bpl
je 0xaeaa
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x2530
jmp 0xaed0
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
testb %bpl, %bpl
je 0xaebd
cmpl $0x4000, %eax           # imm = 0x4000
je 0xaec4
callq 0x2320
movl $0x11, (%rax)
jmp 0xaef7
movl $0x40, %esi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x2510
jmp 0xaed0
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xaedf
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2510
testl %eax, %eax
js 0xaef7
movl %eax, %edi
callq 0x2090
xorl %eax, %eax
jmp 0xaefc
xorl %ecx, %ecx
cmpl $0x4000, %eax           # imm = 0x4000
sete %cl
leal 0x11(,%rcx,4), %ebx
callq 0x2320
movl %ebx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/util.c
// Function: default_file
char *default_file(const char *name, const char *env)
{
#ifdef _WIN32
	static const char env_storage_dir[] = "AppData", ts3d_dir[] = "ts3d";
#else
	static const char env_storage_dir[] = "HOME", ts3d_dir[] = ".ts3d";
#endif
	char *dot_dir = NULL, *path = NULL;
	char *env_root, *env_path = getenv(env);
	if (env_path) return str_dup(env_path);
	env_root = getenv("TS3D_ROOT");
	if (env_root) {
		dot_dir = str_dup(env_root);
	} else {
		char *storage_dir = getenv(env_storage_dir);
		if (storage_dir) {
			dot_dir = mid_cat(storage_dir, DIRSEP, ts3d_dir);
		} else {
			errno = ENOENT;
			return NULL;
		}
	}
	if (!ensure_file(dot_dir, true))
		path = mid_cat(dot_dir, DIRSEP, name);
	free(dot_dir);
	return path;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2300
testq %rax, %rax
je 0xaf4e
movq %rax, %r14
movq %rax, %rdi
callq 0x2200
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0xb080
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2500
leaq 0x225f(%rip), %rdi      # 0xd1b4
callq 0x2300
testq %rax, %rax
je 0xaf89
movq %rax, %r15
movq %rax, %rdi
callq 0x2200
leaq 0x1(%rax), %r12
movq %r12, %rdi
callq 0xb080
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2500
jmp 0xafb1
leaq 0x2200(%rip), %rdi      # 0xd190
callq 0x2300
testq %rax, %rax
je 0xaff0
leaq 0x21f4(%rip), %rdx      # 0xd195
movq %rax, %rdi
movl $0x2f, %esi
callq 0xade9
movq %rax, %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0xae58
testl %eax, %eax
je 0xafc6
xorl %ebx, %ebx
jmp 0xafd9
movq %r14, %rdi
movl $0x2f, %esi
movq %rbx, %rdx
callq 0xade9
movq %rax, %rbx
movq %r14, %rdi
callq 0x2570
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x2320
movl $0x2, (%rax)
xorl %ebx, %ebx
jmp 0xafe1
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/xalloc.c
// Function: xmalloc
void *xmalloc(size_t size)
{
	void *ptr = malloc(size);
	if (!ptr && size != 0) {
		die("malloc(%lu) failed. Aborting.\n", (unsigned long)size);
	}
	return ptr;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x2150
testq %rax, %rax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
je 0xb09b
popq %rbx
retq
leaq 0x211c(%rip), %rdi      # 0xd1be
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb0ac
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/xalloc.c
// Function: die
static void die(const char *fmt, ...)
{
	// Probably thread-unsafety is OK.
	static char msgbuf[128];
	va_list va;
	va_start(va, fmt);
	// Hopefully snprintf doesn't allocate.
	int l = vsnprintf(msgbuf, sizeof(msgbuf), fmt, va);
	va_end(va);
	if (l > 0) {
		ssize_t UNUSED_VAR(w) = write(STDERR_FILENO, msgbuf, (size_t)l);
	} else {
		print_default_oom_message();
	}
	abort();
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
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 0xb10b
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 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0x61ae(%rip), %rbx      # 0x112e0
movl $0x80, %esi
movq %rbx, %rdi
movq %r10, %rdx
callq 0x22d0
testl %eax, %eax
movl $0x1a, %edx
cmovgl %eax, %edx
leaq 0x20dd(%rip), %rsi      # 0xd230
cmovgq %rbx, %rsi
movl $0x2, %edi
callq 0x24c0
callq 0x20c0
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/xalloc.c
// Function: xcalloc
void *xcalloc(size_t count, size_t size)
{
	void *ptr = calloc(count, size);
	if (!ptr && count * size != 0) {
		die("calloc(%lu, %lu) failed. Aborting.\n",
			(unsigned long)count, (unsigned long)size);
	}
	return ptr;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x23c0
testq %rax, %rax
setne %cl
movq %rbx, %rdx
imulq %r14, %rdx
testq %rdx, %rdx
sete %dl
orb %cl, %dl
je 0xb194
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x2042(%rip), %rdi      # 0xd1dd
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb0ac
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/xalloc.c
// Function: xrealloc
void *xrealloc(void *ptr, size_t size)
{
	ptr = realloc(ptr, size);
	if (!ptr && size != 0) {
		die("realloc(%p, %lu) failed. Aborting.\n",
			ptr, (unsigned long)size);
	}
	return ptr;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x2470
testq %rax, %rax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
je 0xb1c3
popq %rbx
retq
leaq 0x2037(%rip), %rdi      # 0xd201
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb0ac
// File: /workspace/github_c_makefile_star2_O3/TurkeyMcMac[P]ts3d/src/xalloc.c
// Function: assert_alloc
void *assert_alloc(void *ptr)
{
	if (!ptr) {
		print_default_oom_message();
		abort();
	}
	return ptr;
}

// Assembly:
testq %rdi, %rdi
je 0xb1df
movq %rdi, %rax
retq
pushq %rax
callq 0xb1ea
callq 0x20c0