// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl (%rdi), %eax
cmpq $0xb, %rax
ja 0x108c8
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x18322(%rip), %rcx     # 0x28a28
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10eea
movsd 0x18(%r14), %xmm0
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x108b3
jp 0x108b3
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f88
movq %rbx, %rdi
callq 0x11052
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r15
movaps %xmm0, (%r15)
addq $0x30, %r14
movq %r14, %rdi
callq 0x11154
leaq 0x10(%rsp), %r12
movq %rax, (%r12)
movq %rdx, 0x8(%r12)
leaq 0x8(%rsp), %r13
movq %rax, %rcx
xorq %r14, %rcx
movq %rdx, %rsi
notq %rsi
orq %rcx, %rsi
je 0x107ca
imulq $0x68, %rdx, %rcx
addq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x111ce
movq %r12, %rdi
callq 0x111bc
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
jmp 0x1078e
leaq 0x20(%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x111da
movq (%r14), %r15
movq 0x8(%r14), %r12
shlq $0x3, %r12
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x10817
movq (%r15,%r13), %r14
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x11074
addq $0x10, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x106e0
addq $0x8, %r13
jmp 0x107ea
movq 0x20(%rsp), %rdi
callq 0x3430
movq %rbx, %rdi
callq 0x1109c
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x108a1
movq %rbx, %rdi
callq 0x11010
movq 0x20(%r14), %r15
imulq $0x58, 0x28(%r14), %r14
testq %r14, %r14
je 0x10869
movq %r15, %rdi
movq %rbx, %rsi
callq 0x106e0
addq $0x58, %r15
addq $-0x58, %r14
jmp 0x1084f
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x11038
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f36
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f04
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10fca
callq 0x3180
nop