// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_spect_array.c
// Function: bcore_array_default_insert
void bcore_array_default_insert( const bcore_array_s* p, bcore_array* o, uz_t index, sr_s src )
{
    uz_t size = get_size( p, o );

    if( index >= size )
    {
        bcore_array_p_set( p, o, index, src );
        return;
    }

    if( size > get_space( p, o ) ) bcore_array_p_make_strong( p, o );
    bcore_array_p_set_size( p, o, size + 1 );
    size++;

    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 = size - 1; i > index; i-- )
            {
                vd_t src = ( u0_t* )arr->data + inst_p->size * ( i - 1 );
                vd_t dst = ( u0_t* )arr->data + inst_p->size * i;
                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 = size - 1; i > index; i-- )
            {
                vd_t src = ( u0_t* )arr->data + inst_p->size * ( i - 1 );
                vd_t dst = ( u0_t* )arr->data + inst_p->size * i;
                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 );
            for( uz_t i = size - 1; i > index; i-- ) arr->data[ i ] = arr->data[ i - 1 ];
            arr->data[ index ] = NULL;
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_TYPED:
        {
            bcore_array_dyn_link_typed_s* arr = obj_vd( p, o );
            for( uz_t i = size - 1; i > index; i-- ) arr->data[ i ] = arr->data[ i - 1 ];
            arr->data[ index ] = NULL;
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_AWARE:
        {
            bcore_array_dyn_link_aware_s* arr = obj_vd( p, o );
            for( uz_t i = size - 1; i > index; i-- ) arr->data[ i ] = arr->data[ i - 1 ];
            arr->data[ index ] = NULL;
        }
        break;

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

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

    bcore_array_p_set( p, o, index, src );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rax
movq %rax, %rbp
testq %rax, %rax
jne 0xf7388
movq 0x20(%r15), %rcx
movq 0x8(%r14,%rcx), %rbp
cmpq %rbx, %rbp
jbe 0xf75a1
testq %rax, %rax
jne 0xf739f
movq 0x20(%r15), %rax
movq 0x10(%r14,%rax), %rax
cmpq %rax, %rbp
jbe 0xf73af
movq %r15, %rdi
movq %r14, %rsi
callq 0xf5ec4
leaq 0x1(%rbp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xf69d8
movq 0x10(%r15), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0xf7580
leaq 0x5c64d(%rip), %rcx     # 0x153a24
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5c99d(%rip), %rdi     # 0x153d84
leaq 0x5c792(%rip), %rsi     # 0x153b80
leaq 0x5c9aa(%rip), %rcx     # 0x153d9f
movl $0x419, %edx            # imm = 0x419
xorl %eax, %eax
callq 0xc80f6
jmp 0xf75a1
movq 0x20(%r15), %rax
cmpq %rbx, %rbp
jbe 0xf7457
movq (%r14,%rax), %rcx
movq -0x8(%rcx,%rbp,8), %rdx
movq %rdx, (%rcx,%rbp,8)
decq %rbp
jmp 0xf740a
movq 0x20(%r15), %rax
cmpq %rbx, %rbp
jbe 0xf7457
movq (%r14,%rax), %rcx
movq -0x8(%rcx,%rbp,8), %rdx
movq %rdx, (%rcx,%rbp,8)
decq %rbp
jmp 0xf7425
movq 0x20(%r15), %rax
cmpq %rbx, %rbp
jbe 0xf7457
movq (%r14,%rax), %rcx
movq -0x8(%rcx,%rbp,8), %rdx
movq %rdx, (%rcx,%rbp,8)
decq %rbp
jmp 0xf7440
movq (%r14,%rax), %rax
movq $0x0, (%rax,%rbx,8)
jmp 0xf75a1
cmpq %rbx, %rbp
jbe 0xf75a1
movq 0x20(%r15), %r13
movq 0x28(%r15), %r12
movq 0x18(%r12), %rsi
movq %rsi, %rdx
imulq %rbp, %rsi
decq %rbp
imulq %rbp, %rdx
cmpq %rdx, %rsi
je 0xf74a6
movq (%r14,%r13), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r12, %rdi
callq *0x90(%r12)
cmpq %rbx, %rbp
ja 0xf7479
jmp 0xf75a1
movq 0x20(%r15), %r12
movq 0x18(%r14,%r12), %rsi
leaq 0xb1fa8(%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 0xf751a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rsi, %rdx
je 0xf751a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rsi, %rdx
je 0xf751a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rsi, %rdx
jne 0xf75be
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0xf7579
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %rsi, (%rsp)
callq 0xf3f85
movq %rax, %r13
leaq 0xb1f28(%rip), %rdi     # 0x1a9468
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x12128c
jmp 0xf7579
movq 0x18(%r13), %rsi
movq %rsi, %rdx
imulq %rbp, %rsi
decq %rbp
imulq %rbp, %rdx
cmpq %rdx, %rsi
je 0xf7579
movq (%r14,%r12), %rax
addq %rax, %rdx
addq %rax, %rsi
movq %r13, %rdi
callq *0x90(%r13)
cmpq %rbx, %rbp
ja 0xf754e
jmp 0xf75a1
leaq 0x5c7fd(%rip), %rdi     # 0x153d84
leaq 0x5c5f2(%rip), %rsi     # 0x153b80
leaq 0x5c62c(%rip), %rcx     # 0x153bc1
movl $0x41f, %edx            # imm = 0x41F
xorl %eax, %eax
callq 0xc80f6
movq 0x38(%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
xorl %r13d, %r13d
jmp 0xf751e