// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/json-util.c
// Function: parse_node
static void parse_node(json_reader *rdr, struct json_node *nd, char **keyp)
{
	size_t cap;
	struct json_item item;
	nd->taken = false;
	if (json_read_item(rdr, &item) < 0) {
		print_json_error(rdr, &item);
		nd->kind = JN_ERROR;
		return;
	}
	*keyp = item.key.bytes;
	switch (item.type) {
	case JSON_EMPTY:
		nd->kind = JN_EMPTY;
		break;
	case JSON_NULL:
		nd->kind = JN_NULL;
		break;
	case JSON_MAP:
		nd->kind = JN_MAP;
		table_init(&nd->d.map, 8);
		for (;;) {
			char *key = NULL;
			struct json_node *entry = xmalloc(sizeof(*entry));
			parse_node(rdr, entry, &key);
			if (entry->kind == JN_END_) {
				free_json_pair(key, entry);
				break;
			} else if (entry->kind == JN_ERROR) {
				free_json_pair(key, entry);
				const char *k;
				void **v;
				TABLE_FOR_EACH(&nd->d.map, k, v) {
					free_json_pair(k, *v);
				}
				table_free(&nd->d.map);
				nd->kind = JN_ERROR;
				return;
			}
			if (!key || table_add(&nd->d.map, key, entry))
				// With duplicate keys, the first is kept:
				free_json_pair(key, entry);
		}
		table_freeze(&nd->d.map);
		break;
	case JSON_LIST:
		nd->kind = JN_LIST;
		cap = 8;
		nd->d.list.n_vals = 0;
		nd->d.list.vals = xmalloc(cap * sizeof(*nd->d.list.vals));
		for (;;) {
			char *key = NULL;
			struct json_node *entry = GROWE(nd->d.list.vals,
				nd->d.list.n_vals, cap);
			parse_node(rdr, entry, &key);
			if (entry->kind == JN_END_) {
				--nd->d.list.n_vals;
				break;
			} else if (entry->kind == JN_ERROR) {
				free(key);
				for (size_t i = 0; i < nd->d.list.n_vals; ++i) {
					free_json_tree(&nd->d.list.vals[i]);
				}
				free(nd->d.list.vals);
				nd->kind = JN_ERROR;
				return;
			}
		}
		break;
	case JSON_STRING:
		nd->kind = JN_STRING;
		nd->d.str = item.val.str.bytes;
		break;
	case JSON_NUMBER:
		nd->kind = JN_NUMBER;
		nd->d.num = item.val.num;
		break;
	case JSON_BOOLEAN:
		nd->kind = JN_BOOLEAN;
		nd->d.boolean = item.val.boolean;
		break;
	case JSON_END_MAP:
	case JSON_END_LIST:
		nd->kind = JN_END_;
		break;
	default:
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7990
cmpl $0x0, %eax
jge 0x6afd
movq -0x8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7350
movq -0x10(%rbp), %rax
movl $0x7, (%rax)
jmp 0x6e1d
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0x38(%rbp), %eax
movq %rax, -0x90(%rbp)
subq $0x8, %rax
ja 0x6e1b
movq -0x90(%rbp), %rax
leaq 0xa84e(%rip), %rcx      # 0x11378
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x2, (%rax)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x8, %esi
callq 0xf990
movq $0x0, -0x50(%rbp)
movl $0x20, %edi
callq 0x10b80
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x6ab0
movq -0x58(%rbp), %rax
cmpl $0x8, (%rax)
jne 0x6baf
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x6f70
jmp 0x6c9f
movq -0x58(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x6c6a
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x6f70
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x91(%rbp)
jae 0x6c24
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x70(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x70(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x68(%rbp)
movb $0x1, %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x6c30
jmp 0x6c4e
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rax
movq (%rax), %rsi
callq 0x6f70
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x6bd1
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0xfce0
movq -0x10(%rbp), %rax
movl $0x7, (%rax)
jmp 0x6e1d
jmp 0x6c6c
cmpq $0x0, -0x50(%rbp)
je 0x6c8d
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xf9e0
cmpl $0x0, %eax
je 0x6c9a
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x6f70
jmp 0x6b6d
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0xfba0
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x3, (%rax)
movq $0x8, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rdi
shlq $0x5, %rdi
callq 0x10b80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
leaq -0x20(%rbp), %rdx
movl $0x20, %ecx
callq 0x6700
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x6ab0
movq -0x80(%rbp), %rax
cmpl $0x8, (%rax)
jne 0x6d41
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
jmp 0x6dbe
movq -0x80(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x6db7
movq -0x78(%rbp), %rdi
callq 0x2580
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x6d9e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x88(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x6e30
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x6d5e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2580
movq -0x10(%rbp), %rax
movl $0x7, (%rax)
jmp 0x6e1d
jmp 0x6db9
jmp 0x6ce7
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x4, (%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x5, (%rax)
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x6, (%rax)
cmpl $0x0, -0x30(%rbp)
setne %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x8(%rax)
jmp 0x6e1d
movq -0x10(%rbp), %rax
movl $0x8, (%rax)
jmp 0x6e1d
jmp 0x6e1d
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)