LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 0x482c(%rip), %rsi      # 0xcd94
movq %rdx, %rdi
movl $0x4, %edx
callq 0x4c98
testq %rax, %rax
je 0x85ce
movq (%rax), %rsi
movq %r15, %rdi
callq 0x42ec
testq %rax, %rax
je 0x85ce
movq %rax, 0x10(%rbx)
movl $0x1, 0x18(%rbx)
movl 0x5c(%rax), %eax
cmpl $-0x1, %eax
je 0x85fc
movl %eax, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x480c(%rip), %rsi      # 0xcdb9
movq %r14, %rdi
movl $0x3, %edx
callq 0x4c98
xorl %ebp, %ebp
testq %rax, %rax
je 0x85f1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x52e6
jmp 0x85f1
movq %r15, %rdi
callq 0x6c5a
leaq 0x47e0(%rip), %rdx      # 0xcdbd
movq %rax, %rdi
movl $0x4, %esi
xorl %eax, %eax
callq 0x6e97
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4796(%rip), %rsi      # 0xcd99
movq %r14, %rdi
movl $0x4, %edx
callq 0x4c98
testq %rax, %rax
je 0x85a0
movq %rax, %r12
movq (%rax), %rdi
callq 0xa920
cmpl $-0x1, %eax
jne 0x859d
movq %r15, %rdi
callq 0x6c5a
movq (%r12), %rcx
leaq 0x4762(%rip), %rdx      # 0xcd9e
movq %rax, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x6e97
jmp 0x85a0
// File: /workspace/github_c_makefile_star2_O1/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 0x8697
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2570
movq 0x8(%rbx), %rdi
callq 0x2570
movq 0x10(%rbx), %rdi
callq 0x39f5
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
// File: /workspace/github_c_makefile_star2_O1/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 0x47a7(%rip), %rdx      # 0xce60
movq %rsi, %rdi
movl $0x2f, %esi
callq 0xaf01
movq %rax, %rbx
leaq 0x3d68(%rip), %rsi      # 0xc438
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x8736
leaq 0x47aa(%rip), %rdi      # 0xce8e
leaq 0x8(%rsp), %rcx
movq %rax, %rsi
movq %r13, %rdx
callq 0x4cd9
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x8754
movl $0x38, %edi
callq 0xb1ac
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rcx
callq 0x87a0
testl %eax, %eax
je 0x876d
movq (%r14), %rdi
callq 0x2570
leaq 0x8(%rsp), %rdi
callq 0x5222
jmp 0x874f
leaq 0x472d(%rip), %rdx      # 0xce6a
movq %r13, %rdi
movl $0x4, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x6e97
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 0x3c0d(%rip), %rax      # 0xc390
movq %rax, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movb $0x1, 0x38(%r14)
leaq 0x8(%rsp), %rdi
callq 0x5222
jmp 0x8754
// File: /workspace/github_c_makefile_star2_O1/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 0x89b5
cmpl $0x1, 0x10(%rcx)
jne 0x89b5
movslq 0x30(%rcx), %rax
cmpq %rax, 0x28(%rcx)
jbe 0x89b5
imulq $0x38, %rax, %rax
addq 0x20(%rcx), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x89e6
movq 0x10(%rdi), %rax
movq 0x30(%rdi), %rdx
movslq 0xc(%rax), %rax
addq $-0x3, %rax
subq %rax, %rdx
movl $0x1, %eax
cmovaq %rdx, %rax
movq %rax, 0x28(%rcx)
movq 0x28(%rcx), %r9
testq %r9, %r9
je 0x8a4b
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 0x8a42
movq 0x10(%rdi), %rsi
movl 0xc(%rsi), %esi
addl $-0x2, %esi
cmpl %r9d, %esi
jg 0x8a3e
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_O1/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 0x8b35
cmpq $0x0, 0x28(%rax)
je 0x8b35
movq %rdi, %rbx
movslq 0x30(%rax), %rax
imulq $0x38, %rax, %rcx
movl 0x10(%r15,%rcx), %eax
cmpl $0x3, %eax
je 0x8b13
addq %rcx, %r15
cmpl $0x2, %eax
je 0x8a9e
cmpl $0x1, %eax
je 0x8b04
jmp 0x8b35
movq 0x18(%rbx), %rdi
movq 0x18(%r15), %rdx
movl $0x2f, %esi
callq 0xaf01
movq %rax, %r14
leaq 0x397e(%rip), %rsi      # 0xc438
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x8b1e
leaq 0x30(%rbx), %rsi
movq %rax, %rdi
callq 0xa0d4
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x8b1e
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 0x8b35
movb $0x1, 0x38(%rbx)
movl $0x2, %ebp
jmp 0x8b35
movq %r14, %rdi
callq 0x2570
movb $0x1, 0x38(%rbx)
leaq 0x4362(%rip), %rax      # 0xce93
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_O1/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 0x8b95
cmpq $0x0, 0x30(%rbx)
je 0x8b84
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 0x8b6a
movq 0x28(%rbx), %rdi
callq 0x2570
movq $0x0, 0x28(%rbx)
movq 0x8(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x8ba9
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_O1/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 0x8ea1
movq (%rbx), %rdi
callq 0x2570
cmpq $0x0, 0x28(%rbx)
je 0x8e9b
cmpq $0x0, 0x30(%rbx)
je 0x8e8d
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 0x8e73
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_O1/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
cmpq $0x0, 0x20(%rdi)
je 0x8edd
cmpq $0x0, 0x28(%rbx)
je 0x8edd
cmpq $0x0, 0x28(%rbx)
je 0x8edd
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x20(%rbx), %rdi
addq %r14, %rdi
callq 0x8ea1
incq %r15
addq $0x38, %r14
cmpq 0x28(%rbx), %r15
jb 0x8ec4
movq 0x20(%rbx), %rdi
callq 0x2570
movq 0x8(%rbx), %rdi
callq 0x2570
movq 0x18(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2570
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/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 0x2238(%rip), %xmm0     # 0xc028
movsd %xmm0, 0x10(%rdi)
movq 0x48(%rsi), %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, 0x18(%rdi)
movsd 0x68(%rax), %xmm0
movsd %xmm0, 0x20(%rdi)
movl 0x44(%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd 0x3230(%rip), %xmm1     # 0xd050
mulsd %xmm1, %xmm0
mulsd 0x322c(%rip), %xmm0     # 0xd058
movsd %xmm0, 0x38(%rdi)
movl 0x48(%rax), %eax
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
movsd 0x21fb(%rip), %xmm0     # 0xc040
divsd %xmm2, %xmm0
ucomisd 0x320f(%rip), %xmm0     # 0xd060
jne 0x9e5b
movsd 0x21dd(%rip), %xmm0     # 0xc038
cvttsd2si %xmm0, %rax
movq %rax, 0x48(%rdi)
movq %rax, 0x40(%rdi)
movq $0x0, 0x30(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rsi
testq %rsi, %rsi
je 0x9f9f
movq 0x40(%rbx), %rax
cmpq 0x48(%rbx), %rax
jge 0x9fa3
xorl %ebp, %ebp
jmp 0x9fb0
xorpd %xmm0, %xmm0
ucomisd 0x18(%rbx), %xmm0
setb %bpl
testb %bpl, %bpl
je 0xa034
movq $0x0, 0x40(%rbx)
movq %r14, %rdi
movl $0x3, %edx
movq %rbx, %rcx
callq 0x4869
movq %r14, %rdi
movq %rax, %rsi
callq 0x4ad4
movq %rax, %r14
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%rbx), %xmm0
callq 0x2190
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%rbx), %xmm0
callq 0x2520
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%r14)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa0d2
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x10(%rsi)
je 0xa0a3
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movl 0x18(%rax), %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x4af1
movl %ebp, %edi
movl %eax, %esi
callq 0xa9bc
testb %al, %al
je 0xa09a
movq %r14, %rdi
movq %r15, %rsi
callq 0x4ac1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x266c
incq %r15
cmpq 0x10(%r14), %r15
jb 0xa065
movsd 0x18(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0xa0c3
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_O1/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 0x2d20(%rip), %rdi      # 0xd068
leaq 0x8(%rsp), %rcx
callq 0x4cd9
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0xa46a
movl $0x5, %esi
movq %rbx, %rdi
callq 0xa720
cmpl $0x2, 0x8(%rsp)
jne 0xa45e
leaq 0x2cf3(%rip), %rsi      # 0xd073
leaq 0x8(%rsp), %rdi
movl $0x3, %edx
callq 0x4c98
testq %rax, %rax
je 0xa3d3
movq %rax, %r14
cmpq $0x0, (%rax)
je 0xa45e
movl $0x8, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rax
cmpl $0x4, -0x8(%rax,%r15)
jne 0xa3c2
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0xa479
incq %r12
addq $0x20, %r15
cmpq (%r14), %r12
jb 0xa3aa
jmp 0xa45e
leaq 0x2ca2(%rip), %rsi      # 0xd07c
leaq 0x8(%rsp), %rdi
movl $0x2, %edx
callq 0x4c98
testq %rax, %rax
je 0xa45e
movq %rax, %r14
cmpq $0x0, (%rax)
je 0xa45e
xorl %r13d, %r13d
movq 0x10(%r14), %rax
movq %r13, %rcx
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rdi
leaq 0x2c62(%rip), %rsi      # 0xd073
movl $0x3, %edx
callq 0x4c98
testq %rax, %rax
je 0xa456
movq %rax, %r12
cmpq $0x0, (%rax)
je 0xa456
movl $0x8, %ebp
xorl %r15d, %r15d
movq 0x8(%r12), %rax
cmpl $0x4, -0x8(%rax,%rbp)
jne 0xa449
movq (%rax,%rbp), %rsi
movq %rbx, %rdi
callq 0xa479
incq %r15
addq $0x20, %rbp
cmpq (%r12), %r15
jb 0xa431
incq %r13
cmpq (%r14), %r13
jb 0xa3fa
leaq 0x8(%rsp), %rdi
callq 0x5222
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_O1/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 0x18(%rsp), %r15
movq $0x40, (%r15)
leaq 0x8(%rsp), %r12
movl $0x40, %esi
movq %r12, %rdi
callq 0xa64c
leaq 0x2b88(%rip), %rdx      # 0xd082
movq %r12, %rdi
movq %r15, %rsi
callq 0xa6bb
movq %r14, %rdi
callq 0xa911
testq %rax, %rax
je 0xa58d
leaq 0x2b83(%rip), %rdx      # 0xd09c
cmpq $0x0, (%r14)
je 0xa594
movq %rbx, 0x20(%rsp)
leaq 0x2b67(%rip), %rdx      # 0xd092
xorl %ebp, %ebp
leaq 0x8(%rsp), %r12
leaq 0x18(%rsp), %r13
xorl %ebx, %ebx
movq 0x10(%r14), %rax
movq (%rax,%rbp), %r15
movq %r12, %rdi
movq %r13, %rsi
callq 0xa6bb
movq %r12, %rdi
movq %r13, %rsi
leaq 0x2b3b(%rip), %rdx      # 0xd094
callq 0xa6bb
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5331
incq %rbx
addq $0x10, %rbp
leaq 0x2b1f(%rip), %rdx      # 0xd099
cmpq (%r14), %rbx
jb 0xa539
movq 0x20(%rsp), %rbx
leaq 0x2b11(%rip), %rdx      # 0xd09c
jmp 0xa594
leaq 0x2b0f(%rip), %rdx      # 0xd0a3
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa6bb
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
addq %r15, %rdi
movq 0x8(%rsp), %rdx
subq %r15, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x2460
movq %rax, %r14
testq %rax, %rax
je 0xa5d8
movq %rbx, %rdi
callq 0x2440
addq %r14, %r15
jmp 0xa5e2
movq 0x10(%rsp), %rdi
callq 0x2570
testq %r14, %r14
je 0xa5fc
cmpq 0x8(%rsp), %r15
jb 0xa5a6
movq 0x10(%rsp), %rdi
callq 0x2570
xorl %eax, %eax
jmp 0xa601
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa63d
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 0xa624
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0xa915
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x4c08
movq (%r14), %r12
decq %r12
movq %r12, (%r14)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0xa7d1
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
jne 0xa7c3
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_O1/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), %rax
decq %rax
xorl %ebp, %ebp
movq %rbp, %r12
movq %rax, %r13
cmpq %rax, %rbp
jg 0xa84a
leaq (%r12,%r13), %rbp
shrq %rbp
movq 0x10(%r14), %rax
movq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rbx
movq (%rax,%rcx), %rsi
movq %r15, %rdi
callq 0x2380
testl %eax, %eax
jle 0xa829
incq %rbp
movb $0x1, %cl
movq %r13, %rax
jmp 0xa844
jns 0xa835
decq %rbp
movb $0x1, %cl
movq %rbp, %rax
jmp 0xa841
movq (%rsp), %rax
movq %rbx, (%rax)
xorl %ecx, %ecx
movq %r13, %rax
movq %r12, %rbp
testb %cl, %cl
jne 0xa7ee
jmp 0xa85c
movq %r12, %rax
shlq $0x4, %rax
addq 0x10(%r14), %rax
movq (%rsp), %rcx
movq %rax, (%rcx)
cmpq %r13, %r12
setle %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa7d1
testb %al, %al
je 0xa904
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 0xa906
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x277d(%rip), %rsi      # 0xd0a8
callq 0x2120
testl %eax, %eax
je 0xa99c
leaq 0x2773(%rip), %rsi      # 0xd0ae
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa9a0
leaq 0x276a(%rip), %rsi      # 0xd0b8
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa9a7
leaq 0x275e(%rip), %rsi      # 0xd0bf
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa9ae
leaq 0x2750(%rip), %rsi      # 0xd0c4
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xa9b5
leaq 0x2743(%rip), %rsi      # 0xd0ca
movq %rbx, %rdi
callq 0x2120
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
orl $0x5, %eax
jmp 0xa9ba
xorl %eax, %eax
jmp 0xa9ba
movl $0x1, %eax
jmp 0xa9ba
movl $0x2, %eax
jmp 0xa9ba
movl $0x3, %eax
jmp 0xa9ba
movl $0x4, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xaa54
leaq 0x8(%rsp), %rdi
movq $0x0, (%rdi)
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x8(%rdi)
xorl %esi, %esi
callq 0x23a0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2130
addq $0x28, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0xaab3
movzbl %sil, %ecx
cmpb $0x0, 0x4(%rdi,%rcx)
jne 0xaaae
movl (%rdi), %edx
movq 0x64f2(%rip), %rsi      # 0x10f90
movl (%rsi), %esi
decl %esi
cmpl %esi, %edx
jge 0xaab3
incl %edx
movl %edx, (%rdi)
movb %dl, 0x4(%rdi,%rcx)
movsbl 0x4(%rdi,%rcx), %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x2658(%rip), %r15      # 0xd120
xorl %ebp, %ebp
movsbl 0x4(%rbx,%r14), %eax
testw %ax, %ax
jle 0xab03
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 0xab03
movb $0x0, 0x4(%rbx,%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incq %r14
cmpq $0x40, %r14
jne 0xaaca
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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), %rcx
testl %ebp, %ebp
setg %al
xorl %r14d, %r14d
cmpb $0x0, (%rcx)
je 0xabac
testl %ebp, %ebp
jle 0xabac
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 0xab8e
movq (%rbx), %rax
movq 0x28(%rbx), %rdi
movsbl (%rax,%r12), %esi
orl 0x10(%rbx), %esi
callq 0x2210
leaq 0x1(%r12), %r14
movq (%rbx), %rcx
cmpq %r15, %r14
setb %al
cmpb $0x0, 0x1(%rcx,%r12)
je 0xabac
movq %r14, %r12
cmpq %r15, %r14
jb 0xab63
testb %al, %al
je 0xabe0
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r14d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xabd6
movq 0x28(%rbx), %rdi
movl 0x10(%rbx), %esi
orl $0x20, %esi
callq 0x2210
incl %r14d
cmpl %ebp, %r14d
jl 0xabb0
jmp 0xac55
movq (%rbx), %rax
movl %r14d, %r15d
cmpb $0x0, (%rax,%r15)
je 0xac55
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r15d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xac18
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 0xabed
jmp 0xac55
movq 0x28(%rbx), %rdi
movl 0x1c(%rbx), %esi
movl 0x18(%rbx), %edx
addl %r14d, %edx
callq 0x2310
cmpl $-0x1, %eax
je 0xac52
movq 0x28(%rbx), %rdi
movl 0x14(%rbx), %esi
orl $0x20, %esi
callq 0x2210
incl %r14d
cmpl 0x20(%rbx), %r14d
jl 0xac2c
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xac98
testl %ecx, %ecx
je 0xaca3
cmpl %ebp, %r15d
leal 0x1(%r15), %ecx
cmovgel %ecx, %ebp
movl %ecx, %r15d
jmp 0xac9e
incl %r13d
xorl %r15d, %r15d
incq %rax
jmp 0xac7d
cmpl $0x1, %r15d
movl %r13d, %r12d
sbbl $-0x1, %r12d
leal 0x2(%r12), %edi
movq 0x62e6(%rip), %rax      # 0x10fa0
movl (%rax), %eax
subl %edi, %eax
jl 0xad73
addl $0x2, %ebp
movq 0x62fa(%rip), %rcx      # 0x10fc8
movl (%rcx), %esi
subl %ebp, %esi
jl 0xad73
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 0xad73
movq %rax, %r14
testl %r12d, %r12d
jle 0xad76
cmpl $0x1, %r15d
sbbl $-0x1, %r13d
incl %r13d
movl $0x1, %r15d
movq %rbx, %rdi
movl $0xa, %esi
callq 0x22c0
testq %rax, %rax
je 0xad29
movq %rax, %r12
subq %rbx, %r12
jmp 0xad34
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 0xad60
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 0xad0f
jmp 0xad76
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_O1/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 0x3970
movslq 0x8(%r14), %r12
cmpq %r12, %rax
cmovbq %rax, %r12
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x3975
movslq 0xc(%r14), %rbx
cmpq %rbx, %rax
cmovbq %rax, %rbx
movq %r12, (%rsp)
testq %r12, %r12
je 0xae4a
xorl %r12d, %r12d
testq %rbx, %rbx
je 0xae41
xorl %r13d, %r13d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x397a
movzbl (%rax), %eax
movl $0x3a, %ebp
cmpq $0x3f, %rax
ja 0xae0e
movq 0x8(%rsp), %rcx
movzbl 0x4(%rcx,%rax), %eax
shll $0x8, %eax
orl $0x3a, %eax
movzwl %ax, %ebp
movq 0x61c3(%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 0xae39
movq (%r15), %rdi
movl %ebp, %esi
callq 0x2210
incq %r13
cmpq %r13, %rbx
jne 0xaddd
incq %r12
cmpq (%rsp), %r12
jne 0xadd5
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xae8f
cvtsi2sd %edi, %xmm0
mulsd 0x2293(%rip), %xmm0     # 0xd110
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
movsd 0x227b(%rip), %xmm1     # 0xd108
jmp 0xaeab
cvtsi2sd %esi, %xmm1
mulsd 0x226d(%rip), %xmm1     # 0xd108
cvtsi2sd %edi, %xmm0
divsd %xmm0, %xmm1
movsd 0x2265(%rip), %xmm0     # 0xd110
xorl %edx, %edx
callq 0x26d7
movq %rax, %rdi
popq %rax
jmp 0xb302
// File: /workspace/github_c_makefile_star2_O1/TurkeyMcMac[P]ts3d/src/util.c
// Function: mid_cat
char *mid_cat(const char *part1, int mid, const char *part2)
{
	char *cat;
	size_t len1, len2, len;
	len1 = strlen(part1);
	len2 = strlen(part2);
	len = len1 + 1 + len2;
	cat = xmalloc(len + 1);
	memcpy(cat, part1, len1);
	cat[len1] = mid;
	memcpy(cat + len1 + 1, part2, len2 + 1);
	return cat;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
callq 0x2200
movq %rax, %r15
movq %rbx, %rdi
callq 0x2200
movq %rax, %r12
leaq (%r15,%rax), %rdi
addq $0x2, %rdi
callq 0xb1ac
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2500
leaq (%r15,%r13), %rdi
incq %rdi
movb %bpl, -0x1(%rdi)
incq %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2500
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xafa0
movq %rbx, %rdi
testb %bpl, %bpl
je 0xafc2
movl $0x1fd, %esi            # imm = 0x1FD
callq 0x2530
jmp 0xafe8
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
testb %bpl, %bpl
je 0xafd5
cmpl $0x4000, %eax           # imm = 0x4000
je 0xafdc
callq 0x2320
movl $0x11, (%rax)
jmp 0xb00f
movl $0x40, %esi
movl $0x1b4, %edx            # imm = 0x1B4
xorl %eax, %eax
callq 0x2510
jmp 0xafe8
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xaff7
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2510
testl %eax, %eax
js 0xb00f
movl %eax, %edi
callq 0x2090
xorl %eax, %eax
jmp 0xb014
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_O1/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 0xb066
movq %rax, %r14
movq %rax, %rdi
callq 0x2200
leaq 0x1(%rax), %rbx
movq %rbx, %rdi
callq 0xb1ac
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2500
leaq 0x20f7(%rip), %rdi      # 0xd164
callq 0x2300
testq %rax, %rax
je 0xb0a1
movq %rax, %r15
movq %rax, %rdi
callq 0x2200
leaq 0x1(%rax), %r12
movq %r12, %rdi
callq 0xb1ac
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2500
jmp 0xb0e1
leaq 0x2098(%rip), %rdi      # 0xd140
callq 0x2300
movq %rax, %r15
testq %rax, %rax
je 0xb0ce
leaq 0x2089(%rip), %rdx      # 0xd145
movq %r15, %rdi
movl $0x2f, %esi
callq 0xaf01
movq %rax, %r14
jmp 0xb0dc
callq 0x2320
movl $0x2, (%rax)
xorl %r14d, %r14d
testq %r15, %r15
je 0xb120
movq %r14, %rdi
movl $0x1, %esi
callq 0xaf70
testl %eax, %eax
je 0xb0f6
xorl %ebx, %ebx
jmp 0xb109
movq %r14, %rdi
movl $0x2f, %esi
movq %rbx, %rdx
callq 0xaf01
movq %rax, %rbx
movq %r14, %rdi
callq 0x2570
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %ebx, %ebx
jmp 0xb111
// File: /workspace/github_c_makefile_star2_O1/TurkeyMcMac[P]ts3d/src/util.c
// Function: vec_norm_mul
void vec_norm_mul(d3d_vec_s *vec, d3d_scalar mag)
{
	d3d_scalar hyp = hypot(vec->x, vec->y);
	if (hyp != 0) {
		vec->x *= mag / hyp;
		vec->y *= mag / hyp;
	}
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
movsd (%rdi), %xmm0
movsd 0x8(%rdi), %xmm1
callq 0x21a0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb185
jnp 0xb1a5
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd (%rbx), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%rbx)
mulsd 0x8(%rbx), %xmm1
movsd %xmm1, 0x8(%rbx)
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0xb1c7
popq %rbx
retq
leaq 0x1fa0(%rip), %rdi      # 0xd16e
movq %rbx, %rsi
xorl %eax, %eax
callq 0xb1d8
// File: /workspace/github_c_makefile_star2_O1/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 0xb237
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 0x6082(%rip), %rbx      # 0x112e0
movl $0x80, %esi
movq %rbx, %rdi
movq %r10, %rdx
callq 0x22d0
testl %eax, %eax
movl $0x1a, %edx
cmovgl %eax, %edx
leaq 0x1f61(%rip), %rsi      # 0xd1e0
cmovgq %rbx, %rsi
movl $0x2, %edi
callq 0x24c0
callq 0x20c0
// File: /workspace/github_c_makefile_star2_O1/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 0xb2c0
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x1ec6(%rip), %rdi      # 0xd18d
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb1d8
// File: /workspace/github_c_makefile_star2_O1/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 0xb2ef
popq %rbx
retq
leaq 0x1ebb(%rip), %rdi      # 0xd1b1
xorl %esi, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb1d8
// File: /workspace/github_c_makefile_star2_O1/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 0xb30b
movq %rdi, %rax
retq
pushq %rax
callq 0xb316
callq 0x20c0
// File: /workspace/github_c_makefile_star2_O1/kaiserschmarrn0[P]mywm/mywm.c
// Function: close_helper
void close_helper(xcb_window_t win) {
	xcb_icccm_get_wm_protocols_reply_t pro;
	xcb_get_property_cookie_t cookie;
	cookie = xcb_icccm_get_wm_protocols_unchecked(conn, win, ewmh->WM_PROTOCOLS);
	if (!xcb_icccm_get_wm_protocols_reply(conn, cookie, &pro, NULL)) {
		xcb_kill_client(conn, win);
		return;
	}

	for (int i = 0; i < pro.atoms_len; i++) {
		if (pro.atoms[i] == wm_atoms[WM_DELETE_WINDOW]) {
			xcb_icccm_get_wm_protocols_reply_wipe(&pro);
			goto a;
		}
	}
	xcb_icccm_get_wm_protocols_reply_wipe(&pro);
	xcb_kill_client(conn, win);
	return;

	a:;
	
	xcb_client_message_event_t ev;
	ev.response_type = XCB_CLIENT_MESSAGE;
	ev.format = 32;
	ev.sequence = 0;
	ev.window = win;
	ev.type = wm_atoms[WM_PROTOCOLS];
	ev.data.data32[0] = wm_atoms[WM_DELETE_WINDOW];
	ev.data.data32[1] = XCB_CURRENT_TIME;
	uint32_t mask = XCB_EVENT_MASK_NO_EVENT;
	xcb_send_event(conn, 0, win, mask, (char *)&ev);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
movq 0x9c50(%rip), %rdi      # 0xd448
movq 0x9c59(%rip), %rax      # 0xd458
movl 0xc8(%rax), %edx
movl %ebx, %esi
callq 0x31d0
movq 0x9c35(%rip), %rdi      # 0xd448
leaq -0x20(%rbp), %rdx
movl %eax, %esi
xorl %ecx, %ecx
callq 0x31b0
testb %al, %al
je 0x386d
movl -0x20(%rbp), %ecx
movl $0x2, %eax
testq %rcx, %rcx
je 0x385a
movq -0x18(%rbp), %rdx
movl 0x9c29(%rip), %esi      # 0xd464
xorl %edi, %edi
cmpl %esi, (%rdx,%rdi,4)
je 0x384c
incq %rdi
cmpq %rdi, %rcx
jne 0x383d
jmp 0x385a
leaq -0x20(%rbp), %rdi
callq 0x3420
movl $0x5, %eax
cmpl $0x5, %eax
je 0x387d
cmpl $0x2, %eax
jne 0x38b1
leaq -0x20(%rbp), %rdi
callq 0x3420
movq 0x9bd4(%rip), %rdi      # 0xd448
movl %ebx, %esi
callq 0x3610
jmp 0x38b1
leaq -0x40(%rbp), %r8
movl $0x2021, (%r8)          # imm = 0x2021
movl %ebx, 0x4(%r8)
movq 0x9bcd(%rip), %rax      # 0xd460
movq %rax, 0x8(%r8)
movl $0x0, 0x10(%r8)
movq 0x9ba2(%rip), %rdi      # 0xd448
xorl %esi, %esi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x3350
addq $0x38, %rsp
popq %rbx
popq %rbp
retq