// File: /workspace/github_cpp_makefile_star2_O2/jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::xpath_allocator::reallocate(void*, unsigned long, unsigned long)
void* reallocate(void* ptr, size_t old_size, size_t new_size)
		{
			// round size up to block alignment boundary
			old_size = (old_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1);
			new_size = (new_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1);

			// we can only reallocate the last object
			assert(ptr == 0 || static_cast<char*>(ptr) + old_size == &_root->data[0] + _root_size);

			// try to reallocate the object inplace
			if (ptr && _root_size - old_size + new_size <= _root->capacity)
			{
				_root_size = _root_size - old_size + new_size;
				return ptr;
			}

			// allocate a new block
			void* result = allocate(new_size);
			if (!result) return 0;

			// we have a new block
			if (ptr)
			{
				// copy old data (we only support growing)
				assert(new_size >= old_size);
				memcpy(result, ptr, old_size);

				// free the previous page if it had no other objects
				assert(_root->data == result);
				assert(_root->next);

				if (_root->next->data == ptr)
				{
					// deallocate the whole page, unless it was the first one
					xpath_memory_block* next = _root->next->next;

					if (next)
					{
						xml_memory::deallocate(_root->next);
						_root->next = next;
					}
				}
			}

			return result;
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
addq $0x7, %r15
andq $-0x8, %r15
addq $0x7, %r12
andq $-0x8, %r12
testq %rsi, %rsi
je 0x27ea4
leaq (%rbx,%r15), %rdx
movq (%r14), %rcx
movq 0x8(%r14), %rax
leaq (%rcx,%rax), %rsi
addq $0x10, %rsi
cmpq %rsi, %rdx
jne 0x27f2f
subq %r15, %rax
addq %r12, %rax
cmpq 0x8(%rcx), %rax
jbe 0x27f19
testq %rbx, %rbx
sete %bpl
movq %r14, %rdi
movq %r12, %rsi
callq 0x26c58
movq %rax, %r13
testq %rax, %rax
sete %al
orb %bpl, %al
jne 0x27f14
cmpq %r15, %r12
jb 0x27f4e
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x6080
movq (%r14), %rax
leaq 0x10(%rax), %rcx
cmpq %r13, %rcx
jne 0x27f6d
movq (%rax), %rdi
testq %rdi, %rdi
je 0x27f8c
leaq 0x10(%rdi), %rax
cmpq %rbx, %rax
jne 0x27f14
movq (%rdi), %rbx
testq %rbx, %rbx
je 0x27f14
callq *0x1b952(%rip)          # 0x43860
movq (%r14), %rax
movq %rbx, (%rax)
movq %r13, %rbx
jmp 0x27f1d
movq %rax, 0x8(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6629(%rip), %rdi      # 0x2e55f
leaq 0x3ff8(%rip), %rsi      # 0x2bf35
leaq 0x666a(%rip), %rcx      # 0x2e5ae
movl $0x1d7a, %edx           # imm = 0x1D7A
callq 0x6100
leaq 0x66b6(%rip), %rdi      # 0x2e60b
leaq 0x3fd9(%rip), %rsi      # 0x2bf35
leaq 0x664b(%rip), %rcx      # 0x2e5ae
movl $0x1d8b, %edx           # imm = 0x1D8B
callq 0x6100
leaq 0x66ac(%rip), %rdi      # 0x2e620
leaq 0x3fba(%rip), %rsi      # 0x2bf35
leaq 0x662c(%rip), %rcx      # 0x2e5ae
movl $0x1d8f, %edx           # imm = 0x1D8F
callq 0x6100
leaq 0x66a3(%rip), %rdi      # 0x2e636
leaq 0x3f9b(%rip), %rsi      # 0x2bf35
leaq 0x660d(%rip), %rcx      # 0x2e5ae
movl $0x1d90, %edx           # imm = 0x1D90
callq 0x6100