// File: swxlion[P]swxJson/src/swxJson.cpp
// Function: swxJson::Json::getParentNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool&, bool&)
JsonPtr Json::getParentNode(const std::string& path, const std::string& delim, std::string& lastSection, bool& nodeTypeError, bool& nodeNotFound)
{
	nodeTypeError = false;
	nodeNotFound = false;

	std::vector<std::string> sections;
	pathSplit(path, delim, sections);

	if (sections.empty())
	{
		lastSection = "";
		return nullptr;
	}

	JsonPtr node;
	for (int i = 0; i < (int)sections.size() - 1; i++)
	{
		JsonPtr next = (i>0) ? node->getNodeByKey(sections[i]) : getNodeByKey(sections[0]);
		if (next == nullptr)
		{
			enum ElementType nodeType = (i>0) ? node->type() : type();
			if (nodeType == JSON_Object)
			{
				nodeNotFound = true;
				lastSection = sections[i];
				return nullptr;
			}
			else
			{
				nodeTypeError = true;
				lastSection = sections[i];
				return nullptr;
			}
		}
		else
			node = next;
	}

	lastSection = sections[sections.size() - 1];
	return node;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0x30(%rsp)
movq %rdi, %rax
movq %rax, 0x38(%rsp)
movq 0xe0(%rsp), %rax
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
movq %r9, 0xa8(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rax
movb $0x0, (%rax)
movq 0xe0(%rsp), %rax
movb $0x0, (%rax)
leaq 0x90(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x3ecd0
movq 0x48(%rsp), %rdx
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x36a80
jmp 0x372ad
leaq 0x90(%rsp), %rdi
callq 0x3ece0
testb $0x1, %al
jne 0x372c0
jmp 0x3730d
movq 0xb0(%rsp), %rdi
leaq 0x141a5(%rip), %rsi     # 0x4b474
callq 0x223e0
jmp 0x372d6
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ec30
movl $0x1, 0x80(%rsp)
jmp 0x37594
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x375ae
leaq 0x70(%rsp), %rdi
callq 0x31340
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x3ed50
movq %rax, %rcx
movl 0x2c(%rsp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x3752e
cmpl $0x0, 0x6c(%rsp)
jle 0x37384
leaq 0x70(%rsp), %rdi
callq 0x312a0
movq %rax, 0x20(%rsp)
movslq 0x6c(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x3ed30
movq 0x20(%rsp), %rsi
movq %rax, %rdx
leaq 0x58(%rsp), %rdi
callq 0x36dd0
jmp 0x37382
jmp 0x373ab
xorl %eax, %eax
movl %eax, %esi
leaq 0x90(%rsp), %rdi
callq 0x3ed30
movq 0x40(%rsp), %rsi
movq %rax, %rdx
leaq 0x58(%rsp), %rdi
callq 0x36dd0
jmp 0x373a9
jmp 0x373ab
leaq 0x58(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ed70
testb $0x1, %al
jne 0x373c2
jmp 0x374eb
cmpl $0x0, 0x6c(%rsp)
jle 0x373eb
leaq 0x70(%rsp), %rdi
callq 0x312a0
movq %rax, %rdi
callq 0x312b0
movl %eax, 0x1c(%rsp)
jmp 0x373e1
movl 0x1c(%rsp), %eax
movl %eax, 0x18(%rsp)
jmp 0x37405
movq 0x40(%rsp), %rdi
callq 0x312b0
movl %eax, 0x14(%rsp)
jmp 0x373fb
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rsp)
jmp 0x37405
movl 0x18(%rsp), %eax
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x54(%rsp)
jne 0x374a1
movq 0xe0(%rsp), %rax
movb $0x1, (%rax)
movslq 0x6c(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x3ed30
movq %rax, %rsi
movq 0xb0(%rsp), %rdi
callq 0x22040
jmp 0x37447
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ec30
movl $0x1, 0x80(%rsp)
jmp 0x37505
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x37588
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x31150
jmp 0x37588
movq 0xa8(%rsp), %rax
movb $0x1, (%rax)
movslq 0x6c(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x3ed30
movq %rax, %rsi
movq 0xb0(%rsp), %rdi
callq 0x22040
jmp 0x374d0
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3ec30
movl $0x1, 0x80(%rsp)
jmp 0x37505
leaq 0x70(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3eda0
movl $0x0, 0x80(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x31150
movl 0x80(%rsp), %eax
testl %eax, %eax
jne 0x3757c
jmp 0x3751c
jmp 0x3751e
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x3731f
leaq 0x90(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x3ed50
movq 0x8(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3ed30
movq %rax, %rsi
movq 0xb0(%rsp), %rdi
callq 0x22040
jmp 0x37562
movq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3edd0
movl $0x1, 0x80(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x31150
jmp 0x37594
leaq 0x70(%rsp), %rdi
callq 0x31150
jmp 0x375ae
leaq 0x90(%rsp), %rdi
callq 0x32770
movq 0x38(%rsp), %rax
addq $0xd8, %rsp
retq
leaq 0x90(%rsp), %rdi
callq 0x32770
movq 0x88(%rsp), %rdi
callq 0x224a0
nopl (%rax,%rax)