// File: /workspace/github_cpp_makefile_star2_O1/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 0x14ffa
movq %rsi, %rbx
cmpw $0x6871, -0x8(%rsi)     # imm = 0x6871
jne 0x15068
movb -0x6(%rbx), %cl
movl -0x4(%rbx), %edi
cmpq $0x9, %rdi
jae 0x15010
xorl %esi, %esi
jmp 0x15055
movq %r15, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1460c
leaq 0x7(%rdi), %rsi
cmpl $0x78, %edi
ja 0x1501e
shrl $0x4, %esi
jmp 0x15055
movq %rsi, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x15035
orb $0x8, %al
movl %eax, %esi
jmp 0x15055
leaq 0x27(%rdi), %rax
movabsq $0x555555555555556, %rdx # imm = 0x555555555555556
mulq %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x150a2
orb $0xc, %dl
movl %edx, %esi
cmpb %sil, %cl
jne 0x15068
leaq 0x8(%r14), %rsi
cmpq $0x11, %rsi
jae 0x15079
xorl %ecx, %ecx
jmp 0x150de
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x7(%r14), %rcx
cmpq $0x80, %rsi
ja 0x1508b
shrl $0x4, %ecx
jmp 0x150de
movq %rcx, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x150ba
orb $0x8, %al
movl %eax, %ecx
jmp 0x150de
movq %rsi, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x15127
orb $0x10, %al
jmp 0x15031
leaq 0x27(%r14), %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq $0x5, %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x1513f
orb $0xc, %dl
movl %edx, %ecx
cmpb -0x6(%rbx), %cl
jne 0x150e9
movl %r14d, -0x4(%rbx)
jmp 0x1506a
movq %r15, %rdi
movq %r14, %rsi
callq 0x1460c
movq %rax, %r12
testq %rax, %rax
je 0x1511f
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 0x14d8c
movq %r12, %rbx
jmp 0x1506a
movq %rsi, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x15157
addb $0x19, %al
jmp 0x15031
movq %rcx, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x1516f
orb $0x10, %al
jmp 0x1509e
movq %rsi, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x15187
addb $0x21, %al
jmp 0x15031
movq %rcx, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x1519e
addb $0x19, %al
jmp 0x1509e
shrq $0x9, %rsi
addq $-0x8, %rsi
cmpq $0x7, %rsi
ja 0x151b6
addb $0x29, %sil
jmp 0x15055
movq %rcx, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x151c8
addb $0x21, %al
jmp 0x1509e
cmpl $0xffff9, %edi          # imm = 0xFFFF9
movb $0x31, %sil
sbbb $-0x1, %sil
jmp 0x15055
shrq $0x9, %rcx
addq $-0x8, %rcx
cmpq $0x7, %rcx
ja 0x151de
addb $0x29, %cl
jmp 0x150de
cmpq $0x100001, %rsi         # imm = 0x100001
movb $0x31, %cl
sbbb $-0x1, %cl
jmp 0x150de