// File: /workspace/github_cpp_makefile_star2_O3/walker-xian[P]teisye/src/teisye.cpp
// Function: teisye::heap::realloc(void*, unsigned long)
inline void* realloc(void *ptr, size_t size) noexcept
    {
        if (!ptr) return alloc(size);

        auto unit = reinterpret_cast<memory_unit*>(reinterpret_cast<size_t>(ptr) - sizeof(memory_unit::header));
        if (!validate(unit)) return nullptr;

        auto key = _book.key(size + sizeof(memory_unit::header));
        if (key == unit->_header._key)
        {
            unit->_header._size = static_cast<uint32_t>(size);
            return ptr;
        }

        void *new_ptr = alloc(size);
        if (new_ptr)
        {
            memcpy(new_ptr, ptr, min(static_cast<size_t>(unit->_header._size), size));
            free(ptr);
        }

        return new_ptr;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %r15
testq %rsi, %rsi
je 0x14db8
movq %rsi, %rbx
cmpw $0x6871, -0x8(%rsi)     # imm = 0x6871
jne 0x14ed2
movb -0x6(%rbx), %cl
movl -0x4(%rbx), %edi
cmpq $0x9, %rdi
jae 0x14dce
xorl %esi, %esi
jmp 0x14e13
movq %r15, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1454c
leaq 0x7(%rdi), %rsi
cmpl $0x78, %edi
ja 0x14ddc
shrl $0x4, %esi
jmp 0x14e13
movq %rsi, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x14df3
orb $0x8, %al
movl %eax, %esi
jmp 0x14e13
leaq 0x27(%rdi), %rax
movabsq $0x555555555555556, %rdx # imm = 0x555555555555556
mulq %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x14e53
orb $0xc, %dl
movl %edx, %esi
cmpb %sil, %cl
jne 0x14ed2
leaq 0x8(%r14), %rdi
cmpq $0x11, %rdi
jae 0x14e2a
xorl %esi, %esi
jmp 0x14e8c
leaq 0x7(%r14), %rsi
cmpq $0x80, %rdi
ja 0x14e3c
shrl $0x4, %esi
jmp 0x14e8c
movq %rsi, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x14e68
orb $0x8, %al
movl %eax, %esi
jmp 0x14e8c
movq %rsi, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x14ee3
orb $0x10, %al
jmp 0x14def
leaq 0x27(%r14), %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq $0x5, %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x14efb
orb $0xc, %dl
movl %edx, %esi
cmpb %cl, %sil
jne 0x14e97
movl %r14d, -0x4(%rbx)
jmp 0x14ed4
movq %r15, %rdi
movq %r14, %rsi
callq 0x1454c
testq %rax, %rax
je 0x14ed2
movq %rax, %r12
movl -0x4(%rbx), %eax
cmpq %r14, %rax
cmovbq %rax, %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4280
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14b1e
movq %r12, %rbx
jmp 0x14ed4
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsi, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f13
addb $0x19, %al
jmp 0x14def
movq %rsi, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x14f2b
orb $0x10, %al
jmp 0x14e4f
movq %rsi, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f43
addb $0x21, %al
jmp 0x14def
movq %rsi, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f5a
addb $0x19, %al
jmp 0x14e4f
shrq $0x9, %rsi
addq $-0x8, %rsi
cmpq $0x7, %rsi
ja 0x14f72
addb $0x29, %sil
jmp 0x14e13
movq %rsi, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f84
addb $0x21, %al
jmp 0x14e4f
cmpl $0xffff9, %edi          # imm = 0xFFFF9
movb $0x31, %sil
sbbb $-0x1, %sil
jmp 0x14e13
shrq $0x9, %rsi
addq $-0x8, %rsi
cmpq $0x7, %rsi
ja 0x14f9b
addb $0x29, %sil
jmp 0x14e8c
cmpq $0x100001, %rdi         # imm = 0x100001
movb $0x31, %sil
sbbb $-0x1, %sil
jmp 0x14e8c