// File: halsafar[P]libtmx-parser/./libs/tinyxml2/tinyxml2.cpp
// Function: tinyxml2::XMLElement::ParseAttributes(char*)
char* XMLElement::ParseAttributes( char* p )
{
    const char* start = p;
    XMLAttribute* prevAttribute = 0;

    // Read the attributes.
    while( p ) {
        p = XMLUtil::SkipWhiteSpace( p );
        if ( !p || !(*p) ) {
            _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
            return 0;
        }

        // attribute.
        if (XMLUtil::IsNameStartChar( *p ) ) {
            XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
            attrib->_memPool = &_document->_attributePool;
			attrib->_memPool->SetTracked();

            p = attrib->ParseDeep( p, _document->ProcessEntities() );
            if ( !p || Attribute( attrib->Name() ) ) {
                DeleteAttribute( attrib );
                _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
                return 0;
            }
            // There is a minor bug here: if the attribute in the source xml
            // document is duplicated, it will not be detected and the
            // attribute will be doubly added. However, tracking the 'prevAttribute'
            // avoids re-scanning the attribute list. Preferring performance for
            // now, may reconsider in the future.
            if ( prevAttribute ) {
                prevAttribute->_next = attrib;
            }
            else {
                _rootAttribute = attrib;
            }
            prevAttribute = attrib;
        }
        // end of the tag
        else if ( *p == '/' && *(p+1) == '>' ) {
            _closingType = CLOSED;
            return p+2;	// done; sealed element.
        }
        // end of the tag
        else if ( *p == '>' ) {
            ++p;
            break;
        }
        else {
            _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
            return 0;
        }
    }
    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1d0c7
movq -0x18(%rbp), %rdi
callq 0x1eeb0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1cf00
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1cf3b
movq -0x38(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x82a0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
movl $0x7, %esi
callq 0x1b580
movq $0x0, -0x8(%rbp)
jmp 0x1d0cf
movq -0x18(%rbp), %rax
movzbl (%rax), %edi
callq 0x1ede0
testb $0x1, %al
jne 0x1cf50
jmp 0x1d052
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x1f4c0
movq %rax, %rdi
movq %rdi, -0x60(%rbp)
callq 0x1f5c0
movq -0x60(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq 0x8(%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq 0x8(%rax), %rdi
callq 0x1f460
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movzbl %al, %edx
andl $0x1, %edx
callq 0x1c020
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1cff7
movq -0x30(%rbp), %rdi
callq 0x1bfe0
movq -0x38(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1c710
cmpq $0x0, %rax
je 0x1d027
movq -0x30(%rbp), %rdi
callq 0x1c5c0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x8, %esi
callq 0x1b580
movq $0x0, -0x8(%rbp)
jmp 0x1d0cf
cmpq $0x0, -0x28(%rbp)
je 0x1d03c
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x1d048
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1d0c2
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x1d084
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3e, %eax
jne 0x1d084
movq -0x38(%rbp), %rax
movl $0x1, 0x58(%rax)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
jmp 0x1d0cf
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x1d09e
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1d0c7
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x7, %esi
callq 0x1b580
movq $0x0, -0x8(%rbp)
jmp 0x1d0cf
jmp 0x1ced8
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)