// File: swxlion[P]swxJson/src/swxJson.cpp
// Function: swxJson::Json::operator[](int)
Json& Json::operator [] (int index)
{
	if (_type == JSON_Uninit)
		setArray();

	if (_type != JSON_Array)
		throw JSON_ERROR_MSG(JsonNodeTypeMissMatchError, "Current node is not an array.");

	std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data;
	auto it = data->begin();
	int i = 0;
	for (; it != data->end(); it++, i++)
	{
		if (i == index)
		{
			JsonPtr node = *it;
			return *(node.get());
		}
	}

	for (; i < index; i++)
	{
		JsonPtr node(new Json());
		pushNode(node);
	}

	JsonPtr node(new Json());
	pushNode(node);
	return *(node.get());
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x108(%rsp)
movl %esi, 0x104(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpl $0x8, (%rax)
jne 0x3d232
movq 0x48(%rsp), %rdi
callq 0x386e0
movq 0x48(%rsp), %rax
cmpl $0x1, (%rax)
je 0x3d32f
movb $0x1, 0xcb(%rsp)
movl $0x60, %edi
callq 0x22100
movq %rax, 0x38(%rsp)
leaq 0xdf(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x224b0
movq 0x40(%rsp), %rdx
leaq 0xe5ef(%rip), %rsi      # 0x4b864
leaq 0xe0(%rsp), %rdi
callq 0x30e50
jmp 0x3d284
movq 0x38(%rsp), %rdi
leaq 0xe3e2(%rip), %rsi      # 0x4b672
leaq 0xe5c2(%rip), %rdx      # 0x4b859
movl $0x532, %ecx            # imm = 0x532
leaq 0xe0(%rsp), %r8
callq 0x3ee00
jmp 0x3d2ab
movq 0x38(%rsp), %rdi
movb $0x0, 0xcb(%rsp)
leaq 0x1a9f9(%rip), %rsi     # 0x57cb8
leaq 0x1b9a(%rip), %rdx      # 0x3ee60
callq 0x22480
jmp 0x3d5f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x3d307
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x22160
leaq 0xdf(%rsp), %rdi
callq 0x22320
testb $0x1, 0xcb(%rsp)
jne 0x3d320
jmp 0x3d32a
movq 0x38(%rsp), %rdi
callq 0x221d0
jmp 0x3d5e5
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x3ead0
movq %rax, 0xb8(%rsp)
movl $0x0, 0xb4(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x3eb00
movq %rax, 0xa8(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x3eb30
testb $0x1, %al
jne 0x3d393
jmp 0x3d416
movl 0xb4(%rsp), %eax
cmpl 0x104(%rsp), %eax
jne 0x3d3e7
leaq 0xb8(%rsp), %rdi
callq 0x3eb50
movq %rax, %rsi
leaq 0x98(%rsp), %rdi
callq 0x31120
leaq 0x98(%rsp), %rdi
callq 0x35600
movq %rax, 0x110(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x31150
jmp 0x3d5d5
jmp 0x3d3e9
leaq 0xb8(%rsp), %rdi
xorl %esi, %esi
callq 0x3eca0
movq %rax, 0x90(%rsp)
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x3d360
jmp 0x3d418
movl 0xb4(%rsp), %eax
cmpl 0x104(%rsp), %eax
jge 0x3d509
movl $0x10, %edi
callq 0x222b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x30(%rsp)
callq 0x30e30
jmp 0x3d448
movq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x33200
movq 0x20(%rsp), %rsi
leaq 0x70(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x31120
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x38770
jmp 0x3d484
leaq 0x70(%rsp), %rdi
callq 0x31150
leaq 0x80(%rsp), %rdi
callq 0x31150
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x3d418
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
movl $0x10, %esi
callq 0x222c0
jmp 0x3d5e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x31150
leaq 0x80(%rsp), %rdi
callq 0x31150
jmp 0x3d5e5
movl $0x10, %edi
callq 0x222b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
callq 0x30e30
jmp 0x3d525
movq 0x18(%rsp), %rsi
leaq 0x60(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x33200
movq 0x8(%rsp), %rsi
leaq 0x50(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x31120
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x38770
jmp 0x3d55e
leaq 0x50(%rsp), %rdi
callq 0x31150
leaq 0x60(%rsp), %rdi
callq 0x35600
movq %rax, 0x110(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x31150
jmp 0x3d5d5
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
movl $0x10, %esi
callq 0x222c0
jmp 0x3d5e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x31150
leaq 0x60(%rsp), %rdi
callq 0x31150
jmp 0x3d5e5
movq 0x110(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xd0(%rsp), %rdi
callq 0x224a0
nopw %cs:(%rax,%rax)