// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movb $0x0, 0x4(%rsi)
leaq 0x10(%rsp), %rsi
callq 0x56c7
testl %eax, %eax
js 0x4ebf
movq 0x10(%rsp), %rax
movq %rax, (%r15)
movl 0x20(%rsp), %eax
cmpq $0x8, %rax
ja 0x5206
leaq 0x7565(%rip), %rcx      # 0xc410
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x8, (%rbx)
jmp 0x5206
movq %r14, %rdi
callq 0x568d
movq (%rax), %r12
movl 0x2010(%r12), %ebp
leaq 0x8(%rsp), %rsi
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x5679
movq 0x28(%rsp), %rdi
movq (%r15), %r14
cmpq %r14, %rdi
jae 0x4f22
movq 0x8(%rsp), %rax
addq %rax, %rdi
addq %rax, %r14
movq %r14, %rdx
subq %rdi, %rdx
movl $0xa, %esi
callq 0x20d0
testq %rax, %rax
je 0x4f22
decl %ebp
incq %rax
movq %r14, %rdx
subq %rax, %rdx
movq %rax, %rdi
jmp 0x4f03
movl 0x20(%rsp), %eax
addl $-0x9, %eax
cmpl $0xb, %eax
ja 0x51d3
leaq 0x74fb(%rip), %rcx      # 0xc434
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x756b(%rip), %r9       # 0xc4b4
jmp 0x51da
movl $0x2, (%rbx)
leaq 0x8(%rbx), %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0xa624
movq %rsp, %r13
movq $0x0, (%rsp)
movl $0x20, %edi
callq 0xb080
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x4e65
movl (%r12), %eax
movq (%rsp), %rbp
cmpl $0x8, %eax
je 0x5107
cmpl $0x7, %eax
je 0x50a4
testq %rbp, %rbp
je 0x4fbc
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0xa645
testl %eax, %eax
je 0x4f68
movq %rbp, %rdi
callq 0x2570
movq %r12, %rdi
callq 0x5215
movq %r12, %rdi
callq 0x2570
jmp 0x4f68
movl $0x0, (%rbx)
jmp 0x5206
movl $0x1, (%rbx)
jmp 0x5206
movl $0x5, (%rbx)
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
jmp 0x5206
movl $0x3, (%rbx)
movq %rsp, %rax
movq $0x8, (%rax)
leaq 0x8(%rbx), %r15
movq $0x0, 0x8(%rbx)
movl $0x100, %edi            # imm = 0x100
callq 0xb080
leaq 0x10(%rbx), %r12
movq %rax, 0x10(%rbx)
leaq 0x8(%rsp), %rbp
movq $0x0, 0x8(%rsp)
movl $0x20, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %rsp, %rdx
callq 0x4c2c
movq %rax, %r13
movq %r14, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x4e65
movl (%r13), %eax
cmpl $0x7, %eax
je 0x512c
cmpl $0x8, %eax
jne 0x5035
decq (%r15)
jmp 0x5206
movl $0x4, (%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rbx)
jmp 0x5206
movl $0x6, (%rbx)
cmpl $0x0, 0x28(%rsp)
setne 0x8(%rbx)
jmp 0x5206
movq %rbp, %rdi
callq 0x2570
movq %r12, %rdi
callq 0x5215
movq %r12, %rdi
callq 0x2570
cmpq $0x0, (%r15)
je 0x50fa
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x18(%rbx), %rax
movq -0x8(%rax,%r12), %rdi
movq (%rax,%r12), %r14
callq 0x2570
movq %r14, %rdi
callq 0x5215
movq %r14, %rdi
callq 0x2570
incq %r13
addq $0x10, %r12
cmpq 0x8(%rbx), %r13
jb 0x50cb
movq %r15, %rdi
callq 0xa7fc
jmp 0x5200
movq %rbp, %rdi
callq 0x2570
movq %r12, %rdi
callq 0x5215
movq %r12, %rdi
callq 0x2570
movq %r15, %rdi
callq 0xa758
jmp 0x5206
movq 0x8(%rsp), %rdi
callq 0x2570
cmpq $0x0, (%r15)
je 0x515a
xorl %r14d, %r14d
xorl %r13d, %r13d
movq (%r12), %rdi
addq %r14, %rdi
callq 0x5215
incq %r13
addq $0x20, %r14
cmpq (%r15), %r13
jb 0x5142
movq 0x10(%rbx), %rdi
callq 0x2570
jmp 0x5200
callq 0x2320
movl (%rax), %edi
callq 0x2260
movq %rax, %r9
jmp 0x51da
leaq 0x737e(%rip), %r9       # 0xc4fe
jmp 0x51da
leaq 0x73e7(%rip), %r9       # 0xc570
jmp 0x51da
leaq 0x7346(%rip), %r9       # 0xc4d8
jmp 0x51da
leaq 0x734b(%rip), %r9       # 0xc4e6
jmp 0x51da
leaq 0x738c(%rip), %r9       # 0xc530
jmp 0x51da
leaq 0x7315(%rip), %r9       # 0xc4c2
jmp 0x51da
leaq 0x7357(%rip), %r9       # 0xc50d
jmp 0x51da
leaq 0x7362(%rip), %r9       # 0xc521
jmp 0x51da
leaq 0x73b7(%rip), %r9       # 0xc57f
jmp 0x51da
leaq 0x7377(%rip), %r9       # 0xc548
jmp 0x51da
leaq 0x73ba(%rip), %r9       # 0xc594
movq 0x2000(%r12), %rcx
movq 0x2018(%r12), %rdi
leaq 0x73b1(%rip), %rdx      # 0xc5a2
movl $0x4, %esi
movl %ebp, %r8d
xorl %eax, %eax
callq 0x6e50
movl $0x7, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq