// File: /workspace/github_c_makefile_star2_O3/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 0xecab4
cmpq %r12, %r15
ja 0xecad4
jmp 0xecb1c
movq 0x20(%r14), %rax
movq 0x8(%rbx,%rax), %r15
cmpq %r12, %r15
jbe 0xecb1c
cmpq 0x10(%rbx,%rax), %r15
jbe 0xecad4
movq %r14, %rdi
movq %rbx, %rsi
callq 0xeba34
movq 0x10(%r14), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0xeccea
leaq 0x5bf1f(%rip), %rcx     # 0x148a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5c23a(%rip), %rdi     # 0x148d37
leaq 0x5c0a4(%rip), %rsi     # 0x148ba8
leaq 0x5c247(%rip), %rcx     # 0x148d52
movl $0x38b, %edx            # imm = 0x38B
xorl %eax, %eax
callq 0xbe592
jmp 0xecd0b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %rcx
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rax
leaq -0x1(%r15), %rsi
cmpq %r12, %rsi
jbe 0xecbba
incq %r12
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xecb43
jmp 0xecbb6
movq 0x20(%r14), %rcx
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rax
leaq -0x1(%r15), %rsi
cmpq %r12, %rsi
jbe 0xecbba
incq %r12
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xecb72
jmp 0xecbb6
movq 0x20(%r14), %rcx
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rax
leaq -0x1(%r15), %rsi
cmpq %r12, %rsi
jbe 0xecbba
incq %r12
movq (%rbx,%rcx), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xecba1
movq (%rbx,%rcx), %rdx
movq %rax, -0x8(%rdx,%r15,8)
jmp 0xecd0b
leaq -0x1(%r15), %rax
cmpq %r12, %rax
jbe 0xecd0b
movq 0x20(%r14), %rbp
movq 0x28(%r14), %r13
incq %r12
leaq -0x1(%r12), %rsi
movq 0x18(%r13), %rdx
imulq %rdx, %rsi
imulq %r12, %rdx
cmpq %rdx, %rsi
je 0xecc06
movq (%rbx,%rbp), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r13, %rdi
callq *0x90(%r13)
incq %r12
cmpq %r12, %r15
jne 0xecbdc
jmp 0xecd0b
movq 0x20(%r14), %r13
movq 0x18(%rbx,%r13), %rsi
leaq 0xaf845(%rip), %rax     # 0x19c468
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rsi, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rsi, %rdx
je 0xecc79
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rsi, %rdx
je 0xecc79
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rsi, %rdx
je 0xecc79
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rsi, %rdx
jne 0xecc82
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0xeccab
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rsi, (%rsp)
callq 0xe9bc5
movq %rax, %rbp
leaq 0xaf7c9(%rip), %rdi     # 0x19c468
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x115fac
leaq -0x1(%r15), %rax
cmpq %r12, %rax
jbe 0xecd0b
incq %r12
leaq -0x1(%r12), %rsi
movq 0x18(%rbp), %rdx
imulq %rdx, %rsi
imulq %r12, %rdx
cmpq %rdx, %rsi
je 0xecce0
movq (%rbx,%r13), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %rbp, %rdi
callq *0x90(%rbp)
incq %r12
cmpq %r12, %r15
jne 0xeccb7
jmp 0xecd0b
leaq 0x5c046(%rip), %rdi     # 0x148d37
leaq 0x5beb0(%rip), %rsi     # 0x148ba8
leaq 0x5beea(%rip), %rcx     # 0x148be9
movl $0x391, %edx            # imm = 0x391
xorl %eax, %eax
callq 0xbe592
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 0xec548