// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_tbman.c
// Function: token_manager_s_release_obj
static void token_manager_s_release_obj( token_manager_s* o, fp_down_obj down, vd_t ptr )
{
    u1_t token = ( ( ptrdiff_t )( ( u0_t* )ptr - ( u0_t* )o ) ) / o->block_size;
    bl_t ptr_is_root = ( ( u0_t* )o + ( ( uz_t )token * o->block_size ) == ptr );

    if( !o->rc_count_arr )
    {
        bcore_mutex_s_unlock( o->mutex );
        if( !ptr_is_root ) ERR( "Object is not root." );
        down( ptr );
        bcore_mutex_s_lock( o->mutex );
        token_manager_s_free_token( o, token );
        return;
    }

    if( o->rc_count_arr[ token ] )
    {
        o->rc_count_arr[ token ]--;

        /* We only safe down instruction when the object is root.
         * Otherwise 'token' refers to a parent to which function down does not apply.
         * In that case shut down information is controlled by the parent object.
         */
        if( ptr_is_root )
        {
            if( !o->rc_down_arr ) token_manager_s_create_rc_down_arr( o );
            if( !o->rc_down_arr[ token ] ) o->rc_down_arr[ token ] = down_obj_s_create( o->down_manager, down );
        }
        return;
    }

    if( !o->rc_down_arr || !o->rc_down_arr[ token ] )
    {
        bcore_mutex_s_unlock( o->mutex );
        down( ptr );
        bcore_mutex_s_lock( o->mutex );
    }
    token_manager_s_free_token( o, token );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x8(%rcx)
movw %ax, -0x1a(%rbp)
movq -0x8(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
movq -0x8(%rbp), %rdx
imulq 0x8(%rdx), %rcx
addq %rcx, %rax
cmpq -0x18(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x1b(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x10d535
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc70
testb $0x1, -0x1b(%rbp)
jne 0x10d50c
leaq 0x4a476(%rip), %rdi     # 0x157968
leaq 0x49ea4(%rip), %rsi     # 0x15739d
movl $0x1d9, %edx            # imm = 0x1D9
leaq 0x4a47f(%rip), %rcx     # 0x157984
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc20
movq -0x8(%rbp), %rdi
movzwl -0x1a(%rbp), %esi
callq 0x10ce30
jmp 0x10d604
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzwl -0x1a(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x10d5b5
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzwl -0x1a(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
addq $-0x1, %rdx
movq %rdx, (%rax,%rcx,8)
testb $0x1, -0x1b(%rbp)
je 0x10d5b3
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x10d57a
movq -0x8(%rbp), %rdi
callq 0x10d740
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x1a(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x10d5b1
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x10d790
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x1a(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x10d5b3
jmp 0x10d604
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x10d5d3
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x1a(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x10d5f7
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc70
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc20
movq -0x8(%rbp), %rdi
movzwl -0x1a(%rbp), %esi
callq 0x10ce30
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)