// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x96ff7
movzwl %bx, %r12d
movq (%rax,%r12,8), %rcx
testq %rcx, %rcx
je 0x96fad
decq %rcx
movq %rcx, (%rax,%r12,8)
jmp 0x97161
movq 0x38(%r14), %rax
testq %rax, %rax
je 0x96ff7
movq (%rax,%r12,8), %r15
testq %r15, %r15
je 0x96ff7
movq 0x18(%r14), %rdi
callq 0x97b12
movq 0x8(%r14), %rsi
imulq %r12, %rsi
addq %r14, %rsi
movq %r15, %rdi
callq *(%r15)
movq 0x18(%r14), %rdi
callq 0x97ae2
movq 0x40(%r14), %rdi
movq %r15, %rsi
callq 0x9716d
movq 0x38(%r14), %rax
andq $0x0, (%rax,%r12,8)
movzwl 0x12(%r14), %eax
cmpw $0x0, 0x48(%r14,%rax,2)
jne 0x97037
movq 0x20(%r14), %rcx
movq 0x18(%rcx), %rdx
movq 0x30(%rcx), %rsi
leaq -0x1(%rsi), %rdi
movq %rdi, 0x30(%rcx)
movq 0x28(%r14), %r8
movq -0x8(%rdx,%rsi,8), %r9
movq %r14, -0x8(%rdx,%rsi,8)
movq 0x18(%rcx), %rcx
movq %r9, (%rcx,%r8,8)
movq %rdi, 0x28(%r14)
movq %r8, 0x28(%r9)
decl %eax
movw %ax, 0x12(%r14)
movzwl %ax, %eax
movw %bx, 0x48(%r14,%rax,2)
testw %ax, %ax
jne 0x97161
movq 0x20(%r14), %rbx
movq 0x28(%r14), %r15
movq %rbx, %rdi
callq 0x971a6
movq 0x20(%rbx), %rcx
cmpq %rcx, %rax
jae 0x9709a
movq %rax, %rdx
notq %rdx
addq %rcx, %rdx
cmpq %rdx, %r15
jae 0x9709a
movq 0x18(%rbx), %rcx
movq (%rcx,%rdx,8), %rsi
movq %rsi, (%rcx,%r15,8)
movq 0x18(%rbx), %rcx
movq %r14, (%rcx,%rdx,8)
movq %rdx, 0x28(%r14)
movq %r15, 0x28(%rsi)
incq %rax
movq 0x20(%rbx), %rcx
movq %rax, %xmm0
movq 0x1d609(%rip), %xmm1    # 0xb46b0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1d60d(%rip), %xmm2    # 0xb46c0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rcx, %rdx
subq %rax, %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(%rbx), %xmm1
ucomisd %xmm1, %xmm3
jbe 0x97161
leaq 0x34190(%rip), %r14     # 0xcb284
leaq 0x33c22(%rip), %r15     # 0xcad1d
leaq 0x341a0(%rip), %r12     # 0xcb2a2
testq %rcx, %rcx
je 0x97161
movq 0x18(%rbx), %rax
movq -0x8(%rax,%rcx,8), %rsi
cmpw $0x0, 0x12(%rsi)
jne 0x97161
decq %rcx
movq %rcx, 0x20(%rbx)
movq 0x58(%rbx), %rdi
callq 0xa48fd
cmpl $0x1, %eax
je 0x97141
movq %r14, %rdi
movq %r15, %rsi
movl $0x3ac, %edx            # imm = 0x3AC
movq %r12, %rcx
xorl %eax, %eax
callq 0x60031
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x96f48
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
andq $0x0, (%rax,%rcx,8)
jmp 0x97102
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq