// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/map.c
// Function: parse_block
static void parse_block(d3d_block_s *block, uint8_t *wall, struct json_node *nd,
	struct loader *ldr)
{
	union json_node_data *got;
	*wall = 0;
	memset(block, 0, sizeof(*block));
	if (nd->kind != JN_MAP) return;
	bool all_solid = false;
	if ((got = json_map_get(nd, "all_solid", JN_BOOLEAN))) {
		if (got->boolean) {
			*wall = 0xFF;
			all_solid = true;
		}
	}
	if ((got = json_map_get(nd, "all", JN_STRING))) {
		const d3d_texture *txtr = load_texture(ldr, got->str);
		if (txtr) {
			block->faces[D3D_DPOSX] =
			block->faces[D3D_DPOSY] =
			block->faces[D3D_DNEGX] =
			block->faces[D3D_DNEGY] =
			block->faces[D3D_DUP] =
			block->faces[D3D_DDOWN] = txtr;
		}
	}
	struct { const char *txtr, *wall; d3d_direction dir; } faces[] = {
		{"north" , "north_solid", D3D_DPOSY}, // See DIRECTION NOTE.
		{"south" , "south_solid", D3D_DNEGY},
		{"east"  , "east_solid" , D3D_DPOSX},
		{"west"  , "west_solid" , D3D_DNEGX},
		{"top"   , "" /* N/A */ , D3D_DUP  },
		{"bottom", "" /* N/A */ , D3D_DDOWN}
	};
	for (size_t i = 0; i < ARRSIZE(faces); ++i) {
		if ((got = json_map_get(nd, faces[i].txtr, JN_STRING))) {
			const d3d_texture *txtr = load_texture(ldr, got->str);
			if (txtr) block->faces[faces[i].dir] = txtr;
		}
		if (!all_solid
		 && (got = json_map_get(nd, faces[i].wall, JN_BOOLEAN)))
			if (got->boolean) *wall |= 1 << faces[i].dir;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2060
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
je 0xc370
jmp 0xc53c
movb $0x0, -0x29(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x5c12(%rip), %rsi      # 0x11f91
movl $0x6, %edx
callq 0x6820
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xc3a9
movq -0x28(%rbp), %rax
testb $0x1, (%rax)
je 0xc3a7
movq -0x10(%rbp), %rax
movb $-0x1, (%rax)
movb $0x1, -0x29(%rbp)
jmp 0xc3a9
movq -0x18(%rbp), %rdi
leaq 0x5a93(%rip), %rsi      # 0x11e47
movl $0x4, %edx
callq 0x6820
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xc418
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0x95d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xc416
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
jmp 0xc418
leaq -0xd0(%rbp), %rdi
leaq 0x98ca(%rip), %rsi      # 0x15cf0
movl $0x90, %edx
callq 0x2510
movq $0x0, -0xd8(%rbp)
cmpq $0x6, -0xd8(%rbp)
jae 0xc53c
movq -0x18(%rbp), %rdi
leaq -0xd0(%rbp), %rax
imulq $0x18, -0xd8(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl $0x4, %edx
callq 0x6820
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xc4bd
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0x95d0
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0xc4bb
movq -0xe0(%rbp), %rdx
movq -0x8(%rbp), %rax
leaq -0xd0(%rbp), %rcx
imulq $0x18, -0xd8(%rbp), %rsi
addq %rsi, %rcx
movl 0x10(%rcx), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0xc4bd
testb $0x1, -0x29(%rbp)
jne 0xc523
movq -0x18(%rbp), %rdi
leaq -0xd0(%rbp), %rax
imulq $0x18, -0xd8(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movl $0x6, %edx
callq 0x6820
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xc523
movq -0x28(%rbp), %rax
testb $0x1, (%rax)
je 0xc521
leaq -0xd0(%rbp), %rax
imulq $0x18, -0xd8(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movl $0x1, %edx
shll %cl, %edx
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
orl %edx, %ecx
movb %cl, (%rax)
jmp 0xc523
jmp 0xc525
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0xc43b
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)