// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/arlib/json.cpp
// Function: JSON::construct(jsonparser&, jsonparser::event&, bool*, unsigned long)
void JSON::construct(jsonparser& p, jsonparser::event& ev, bool* ok, size_t maxdepth)
{
	m_action = ev.action;
	if(0);
	else if (ev.action == jsonparser::str) m_str = ev.str;
	else if (ev.action == jsonparser::num) fromstring(ev.str, m_num);
	else if (ev.action == jsonparser::error) *ok = false;
	else if (maxdepth == 0)
	{
		*ok = false;
		m_action = jsonparser::error;
		if (ev.action == jsonparser::enter_list || ev.action == jsonparser::enter_map)
		{
			// it would be faster to reset the jsonparser somehow,
			// but performance on hostile inputs isn't really a priority
			size_t xdepth = 1;
			while (xdepth)
			{
				jsonparser::event next = p.next();
				if (next.action == jsonparser::enter_list) xdepth++;
				if (next.action == jsonparser::enter_map) xdepth++;
				if (next.action == jsonparser::exit_list) xdepth--;
				if (next.action == jsonparser::exit_map) xdepth--;
			}
		}
		return;
	}
	else if (ev.action == jsonparser::enter_list)
	{
		while (true)
		{
			jsonparser::event next = p.next();
			if (next.action == jsonparser::exit_list) break;
			if (next.action == jsonparser::error) *ok = false;
			m_chld_list.append().construct(p, next, ok, maxdepth-1);
		}
	}
	else if (ev.action == jsonparser::enter_map)
	{
		while (true)
		{
			jsonparser::event next = p.next();
			if (next.action == jsonparser::exit_map) break;
			if (next.action == jsonparser::map_key)
			{
				jsonparser::event ev = p.next();
				m_chld_map.insert(next.str).construct(p, ev, ok, maxdepth-1);
			}
			if (next.action == jsonparser::error) *ok = false;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r15
movl (%rdx), %eax
movl %eax, (%rdi)
cmpl $0xb, %eax
je 0x1414c
movq %rdi, %r14
cmpl $0x5, %eax
je 0x1412a
cmpl $0x4, %eax
jne 0x1415f
addq $0x8, %r14
movq 0x8(%rdx), %rsi
movq 0x10(%rdx), %rax
leaq 0x8(%rsp), %rcx
movq %rsi, (%rcx)
movq %rax, 0x8(%rcx)
movzbl 0xf(%rcx), %edx
movq %rdx, %rdi
xorq $0xf, %rdi
testb %dl, %dl
movl %eax, %edx
cmovnsq %rcx, %rsi
cmovnsq %rdi, %rdx
movq %r14, %rdi
callq 0x193dc
jmp 0x14150
movq 0x8(%rdx), %rdi
movq 0x10(%rdx), %rsi
addq $0x18, %r14
movq %r14, %rdx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1ad98
movb $0x0, (%r15)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %r12
movq %rsi, %rbx
testq %r8, %r8
je 0x14226
cmpl $0x6, %eax
je 0x1428e
cmpl $0x8, %eax
jne 0x14150
addq $0x30, %r14
decq %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x134f2
movl 0x8(%rsp), %eax
cmpl $0x9, %eax
je 0x141a3
cmpl $0xa, %eax
jne 0x14212
jmp 0x14150
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x134f2
movups 0x10(%rsp), %xmm0
movups %xmm0, 0x30(%rsp)
movq %r12, %r13
leaq 0x20(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x19372
movq %r14, %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %r12
xorl %edx, %edx
callq 0x14c22
leaq 0x10(%rax), %rdi
movq %rbx, %rsi
leaq 0x40(%rsp), %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0x140ca
cmpb $0x0, 0x2f(%rsp)
jns 0x1420a
movq 0x20(%rsp), %rdi
callq 0x3430
leaq 0x8(%rsp), %r13
movq %rbp, %r14
cmpl $0xb, 0x8(%rsp)
jne 0x14188
movb $0x0, (%r15)
jmp 0x14188
movb $0x0, (%r15)
movl $0xb, (%r14)
cmpl $0x8, %eax
je 0x1423f
cmpl $0x6, %eax
jne 0x14150
movl $0x1, %r15d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x134f2
movl 0x8(%rsp), %eax
xorl %ecx, %ecx
cmpl $0x6, %eax
sete %cl
addq %r15, %rcx
xorl %r15d, %r15d
cmpl $0x8, %eax
sete %r15b
addq %rcx, %r15
xorl %ecx, %ecx
cmpl $0x7, %eax
sete %cl
subq %rcx, %r15
xorl %ecx, %ecx
cmpl $0xa, %eax
sete %cl
subq %rcx, %r15
jne 0x1424a
jmp 0x14150
leaq 0x20(%r14), %r13
decq %r12
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x134f2
movl 0x8(%rsp), %eax
cmpl $0xb, %eax
je 0x142b8
cmpl $0x7, %eax
jne 0x142bc
jmp 0x14150
movb $0x0, (%r15)
movq 0x28(%r14), %rsi
movq %r13, %rdi
callq 0x14b1e
movq %rax, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x140ca
jmp 0x1429a