// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_tbman.c
// Function: token_manager_s_free_token
static void token_manager_s_free_token( token_manager_s* o, u1_t token )
{
    #ifdef RTCHECKS
        if( token * o->block_size < sizeof( token_manager_s ) ) ERR( "Attempt to free reserved memory." );
        for( uz_t i = o->stack_index; i < o->stack_size; i++ ) if( o->token_stack[ i ] == token ) ERR( "Attempt to free memory that is declared free." );
    #endif // RTCHECKS

    // reference control
    if( o->rc_count_arr )
    {
        if( o->rc_count_arr[ token ] )
        {
            o->rc_count_arr[ token ]--;
            return;
        }

        if( o->rc_down_arr )
        {
            vd_t down = o->rc_down_arr[ token ];
            if( down )
            {
                bcore_mutex_s_unlock( o->mutex );
                ( ( down_s* )down )->_( down, ( u0_t* )o + token * o->block_size );
                bcore_mutex_s_lock( o->mutex );
                assert( o->down_manager );
                down_s_discard( o->down_manager, down );
                o->rc_down_arr[ token ] = NULL;
            }
        }
    }

    if( o->token_stack[ o->stack_index ] == 0 ) block_manager_s_full_to_free( o->parent, o );
    o->stack_index--;
    o->token_stack[ o->stack_index ] = token;
    if( o->stack_index == 0 ) block_manager_s_free_to_empty( o->parent, o );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x11eafb
movzwl %bp, %r15d
movq (%rax,%r15,8), %rcx
testq %rcx, %rcx
je 0x11eaae
decq %rcx
movq %rcx, (%rax,%r15,8)
jmp 0x11eca4
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x11eafb
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x11eafb
movq 0x18(%rbx), %rdi
callq 0x11f547
movq 0x8(%rbx), %rsi
imulq %r15, %rsi
addq %rbx, %rsi
movq %r14, %rdi
callq *(%r14)
movq 0x18(%rbx), %rdi
callq 0x11f515
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x11ecad
movq 0x38(%rbx), %rax
movq $0x0, (%rax,%r15,8)
movzwl 0x12(%rbx), %eax
cmpw $0x0, 0x48(%rbx,%rax,2)
jne 0x11eb39
movq 0x20(%rbx), %rcx
movq 0x18(%rcx), %rdx
movq 0x30(%rcx), %rsi
leaq -0x1(%rsi), %rdi
movq %rdi, 0x30(%rcx)
movq 0x28(%rbx), %r8
movq -0x8(%rdx,%rsi,8), %r9
movq %rbx, -0x8(%rdx,%rsi,8)
movq 0x18(%rcx), %rcx
movq %r9, (%rcx,%r8,8)
movq %rdi, 0x28(%rbx)
movq %r8, 0x28(%r9)
decl %eax
movw %ax, 0x12(%rbx)
movzwl %ax, %eax
movw %bp, 0x48(%rbx,%rax,2)
testw %ax, %ax
jne 0x11eca4
movq 0x20(%rbx), %r12
movq 0x20(%r12), %rax
testq %rax, %rax
je 0x11eb81
movq 0x18(%r12), %rcx
movq %rax, %rdx
movq -0x8(%rcx,%rdx,8), %rsi
cmpw $0x0, 0x12(%rsi)
jne 0x11eb79
decq %rdx
jne 0x11eb66
xorl %edx, %edx
movq %rax, %rcx
subq %rdx, %rcx
jmp 0x11eb83
xorl %ecx, %ecx
cmpq %rax, %rcx
jae 0x11ebbb
movq 0x28(%rbx), %rdx
movq %rcx, %rsi
notq %rsi
addq %rsi, %rax
cmpq %rax, %rdx
jae 0x11ebbb
movq 0x18(%r12), %rsi
movq (%rsi,%rax,8), %rdi
movq %rdi, (%rsi,%rdx,8)
movq 0x18(%r12), %rsi
movq %rbx, (%rsi,%rax,8)
movq %rax, 0x28(%rbx)
movq %rdx, 0x28(%rdi)
incq %rcx
movq %rcx, %xmm0
movq 0x236c8(%rip), %xmm1    # 0x142290
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x236cc(%rip), %xmm2    # 0x1422a0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq 0x20(%r12), %rax
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x38(%r12), %xmm1
ucomisd %xmm1, %xmm3
jbe 0x11eca4
testq %rax, %rax
je 0x11eca4
leaq 0x395d3(%rip), %rbx     # 0x1581fc
leaq 0x39065(%rip), %r14     # 0x157c95
leaq 0x395e3(%rip), %r15     # 0x15821a
movq 0x18(%r12), %rcx
movq -0x8(%rcx,%rax,8), %rdx
cmpw $0x0, 0x12(%rdx)
jne 0x11eca4
leaq -0x1(%rax), %rdx
movq %rdx, 0x20(%r12)
movq 0x58(%r12), %rdi
movq -0x8(%rcx,%rax,8), %rsi
callq 0x131edb
cmpl $0x1, %eax
je 0x11ec7a
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3ac, %edx            # imm = 0x3AC
movq %r15, %rcx
xorl %eax, %eax
callq 0xc80f6
movq 0x18(%r12), %rax
movq 0x20(%r12), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x11ea50
movq 0x18(%r12), %rcx
movq 0x20(%r12), %rax
movq $0x0, (%rcx,%rax,8)
testq %rax, %rax
jne 0x11ec37
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq