// File: jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::xml_document::_destroy()
PUGI__FN void xml_document::_destroy()
	{
		assert(_root);

		// destroy static storage
		if (_buffer)
		{
			impl::xml_memory::deallocate(_buffer);
			_buffer = 0;
		}

		// destroy extra buffers (note: no need to destroy linked list nodes, they're allocated using document allocator)
		for (impl::xml_extra_buffer* extra = static_cast<impl::xml_document_struct*>(_root)->extra_buffers; extra; extra = extra->next)
		{
			if (extra->buffer) impl::xml_memory::deallocate(extra->buffer);
		}

		// destroy dynamic storage, leave sentinel page (it's in static memory)
		impl::xml_memory_page* root_page = PUGI__GETPAGE(_root);
		assert(root_page && !root_page->prev);
		assert(reinterpret_cast<char*>(root_page) >= _memory && reinterpret_cast<char*>(root_page) < _memory + sizeof(_memory));

		for (impl::xml_memory_page* page = root_page->next; page; )
		{
			impl::xml_memory_page* next = page->next;

			impl::xml_allocator::deallocate_page(page);

			page = next;
		}

	#ifdef PUGIXML_COMPACT
		// destroy hash table
		static_cast<impl::xml_document_struct*>(_root)->hash.clear();
	#endif

		_root = 0;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, (%rax)
je 0x4785c
jmp 0x4787b
leaq 0x24118(%rip), %rdi     # 0x6b97b
leaq 0x23aeb(%rip), %rsi     # 0x6b355
movl $0x1b0c, %edx           # imm = 0x1B0C
leaq 0x2418e(%rip), %rcx     # 0x6ba04
callq 0x7180
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x478a3
movq -0x30(%rbp), %rcx
movq 0x4e14f(%rip), %rax     # 0x959e0
movq 0x8(%rcx), %rdi
callq *%rax
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x58(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x478e3
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x478d3
movq 0x4e116(%rip), %rax     # 0x959e0
movq -0x10(%rbp), %rcx
movq (%rcx), %rdi
callq *%rax
jmp 0x478d5
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x478b2
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
movq (%rcx), %rcx
movq (%rcx), %rdx
shrq $0x8, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x31(%rbp)
je 0x4791d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x47926
jmp 0x47928
jmp 0x47947
leaq 0x240f9(%rip), %rdi     # 0x6ba28
leaq 0x23a1f(%rip), %rsi     # 0x6b355
movl $0x1b1d, %edx           # imm = 0x1B1D
leaq 0x240c2(%rip), %rcx     # 0x6ba04
callq 0x7180
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x10, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x32(%rbp)
jb 0x47979
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
addq $0x10, %rcx
addq $0xc0, %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0x47982
jmp 0x47984
jmp 0x479a3
leaq 0x240bb(%rip), %rdi     # 0x6ba46
leaq 0x239c3(%rip), %rsi     # 0x6b355
movl $0x1b1e, %edx           # imm = 0x1B1E
leaq 0x24066(%rip), %rcx     # 0x6ba04
callq 0x7180
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x479d5
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x47f50
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x479af
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)