// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_tbman.c
// Function: token_manager_s_release_arg
static void token_manager_s_release_arg( token_manager_s* o, fp_down_arg down, vc_t arg, 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( arg, 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_arg_s_create( o->down_manager, down, arg );
        }
        return;
    }

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

    token_manager_s_free_token( o, token );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x8(%rcx)
movw %ax, -0x22(%rbp)
movq -0x8(%rbp), %rax
movzwl -0x22(%rbp), %ecx
movq -0x8(%rbp), %rdx
imulq 0x8(%rdx), %rcx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x23(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x10de7d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc70
testb $0x1, -0x23(%rbp)
jne 0x10de50
leaq 0x49c62(%rip), %rdi     # 0x157a98
leaq 0x49560(%rip), %rsi     # 0x15739d
movl $0x203, %edx            # imm = 0x203
leaq 0x49b3b(%rip), %rcx     # 0x157984
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc20
movq -0x8(%rbp), %rdi
movzwl -0x22(%rbp), %esi
callq 0x10ce30
jmp 0x10df54
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzwl -0x22(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x10df01
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movzwl -0x22(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
addq $-0x1, %rdx
movq %rdx, (%rax,%rcx,8)
testb $0x1, -0x23(%rbp)
je 0x10deff
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x10dec2
movq -0x8(%rbp), %rdi
callq 0x10d740
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x22(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x10defd
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x10e0a0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x22(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x10deff
jmp 0x10df54
movq -0x8(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x10df1f
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movzwl -0x22(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x10df47
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc70
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10fc20
movq -0x8(%rbp), %rdi
movzwl -0x22(%rbp), %esi
callq 0x10ce30
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)