// File: halsafar[P]libtmx-parser/./libs/tinyxml2/tinyxml2.cpp
// Function: tinyxml2::XMLDocument::Parse(char const*, unsigned long)
XMLError XMLDocument::Parse( const char* p, size_t len )
{
	const char* start = p;
    Clear();

    if ( len == 0 || !p || !*p ) {
        SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
        return _errorID;
    }
    if ( len == (size_t)(-1) ) {
        len = strlen( p );
    }
    _charBuffer = new char[ len+1 ];
    memcpy( _charBuffer, p, len );
    _charBuffer[len] = 0;

    p = XMLUtil::SkipWhiteSpace( p );
    p = XMLUtil::ReadBOM( p, &_writeBOM );
    if ( !p || !*p ) {
        SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
        return _errorID;
    }

    ptrdiff_t delta = p - start;	// skip initial whitespace, BOM, etc.
    ParseDeep( _charBuffer+delta, 0 );
    if (_errorID) {
        // clean up now essentially dangling memory.
        // and the parse fail can put objects in the
        // pools that are dead and inaccessible.
        DeleteChildren();
        _elementPool.Clear();
        _attributePool.Clear();
        _textPool.Clear();
        _commentPool.Clear();
    }
    return _errorID;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x1d640
cmpq $0x0, -0x20(%rbp)
je 0x1dbb0
cmpq $0x0, -0x18(%rbp)
je 0x1dbb0
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1dbd4
movq -0x38(%rbp), %rdi
movl $0xf, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x38(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1dcf9
cmpq $-0x1, -0x20(%rbp)
jne 0x1dbe8
movq -0x18(%rbp), %rdi
callq 0x4120
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
callq 0x4040
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x78(%rax)
movq 0x78(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x41f0
movq -0x38(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x20(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rdi
callq 0x1fa40
movq -0x38(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
addq $0x58, %rsi
callq 0x1a140
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1dc53
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1dc77
movq -0x38(%rbp), %rdi
movl $0xf, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x38(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1dcf9
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq 0x78(%rdi), %rsi
addq -0x30(%rbp), %rsi
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x78(%rax)
movq -0x38(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x1dcef
movq -0x38(%rbp), %rdi
callq 0x1aab0
movq -0x38(%rbp), %rdi
addq $0x80, %rdi
callq 0x1fad0
movq -0x38(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x1fb60
movq -0x38(%rbp), %rdi
addq $0x180, %rdi            # imm = 0x180
callq 0x1fbf0
movq -0x38(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
callq 0x1fc80
movq -0x38(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)