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

	#ifdef PUGIXML_COMPACT
		// space for page marker for the first page (uint32_t), rounded up to pointer size; assumes pointers are at least 32-bit
		const size_t page_offset = sizeof(void*);
	#else
		const size_t page_offset = 0;
	#endif

		// initialize sentinel page
		PUGI__STATIC_ASSERT(sizeof(impl::xml_memory_page) + sizeof(impl::xml_document_struct) + page_offset <= sizeof(_memory));

		// prepare page structure
		impl::xml_memory_page* page = impl::xml_memory_page::construct(_memory);
		assert(page);

		page->busy_size = impl::xml_memory_page_size;

		// setup first page marker
	#ifdef PUGIXML_COMPACT
		// round-trip through void* to avoid 'cast increases required alignment of target type' warning
		page->compact_page_marker = reinterpret_cast<uint32_t*>(static_cast<void*>(reinterpret_cast<char*>(page) + sizeof(impl::xml_memory_page)));
		*page->compact_page_marker = sizeof(impl::xml_memory_page);
	#endif

		// allocate new root
		_root = new (reinterpret_cast<char*>(page) + sizeof(impl::xml_memory_page) + page_offset) impl::xml_document_struct(page);
		_root->prev_sibling_c = _root;

		// setup sentinel page
		page->allocator = static_cast<impl::xml_document_struct*>(_root);

		// setup hash table pointer in allocator
	#ifdef PUGIXML_COMPACT
		page->allocator->_hash = &static_cast<impl::xml_document_struct*>(_root)->hash;
	#endif

		// verify the document allocation
		assert(reinterpret_cast<char*>(_root) + sizeof(impl::xml_document_struct) <= _memory + sizeof(_memory));
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, (%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x47703
jmp 0x47705
jmp 0x47724
leaq 0x2426e(%rip), %rdi     # 0x6b97a
leaq 0x23c42(%rip), %rsi     # 0x6b355
movl $0x1ae1, %edx           # imm = 0x1AE1
leaq 0x24262(%rip), %rcx     # 0x6b981
callq 0x7180
movq -0x20(%rbp), %rdi
movq $0x0, -0x10(%rbp)
addq $0x10, %rdi
callq 0x47e90
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x47746
jmp 0x47765
leaq 0x24a45(%rip), %rdi     # 0x6c192
leaq 0x23c01(%rip), %rsi     # 0x6b355
movl $0x1aef, %edx           # imm = 0x1AEF
leaq 0x24221(%rip), %rcx     # 0x6b981
callq 0x7180
movq -0x18(%rbp), %rax
movq $0x7fd8, 0x18(%rax)     # imm = 0x7FD8
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x38(%rbp)
movq -0x18(%rbp), %rsi
callq 0x47ef0
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq (%rax), %rdx
movq (%rax), %rcx
movq %rdx, 0x28(%rcx)
movq (%rax), %rcx
movq %rcx, -0x30(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movq %rax, -0x28(%rbp)
je 0x477ba
movq -0x30(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rax
movq %rdx, (%rax)
movq (%rcx), %rax
addq $0x60, %rax
addq $0x10, %rcx
addq $0xc0, %rcx
cmpq %rcx, %rax
ja 0x477e2
jmp 0x47801
leaq 0x241bb(%rip), %rdi     # 0x6b9a4
leaq 0x23b65(%rip), %rsi     # 0x6b355
movl $0x1b07, %edx           # imm = 0x1B07
leaq 0x24185(%rip), %rcx     # 0x6b981
callq 0x7180
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)