// File: swxlion[P]swxJson/src/swxJson.cpp
// Function: swxJson::Json::output(std::ostream&) const
std::ostream& Json::output(std::ostream& os) const
{
	if (_type == JSON_String)
	{
		std::string * str = (std::string*)_data;
		os << '"' << gc_JsonStringEscaper.escape(str) << '"';
	}
	else if (_type == JSON_Integer)
	{
		intmax_t * data = (intmax_t*)_data;
		os << (*data);
	}
	else if (_type == JSON_UInteger)
	{
		uintmax_t * data = (uintmax_t*)_data;
		os << (*data);
	}
	else if (_type == JSON_Object)
	{
		std::map<std::string, JsonPtr>* data = (std::map<std::string, JsonPtr>*)_data;
		os << "{";
		
		bool first = true;
		for (auto& pair: *data)
		{
			if (first)
				first = false;
			else
				os << ", ";

			os << '"' << gc_JsonStringEscaper.escape(&(pair.first)) << "\":";
			pair.second->output(os);
		}

		os << "}";
	}
	else if (_type == JSON_Array)
	{
		std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data;
		os << "[";
		
		bool first = true;
		for (JsonPtr node: *data)
		{
			if (first)
				first = false;
			else
				os << ", ";

			node->output(os);
		}

		os << "]";
	}
	else if (_type == JSON_Real)
	{
		double * data = (double*)_data;
		os << (*data);
	}
	else if (_type == JSON_Boolean)
	{
		os << ((bool)_data ? "true" : "false");
	}
	else if (_type == JSON_Null)
	{
		os << "null";
	}
	else if (_type == JSON_Uninit)
	{
		os << "null";
	}

	return os;
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpl $0x2, (%rax)
jne 0x36595
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
movl $0x22, %esi
callq 0x22380
movq %rax, 0x20(%rsp)
movq 0x110(%rsp), %rdx
leaq 0x21dc4(%rip), %rsi     # 0x582e8
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x3e2a0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x22250
movq %rax, 0x30(%rsp)
jmp 0x3654c
movq 0x30(%rsp), %rdi
movl $0x22, %esi
callq 0x22380
jmp 0x3655d
leaq 0xf0(%rsp), %rdi
callq 0x22160
jmp 0x3698e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe8(%rsp)
movl %eax, 0xe4(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x22160
jmp 0x3699e
movq 0x38(%rsp), %rax
cmpl $0x3, (%rax)
jne 0x365cd
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0x118(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
callq 0x224f0
jmp 0x3698c
movq 0x38(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x36605
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xd0(%rsp)
movq 0x118(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq (%rax), %rsi
callq 0x22080
jmp 0x3698a
movq 0x38(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x367b5
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xc8(%rsp)
movq 0x118(%rsp), %rdi
leaq 0x15035(%rip), %rsi     # 0x4b668
callq 0x222a0
movb $0x1, 0xc7(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x3ea00
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x3ea30
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x3ea60
testb $0x1, %al
jne 0x36698
jmp 0x3679c
leaq 0xb0(%rsp), %rdi
callq 0x3ea80
movq %rax, 0xa0(%rsp)
testb $0x1, 0xc7(%rsp)
je 0x366c1
movb $0x0, 0xc7(%rsp)
jmp 0x366d5
movq 0x118(%rsp), %rdi
leaq 0x14f9a(%rip), %rsi     # 0x4b66a
callq 0x222a0
movq 0x118(%rsp), %rdi
movl $0x22, %esi
callq 0x22380
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rdx
leaq 0x21bed(%rip), %rsi     # 0x582e8
leaq 0x80(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x3e2a0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x22250
movq %rax, 0x18(%rsp)
jmp 0x36723
movq 0x18(%rsp), %rdi
leaq 0x14f3e(%rip), %rsi     # 0x4b66d
callq 0x222a0
jmp 0x36736
leaq 0x80(%rsp), %rdi
callq 0x22160
movq 0xa0(%rsp), %rdi
addq $0x20, %rdi
callq 0x312a0
movq %rax, %rdi
movq 0x118(%rsp), %rsi
callq 0x364c0
leaq 0xb0(%rsp), %rdi
callq 0x3eaa0
jmp 0x3667a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe8(%rsp)
movl %eax, 0xe4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x22160
jmp 0x3699e
movq 0x118(%rsp), %rdi
leaq 0x14ec5(%rip), %rsi     # 0x4b670
callq 0x222a0
jmp 0x36988
movq 0x38(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x368d8
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x118(%rsp), %rdi
leaq 0x13ae0(%rip), %rsi     # 0x4a2c0
callq 0x222a0
movb $0x1, 0x77(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x3ead0
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
callq 0x3eb00
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3eb30
testb $0x1, %al
jne 0x3682a
jmp 0x368bf
leaq 0x60(%rsp), %rdi
callq 0x3eb50
movq %rax, %rsi
leaq 0x48(%rsp), %rdi
callq 0x31120
testb $0x1, 0x77(%rsp)
je 0x3684f
movb $0x0, 0x77(%rsp)
jmp 0x3688a
movq 0x118(%rsp), %rdi
leaq 0x14e0c(%rip), %rsi     # 0x4b66a
callq 0x222a0
jmp 0x36865
jmp 0x3688a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe8(%rsp)
movl %eax, 0xe4(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x31150
jmp 0x3699e
leaq 0x48(%rsp), %rdi
callq 0x312a0
movq %rax, %rdi
movq 0x118(%rsp), %rsi
callq 0x364c0
jmp 0x368a6
leaq 0x48(%rsp), %rdi
callq 0x31150
leaq 0x60(%rsp), %rdi
callq 0x3eb70
jmp 0x36812
movq 0x118(%rsp), %rdi
leaq 0x14f94(%rip), %rsi     # 0x4b862
callq 0x222a0
jmp 0x36986
movq 0x38(%rsp), %rax
cmpl $0x5, (%rax)
jne 0x36908
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x118(%rsp), %rdi
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
callq 0x22510
jmp 0x36984
movq 0x38(%rsp), %rax
cmpl $0x6, (%rax)
jne 0x36940
movq 0x38(%rsp), %rax
movq 0x118(%rsp), %rdi
movq 0x8(%rax), %rcx
leaq 0x13ba1(%rip), %rsi     # 0x4a4cb
leaq 0x13ba8(%rip), %rax     # 0x4a4d9
cmpq $0x0, %rcx
cmovneq %rax, %rsi
callq 0x222a0
jmp 0x36982
movq 0x38(%rsp), %rax
cmpl $0x7, (%rax)
jne 0x36960
movq 0x118(%rsp), %rdi
leaq 0x13d1b(%rip), %rsi     # 0x4a674
callq 0x222a0
jmp 0x36980
movq 0x38(%rsp), %rax
cmpl $0x8, (%rax)
jne 0x3697e
movq 0x118(%rsp), %rdi
leaq 0x13cfb(%rip), %rsi     # 0x4a674
callq 0x222a0
jmp 0x36980
jmp 0x36982
jmp 0x36984
jmp 0x36986
jmp 0x36988
jmp 0x3698a
jmp 0x3698c
jmp 0x3698e
movq 0x118(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xe8(%rsp), %rdi
callq 0x224a0
nopl (%rax,%rax)