// File: /workspace/github_cpp_makefile_star2_O1/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 0x149b1
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1b355(%rip), %rcx     # 0x2faa8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x15368
leaq 0x1b382(%rip), %rsi     # 0x2faed
jmp 0x14980
movsd 0x18(%r14), %xmm0
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1499b
jp 0x1499b
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15230
movq %rbx, %rdi
callq 0x15368
leaq 0x1b351(%rip), %rsi     # 0x2fb08
movl $0x1, %edx
movq %rbx, %rdi
callq 0x19466
movb $0x0, 0x10(%rbx)
incl 0x14(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
addq $0x30, %r14
leaq 0x18(%rsp), %r15
movq %r14, (%r15)
movq $0x0, 0x8(%r15)
movq %r15, %rdi
callq 0x153fc
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
movq %rax, %rdx
xorq %r14, %rdx
movq %rcx, %rsi
notq %rsi
orq %rdx, %rsi
je 0x14881
movq %rsp, %r15
leaq 0x18(%rsp), %r12
imulq $0x68, %rcx, %r13
addq (%rax), %r13
movq 0x8(%rsp), %rbp
leaq 0x1(%rbp), %rsi
movq %r15, %rdi
callq 0x155c0
movq (%rsp), %rax
leaq (%rax,%rbp,8), %rsi
leaq (%rax,%rbp,8), %rdi
addq $0x8, %rdi
movq %rbp, %rdx
notq %rdx
addq 0x8(%rsp), %rdx
shlq $0x3, %rdx
callq 0x3600
movq (%rsp), %rax
movq %r13, (%rax,%rbp,8)
incq 0x20(%rsp)
movq %r12, %rdi
callq 0x153fc
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rax, %rdx
xorq %r14, %rdx
movq %rcx, %rsi
notq %rsi
orq %rdx, %rsi
jne 0x14815
movq %rsp, %r14
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x15486
movq 0x8(%r14), %r15
testq %r15, %r15
je 0x148d0
movq (%rsp), %r12
shlq $0x3, %r15
xorl %r13d, %r13d
movq (%r12,%r13), %r14
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x1533a
addq $0x10, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1472c
addq $0x8, %r13
cmpq %r13, %r15
jne 0x148a5
movq (%rsp), %rdi
callq 0x3430
leaq 0x1b22a(%rip), %rsi     # 0x2fb0a
jmp 0x14930
movq %rbx, %rdi
callq 0x15368
leaq 0x1b20f(%rip), %rsi     # 0x2fb00
movl $0x5, %edx
jmp 0x14985
movq %rbx, %rdi
callq 0x1530e
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x14929
movq 0x20(%r14), %r14
imulq $0x58, %rax, %r15
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1472c
addq $0x58, %r14
addq $-0x58, %r15
jne 0x14914
leaq 0x229cd(%rip), %rsi     # 0x372fd
movl $0x1, %edx
movq %rbx, %rdi
callq 0x19466
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 0x151b2
movq %rbx, %rdi
callq 0x15368
leaq 0x1b17b(%rip), %rsi     # 0x2fafb
movl $0x4, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x19466
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1529c
callq 0x3180