// File: adamiaonr[P]rid-analytics/src/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);

			// adjust root size so that we have not allocated the object at all
			bool only_object = (_root_size == old_size);

			if (ptr) _root_size -= old_size;

			// allocate a new version (this will obviously reuse the memory if possible)
			void* result = allocate(new_size);
			assert(result);

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

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

					xpath_memory_block* next = _root->next->next;

					if (next)
					{
						// deallocate the whole page, unless it was the first one
						xml_memory::deallocate(_root->next);
						_root->next = next;
					}
				}
			}

			return result;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
subq $0x1, %rax
andq $-0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
addq $0x8, %rax
subq $0x1, %rax
andq $-0x8, %rax
movq %rax, -0x20(%rbp)
movb $0x1, %al
cmpq $0x0, -0x10(%rbp)
movb %al, -0x39(%rbp)
je 0x26204
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq (%rdx), %rcx
addq $0x10, %rcx
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x2620d
jmp 0x2620f
jmp 0x2622e
leaq 0x3b555(%rip), %rdi     # 0x6176b
leaq 0x38958(%rip), %rsi     # 0x5eb75
movl $0x1d2d, %edx           # imm = 0x1D2D
leaq 0x3b591(%rip), %rcx     # 0x617ba
callq 0x5310
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x18(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x21(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2625c
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rdx
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x263a0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x26276
jmp 0x26295
leaq 0x3b5be(%rip), %rdi     # 0x6183b
leaq 0x388f1(%rip), %rsi     # 0x5eb75
movl $0x1d36, %edx           # imm = 0x1D36
leaq 0x3b52a(%rip), %rcx     # 0x617ba
callq 0x5310
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x26391
cmpq $0x0, -0x10(%rbp)
je 0x26391
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x262ba
jmp 0x262d9
leaq 0x3b556(%rip), %rdi     # 0x61817
leaq 0x388ad(%rip), %rsi     # 0x5eb75
movl $0x1d3c, %edx           # imm = 0x1D3C
leaq 0x3b4e6(%rip), %rcx     # 0x617ba
callq 0x5310
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x5400
testb $0x1, -0x21(%rbp)
je 0x2638f
movq -0x48(%rbp), %rax
movq (%rax), %rax
addq $0x10, %rax
cmpq -0x30(%rbp), %rax
jne 0x26307
jmp 0x26326
leaq 0x3b51e(%rip), %rdi     # 0x6182c
leaq 0x38860(%rip), %rsi     # 0x5eb75
movl $0x1d42, %edx           # imm = 0x1D42
leaq 0x3b499(%rip), %rcx     # 0x617ba
callq 0x5310
movq -0x48(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, (%rax)
je 0x26335
jmp 0x26354
leaq 0x3b506(%rip), %rdi     # 0x61842
leaq 0x38832(%rip), %rsi     # 0x5eb75
movl $0x1d43, %edx           # imm = 0x1D43
leaq 0x3b46b(%rip), %rcx     # 0x617ba
callq 0x5310
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x2638d
movq -0x48(%rbp), %rcx
movq 0x5c1d9(%rip), %rax     # 0x82550
movq (%rcx), %rcx
movq (%rcx), %rdi
callq *%rax
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax), %rax
movq %rcx, (%rax)
jmp 0x2638f
jmp 0x26391
movq -0x30(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)