// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_tbman.c
// Function: external_manager_s_release_arg_arr
static void external_manager_s_release_arg_arr( external_manager_s* o, fp_down_arg down, vc_t arg, vd_t ptr, uz_t size, uz_t step )
{
    vd_t* ext_p = bcore_btree_pp_s_val( o->ex_btree, ptr );
    if( !ext_p ) ERR( "Object is not root." );
    ext_s* ext = *ext_p;

    bl_t free_token  = true;
    bl_t direct_down = true;

    if( ext->rc_count )
    {
        ext->rc_count--;
        assert( o->down_manager );
        free_token = false;
        direct_down = false;
    }
    else if( ext->rc_down )
    {
        direct_down = false;
    }

    if( direct_down )
    {
        bcore_mutex_s_unlock( o->mutex );
        for( uz_t i = 0; i < size; i++ ) down( arg, ( u0_t* )ptr + i * step );
        bcore_mutex_s_lock( o->mutex );
    }
    else
    {
        down_s** p_down = ( down_s** )&ext->rc_down;

        if
        (
            !( *p_down ) ||
            (
                ( ( *p_down )->_ != ( fp_down )_down_obj_arr ) &&
                ( ( *p_down )->_ != ( fp_down )_down_arg_arr )
            )
        )
        {
            if( *p_down )
            {
                down_s_discard( o->down_manager, *p_down ); // *p_down came from a forked reference
            }
            *p_down = ( down_s* )down_arg_arr_s_create( o->down_manager, down, arg, size, step );
        }
    }

    if( free_token )
    {
        external_manager_s_free_ext( o, ptr, ext );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1265c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x10e7fd
leaq 0x49313(%rip), %rdi     # 0x157af6
leaq 0x48bb3(%rip), %rsi     # 0x15739d
movl $0x5a8, %edx            # imm = 0x5A8
leaq 0x4918e(%rip), %rcx     # 0x157984
movb $0x0, %al
callq 0x9cf40
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movb $0x1, -0x41(%rbp)
movb $0x1, -0x42(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10e835
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movb $0x0, -0x41(%rbp)
movb $0x0, -0x42(%rbp)
jmp 0x10e846
movq -0x40(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x10e844
movb $0x0, -0x42(%rbp)
jmp 0x10e846
testb $0x1, -0x42(%rbp)
je 0x10e8ab
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x10fc70
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x10e896
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x50(%rbp), %rcx
imulq -0x30(%rbp), %rcx
addq %rcx, %rsi
callq *%rax
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x10e864
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x10fc20
jmp 0x10e934
movq -0x40(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
je 0x10e8e7
movq -0x58(%rbp), %rax
movq (%rax), %rax
leaq -0x42f(%rip), %rcx      # 0x10e4a0
cmpq %rcx, (%rax)
je 0x10e932
movq -0x58(%rbp), %rax
movq (%rax), %rax
leaq -0x3e2(%rip), %rcx      # 0x10e500
cmpq %rcx, (%rax)
je 0x10e932
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
je 0x10e908
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
callq 0x10cf80
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x10e960
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x10e934
testb $0x1, -0x41(%rbp)
je 0x10e94b
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x10d320
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)