// File: /workspace/github_c_makefile_star2_O3/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 0xed0fa
movq 0x20(%r12), %rax
movq 0x8(%r15,%rax), %r13
cmpq %r14, %r13
ja 0xed126
leaq 0x5bcf2(%rip), %rdi     # 0x148df8
leaq 0x5ba9b(%rip), %rsi     # 0x148ba8
leaq 0x5bcfd(%rip), %rcx     # 0x148e11
movl $0x430, %edx            # imm = 0x430
movq %r14, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0xbe6f9
cmpq %rbx, %r13
ja 0xed152
leaq 0x5bcc6(%rip), %rdi     # 0x148df8
leaq 0x5ba6f(%rip), %rsi     # 0x148ba8
leaq 0x5bcfa(%rip), %rcx     # 0x148e3a
movl $0x431, %edx            # imm = 0x431
movq %rbx, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0xbe6f9
movq 0x10(%r12), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0xed2f4
leaq 0x5b900(%rip), %rcx     # 0x148a6c
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 0xed1a9
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 0xed272
movq 0x20(%r12), %rbp
movq 0x18(%r15,%rbp), %r13
leaq 0xaf28c(%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 %r13, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0xed232
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0xed232
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0xed232
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0xed23b
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0xed262
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0xaf211(%rip), %rdi     # 0x19c468
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
movq (%r15,%rbp), %r15
jmp 0xed272
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 0xed2a7
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq *0x90(%r12)
addq %rbx, %r15
cmpq %rbx, %r14
je 0xed2c0
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq *0x90(%r12)
cmpq %r13, %r15
je 0xed2d6
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 0x5bafd(%rip), %rdi     # 0x148df8
leaq 0x5b8a6(%rip), %rsi     # 0x148ba8
leaq 0x5b8e0(%rip), %rcx     # 0x148be9
movl $0x485, %edx            # imm = 0x485
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbe592