// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::xml_parse_status pugi::impl::(anonymous namespace)::load_stream_data_seek<char>(std::basic_istream<char, std::char_traits<char>>&, void**, unsigned long*)
PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream<T>& stream, void** out_buffer, size_t* out_size)
	{
		// get length of remaining data in stream
		typename std::basic_istream<T>::pos_type pos = stream.tellg();
		stream.seekg(0, std::ios::end);
		std::streamoff length = stream.tellg() - pos;
		stream.seekg(pos);

		if (stream.fail() || pos < 0) return status_io_error;

		// guard against huge files
		size_t read_length = static_cast<size_t>(length);

		if (static_cast<std::streamsize>(read_length) != length || length < 0) return status_out_of_memory;

		size_t max_suffix_size = sizeof(char_t);

		// read stream data into memory (guard against stream exceptions with buffer holder)
		auto_deleter<void> buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate);
		if (!buffer.data) return status_out_of_memory;

		stream.read(static_cast<T*>(buffer.data), static_cast<std::streamsize>(read_length));

		// read may set failbit | eofbit in case gcount() is less than read_length (i.e. line ending conversion), so check for other I/O errors
		if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error;

		// return buffer
		size_t actual_length = static_cast<size_t>(stream.gcount());
		assert(actual_length <= read_length);

		*out_buffer = buffer.release();
		*out_size = actual_length * sizeof(T);

		return status_ok;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7130
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x7300
movq -0x10(%rbp), %rdi
callq 0x7130
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x68790
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x7560
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x79a0
testb $0x1, %al
jne 0x67ab0
leaq -0x30(%rbp), %rdi
callq 0x68770
cmpq $0x0, %rax
jge 0x67abc
movl $0x2, -0x4(%rbp)
jmp 0x67c7d
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x67ad5
cmpq $0x0, -0x38(%rbp)
jge 0x67ae1
movl $0x3, -0x4(%rbp)
jmp 0x67c7d
movq $0x1, -0x68(%rbp)
movq 0x2def8(%rip), %rax     # 0x959e8
movq -0x60(%rbp), %rdi
shlq $0x0, %rdi
addq -0x68(%rbp), %rdi
callq *%rax
movq %rax, %rsi
movq 0x2ded8(%rip), %rdx     # 0x959e0
leaq -0x78(%rbp), %rdi
callq 0x67dc0
cmpq $0x0, -0x78(%rbp)
jne 0x67b2b
movl $0x3, -0x4(%rbp)
movl $0x1, -0x7c(%rbp)
jmp 0x67c74
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x7470
jmp 0x67b3e
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x76a0
movb %al, -0x99(%rbp)
jmp 0x67b59
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x67bb3
jmp 0x67b65
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x7b30
movb %al, -0x9a(%rbp)
jmp 0x67b80
movb -0x9a(%rbp), %al
testb $0x1, %al
jne 0x67be6
jmp 0x67b8c
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x79a0
movb %al, -0x9b(%rbp)
jmp 0x67ba7
movb -0x9b(%rbp), %al
testb $0x1, %al
jne 0x67bb3
jmp 0x67be6
movl $0x2, -0x4(%rbp)
movl $0x1, -0x7c(%rbp)
jmp 0x67c74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x67e10
jmp 0x67c89
movq -0x10(%rbp), %rdi
callq 0x7210
movq %rax, -0xa8(%rbp)
jmp 0x67bf8
movq -0xa8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x60(%rbp), %rax
ja 0x67c15
jmp 0x67c34
leaq 0x74f5(%rip), %rdi      # 0x6f111
leaq 0x3732(%rip), %rsi      # 0x6b355
movl $0x133d, %edx           # imm = 0x133D
leaq 0x74ff(%rip), %rcx      # 0x6f12e
callq 0x7180
leaq -0x78(%rbp), %rdi
callq 0x67df0
movq %rax, -0xb0(%rbp)
jmp 0x67c46
movq -0xb0(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
shlq $0x0, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl $0x1, -0x7c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x67e10
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x7600
nopw %cs:(%rax,%rax)