// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_spect_array.c
// Function: bcore_array_default_swap
void bcore_array_default_swap( const bcore_array_s* p, bcore_array* o, uz_t index1, uz_t index2 )
{
    uz_t size = get_size( p, o );
    if( index1 >= size ) ERR_fa( "index1 (#<uz_t>) >= array size (#<uz_t>)", index1, size );
    if( index2 >= size ) ERR_fa( "index2 (#<uz_t>) >= array size (#<uz_t>)", index2, 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;
            vd_t item1 = ( u0_t* )arr->data + inst_p->size * index1;
            vd_t item2 = ( u0_t* )arr->data + inst_p->size * index2;
            vd_t tmp = inst_p->create( inst_p );
            bcore_inst_p_copy( inst_p, tmp, item1 );
            bcore_inst_p_copy( inst_p, item1, item2 );
            bcore_inst_p_copy( inst_p, item2, tmp );
            inst_p->discard( inst_p, tmp );
        }
        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 );
            vd_t item1 = ( u0_t* )arr->data + inst_p->size * index1;
            vd_t item2 = ( u0_t* )arr->data + inst_p->size * index2;
            vd_t tmp = inst_p->create( inst_p );
            bcore_inst_p_copy( inst_p, tmp, item1 );
            bcore_inst_p_copy( inst_p, item1, item2 );
            bcore_inst_p_copy( inst_p, item2, tmp );
            inst_p->discard( inst_p, tmp );
        }
        break;

        case BCORE_CAPS_ARRAY_FIX_SOLID_STATIC:
        {
            vd_t data = obj_vd( p, o );
            const bcore_inst_s* inst_p = p->item_p;
            vd_t item1 = ( u0_t* )data + inst_p->size * index1;
            vd_t item2 = ( u0_t* )data + inst_p->size * index2;
            vd_t tmp = inst_p->create( inst_p );
            bcore_inst_p_copy( inst_p, tmp, item1 );
            bcore_inst_p_copy( inst_p, item1, item2 );
            bcore_inst_p_copy( inst_p, item2, tmp );
            inst_p->discard( inst_p, tmp );
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_STATIC:
        {
            bcore_array_dyn_link_static_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index1 ];
            arr->data[ index1 ] = arr->data[ index2 ];
            arr->data[ index2 ] = temp;
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_TYPED:
        {
            bcore_array_dyn_link_typed_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index1 ];
            arr->data[ index1 ] = arr->data[ index2 ];
            arr->data[ index2 ] = temp;
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_LINK_AWARE:
        {
            bcore_array_dyn_link_aware_s* arr = obj_vd( p, o );
            vd_t temp = arr->data[ index1 ];
            arr->data[ index1 ] = arr->data[ index2 ];
            arr->data[ index2 ] = temp;
        }
        break;

        case BCORE_CAPS_ARRAY_FIX_LINK_STATIC:
        case BCORE_CAPS_ARRAY_FIX_LINK_AWARE:
        {
            vd_t* data = obj_vd( p, o );
            vd_t temp = data[ index1 ];
            data[ index1 ] = data[ index2 ];
            data[ index2 ] = temp;
        }
        break;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x18(%rdi), %r13
testq %r13, %r13
jne 0xf75f0
movq 0x20(%r12), %rax
movq 0x8(%r15,%rax), %r13
cmpq %r14, %r13
ja 0xf761c
leaq 0x5c7d4(%rip), %rdi     # 0x153dd0
leaq 0x5c57d(%rip), %rsi     # 0x153b80
leaq 0x5c7df(%rip), %rcx     # 0x153de9
movl $0x430, %edx            # imm = 0x430
movq %r14, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0xc825d
cmpq %rbx, %r13
ja 0xf7648
leaq 0x5c7a8(%rip), %rdi     # 0x153dd0
leaq 0x5c551(%rip), %rsi     # 0x153b80
leaq 0x5c7dc(%rip), %rcx     # 0x153e12
movl $0x431, %edx            # imm = 0x431
movq %rbx, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0xc825d
movq 0x10(%r12), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0xf77ee
leaq 0x5c3e2(%rip), %rcx     # 0x153a44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x20(%r12), %rax
movq (%r15,%rax), %rcx
movq (%rcx,%r14,8), %rdx
movq (%rcx,%rbx,8), %rsi
movq %rsi, (%rcx,%r14,8)
movq (%r15,%rax), %rax
movq %rdx, (%rax,%rbx,8)
jmp 0xf769f
addq 0x20(%r12), %r15
movq (%r15,%r14,8), %rax
movq (%r15,%rbx,8), %rcx
movq %rcx, (%r15,%r14,8)
movq %rax, (%r15,%rbx,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r12), %rax
movq 0x28(%r12), %r12
movq (%r15,%rax), %r15
jmp 0xf776c
movq 0x20(%r12), %rbp
movq 0x18(%r15,%rbp), %r13
leaq 0xb1d96(%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 %r13, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0xf772c
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0xf772c
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0xf772c
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0xf781d
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0xf775c
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r13, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0xb1d17(%rip), %rdi     # 0x1a9468
movq %r13, %rsi
movq %rax, %rdx
callq 0x12128c
movq (%r15,%rbp), %r15
jmp 0xf776c
addq 0x20(%r12), %r15
movq 0x28(%r12), %r12
movq 0x18(%r12), %rax
imulq %rax, %r14
leaq (%r15,%r14), %rbp
imulq %rax, %rbx
movq %r12, %rdi
callq *0xa8(%r12)
movq %rax, %r13
cmpq %rbp, %rax
je 0xf77a1
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq *0x90(%r12)
addq %rbx, %r15
cmpq %rbx, %r14
je 0xf77ba
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq *0x90(%r12)
cmpq %r13, %r15
je 0xf77d0
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *0x90(%r12)
movq 0xb8(%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x5c5db(%rip), %rdi     # 0x153dd0
leaq 0x5c384(%rip), %rsi     # 0x153b80
leaq 0x5c3be(%rip), %rcx     # 0x153bc1
movl $0x485, %edx            # imm = 0x485
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc80f6
xorl %r12d, %r12d
jmp 0xf7730