// File: /workspace/github_cpp_makefile_star2_O3/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 0x143c7
movq %rdi, %r14
cmpl $0x5, %eax
je 0x143a5
cmpl $0x4, %eax
jne 0x143da
addq $0x8, %r14
movq 0x8(%rdx), %rsi
movq 0x10(%rdx), %rax
movq %rsp, %rcx
movq %rsi, (%rcx)
movq %rax, 0x8(%rcx)
movq %rax, %rdi
shrq $0x38, %rdi
xorq $0xf, %rdi
testq %rax, %rax
movl %eax, %edx
cmovnsq %rdi, %rdx
cmovnsq %rcx, %rsi
movq %r14, %rdi
callq 0x195fc
jmp 0x143cb
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 0x1ae50
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 0x144a8
cmpl $0x6, %eax
je 0x1450d
cmpl $0x8, %eax
jne 0x143cb
addq $0x30, %r14
decq %r12
movq %rsp, %r13
movq %r14, 0x18(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1380a
movl (%rsp), %eax
cmpl $0x9, %eax
je 0x14420
cmpl $0xa, %eax
jne 0x14496
jmp 0x143cb
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1380a
movups 0x8(%rsp), %xmm0
movups %xmm0, 0x30(%rsp)
movq %r12, %rbp
leaq 0x20(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x19592
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %r12
xorl %edx, %edx
callq 0x14ee6
leaq 0x10(%rax), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rbp
movq %r15, %rcx
movq %r12, %r8
callq 0x14346
cmpb $0x0, 0x2f(%rsp)
jns 0x14488
movq 0x20(%rsp), %rdi
callq 0x3430
movl (%rsp), %eax
movq %rsp, %r13
movq 0x18(%rsp), %r14
movq %rbp, %r15
cmpl $0xb, %eax
jne 0x14406
movb $0x0, (%r15)
jmp 0x14406
movb $0x0, (%r15)
movl $0xb, (%r14)
cmpl $0x8, %eax
je 0x144c1
cmpl $0x6, %eax
jne 0x143cb
movl $0x1, %r15d
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1380a
movl (%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 0x144ca
jmp 0x143cb
leaq 0x20(%r14), %r13
decq %r12
movq %rsp, %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x1380a
movl (%rsp), %eax
cmpl $0xb, %eax
je 0x14534
cmpl $0x7, %eax
jne 0x14538
jmp 0x143cb
movb $0x0, (%r15)
movq 0x28(%r14), %rsi
movq %r13, %rdi
callq 0x14de2
movq %rax, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x14346
jmp 0x14517