// File: NovaGL[P]HarmonyHubControl/./rapidjson/allocators.h
// Function: rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>::Realloc(void*, unsigned long, unsigned long)
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {
        if (originalPtr == 0)
            return Malloc(newSize);

        RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0);
        if (newSize == 0)
            return NULL;

        originalSize = RAPIDJSON_ALIGN(originalSize);
        newSize = RAPIDJSON_ALIGN(newSize);

        // Do not shrink if new size is smaller than original
        if (originalSize >= newSize)
            return originalPtr;

        // Simply expand it if it is the last allocation and there is sufficient space
        if (originalPtr == GetChunkBuffer(shared_) + shared_->chunkHead->size - originalSize) {
            size_t increment = static_cast<size_t>(newSize - originalSize);
            if (shared_->chunkHead->size + increment <= shared_->chunkHead->capacity) {
                shared_->chunkHead->size += increment;
                return originalPtr;
            }
        }

        // Realloc process: allocate and copy memory, do not free original buffer.
        if (void* newBuffer = Malloc(newSize)) {
            if (originalSize)
                std::memcpy(newBuffer, originalPtr, originalSize);
            return newBuffer;
        }
        else
            return NULL;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1062d
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xfed0
movq %rax, -0x8(%rbp)
jmp 0x10771
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x10(%rax)
jbe 0x1063e
jmp 0x1065d
leaq 0x6de9(%rip), %rdi      # 0x1742e
leaq 0x6d43(%rip), %rsi      # 0x1738f
movl $0x154, %edx            # imm = 0x154
leaq 0x840f(%rip), %rcx      # 0x18a67
callq 0x3260
cmpq $0x0, -0x28(%rbp)
jne 0x10671
movq $0x0, -0x8(%rbp)
jmp 0x10771
movq -0x20(%rbp), %rax
addq $0x7, %rax
andq $-0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $0x7, %rax
andq $-0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jb 0x106a8
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x10771
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq 0x10(%rax), %rdi
callq 0x100f0
movq -0x40(%rbp), %rdx
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq 0x10(%rdx), %rdx
movq (%rdx), %rdx
addq 0x8(%rdx), %rcx
xorl %edx, %edx
subq -0x20(%rbp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x1072f
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0x10(%rcx), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
addq -0x30(%rbp), %rax
movq 0x10(%rcx), %rcx
movq (%rcx), %rcx
cmpq (%rcx), %rax
ja 0x1072d
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rax), %rax
movq (%rax), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x10771
jmp 0x1072f
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xfed0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x10769
cmpq $0x0, -0x20(%rbp)
je 0x1075f
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x32f0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x10771
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)