// File: /workspace/github_cpp_makefile_star2_O3/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)
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 0x2272d
movq %rcx, %r9
subq %rdi, %r9
cmpq $0x0, 0x10(%r9)
jne 0x2272d
movq (%rax), %rdi
movq %rdi, %r10
shrq $0x8, %r10
movq %r10, %r8
negq %r8
cmpq $0x0, 0x8(%rax,%r8)
jne 0x2274c
movq %rax, %r8
subq %r10, %r8
movq 0x10(%r8), %r10
testq %r10, %r10
je 0x22690
cmpq %r8, 0x8(%r10)
jne 0x2278a
movq %r9, 0x8(%r10)
movq %r10, 0x10(%r9)
movq $0x0, 0x10(%r8)
movq 0x10(%r9), %r9
testq %r9, %r9
je 0x22690
leaq 0x40(%rax), %r10
leaq 0x40(%rcx), %r11
cmpq %r10, (%r9)
jne 0x2270e
movq %r11, (%r9)
movq 0x10(%r9), %r9
testq %r9, %r9
jne 0x2267b
cmpq $0x0, 0x20(%rcx)
jne 0x2276b
movq %rdx, 0x20(%rcx)
testq %rdx, %rdx
je 0x226b4
cmpq %rax, 0x18(%rdx)
jne 0x226ef
movq %rcx, 0x18(%rdx)
movq 0x30(%rdx), %rdx
jmp 0x2269f
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 0xfff2(%rip), %rdi      # 0x326e8
leaq 0xf828(%rip), %rsi      # 0x31f25
leaq 0xff51(%rip), %rcx      # 0x32655
movl $0x1b91, %edx           # imm = 0x1B91
callq 0x6120
leaq 0xffa8(%rip), %rdi      # 0x326bd
leaq 0xf809(%rip), %rsi      # 0x31f25
leaq 0xff32(%rip), %rcx      # 0x32655
movl $0x1b79, %edx           # imm = 0x1B79
callq 0x6120
leaq 0xfef2(%rip), %rdi      # 0x32626
leaq 0xf7ea(%rip), %rsi      # 0x31f25
leaq 0xff13(%rip), %rcx      # 0x32655
movl $0x1b66, %edx           # imm = 0x1B66
callq 0x6120
leaq 0xff31(%rip), %rdi      # 0x32684
leaq 0xf7cb(%rip), %rsi      # 0x31f25
leaq 0xfef4(%rip), %rcx      # 0x32655
movl $0x1b69, %edx           # imm = 0x1B69
callq 0x6120
leaq 0xff64(%rip), %rdi      # 0x326d6
leaq 0xf7ac(%rip), %rsi      # 0x31f25
leaq 0xfed5(%rip), %rcx      # 0x32655
movl $0x1b85, %edx           # imm = 0x1B85
callq 0x6120
leaq 0xff13(%rip), %rdi      # 0x326a4
leaq 0xf78d(%rip), %rsi      # 0x31f25
leaq 0xfeb6(%rip), %rcx      # 0x32655
movl $0x1b6e, %edx           # imm = 0x1B6E
callq 0x6120
nop