// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/ent.c
// Function: load_ent_type
struct ent_type *load_ent_type(struct loader *ldr, const char *name)
{
	struct logger *log = loader_logger(ldr);
	FILE *file;
	struct ent_type *ent, **entp;
	entp = loader_ent(ldr, name, &file);
	if (!entp) return NULL;
	ent = *entp;
	if (ent) return ent;
	ent = xmalloc(sizeof(*ent));
	struct json_node jtree;
	ent->name = str_dup(name);
	ent->frames = NULL;
	ent->n_frames = 0;
	ent->turn_chance = CHANCE_NEVER;
	ent->shoot_chance = CHANCE_NEVER;
	ent->death_spawn = NULL;
	ent->bullet = NULL;
	ent->lifetime = -1;
	ent->wall_block = true;
	ent->wall_die = false;
	ent->team_override = TEAM_INVALID;
	ent->health = 1.0;
	ent->damage = 0;
	if (parse_json_tree(name, file, log, &jtree)) return NULL;
	if (jtree.kind != JN_MAP) {
		if (jtree.kind != JN_ERROR)
			logger_printf(log, LOGGER_WARNING,
				"Entity type \"%s\" is not a JSON dictionary\n",
				name);
		*entp = ent;
		goto end;
	}
	union json_node_data *got;
	if ((got = json_map_get(&jtree, "name", TAKE_NODE | JN_STRING))) {
		free(ent->name);
		ent->name = got->str;
	}
	ent->width = 1.0;
	if ((got = json_map_get(&jtree, "width", JN_NUMBER)))
		ent->width = got->num;
	ent->height = 1.0;
	if ((got = json_map_get(&jtree, "height", JN_NUMBER)))
		ent->height = got->num;
	ent->speed = 0.0;
	if ((got = json_map_get(&jtree, "speed", JN_NUMBER)))
		ent->speed = got->num;
	if ((got = json_map_get(&jtree, "turn_chance", JN_NUMBER)))
		ent->turn_chance = chance_from_percent(got->num);
	if ((got = json_map_get(&jtree, "shoot_chance", JN_NUMBER)))
		ent->shoot_chance = chance_from_percent(got->num);
	ent->random_start_frame =
		(got = json_map_get(&jtree, "random_start_frame", JN_BOOLEAN))
		&& got->boolean;
	if ((got = json_map_get(&jtree, "frames", JN_LIST))) {
		ent->n_frames = got->list.n_vals;
		ent->frames = xmalloc(ent->n_frames * sizeof(*ent->frames));
		for (size_t i = 0; i < ent->n_frames; ++i) {
			parse_frame(&got->list.vals[i], &ent->frames[i], ldr);
		}
	}
	// To prevent infinite recursion with infinite cycles.
	*entp = ent;
	if ((got = json_map_get(&jtree, "death_spawn", JN_STRING)))
		ent->death_spawn = load_ent_type(ldr, got->str);
	if ((got = json_map_get(&jtree, "bullet", JN_STRING)))
		ent->bullet = load_ent_type(ldr, got->str);
	if ((got = json_map_get(&jtree, "lifetime", JN_NUMBER)))
		ent->lifetime = got->num;
	if ((got = json_map_get(&jtree, "wall_block", JN_BOOLEAN))
	 && !got->boolean)
		ent->wall_block = false;
	if ((got = json_map_get(&jtree, "wall_die", JN_BOOLEAN))
	 && got->boolean)
		ent->wall_die = true;
	if ((got = json_map_get(&jtree, "team_override", JN_STRING))
	 && (ent->team_override = team_from_str(got->str)) == TEAM_INVALID)
		logger_printf(log, LOGGER_WARNING,
			"Invalid team override: \"%s\"\n", got->str);
	if ((got = json_map_get(&jtree, "health", JN_NUMBER)))
		ent->health = got->num;
	if ((got = json_map_get(&jtree, "damage", JN_NUMBER)))
		ent->damage = got->num;
end:
	if (ent->n_frames == 0) {
		ent->frames = xrealloc(ent->frames, sizeof(*ent->frames));
		ent->frames[0].txtr = loader_empty_texture(ldr);
		ent->frames[0].duration = 0;
	}
	free_json_tree(&jtree);
	return ent;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9da0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x9a30
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x58b6
movq $0x0, -0x8(%rbp)
jmp 0x5e75
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x58d5
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5e75
movl $0x70, %edi
callq 0x10b80
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x106a0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movq $-0x1, 0x38(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x58(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x59(%rax)
movq -0x30(%rbp), %rax
movl $0xffffffff, 0x5c(%rax) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rax
movsd 0xb6c9(%rip), %xmm0     # 0x11038
movsd %xmm0, 0x60(%rax)
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rax)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x68e0
cmpl $0x0, %eax
je 0x59a7
movq $0x0, -0x8(%rbp)
jmp 0x5e75
cmpl $0x2, -0x58(%rbp)
je 0x59de
cmpl $0x7, -0x58(%rbp)
je 0x59ce
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x2, %esi
leaq 0xb8d1(%rip), %rdx      # 0x11298
movb $0x0, %al
callq 0xa260
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5e15
leaq -0x58(%rbp), %rdi
leaq 0xb8da(%rip), %rsi      # 0x112c3
movl $0x1004, %edx           # imm = 0x1004
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5a17
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x2580
movq -0x60(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movsd 0xb615(%rip), %xmm0     # 0x11038
movsd %xmm0, 0x8(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb895(%rip), %rsi      # 0x112c8
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5a58
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x30(%rbp), %rax
movsd 0xb5d4(%rip), %xmm0     # 0x11038
movsd %xmm0, 0x10(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb85a(%rip), %rsi      # 0x112ce
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5a99
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb825(%rip), %rsi      # 0x112d5
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5ad5
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x50(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb7fb(%rip), %rsi      # 0x112db
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5b22
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movsd 0xb784(%rip), %xmm1     # 0x11288
divsd %xmm1, %xmm0
movsd 0xb780(%rip), %xmm1     # 0x11290
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x44(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb7ba(%rip), %rsi      # 0x112e7
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5b6f
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movsd 0xb737(%rip), %xmm1     # 0x11288
divsd %xmm1, %xmm0
movsd 0xb733(%rip), %xmm1     # 0x11290
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x48(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb77a(%rip), %rsi      # 0x112f4
movl $0x6, %edx
callq 0x6820
movq %rax, %rcx
movq %rcx, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x69(%rbp)
je 0x5b9f
movq -0x60(%rbp), %rax
movb (%rax), %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %cl
movq -0x30(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x40(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb750(%rip), %rsi      # 0x11307
movl $0x3, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5c4f
movq -0x60(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
shlq $0x4, %rdi
callq 0x10b80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x5c4d
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x68(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x68(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rdx
callq 0x5e80
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x5c02
jmp 0x5c4f
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb6a9(%rip), %rsi      # 0x1130e
movl $0x4, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5c94
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
callq 0x5870
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb67b(%rip), %rsi      # 0x1131a
movl $0x4, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5cce
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
callq 0x5870
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb648(%rip), %rsi      # 0x11321
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5cfe
movq -0x60(%rbp), %rax
cvttsd2si (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb621(%rip), %rsi      # 0x1132a
movl $0x6, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5d2e
movq -0x60(%rbp), %rax
testb $0x1, (%rax)
jne 0x5d2e
movq -0x30(%rbp), %rax
movb $0x0, 0x58(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb5fc(%rip), %rsi      # 0x11335
movl $0x6, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5d5e
movq -0x60(%rbp), %rax
testb $0x1, (%rax)
je 0x5d5e
movq -0x30(%rbp), %rax
movb $0x1, 0x59(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb5d5(%rip), %rsi      # 0x1133e
movl $0x4, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5db3
movq -0x60(%rbp), %rax
movq (%rax), %rdi
callq 0xfd00
movq -0x30(%rbp), %rcx
movl %eax, 0x5c(%rcx)
cmpl $-0x1, %eax
jne 0x5db3
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rcx
movl $0x2, %esi
leaq 0xb5a0(%rip), %rdx      # 0x1134c
movb $0x0, %al
callq 0xa260
leaq -0x58(%rbp), %rdi
leaq 0xb5ab(%rip), %rsi      # 0x11369
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5de3
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x60(%rax)
leaq -0x58(%rbp), %rdi
leaq 0xb582(%rip), %rsi      # 0x11370
movl $0x5, %edx
callq 0x6820
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x5e13
movq -0x60(%rbp), %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, 0x68(%rax)
jmp 0x5e15
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x5e64
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movl $0x10, %esi
callq 0x10d00
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
callq 0x9ca0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq $0x0, 0x8(%rax)
leaq -0x58(%rbp), %rdi
callq 0x6e30
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop