// File: /workspace/github_c_makefile_star2_O2/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 0x7c173
movq 0x20(%r12), %rax
movq 0x8(%r15,%rax), %r13
cmpq %r14, %r13
ja 0x7c19f
leaq 0x4ab41(%rip), %rdi     # 0xc6cc0
leaq 0x4a8ea(%rip), %rsi     # 0xc6a70
leaq 0x4ab4c(%rip), %rcx     # 0xc6cd9
movl $0x430, %edx            # imm = 0x430
movq %r14, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x60186
cmpq %rbx, %r13
ja 0x7c1cb
leaq 0x4ab15(%rip), %rdi     # 0xc6cc0
leaq 0x4a8be(%rip), %rsi     # 0xc6a70
leaq 0x4ab49(%rip), %rcx     # 0xc6d02
movl $0x431, %edx            # imm = 0x431
movq %rbx, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x60186
movq 0x10(%r12), %r8
leaq -0x6(%r8), %rax
cmpq $0x7, %rax
ja 0x7c2e9
leaq 0x4a74f(%rip), %rcx     # 0xc6934
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 0x7c222
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 0x7c267
movq 0x20(%r12), %r13
movq 0x18(%r15,%r13), %rdi
callq 0x7b39a
movq %rax, %r12
movq (%r15,%r13), %r15
movq 0x18(%rax), %rax
jmp 0x7c26c
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 0x7c29c
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq *0x90(%r12)
addq %rbx, %r15
cmpq %rbx, %r14
je 0x7c2b5
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq *0x90(%r12)
cmpq %r13, %r15
je 0x7c2cb
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 0x4a9d0(%rip), %rdi     # 0xc6cc0
leaq 0x4a779(%rip), %rsi     # 0xc6a70
leaq 0x4a7b3(%rip), %rcx     # 0xc6ab1
movl $0x485, %edx            # imm = 0x485
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x60031