// File: halsafar[P]libtmx-parser/./libs/tinyxml2/tinyxml2.cpp
// Function: tinyxml2::XMLDocument::LoadFile(_IO_FILE*)
XMLError XMLDocument::LoadFile( FILE* fp )
{
    Clear();

    fseek( fp, 0, SEEK_SET );
    if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
        SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
        return _errorID;
    }

    fseek( fp, 0, SEEK_END );
    const long filelength = ftell( fp );
    fseek( fp, 0, SEEK_SET );
    if ( filelength == -1L ) {
        SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
        return _errorID;
    }

    const size_t size = filelength;
    if ( size == 0 ) {
        SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
        return _errorID;
    }

    _charBuffer = new char[size+1];
    size_t read = fread( _charBuffer, 1, size, fp );
    if ( read != size ) {
        SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
        return _errorID;
    }

    _charBuffer[size] = 0;

    const char* p = _charBuffer;
    p = XMLUtil::SkipWhiteSpace( p );
    p = XMLUtil::ReadBOM( p, &_writeBOM );
    if ( !p || !*p ) {
        SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
        return _errorID;
    }

    ParseDeep( _charBuffer + (p-_charBuffer), 0 );
    return _errorID;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x40(%rbp)
callq 0x1d640
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x42c0
movq -0x18(%rbp), %rdi
callq 0x43f0
cmpl $-0x1, %eax
jne 0x1d7fc
movq -0x18(%rbp), %rdi
callq 0x44b0
cmpl $0x0, %eax
je 0x1d7fc
movq -0x40(%rbp), %rdi
movl $0x5, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d97d
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x42c0
movq -0x18(%rbp), %rdi
callq 0x4030
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x42c0
cmpq $-0x1, -0x20(%rbp)
jne 0x1d855
movq -0x40(%rbp), %rdi
movl $0x5, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d97d
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1d888
movq -0x40(%rbp), %rdi
movl $0xf, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d97d
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
callq 0x4040
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x78(%rax)
movq 0x78(%rax), %rdi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %esi
callq 0x43c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x1d8e8
movq -0x40(%rbp), %rdi
movl $0x5, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d97d
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rcx
movq -0x28(%rbp), %rdx
movb $0x0, (%rcx,%rdx)
movq 0x78(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x1fa40
movq -0x40(%rbp), %rsi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x58, %rsi
callq 0x1a140
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x1d932
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1d953
movq -0x40(%rbp), %rdi
movl $0xf, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x1b580
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d97d
movq -0x40(%rbp), %rdi
movq 0x78(%rdi), %rsi
movq -0x38(%rbp), %rax
movq 0x78(%rdi), %rcx
subq %rcx, %rax
addq %rax, %rsi
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x78(%rax)
movq -0x40(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)