// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore_spect_array.c
// Function: bcore_array_default_remove
void bcore_array_default_remove( const bcore_array_s* p, bcore_array* o, uz_t index )
{
    uz_t size = get_size( p, o );
    if( index >= size ) return;
    if( size > get_space( p, o ) ) bcore_array_p_make_strong( p, o );

    switch( p->type_caps )
    {
        case BCORE_CAPS_ARRAY_DYN_SOLID_STATIC:
        {
            bcore_array_dyn_solid_static_s* arr = obj_vd( p, o );
            const bcore_inst_s* inst_p = p->item_p;
            for( uz_t i = index; i < size - 1; i++ )
            {
                vd_t dst = ( u0_t* )arr->data + inst_p->size * i;
                vd_t src = ( u0_t* )arr->data + inst_p->size * ( i + 1 );
                bcore_inst_p_copy( inst_p, dst, src );
            }
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_SOLID_TYPED:
        {
            bcore_array_dyn_solid_typed_s* arr = obj_vd( p, o );
            const bcore_inst_s* inst_p = bcore_inst_s_get_typed( arr->type );
            for( uz_t i = index; i < size - 1; i++ )
            {
                vd_t dst = ( u0_t* )arr->data + inst_p->size * i;
                vd_t src = ( u0_t* )arr->data + inst_p->size * ( i + 1 );
                bcore_inst_p_copy( inst_p, dst, src );
            }
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_STATIC:
        {
            bcore_array_dyn_link_static_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index ];
            for( uz_t i = index; i < size - 1; i++ ) arr->data[ i ] = arr->data[ i + 1 ];
            arr->data[ size - 1 ] = temp; // removal of the temp object is handled in set_size below
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_TYPED:
        {
            bcore_array_dyn_link_typed_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index ];
            for( uz_t i = index; i < size - 1; i++ ) arr->data[ i ] = arr->data[ i + 1 ];
            arr->data[ size - 1 ] = temp; // removal of the temp object is handled in set_size below
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_AWARE:
        {
            bcore_array_dyn_link_aware_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index ];
            for( uz_t i = index; i < size - 1; i++ ) arr->data[ i ] = arr->data[ i + 1 ];
            arr->data[ size - 1 ] = temp; // removal of the temp object is handled in set_size below
        }
        break;

        case BCORE_CAPS_ARRAY_FIX_SOLID_STATIC:
        case BCORE_CAPS_ARRAY_FIX_LINK_STATIC:
        case BCORE_CAPS_ARRAY_FIX_LINK_AWARE:
        {
            ERR( "cannot remove an element from a fixed-size-array" );
        }
        break;

        default:
        {
            ERR( "invalid type_caps (%"PRIu32")", ( u2_t )p->type_caps );
        }
        break;
    }

    bcore_array_p_set_size( p, o, size - 1 );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %r15
testq %r15, %r15
je 0x7bc61
cmpq %r12, %r15
ja 0x7bc81
jmp 0x7bcc9
movq 0x20(%r14), %rax
movq 0x8(%rbx,%rax), %r15
cmpq %r12, %r15
jbe 0x7bcc9
cmpq 0x10(%rbx,%rax), %r15
jbe 0x7bc81
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7b108
movq 0x10(%r14), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0x7bdf0
leaq 0x4ac3a(%rip), %rcx     # 0xc68d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x4af55(%rip), %rdi     # 0xc6bff
leaq 0x4adbf(%rip), %rsi     # 0xc6a70
leaq 0x4af62(%rip), %rcx     # 0xc6c1a
movl $0x38b, %edx            # imm = 0x38B
xorl %eax, %eax
callq 0x60031
jmp 0x7be11
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %rax
movq (%rbx,%rax), %rcx
movq (%rcx,%r12,8), %rcx
leaq -0x1(%r15), %rdx
movq (%rbx,%rax), %rsi
cmpq %rdx, %r12
jae 0x7bd4d
movq 0x8(%rsi,%r12,8), %rdi
movq %rdi, (%rsi,%r12,8)
incq %r12
jmp 0x7bce8
movq 0x20(%r14), %rax
movq (%rbx,%rax), %rcx
movq (%rcx,%r12,8), %rcx
leaq -0x1(%r15), %rdx
movq (%rbx,%rax), %rsi
cmpq %rdx, %r12
jae 0x7bd4d
movq 0x8(%rsi,%r12,8), %rdi
movq %rdi, (%rsi,%r12,8)
incq %r12
jmp 0x7bd0f
movq 0x20(%r14), %rax
movq (%rbx,%rax), %rcx
movq (%rcx,%r12,8), %rcx
leaq -0x1(%r15), %rdx
movq (%rbx,%rax), %rsi
cmpq %rdx, %r12
jae 0x7bd4d
movq 0x8(%rsi,%r12,8), %rdi
movq %rdi, (%rsi,%r12,8)
incq %r12
jmp 0x7bd36
movq %rcx, -0x8(%rsi,%r15,8)
jmp 0x7be11
movq 0x20(%r14), %rax
movq %rax, (%rsp)
movq 0x28(%r14), %r13
leaq -0x1(%r15), %rbp
cmpq %rbp, %r12
jae 0x7be11
movq 0x18(%r13), %rdx
movq %rdx, %rsi
imulq %r12, %rsi
incq %r12
imulq %r12, %rdx
cmpq %rdx, %rsi
je 0x7bd67
movq (%rsp), %rax
movq (%rbx,%rax), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r13, %rdi
callq *0x90(%r13)
jmp 0x7bd67
movq 0x20(%r14), %rax
movq %rax, (%rsp)
movq 0x18(%rbx,%rax), %rdi
callq 0x7b39a
movq %rax, %r13
leaq -0x1(%r15), %rbp
cmpq %rbp, %r12
jae 0x7be11
movq 0x18(%r13), %rdx
movq %rdx, %rsi
imulq %r12, %rsi
incq %r12
imulq %r12, %rdx
cmpq %rdx, %rsi
je 0x7bdba
movq (%rsp), %rax
movq (%rbx,%rax), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r13, %rdi
callq *0x90(%r13)
jmp 0x7bdba
leaq 0x4ae08(%rip), %rdi     # 0xc6bff
leaq 0x4ac72(%rip), %rsi     # 0xc6a70
leaq 0x4acac(%rip), %rcx     # 0xc6ab1
movl $0x391, %edx            # imm = 0x391
xorl %eax, %eax
callq 0x60031
decq %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7b8b6