// File: walker-xian[P]teisye/src/teisye.cpp
// Function: teisye::size_book::key(unsigned long) const
inline key_t key(size_t size) const noexcept
    {
        if (size <= 16) return 0;;

        key_t base = 0;
        size_t k;

        k = (size - 1) / 16;
        if (k < 8)
        {
            return static_cast<key_t>(k);
        }

        base += 8;
        k = (size - 1) / 32 - 4;
        if (k < 4)
        {
            return base + static_cast<key_t>(k);
        }

        base += 4;
        k = (size + 31) / 48 - 6;
        if (k < 4)
        {
            return base + static_cast<key_t>(k);
        }

        base += 4;
        k = (size - 1) / 64 - 7;
        if (k < 9)
        {
            return base + static_cast<key_t>(k);
        }

        base += 9;
        k = (size - 1) / 128 - 8;
        if (k < 8)
        {
            return base + static_cast<key_t>(k);
        }

        base += 8;
        k = (size - 1) / 256 - 8;
        if (k < 8)
        {
            return base + static_cast<key_t>(k);
        }

        base += 8;
        k = (size - 1) / 512 - 8;
        if (k < 8)
        {
            return base + static_cast<key_t>(k);
        }

        //base += 8;
        //k = (size - 1) / 1024 - 8;
        //if (k < 8)
        //{
        //    return base + static_cast<key_t>(k);
        //}

        base += 8;
        if (size > max_large_size)
        {
            ++base;
        }

        return base;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x10, -0x18(%rbp)
ja 0x3735c
movb $0x0, -0x1(%rbp)
jmp 0x37501
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x4, %rax
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
jae 0x37383
movq -0x28(%rbp), %rax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x8, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x5, %rax
subq $0x4, %rax
movq %rax, -0x28(%rbp)
cmpq $0x4, -0x28(%rbp)
jae 0x373bd
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x4, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
addq $0x1f, %rax
movl $0x30, %ecx
xorl %edx, %edx
divq %rcx
subq $0x6, %rax
movq %rax, -0x28(%rbp)
cmpq $0x4, -0x28(%rbp)
jae 0x373fd
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x4, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x6, %rax
subq $0x7, %rax
movq %rax, -0x28(%rbp)
cmpq $0x9, -0x28(%rbp)
jae 0x37437
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x9, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x7, %rax
subq $0x8, %rax
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
jae 0x37471
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x8, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x8, %rax
subq $0x8, %rax
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
jae 0x374a8
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x8, %eax
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
shrq $0x9, %rax
subq $0x8, %rax
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
jae 0x374df
movsbl -0x19(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl %cl, %ecx
addl %ecx, %eax
movb %al, -0x1(%rbp)
jmp 0x37501
movsbl -0x19(%rbp), %eax
addl $0x8, %eax
movb %al, -0x19(%rbp)
cmpq $0x100000, -0x18(%rbp)  # imm = 0x100000
jbe 0x374fb
movb -0x19(%rbp), %al
addb $0x1, %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
popq %rbp
retq
nopw %cs:(%rax,%rax)