// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
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)
movups 0x50(%rax), %xmm0
movups %xmm0, 0x50(%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 0x1ca65
movq %rcx, %r10
subq %rdi, %r10
cmpq $0x0, 0x10(%r10)
jne 0x1ca65
movq (%rax), %rdi
movq %rdi, %r9
shrq $0x8, %r9
movq %r9, %r8
negq %r8
cmpq $0x0, 0x8(%rax,%r8)
jne 0x1ca84
movq %rax, %r8
subq %r9, %r8
movq 0x10(%r8), %r9
testq %r9, %r9
je 0x1c9a9
cmpq %r8, 0x8(%r9)
jne 0x1cac2
movq %r10, 0x8(%r9)
movq %r9, 0x10(%r10)
andq $0x0, 0x10(%r8)
leaq 0x40(%rax), %r11
leaq 0x40(%rcx), %rbx
leaq 0x50(%rax), %r9
addq $0x10, %r10
movq (%r10), %r10
testq %r10, %r10
je 0x1c9cb
cmpq %r11, (%r10)
jne 0x1ca27
movq %rbx, (%r10)
jmp 0x1c9b5
cmpq $0x0, 0x20(%rcx)
jne 0x1caa3
movq %rdx, 0x20(%rcx)
testq %rdx, %rdx
je 0x1c9ef
cmpq %rax, 0x18(%rdx)
jne 0x1ca46
movq %rcx, 0x18(%rdx)
movq 0x30(%rdx), %rdx
jmp 0x1c9da
andq $-0x100, %rdi
incq %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x8(%rax)
andq $0x0, 0x38(%rax)
movq %rdi, (%rax)
movq %r8, 0x40(%rax)
movq 0x18(%r8), %rcx
movq %rcx, 0x48(%rax)
movups %xmm0, (%r9)
andq $0x0, 0x8(%rsi)
popq %rbx
retq
leaq 0xfc9f(%rip), %rdi      # 0x2c6cd
leaq 0xf500(%rip), %rsi      # 0x2bf35
leaq 0xfc29(%rip), %rcx      # 0x2c665
movl $0x1b79, %edx           # imm = 0x1B79
callq 0x6100
leaq 0xfcab(%rip), %rdi      # 0x2c6f8
leaq 0xf4e1(%rip), %rsi      # 0x2bf35
leaq 0xfc0a(%rip), %rcx      # 0x2c665
movl $0x1b91, %edx           # imm = 0x1B91
callq 0x6100
leaq 0xfbca(%rip), %rdi      # 0x2c636
leaq 0xf4c2(%rip), %rsi      # 0x2bf35
leaq 0xfbeb(%rip), %rcx      # 0x2c665
movl $0x1b66, %edx           # imm = 0x1B66
callq 0x6100
leaq 0xfc09(%rip), %rdi      # 0x2c694
leaq 0xf4a3(%rip), %rsi      # 0x2bf35
leaq 0xfbcc(%rip), %rcx      # 0x2c665
movl $0x1b69, %edx           # imm = 0x1B69
callq 0x6100
leaq 0xfc3c(%rip), %rdi      # 0x2c6e6
leaq 0xf484(%rip), %rsi      # 0x2bf35
leaq 0xfbad(%rip), %rcx      # 0x2c665
movl $0x1b85, %edx           # imm = 0x1B85
callq 0x6100
leaq 0xfbeb(%rip), %rdi      # 0x2c6b4
leaq 0xf465(%rip), %rsi      # 0x2bf35
leaq 0xfb8e(%rip), %rcx      # 0x2c665
movl $0x1b6e, %edx           # imm = 0x1B6E
callq 0x6100
nop