// File: /workspace/github_cpp_makefile_star2_O3/walker-xian[P]teisye/src/teisye.cpp
// Function: teisye::heap::free(void*)
inline void free(void* ptr) noexcept
    {
        if (!ptr) return;

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

        if (unit->_header._idle) return;
        unit->_header._idle = true;

        auto key = unit->_header._key;
        if (key <= _book.key_max_small())
        {
            _thread_cache.free(unit);
        }
        else if (key <= _book.key_max_medium())
        {
            _shared_cache.free(unit);
        }
        else if (key <= _book.key_max_large())
        {
            _large.free(unit);
        }
        else
        {
            auto hu = reinterpret_cast<huge_unit*>(reinterpret_cast<size_t>(unit) - sizeof(huge_unit::_raw_ptr));
            ::free(hu->_raw_ptr);
        }
    }

// Assembly:
pushq %rbx
testq %rsi, %rsi
je 0x14b9a
cmpw $0x6871, -0x8(%rsi)     # imm = 0x6871
jne 0x14b9a
leaq -0x8(%rsi), %rbx
movb 0x2(%rbx), %cl
movl 0x4(%rbx), %r9d
cmpq $0x9, %r9
jae 0x14b42
xorl %r8d, %r8d
jmp 0x14b8f
leaq 0x7(%r9), %r8
cmpl $0x78, %r9d
ja 0x14b52
shrl $0x4, %r8d
jmp 0x14b8f
movq %r8, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x14b6a
orb $0x8, %al
movl %eax, %r8d
jmp 0x14b8f
leaq 0x27(%r9), %rax
movabsq $0x555555555555556, %rdx # imm = 0x555555555555556
mulq %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x14ca3
orb $0xc, %dl
movl %edx, %r8d
cmpb %r8b, %cl
jne 0x14b9a
cmpb $0x0, 0x3(%rbx)
je 0x14b9c
popq %rbx
retq
movb $0x1, 0x3(%rbx)
cmpb 0xbd12(%rip), %cl       # 0x208b8
jle 0x14bca
cmpb 0xbd0b(%rip), %cl       # 0x208b9
jle 0x14cbb
cmpb 0xbd00(%rip), %cl       # 0x208ba
jle 0x14d02
movq -0x10(%rsi), %rdi
popq %rbx
jmp 0x4548
cmpb $0x0, %fs:-0x8
je 0x14d51
movq %fs:0x0, %rax
movsbq %cl, %rdx
movq %fs:-0x1a0(,%rdx,8), %rcx
movq %rcx, 0x8(%rbx)
movq %rbx, %fs:-0x1a0(,%rdx,8)
movq $-0x1, %rcx
cmpb $0x31, %dl
jg 0x14c13
leaq 0xbb19(%rip), %rcx      # 0x20728
movq (%rcx,%rdx,8), %rcx
addq %fs:-0x10, %rcx
movq %rcx, %fs:-0x10
cmpq $0x80001, %rcx          # imm = 0x80001
jb 0x14b9a
leaq -0x1a0(%rax), %rax
xorl %ecx, %ecx
leaq 0xbc7e(%rip), %rdx      # 0x208c0
movq (%rax,%rcx,8), %rsi
movq $0x0, (%rax,%rcx,8)
testq %rsi, %rsi
je 0x14c88
movq %rsi, %r8
movq %r8, %rdi
movq 0x8(%r8), %r8
testq %r8, %r8
jne 0x14c56
movq %rcx, %r8
shlq $0x4, %r8
addq %rdx, %r8
movb $0x1, %r9b
xchgb %r9b, 0x8(%r8)
testb %r9b, %r9b
jne 0x14c6c
movq (%r8), %r9
movq %r9, 0x8(%rdi)
movq %rsi, (%r8)
xorl %esi, %esi
xchgb %sil, 0x8(%r8)
incq %rcx
cmpq $0x32, %rcx
jne 0x14c42
movq $0x0, %fs:-0x10
jmp 0x14b9a
movq %r8, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x14cea
orb $0x10, %al
jmp 0x14b65
movsbq %cl, %rcx
shlq $0x4, %rcx
leaq 0xbbf6(%rip), %rax      # 0x208c0
addq %rcx, %rax
movb $0x1, %cl
xchgb %cl, 0x8(%rax)
testb %cl, %cl
jne 0x14ccd
movq (%rax), %rcx
movq %rcx, 0x8(%rbx)
movq %rbx, (%rax)
xorl %ecx, %ecx
xchgb %cl, 0x8(%rax)
jmp 0x14b9a
movq %r8, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14d0f
addb $0x19, %al
jmp 0x14b65
addq $0x8, %rdi
movq %rbx, %rsi
popq %rbx
jmp 0x152ec
movq %r8, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14d27
addb $0x21, %al
jmp 0x14b65
shrq $0x9, %r8
addq $-0x8, %r8
cmpq $0x7, %r8
ja 0x14d3e
addb $0x29, %r8b
jmp 0x14b8f
cmpl $0xffff9, %r9d          # imm = 0xFFFF9
movb $0x31, %r8b
sbbb $-0x1, %r8b
jmp 0x14b8f
movb $0x1, %fs:-0x8
movq %fs:0x0, %rax
leaq -0x1a0(%rax), %rsi
leaq -0x889(%rip), %rdi      # 0x144e8
leaq 0xb530(%rip), %rdx      # 0x202a8
callq 0x44b0
movb 0x2(%rbx), %cl
jmp 0x14bd9
nop