// File: /workspace/github_c_makefile_star2_O1/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), %rax
movq %rax, %r15
testq %rax, %rax
jne 0xf6f87
movq 0x20(%r14), %rcx
movq 0x8(%rbx,%rcx), %r15
cmpq %r12, %r15
jbe 0xf6ff2
testq %rax, %rax
jne 0xf6f9a
movq 0x20(%r14), %rax
movq 0x10(%rbx,%rax), %rax
cmpq %rax, %r15
jbe 0xf6faa
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf5ec4
movq 0x10(%r14), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0xf71c4
leaq 0x5ca21(%rip), %rcx     # 0x1539e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5cd3c(%rip), %rdi     # 0x153d0f
leaq 0x5cba6(%rip), %rsi     # 0x153b80
leaq 0x5cd49(%rip), %rcx     # 0x153d2a
movl $0x38b, %edx            # imm = 0x38B
xorl %eax, %eax
callq 0xc80f6
jmp 0xf71e5
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
cmpq %r12, %rdx
jbe 0xf708c
incq %r12
movq (%rbx,%rax), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xf7019
jmp 0xf708c
movq 0x20(%r14), %rax
movq (%rbx,%rax), %rcx
movq (%rcx,%r12,8), %rcx
leaq -0x1(%r15), %rdx
cmpq %r12, %rdx
jbe 0xf708c
incq %r12
movq (%rbx,%rax), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xf7048
jmp 0xf708c
movq 0x20(%r14), %rax
movq (%rbx,%rax), %rcx
movq (%rcx,%r12,8), %rcx
leaq -0x1(%r15), %rdx
cmpq %r12, %rdx
jbe 0xf708c
incq %r12
movq (%rbx,%rax), %rdx
movq (%rdx,%r12,8), %rsi
movq %rsi, -0x8(%rdx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0xf7077
movq (%rbx,%rax), %rax
movq %rcx, -0x8(%rax,%r15,8)
jmp 0xf71e5
leaq -0x1(%r15), %rax
cmpq %r12, %rax
jbe 0xf71e5
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 0xf70dc
movq (%rbx,%rbp), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r13, %rdi
callq *0x90(%r13)
incq %r12
cmpq %r12, %r15
jne 0xf70b2
jmp 0xf71e5
movq 0x20(%r14), %r13
movq 0x18(%rbx,%r13), %rsi
leaq 0xb236f(%rip), %rax     # 0x1a9468
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 0xf7153
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rsi, %rdx
je 0xf7153
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rsi, %rdx
je 0xf7153
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rsi, %rdx
jne 0xf7204
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0xf7185
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rsi, (%rsp)
callq 0xf3f85
movq %rax, %rbp
leaq 0xb22ef(%rip), %rdi     # 0x1a9468
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x12128c
leaq -0x1(%r15), %rax
cmpq %r12, %rax
jbe 0xf71e5
incq %r12
leaq -0x1(%r12), %rsi
movq 0x18(%rbp), %rdx
imulq %rdx, %rsi
imulq %r12, %rdx
cmpq %rdx, %rsi
je 0xf71ba
movq (%rbx,%r13), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %rbp, %rdi
callq *0x90(%rbp)
incq %r12
cmpq %r12, %r15
jne 0xf7191
jmp 0xf71e5
leaq 0x5cb44(%rip), %rdi     # 0x153d0f
leaq 0x5c9ae(%rip), %rsi     # 0x153b80
leaq 0x5c9e8(%rip), %rcx     # 0x153bc1
movl $0x391, %edx            # imm = 0x391
xorl %eax, %eax
callq 0xc80f6
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 0xf69d8
xorl %ebp, %ebp
jmp 0xf7157