// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_spect_via.c
// Function: bcore_via_default_iset
er_t bcore_via_default_iset( const bcore_via_s* p, bcore_via* o, uz_t index, sr_s src )
{
    if( index >= p->size )
    {
        sr_down( src );
        return EM_ERR_fa( "index #<uz_t> out of range #<uz_t>", index, p->size );
    }

    const bcore_vitem_s* vitem  = &p->vitem_arr[ index ];

    if( vitem->fp_set ) // explicit setter
    {
        vitem->fp_set( o, src );
        return 0;
    }

    er_t err = 0;
    switch( vitem->caps )
    {
        case BCORE_CAPS_SOLID_STATIC:
        {
            vd_t dst = ( u0_t* )o + vitem->offs;
            const bcore_inst_s* inst_p = vitem->via_p->inst_p;
            if( sr_s_type( &src ) == vitem->type )
            {
                bcore_inst_p_copy( inst_p, dst, src.o );
            }
            else
            {
                err = bcore_inst_p_copy_typed( inst_p, dst, sr_s_type( &src ), src.o );
            }
        }
        break;

        case BCORE_CAPS_LINK_STATIC:
        {
            bcore_link_static_s* dst = ( vd_t )( ( u0_t* )o + vitem->offs );
            const bcore_inst_s* inst_p = vitem->via_p->inst_p;
            if( dst->link )
            {
                bcore_inst_p_discard( inst_p, dst->link );
                dst->link = NULL;
            }
            if( src.o )
            {
                if( sr_s_type( &src ) == vitem->type )
                {
                    dst->link = sr_s_is_strong( &src ) ? src.o : bcore_inst_p_clone( inst_p, src.o );
                    src = sr_cw( src );
                }
                else
                {
                    dst->link = bcore_inst_p_create_typed( inst_p, sr_s_type( &src ), src.o );
                    if( !dst->link ) return bcore_error_last();
                }
            }
        }
        break;

        case BCORE_CAPS_LINK_TYPED:
        {
            bcore_link_typed_s* dst = ( vd_t )( ( u0_t* )o + vitem->offs );
            if( dst->type && dst->link )
            {
                bcore_inst_t_discard( dst->type, dst->link );
                dst->link = NULL;
            }
            if( sr_s_type( &src ) )
            {
                dst->type = sr_s_type( &src );
                if( src.o )
                {
                    dst->link = sr_s_is_strong( &src ) ? src.o : bcore_inst_t_clone( sr_s_type( &src ), src.o );
                }
                src = sr_cw( src );
            }
        }
        break;

        case BCORE_CAPS_LINK_AWARE:
        {
            bcore_link_aware_s* dst = ( vd_t )( ( u0_t* )o + vitem->offs );

            if( dst->link )
            {
                bcore_inst_a_discard( dst->link );
                dst->link = NULL;
            }

            if( src.o )
            {
                if( sr_s_type( &src ) )
                {
                    const bcore_inst_s* inst_p = bcore_inst_s_get_typed( sr_s_type( &src ) );
                    if( inst_p->aware )
                    {
                        dst->link = sr_s_is_strong( &src ) ? src.o : bcore_inst_p_clone( inst_p, src.o );
                        src = sr_cw( src );
                    }
                    else
                    {
                        err = EM_ERR_fa( "Cannot convert #<sc_t> to self-aware object", ifnameof( sr_s_type( &src ) ) );
                    }
                }
                else
                {
                    dst->link = sr_s_is_strong( &src ) ? src.o : bcore_inst_a_clone( src.o );
                    src = sr_cw( src );
                }
            }
        }
        break;

        case BCORE_CAPS_ARRAY_DYN_SOLID_STATIC:
        case BCORE_CAPS_ARRAY_DYN_SOLID_TYPED:
        case BCORE_CAPS_ARRAY_DYN_LINK_STATIC:
        case BCORE_CAPS_ARRAY_DYN_LINK_TYPED:
        case BCORE_CAPS_ARRAY_DYN_LINK_AWARE:
        case BCORE_CAPS_ARRAY_FIX_SOLID_STATIC:
        case BCORE_CAPS_ARRAY_FIX_LINK_STATIC:
        case BCORE_CAPS_ARRAY_FIX_LINK_AWARE:
        {
            vd_t dst = ( ( u0_t* )o + vitem->offs );
            const bcore_inst_s* inst_p = vitem->via_p->inst_p;
            if( sr_s_type( &src ) == vitem->type )
            {
                bcore_inst_p_copy( inst_p, dst, src.o );
            }
            else
            {
                err = bcore_inst_p_copy_typed( inst_p, dst, sr_s_type( &src ), src.o );
            }
        }
        break;

        default:
            err = EM_ERR_fa( "Unsupported caps '#<sc_t>'", bcore_flect_caps_e_sc( vitem->caps ) );
            break;
    }
    sr_down( src );
    return err;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r14
movq %rdi, %r15
leaq 0x50(%rsp), %r12
movq 0x20(%rdi), %r9
cmpq %rdx, %r9
jbe 0x102011
movq %rsi, %rbx
movq 0x30(%r15), %r15
imulq $0x38, %r14, %rcx
movq 0x30(%r15,%rcx), %rax
testq %rax, %rax
je 0x102066
movq 0x10(%r12), %rcx
movq %rcx, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq *%rax
xorl %ebx, %ebx
jmp 0x10226a
testb $0x2, 0x10(%r12)
je 0x102035
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x107590
movq 0x20(%r15), %r9
leaq 0x49639(%rip), %rdi     # 0x14b675
leaq 0x49604(%rip), %rsi     # 0x14b647
leaq 0x49642(%rip), %rcx     # 0x14b68c
movl $0x80, %edx
movq %r14, %r8
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xbedd5
addq %rcx, %r15
movl 0x10(%r15), %edi
leal -0x1(%rdi), %eax
cmpl $0xc, %eax
ja 0x10221e
leaq 0x49534(%rip), %rcx     # 0x14b5b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq 0x18(%r15), %rbx
movq 0x20(%r15), %rax
movq 0x10(%rax), %rdi
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x1020aa
movq 0x8(%rax), %rdx
cmpq (%r15), %rdx
jne 0x1020b2
jmp 0x1020c9
cmpq $0x0, (%r15)
je 0x1020c9
xorl %edx, %edx
movq (%r12), %rcx
cmpq %rcx, %rbx
je 0x1020db
cmpq %rdx, 0x8(%rdi)
jne 0x1020e2
movq %rbx, %rsi
movq %rcx, %rdx
jmp 0x1020d5
movq (%r12), %rdx
cmpq %rdx, %rbx
je 0x1020db
movq %rbx, %rsi
callq *0x90(%rdi)
xorl %ebx, %ebx
jmp 0x10224a
movq %rbx, %rsi
callq *0x98(%rdi)
jmp 0x102247
movq 0x18(%r15), %r14
movq 0x8(%rbx,%r14), %rdi
testq %rdi, %rdi
je 0x102114
movq (%rbx,%r14), %rsi
testq %rsi, %rsi
je 0x102114
callq 0x102337
movq $0x0, (%rbx,%r14)
movq 0x8(%r12), %rcx
testq %rcx, %rcx
je 0x1020db
movq 0x8(%rcx), %rax
testq %rax, %rax
je 0x1020db
movq %rax, 0x8(%rbx,%r14)
movq (%r12), %rax
movq 0x10(%r12), %r15
testq %rax, %rax
je 0x1022f3
testb $0x2, %r15b
jne 0x102150
movq 0x8(%rcx), %rdi
movq %rax, %rsi
callq 0x1023e3
movq %rax, (%rbx,%r14)
jmp 0x1022f3
movq 0x18(%r15), %r15
movq (%rbx,%r15), %rdi
testq %rdi, %rdi
je 0x102173
callq 0x10249c
movq $0x0, (%rbx,%r15)
movq (%r12), %r14
testq %r14, %r14
je 0x1020db
movq 0x8(%r12), %r13
testq %r13, %r13
je 0x10227b
movq 0x8(%r13), %rdi
testq %rdi, %rdi
je 0x10227b
callq 0x102548
cmpb $0x1, 0x28(%rax)
jne 0x102301
movq 0x10(%r12), %r13
testb $0x2, %r13b
jne 0x102291
movq %rax, %rdi
movq %r14, %rsi
callq *0xc0(%rax)
jmp 0x10228e
movq 0x18(%r15), %r13
movq 0x20(%r15), %rax
movq 0x10(%rax), %r14
movq (%rbx,%r13), %rsi
testq %rsi, %rsi
je 0x1021f1
movq %r14, %rdi
callq *0xb8(%r14)
movq $0x0, (%rbx,%r13)
movq (%r12), %rdx
testq %rdx, %rdx
je 0x1020db
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x1022a3
movq 0x8(%rax), %rsi
cmpq (%r15), %rsi
jne 0x1022ab
jmp 0x1022d4
callq 0xbf808
leaq 0x4944b(%rip), %rdi     # 0x14b675
leaq 0x49416(%rip), %rsi     # 0x14b647
leaq 0x494a3(%rip), %rcx     # 0x14b6db
movl $0x103, %edx            # imm = 0x103
movq %rax, %r8
xorl %eax, %eax
callq 0xbedd5
movq %rax, %rbx
testb $0x2, 0x10(%r12)
je 0x10226a
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x107590
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x10(%r12), %r13
testb $0x2, %r13b
jne 0x102291
movq %r14, %rdi
callq 0x1025e7
movq %rax, %r14
movq %r14, (%rbx,%r15)
andq $-0x3, %r13
movq %r13, 0x10(%r12)
jmp 0x1020db
cmpq $0x0, (%r15)
je 0x1022d4
xorl %esi, %esi
movq %r14, %rdi
callq *0xb0(%r14)
movq %rax, (%rbx,%r13)
testq %rax, %rax
jne 0x1020db
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xbee72
movq 0x10(%r12), %r15
testb $0x2, %r15b
jne 0x1022ef
movq %r14, %rdi
movq %rdx, %rsi
callq *0xc0(%r14)
movq %rax, %rdx
movq %rdx, (%rbx,%r13)
andq $-0x3, %r15
movq %r15, 0x10(%r12)
jmp 0x1020db
movq 0x8(%r13), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x46401(%rip), %r8      # 0x148715
cmovneq %rax, %r8
leaq 0x49356(%rip), %rdi     # 0x14b675
leaq 0x49321(%rip), %rsi     # 0x14b647
leaq 0x49382(%rip), %rcx     # 0x14b6af
movl $0xe0, %edx
jmp 0x102240