// File: /workspace/github_cpp_makefile_star2_O1/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 0x14e08
cmpw $0x6871, -0x8(%rsi)     # imm = 0x6871
jne 0x14e08
leaq -0x8(%rsi), %rbx
movb 0x2(%rbx), %cl
movl 0x4(%rbx), %r9d
cmpq $0x9, %r9
jae 0x14db0
xorl %r8d, %r8d
jmp 0x14dfd
leaq 0x7(%r9), %r8
cmpl $0x78, %r9d
ja 0x14dc0
shrl $0x4, %r8d
jmp 0x14dfd
movq %r8, %rax
shrq $0x5, %rax
addq $-0x4, %rax
cmpq $0x3, %rax
ja 0x14dd8
orb $0x8, %al
movl %eax, %r8d
jmp 0x14dfd
leaq 0x27(%r9), %rax
movabsq $0x555555555555556, %rdx # imm = 0x555555555555556
mulq %rdx
addq $-0x6, %rdx
cmpq $0x3, %rdx
ja 0x14f18
orb $0xc, %dl
movl %edx, %r8d
cmpb %r8b, %cl
jne 0x14e08
cmpb $0x0, 0x3(%rbx)
je 0x14e0a
popq %rbx
retq
movb $0x1, 0x3(%rbx)
movsbq 0x2(%rbx), %rax
cmpb 0xba9f(%rip), %al       # 0x208b8
jle 0x14e3d
cmpb 0xba98(%rip), %al       # 0x208b9
jle 0x14f30
cmpb 0xba8d(%rip), %al       # 0x208ba
jle 0x14f73
movq -0x10(%rsi), %rdi
popq %rbx
jmp 0x4548
cmpb $0x0, %fs:-0x8
je 0x14fc2
movq %fs:0x0, %rax
movsbq 0x2(%rbx), %rcx
movq %fs:-0x1a0(,%rcx,8), %rdx
movq %rdx, 0x8(%rbx)
movq %rbx, %fs:-0x1a0(,%rcx,8)
movq $-0x1, %rdx
cmpq $0x31, %rcx
jg 0x14e88
leaq 0xb8a4(%rip), %rdx      # 0x20728
movq (%rdx,%rcx,8), %rdx
addq %fs:-0x10, %rdx
movq %rdx, %fs:-0x10
cmpq $0x80001, %rdx          # imm = 0x80001
jb 0x14e08
leaq -0x1a0(%rax), %rax
xorl %ecx, %ecx
leaq 0xba09(%rip), %rdx      # 0x208c0
movq (%rax,%rcx,8), %rsi
movq $0x0, (%rax,%rcx,8)
testq %rsi, %rsi
je 0x14efd
movq %rsi, %r8
movq %r8, %rdi
movq 0x8(%r8), %r8
testq %r8, %r8
jne 0x14ecb
movq %rcx, %r8
shlq $0x4, %r8
addq %rdx, %r8
movb $0x1, %r9b
xchgb %r9b, 0x8(%r8)
testb %r9b, %r9b
jne 0x14ee1
movq (%r8), %r9
movq %r9, 0x8(%rdi)
movq %rsi, (%r8)
xorl %esi, %esi
xchgb %sil, 0x8(%r8)
incq %rcx
cmpq $0x32, %rcx
jne 0x14eb7
movq $0x0, %fs:-0x10
jmp 0x14e08
movq %r8, %rax
shrq $0x6, %rax
addq $-0x7, %rax
cmpq $0x8, %rax
ja 0x14f5b
orb $0x10, %al
jmp 0x14dd3
shlq $0x4, %rax
leaq 0xb985(%rip), %rcx      # 0x208c0
addq %rax, %rcx
movb $0x1, %al
xchgb %al, 0x8(%rcx)
testb %al, %al
jne 0x14f3e
movq (%rcx), %rax
movq %rax, 0x8(%rbx)
movq %rbx, (%rcx)
xorl %eax, %eax
xchgb %al, 0x8(%rcx)
jmp 0x14e08
movq %r8, %rax
shrq $0x7, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f80
addb $0x19, %al
jmp 0x14dd3
addq $0x8, %rdi
movq %rbx, %rsi
popq %rbx
jmp 0x1531c
movq %r8, %rax
shrq $0x8, %rax
addq $-0x8, %rax
cmpq $0x7, %rax
ja 0x14f98
addb $0x21, %al
jmp 0x14dd3
shrq $0x9, %r8
addq $-0x8, %r8
cmpq $0x7, %r8
ja 0x14faf
addb $0x29, %r8b
jmp 0x14dfd
cmpl $0xffff9, %r9d          # imm = 0xFFFF9
movb $0x31, %r8b
sbbb $-0x1, %r8b
jmp 0x14dfd
callq 0x470d
jmp 0x14e4c