// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_tbman.c
// Function: external_manager_s_release_obj_arr
static void external_manager_s_release_obj_arr( external_manager_s* o, fp_down_obj down, 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( ( 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_obj_arr_s_create( o->down_manager, down, size, step );
        }
    }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x1265c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x10e349
leaq 0x497a4(%rip), %rdi     # 0x157ad3
leaq 0x49067(%rip), %rsi     # 0x15739d
movl $0x570, %edx            # imm = 0x570
leaq 0x49642(%rip), %rcx     # 0x157984
movb $0x0, %al
callq 0x9cf40
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movb $0x1, -0x39(%rbp)
movb $0x1, -0x3a(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x10e381
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movb $0x0, -0x39(%rbp)
movb $0x0, -0x3a(%rbp)
jmp 0x10e392
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x10e390
movb $0x0, -0x3a(%rbp)
jmp 0x10e392
testb $0x1, -0x3a(%rbp)
je 0x10e3f3
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x10fc70
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x10e3de
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rcx
imulq -0x28(%rbp), %rcx
addq %rcx, %rdi
callq *%rax
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x10e3b0
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x10fc20
jmp 0x10e478
movq -0x38(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
je 0x10e42f
movq -0x50(%rbp), %rax
movq (%rax), %rax
leaq 0x89(%rip), %rcx        # 0x10e4a0
cmpq %rcx, (%rax)
je 0x10e476
movq -0x50(%rbp), %rax
movq (%rax), %rax
leaq 0xd6(%rip), %rcx        # 0x10e500
cmpq %rcx, (%rax)
je 0x10e476
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
je 0x10e450
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rsi
callq 0x10cf80
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x10e560
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
jmp 0x10e478
testb $0x1, -0x39(%rbp)
je 0x10e48f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x10d320
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)