// File: /workspace/github_cpp_makefile_star2_O1/jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::xml_document::_move(pugi::xml_document&)
PUGI__FN void xml_document::_move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT
	{
		impl::xml_document_struct* doc = static_cast<impl::xml_document_struct*>(_root);
		impl::xml_document_struct* other = static_cast<impl::xml_document_struct*>(rhs._root);

		// save first child pointer for later; this needs hash access
		xml_node_struct* other_first_child = other->first_child;

	#ifdef PUGIXML_COMPACT
		// reserve space for the hash table up front; this is the only operation that can fail
		// if it does, we have no choice but to throw (if we have exceptions)
		if (other_first_child)
		{
			size_t other_children = 0;
			for (xml_node_struct* node = other_first_child; node; node = node->next_sibling)
				other_children++;

			// in compact mode, each pointer assignment could result in a hash table request
			// during move, we have to relocate document first_child and parents of all children
			// normally there's just one child and its parent has a pointerless encoding but
			// we assume the worst here
			if (!other->_hash->reserve(other_children + 1))
			{
			#ifdef PUGIXML_NO_EXCEPTIONS
				return;
			#else
				throw std::bad_alloc();
			#endif
			}
		}
	#endif

		// move allocation state
		doc->_root = other->_root;
		doc->_busy_size = other->_busy_size;

		// move buffer state
		doc->buffer = other->buffer;
		doc->extra_buffers = other->extra_buffers;
		_buffer = rhs._buffer;

	#ifdef PUGIXML_COMPACT
		// move compact hash; note that the hash table can have pointers to other but they will be "inactive", similarly to nodes removed with remove_child
		doc->hash = other->hash;
		doc->_hash = &doc->hash;

		// make sure we don't access other hash up until the end when we reinitialize other document
		other->_hash = 0;
	#endif

		// move page structure
		impl::xml_memory_page* doc_page = PUGI__GETPAGE(doc);
		assert(doc_page && !doc_page->prev && !doc_page->next);

		impl::xml_memory_page* other_page = PUGI__GETPAGE(other);
		assert(other_page && !other_page->prev);

		// relink pages since root page is embedded into xml_document
		if (impl::xml_memory_page* page = other_page->next)
		{
			assert(page->prev == other_page);

			page->prev = doc_page;

			doc_page->next = page;
			other_page->next = 0;
		}

		// make sure pages point to the correct document state
		for (impl::xml_memory_page* page = doc_page->next; page; page = page->next)
		{
			assert(page->allocator == other);

			page->allocator = doc;

		#ifdef PUGIXML_COMPACT
			// this automatically migrates most children between documents and prevents ->parent assignment from allocating
			if (page->compact_shared_parent == other)
				page->compact_shared_parent = doc;
		#endif
		}

		// move tree structure
		assert(!doc->first_child);

		doc->first_child = other_first_child;

		for (xml_node_struct* node = other_first_child; node; node = node->next_sibling)
		{
		#ifdef PUGIXML_COMPACT
			// most children will have migrated when we reassigned compact_shared_parent
			assert(node->parent == other || node->parent == doc);

			node->parent = doc;
		#else
			assert(node->parent == other);
			node->parent = doc;
		#endif
		}

		// reset other document
		new (other) impl::xml_document_struct(PUGI__GETPAGE(other));
		rhs._buffer = 0;
	}

// Assembly:
pushq %rax
movq (%rdi), %rcx
movq (%rsi), %rax
movq 0x20(%rax), %rdx
movq 0x40(%rax), %r8
movq %r8, 0x40(%rcx)
movq 0x48(%rax), %r8
movq %r8, 0x48(%rcx)
movq 0x50(%rax), %r8
movq %r8, 0x50(%rcx)
movq 0x58(%rax), %r8
movq %r8, 0x58(%rcx)
movq 0x8(%rsi), %r8
movq %r8, 0x8(%rdi)
movq (%rcx), %rdi
shrq $0x8, %rdi
movq %rdi, %r8
negq %r8
cmpq $0x0, 0x8(%rcx,%r8)
jne 0x229e7
movq %rcx, %r9
subq %rdi, %r9
cmpq $0x0, 0x10(%r9)
jne 0x229e7
movq (%rax), %rdi
movq %rdi, %r10
shrq $0x8, %r10
movq %r10, %r8
negq %r8
cmpq $0x0, 0x8(%rax,%r8)
jne 0x22a06
movq %rax, %r8
subq %r10, %r8
movq 0x10(%r8), %r10
testq %r10, %r10
je 0x22928
cmpq %r8, 0x8(%r10)
jne 0x22a44
movq %r9, 0x8(%r10)
movq %r10, 0x10(%r9)
movq $0x0, 0x10(%r8)
movq 0x10(%r9), %r9
testq %r9, %r9
je 0x2294a
leaq 0x40(%rax), %r10
leaq 0x40(%rcx), %r11
cmpq %r10, (%r9)
jne 0x229a9
movq %r11, (%r9)
movq 0x10(%r9), %r9
testq %r9, %r9
jne 0x22939
cmpq $0x0, 0x20(%rcx)
jne 0x22a25
movq %rdx, 0x20(%rcx)
testq %rdx, %rdx
je 0x2296e
cmpq %rax, 0x18(%rdx)
jne 0x229c8
movq %rcx, 0x18(%rdx)
movq 0x30(%rdx), %rdx
jmp 0x22959
leaq 0x50(%rax), %rcx
andq $-0x100, %rdi
incq %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x8(%rax)
xorl %edx, %edx
movq %rdx, 0x38(%rax)
movq %rdi, (%rax)
movq %r8, 0x40(%rax)
movq 0x18(%r8), %rdi
movq %rdi, 0x48(%rax)
movups %xmm0, (%rcx)
movq %rdx, 0x8(%rsi)
popq %rax
retq
leaq 0x10cdd(%rip), %rdi     # 0x3368d
leaq 0x1053e(%rip), %rsi     # 0x32ef5
leaq 0x10c67(%rip), %rcx     # 0x33625
movl $0x1b79, %edx           # imm = 0x1B79
callq 0x6120
leaq 0x10ce9(%rip), %rdi     # 0x336b8
leaq 0x1051f(%rip), %rsi     # 0x32ef5
leaq 0x10c48(%rip), %rcx     # 0x33625
movl $0x1b91, %edx           # imm = 0x1B91
callq 0x6120
leaq 0x10c08(%rip), %rdi     # 0x335f6
leaq 0x10500(%rip), %rsi     # 0x32ef5
leaq 0x10c29(%rip), %rcx     # 0x33625
movl $0x1b66, %edx           # imm = 0x1B66
callq 0x6120
leaq 0x10c47(%rip), %rdi     # 0x33654
leaq 0x104e1(%rip), %rsi     # 0x32ef5
leaq 0x10c0a(%rip), %rcx     # 0x33625
movl $0x1b69, %edx           # imm = 0x1B69
callq 0x6120
leaq 0x10c7a(%rip), %rdi     # 0x336a6
leaq 0x104c2(%rip), %rsi     # 0x32ef5
leaq 0x10beb(%rip), %rcx     # 0x33625
movl $0x1b85, %edx           # imm = 0x1B85
callq 0x6120
leaq 0x10c29(%rip), %rdi     # 0x33674
leaq 0x104a3(%rip), %rsi     # 0x32ef5
leaq 0x10bcc(%rip), %rcx     # 0x33625
movl $0x1b6e, %edx           # imm = 0x1B6E
callq 0x6120
nop