// File: halsafar[P]libtmx-parser/./libs/tinyxml2/tinyxml2.cpp
// Function: tinyxml2::XMLNode::ParseDeep(char*, tinyxml2::StrPair*)
char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
{
    // This is a recursive method, but thinking about it "at the current level"
    // it is a pretty simple flat list:
    //		<foo/>
    //		<!-- comment -->
    //
    // With a special case:
    //		<foo>
    //		</foo>
    //		<!-- comment -->
    //
    // Where the closing element (/foo) *must* be the next thing after the opening
    // element, and the names must match. BUT the tricky bit is that the closing
    // element will be read by the child.
    //
    // 'endTag' is the end tag for this node, it is returned by a call to a child.
    // 'parentEnd' is the end tag for the parent, which is filled in and returned.

    while( p && *p ) {
        XMLNode* node = 0;

        p = _document->Identify( p, &node );
        if ( p == 0 || node == 0 ) {
            break;
        }

        StrPair endTag;
        p = node->ParseDeep( p, &endTag );
        if ( !p ) {
            DeleteNode( node );
            node = 0;
            if ( !_document->Error() ) {
                _document->SetError( XML_ERROR_PARSING, 0, 0 );
            }
            break;
        }

        XMLElement* ele = node->ToElement();
        // We read the end tag. Return it to the parent.
        if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
            if ( parentEnd ) {
                ele->_value.TransferTo( parentEnd );
            }
			node->_memPool->SetTracked();	// created and then immediately deleted.
            DeleteNode( node );
            return p;
        }

        // Handle an end tag returned to this level.
        // And handle a bunch of annoying errors.
        if ( ele ) {
            bool mismatch = false;
            if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
                mismatch = true;
            }
            else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
                mismatch = true;
            }
            else if ( !endTag.Empty() ) {
                if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
                    mismatch = true;
                }
            }
            if ( mismatch ) {
                _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
                p = 0;
            }
        }
        if ( p == 0 ) {
            DeleteNode( node );
            node = 0;
        }
        if ( node ) {
            this->InsertEndChild( node );
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x69(%rbp)
je 0x1b228
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x1b234
jmp 0x1b562
movq -0x68(%rbp), %rax
movq $0x0, -0x28(%rbp)
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x1a670
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1b263
cmpq $0x0, -0x28(%rbp)
jne 0x1b268
jmp 0x1b562
leaq -0x40(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x1f380
movq -0x80(%rbp), %rdx
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq (%rdi), %rax
movq 0x78(%rax), %rax
callq *%rax
movq %rax, -0x78(%rbp)
jmp 0x1b290
movq -0x78(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1b316
movq -0x28(%rbp), %rdi
callq 0x1ac40
jmp 0x1b2aa
movq -0x68(%rbp), %rax
movq $0x0, -0x28(%rbp)
movq 0x8(%rax), %rdi
callq 0x1f3e0
movb %al, -0x81(%rbp)
jmp 0x1b2c7
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x1b30a
jmp 0x1b2d3
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0x11, %esi
movq %rcx, %rdx
callq 0x1b580
jmp 0x1b2ee
jmp 0x1b30a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x197d0
jmp 0x1b577
movl $0x3, -0x50(%rbp)
jmp 0x1b536
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movq %rax, -0x90(%rbp)
jmp 0x1b32b
movq -0x90(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x1b3a7
movq -0x58(%rbp), %rdi
callq 0x1f400
movl %eax, -0x94(%rbp)
jmp 0x1b34e
movl -0x94(%rbp), %eax
cmpl $0x2, %eax
jne 0x1b3a7
cmpq $0x0, -0x20(%rbp)
je 0x1b375
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
callq 0x19860
jmp 0x1b373
jmp 0x1b375
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
jmp 0x1b388
movq -0x28(%rbp), %rdi
callq 0x1ac40
jmp 0x1b393
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x1b536
cmpq $0x0, -0x58(%rbp)
je 0x1b4fd
movb $0x0, -0x59(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x1f420
movb %al, -0x95(%rbp)
jmp 0x1b3c7
movb -0x95(%rbp), %al
testb $0x1, %al
jne 0x1b3d3
jmp 0x1b3f8
movq -0x58(%rbp), %rdi
callq 0x1f400
movl %eax, -0x9c(%rbp)
jmp 0x1b3e4
movl -0x9c(%rbp), %eax
cmpl $0x0, %eax
jne 0x1b3f8
movb $0x1, -0x59(%rbp)
jmp 0x1b4ae
leaq -0x40(%rbp), %rdi
callq 0x1f420
movb %al, -0x9d(%rbp)
jmp 0x1b409
movb -0x9d(%rbp), %al
testb $0x1, %al
jne 0x1b437
jmp 0x1b415
movq -0x58(%rbp), %rdi
callq 0x1f400
movl %eax, -0xa4(%rbp)
jmp 0x1b426
movl -0xa4(%rbp), %eax
cmpl $0x0, %eax
je 0x1b437
movb $0x1, -0x59(%rbp)
jmp 0x1b4ac
leaq -0x40(%rbp), %rdi
callq 0x1f420
movb %al, -0xa5(%rbp)
jmp 0x1b448
movb -0xa5(%rbp), %al
testb $0x1, %al
jne 0x1b4aa
jmp 0x1b454
leaq -0x40(%rbp), %rdi
callq 0x19bb0
movq %rax, -0xb0(%rbp)
jmp 0x1b466
movq -0x28(%rbp), %rdi
callq 0x1abc0
movq %rax, -0xb8(%rbp)
jmp 0x1b478
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x1ef10
movb %al, -0xb9(%rbp)
jmp 0x1b498
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x1b4a8
jmp 0x1b4a4
movb $0x1, -0x59(%rbp)
jmp 0x1b4aa
jmp 0x1b4ac
jmp 0x1b4ae
testb $0x1, -0x59(%rbp)
je 0x1b4fb
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1abc0
movq %rax, -0xc8(%rbp)
jmp 0x1b4d5
movq -0xc8(%rbp), %rdx
movq -0xd0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movl $0x10, %esi
callq 0x1b580
jmp 0x1b4f3
movq $0x0, -0x18(%rbp)
jmp 0x1b4fd
cmpq $0x0, -0x18(%rbp)
jne 0x1b517
movq -0x28(%rbp), %rdi
callq 0x1ac40
jmp 0x1b50f
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1b52f
movq -0x68(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1acb0
jmp 0x1b52d
jmp 0x1b52f
movl $0x0, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x197d0
movl -0x50(%rbp), %eax
movl %eax, -0xd4(%rbp)
testl %eax, %eax
je 0x1b55d
jmp 0x1b54e
movl -0xd4(%rbp), %eax
subl $0x1, %eax
je 0x1b56a
jmp 0x1b55b
jmp 0x1b562
jmp 0x1b20f
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4470