// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/json.cpp
// Function: void JSON::serialize<true>(jsonwriter&) const
void JSON::serialize(jsonwriter& w) const
{
	switch (m_action)
	{
	case jsonparser::unset:
	case jsonparser::error:
	case jsonparser::jnull:
		w.null();
		break;
	case jsonparser::jtrue:
		w.boolean(true);
		break;
	case jsonparser::jfalse:
		w.boolean(false);
		break;
	case jsonparser::str:
		w.str(m_str);
		break;
	case jsonparser::num:
		if (m_num == (int)m_num) w.num((int)m_num);
		else w.num(m_num);
		break;
	case jsonparser::enter_list:
		w.list_enter();
		for (const JSON& j : m_chld_list) j.serialize<sort>(w);
		w.list_exit();
		break;
	case jsonparser::enter_map:
		w.map_enter();
		if (sort)
		{
			array<const map<string,JSON>::node*> items;
			for (const map<string,JSON>::node& e : m_chld_map)
			{
				items.append(&e);
			}
			items.ssort([](const map<string,JSON>::node* a, const map<string,JSON>::node* b) { return string::less(a->key, b->key); });
			for (const map<string,JSON>::node* e : items)
			{
				w.map_key(e->key);
				e->value.serialize<sort>(w);
			}
		}
		else
		{
			for (auto& e : m_chld_map)
			{
				w.map_key(e.key);
				e.value.serialize<sort>(w);
			}
		}
		w.map_exit();
		break;
	default: abort(); // unreachable
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl (%rdi), %eax
cmpq $0xb, %rax
ja 0x14c75
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1b0db(%rip), %rcx     # 0x2fac8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x155f0
leaq 0x1b108(%rip), %rsi     # 0x2fb0d
jmp 0x14c44
movsd 0x18(%r14), %xmm0
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x14c5f
jp 0x14c5f
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x154b8
movq %rbx, %rdi
callq 0x155f0
leaq 0x1b0d7(%rip), %rsi     # 0x2fb28
movl $0x1, %edx
movq %rbx, %rdi
callq 0x1967e
movb $0x0, 0x10(%rbx)
incl 0x14(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
addq $0x30, %r14
movq %r14, %rdi
callq 0x15684
movq %rax, %r15
xorq %r14, %rax
movq %rdx, %rcx
notq %rcx
orq %rax, %rcx
je 0x14b40
movq %rdx, %r12
leaq 0x8(%r15), %rax
movq %rax, 0x20(%rsp)
imulq $0x68, %r12, %r13
addq (%r15), %r13
movq 0x18(%rsp), %rbp
leaq 0x1(%rbp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x15814
movq 0x10(%rsp), %rax
leaq (%rax,%rbp,8), %rsi
leaq (%rax,%rbp,8), %rdi
addq $0x8, %rdi
movq %rbp, %rdx
notq %rdx
addq 0x18(%rsp), %rdx
shlq $0x3, %rdx
callq 0x3600
movq 0x10(%rsp), %rax
movq %r13, (%rax,%rbp,8)
movq %r12, %rax
incq %rax
movq 0x10(%r15), %rcx
movq $-0x1, %r12
cmpq %rcx, %rax
jae 0x14b2d
movq 0x20(%rsp), %rdx
cmpq $0x41, %rcx
jb 0x14b0b
movq 0x20(%rsp), %rdx
movq (%rdx), %rdx
movq %rax, %rsi
shrq $0x3, %rsi
movzbl (%rdx,%rsi), %esi
movl %eax, %edi
andl $0x7, %edi
btl %edi, %esi
jb 0x14b2a
incq %rax
cmpq %rax, %rcx
jne 0x14b0b
jmp 0x14b2d
movq %rax, %r12
cmpq %r14, %r15
jne 0x14a9a
cmpq $-0x1, %r12
jne 0x14a9a
leaq 0x10(%rsp), %r15
leaq 0xf(%rsp), %rsi
movq %r15, %rdi
callq 0x156d0
movq (%r15), %r14
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x14b95
shlq $0x3, %r12
xorl %r13d, %r13d
movq (%r14,%r13), %r15
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x155c2
addq $0x10, %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x149c6
addq $0x8, %r13
cmpq %r13, %r12
jne 0x14b65
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x3430
leaq 0x1af86(%rip), %rsi     # 0x2fb2a
jmp 0x14bf4
movq %rbx, %rdi
callq 0x155f0
leaq 0x1af6b(%rip), %rsi     # 0x2fb20
movl $0x5, %edx
jmp 0x14c49
movq %rbx, %rdi
callq 0x15596
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x14bed
movq 0x20(%r14), %r14
imulq $0x58, %rax, %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x149c6
addq $0x58, %r14
addq $-0x58, %r15
jne 0x14bd8
leaq 0x22803(%rip), %rsi     # 0x373f7
movl $0x1, %edx
movq %rbx, %rdi
callq 0x1967e
movb $0x1, 0x10(%rbx)
decl 0x14(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15438
movq %rbx, %rdi
callq 0x155f0
leaq 0x1aed7(%rip), %rsi     # 0x2fb1b
movl $0x4, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1967e
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15524
callq 0x3180