// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_spect_via.c
// Function: bcore_via_s_create_from_self
static bcore_via_s* bcore_via_s_create_from_self( const bcore_self_s* self )
{
    assert( self != NULL );

    bcore_via_s* o = bcore_inst_t_create( entypeof( "bcore_via_s" ) );
    o->header.p_type  = typeof( "bcore_via_s" );
    o->header.o_type  = self->type;
    o->is_leaf = bcore_type_is_leaf( self->type );

    const bcore_inst_s* inst_p = bcore_inst_s_get_typed( self->type );
    o->inst_p = inst_p;
    o->via_call_p = bcore_via_call_spect_s_get_typed( self->type );

    o->vitem_arr = NULL;
    uz_t vitem_arr_size  = 0;
    uz_t vitem_arr_space = 0;

    uz_t items_size = bcore_self_s_items_size( self );
    for( uz_t i = 0; i < items_size; i++ )
    {
        const bcore_self_item_s* self_item = bcore_self_s_get_item( self, i );

        if( self_item->flags.f_hidden ) continue; // hidden items are not accessible in via
        if( self_item->flags.f_const  ) continue; // constants are not accessible in via

        // self-aware type is not directly accessible in via but can be queried from flag 'is_aware'
        if( i == 0 && self_item->type == TYPEOF_aware_t )
        {
            o->is_aware = true;
            continue;
        }

        const bcore_inst_item_s* inst_item = bcore_inst_s_get_item_from_self_item( inst_p, self_item );

        if( inst_item && inst_item->no_trace ) continue; // instance no-trace items (private, external, ...) are not accessible in via

        bcore_vitem_s vitem;
        bcore_memzero( &vitem, sizeof( bcore_vitem_s ) );
        vitem.name = self_item->name;
        vitem.caps = self_item->caps;
        vitem.offs = inst_item ? inst_item->offset : 0;
        vitem.flags = self_item->flags;

        switch( vitem.caps )
        {
            case BCORE_CAPS_SOLID_STATIC:
            case BCORE_CAPS_LINK_STATIC:
            {
                vitem.type = self_item->type;
            }
            break;

            case BCORE_CAPS_LINK_TYPED:
            case BCORE_CAPS_LINK_AWARE:
                vitem.type = 0;
                break;

            case BCORE_CAPS_ARRAY_DYN_SOLID_STATIC:
                vitem.type = bcore_array_dyn_solid_static_type_of( self_item->type );
                break;

            case BCORE_CAPS_ARRAY_DYN_SOLID_TYPED:
                vitem.type = typeof( "bcore_array_dyn_solid_typed_s" );
                break;

            case BCORE_CAPS_ARRAY_DYN_LINK_STATIC:
                vitem.type = bcore_array_dyn_link_static_type_of( self_item->type );
                break;

            case BCORE_CAPS_ARRAY_DYN_LINK_TYPED:
                vitem.type = typeof( "bcore_array_dyn_link_typed_s" );
                break;

            case BCORE_CAPS_ARRAY_DYN_LINK_AWARE:
                vitem.type = typeof( "bcore_array_dyn_link_aware_s" );
                break;

            case BCORE_CAPS_ARRAY_FIX_SOLID_STATIC:
                vitem.type = bcore_array_fix_solid_static_type_of( self_item->type, self_item->array_fix_size );
                break;

            case BCORE_CAPS_ARRAY_FIX_LINK_STATIC:
                vitem.type = bcore_array_fix_link_static_type_of( self_item->type, self_item->array_fix_size );
                break;

            case BCORE_CAPS_ARRAY_FIX_LINK_AWARE:
                vitem.type = bcore_array_fix_link_aware_type_of( self_item->array_fix_size );
                break;

            case BCORE_CAPS_EXTERNAL_FUNC:
                continue; // external items are (currently) not accessible in via
                break;

            default:
                ERR( "Unexpected caps '%s'", bcore_flect_caps_e_sc( vitem.caps ) );
                break;
        }

        if( vitem.type )
        {
            if( vitem.type == o->header.o_type )
            {
                vitem.via_p = o;
            }
            else
            {
                vitem.via_p = bcore_via_s_get_typed( vitem.type );
            }
        }

        // explicit setter, getter
        {

            bcore_life_s* l = bcore_life_s_create();
            vitem.fp_get = ( bcore_fp_get )bcore_self_s_try_external_fp( self, typeof( "bcore_fp_get" ), typeof( st_s_createf_l( l, "get_%s", ifnameof( vitem.name ) )->sc ) );
            vitem.fp_set = ( bcore_fp_set )bcore_self_s_try_external_fp( self, typeof( "bcore_fp_set" ), typeof( st_s_createf_l( l, "set_%s", ifnameof( vitem.name ) )->sc ) );
            if( vitem.flags.f_shell )
            {
                if( !vitem.fp_get ) ERR( "Object '%s' has shell '%s' but no function 'get_%s'.", ifnameof( o->header.o_type ), ifnameof( vitem.name ), ifnameof( vitem.name ) );
                if( !vitem.fp_set ) ERR( "Object '%s' has shell '%s' but no function 'set_%s'.", ifnameof( o->header.o_type ), ifnameof( vitem.name ), ifnameof( vitem.name ) );
            }
            bcore_life_s_discard( l );
        }

        if( vitem_arr_size == vitem_arr_space )
        {
            o->vitem_arr = bcore_un_alloc( sizeof( bcore_vitem_s ), o->vitem_arr, vitem_arr_space, vitem_arr_space > 0 ? vitem_arr_space * 2 : 1, &vitem_arr_space );
        }
        o->vitem_arr[ vitem_arr_size++ ] = vitem;
    }

    o->size = vitem_arr_size;

    return o;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r13
leaq 0x40246(%rip), %rdi     # 0x146f30
callq 0xd7476
testq %rax, %rax
je 0x106d97
movq %rax, %r14
leaq 0x95766(%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 %r14, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r14, %rdx
je 0x106d58
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x106d58
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x106d58
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x106d61
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0x106d88
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r14, %rsi
callq 0xe9bc5
movq %rax, %r15
leaq 0x956eb(%rip), %rdi     # 0x19c468
movq %r14, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r15, %rdi
callq *0xa8(%r15)
movq %rax, %rbx
jmp 0x106d99
xorl %ebx, %ebx
movabsq $0x541d0401d4dcff33, %rax # imm = 0x541D0401D4DCFF33
movq %rax, (%rbx)
movq 0x8(%r13), %rdi
movq %rdi, 0x8(%rbx)
callq 0xda39e
movb %al, 0x28(%rbx)
movq 0x8(%r13), %r15
leaq 0x956a7(%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 %r15, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x106e17
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x106e17
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x106e17
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x106e20
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x106e47
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x9562c(%rip), %rdi     # 0x19c468
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, 0x8(%rsp)
movq %r14, 0x58(%rsp)
movq %r14, 0x10(%rbx)
movq 0x8(%r13), %r15
leaq 0x90e50(%rip), %rax     # 0x197cb0
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r15, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x106eb6
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x106eb6
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x106eb6
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x106ebf
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x106ee6
movabsq $-0x220988275314685e, %rdi # imm = 0xDDF677D8ACEB97A2
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x90dd5(%rip), %rdi     # 0x197cb0
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x8(%rsp), %rax
movq %r14, 0x18(%rax)
movq %rax, %r14
xorl %r15d, %r15d
movq %r15, 0x30(%rax)
movq %r15, 0x50(%rsp)
movq %r13, %rdi
callq 0xc32f5
movq %rax, 0x60(%rsp)
testq %rax, %rax
je 0x10740a
movabsq $0x100000001b3, %rbx    # imm = 0x100000001B3
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %r13, 0x48(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xc3306
testb $0x14, 0x14(%rax)
jne 0x1073fc
movq %rax, %r12
testq %rbp, %rbp
jne 0x106f5f
movabsq $-0x388c46b188de83fe, %rax # imm = 0xC773B94E77217C02
cmpq %rax, (%r12)
jne 0x106f5f
movb $0x1, 0x29(%r14)
jmp 0x1073fc
movq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0xf7246
movq %rax, %r14
testq %rax, %rax
je 0x106f85
cmpb $0x0, 0x28(%r14)
je 0x106f85
movq 0x8(%rsp), %r14
jmp 0x1073fc
movl $0x38, %esi
leaq 0x10(%rsp), %rdi
callq 0xbe802
movq 0x8(%r12), %rax
movq %rax, 0x18(%rsp)
movl 0x10(%r12), %edi
movl %edi, 0x20(%rsp)
testq %r14, %r14
je 0x106fb1
movq (%r14), %rax
jmp 0x106fb3
xorl %eax, %eax
movq 0x8(%rsp), %r14
movq %rax, 0x28(%rsp)
movl 0x14(%r12), %eax
movl %eax, 0x24(%rsp)
leal -0x1(%rdi), %eax
cmpl $0xd, %eax
ja 0x107031
leaq 0x44613(%rip), %rcx     # 0x14b5e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r12), %r12
movq %r12, 0x10(%rsp)
jmp 0x10707e
movq $0x0, 0x10(%rsp)
jmp 0x10714d
movq (%r12), %rdi
movq 0x18(%r12), %rsi
callq 0xede20
jmp 0x107076
movq 0x18(%r12), %rdi
callq 0xede3e
jmp 0x107076
movq (%r12), %rdi
callq 0xede02
jmp 0x107076
movq (%r12), %rdi
movq 0x18(%r12), %rsi
callq 0xede2f
jmp 0x107076
callq 0xbf808
leaq 0x4493c(%rip), %rdi     # 0x14b979
leaq 0x44603(%rip), %rsi     # 0x14b647
movl $0x268, %edx            # imm = 0x268
leaq 0x44a74(%rip), %rcx     # 0x14bac4
movq %rax, %r8
xorl %eax, %eax
callq 0xbe592
movq 0x10(%rsp), %r12
jmp 0x10707e
movabsq $0x72d477d53e64ab9, %r12 # imm = 0x72D477D53E64AB9
jmp 0x10709e
movq (%r12), %rdi
callq 0xede11
movq %rax, %r12
movq %rax, 0x10(%rsp)
testq %r12, %r12
jne 0x1070a3
jmp 0x10714d
movabsq $-0x1f264e2c468e2e92, %r12 # imm = 0xE0D9B1D3B971D16E
jmp 0x10709e
movabsq $0x21249c2761f660b4, %r12 # imm = 0x21249C2761F660B4
movq %r12, 0x10(%rsp)
cmpq 0x8(%r14), %r12
jne 0x1070b3
movq %r14, 0x30(%rsp)
jmp 0x10714d
movl 0x9603f(%rip), %eax     # 0x19d0f8
cltq
leaq (%rax,%rax,2), %rax
leaq 0x96032(%rip), %rdx     # 0x19d0f8
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x107113
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x107113
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x107113
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x10711c
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x107143
movabsq $0x541d0401d4dcff33, %rdi # imm = 0x541D0401D4DCFF33
movq %r12, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x95fc0(%rip), %rdi     # 0x19d0f8
movq %r12, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r14, 0x30(%rsp)
movq 0x8(%rsp), %r14
xorl %eax, %eax
callq 0xd6618
movq %rax, %r12
movq 0x18(%rsp), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x415aa(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
movq %r12, %rdi
leaq 0x44960(%rip), %rsi     # 0x14bad9
movq %rax, %rdx
xorl %eax, %eax
callq 0x10a03d
movq 0x8(%rax), %rax
movabsq $-0x509c42b379fe4821, %rdx # imm = 0xAF63BD4C8601B7DF
testq %rax, %rax
je 0x1071c9
movb (%rax), %cl
movabsq $-0x340d631b7bdddcdb, %rdx # imm = 0xCBF29CE484222325
testb %cl, %cl
je 0x1071c9
incq %rax
movabsq $-0x340d631b7bdddcdb, %rsi # imm = 0xCBF29CE484222325
movzbl %cl, %edx
xorq %rsi, %rdx
imulq %rbx, %rdx
movb (%rax), %cl
incq %rax
movq %rdx, %rsi
testb %cl, %cl
jne 0x1071b3
movq %r13, %rdi
movabsq $-0x48eadf26356e3b8e, %rsi # imm = 0xB71520D9CA91C472
callq 0xc473a
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x41521(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
movq %r12, %rdi
leaq 0x448de(%rip), %rsi     # 0x14bae0
movq %rax, %rdx
xorl %eax, %eax
callq 0x10a03d
movq 0x8(%rax), %rax
movabsq $-0x509c42b379fe4821, %rdx # imm = 0xAF63BD4C8601B7DF
testq %rax, %rax
je 0x107252
movb (%rax), %cl
movabsq $-0x340d631b7bdddcdb, %rdx # imm = 0xCBF29CE484222325
testb %cl, %cl
je 0x107252
incq %rax
movabsq $-0x340d631b7bdddcdb, %rsi # imm = 0xCBF29CE484222325
movzbl %cl, %edx
xorq %rsi, %rdx
imulq %rbx, %rdx
movb (%rax), %cl
incq %rax
movq %rdx, %rsi
testb %cl, %cl
jne 0x10723c
movq %r13, %rdi
movabsq $0x4f0844d98f9ae3ee, %rsi # imm = 0x4F0844D98F9AE3EE
callq 0xc473a
movq %rax, 0x40(%rsp)
testb $0x2, 0x24(%rsp)
je 0x107392
cmpq $0x0, 0x38(%rsp)
jne 0x107307
movq 0x8(%r14), %rdi
callq 0xd6ec4
movq %rax, %r14
testq %rax, %rax
leaq 0x4147f(%rip), %rax     # 0x148715
cmoveq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0xd6ec4
movq %rax, %r13
testq %rax, %rax
leaq 0x41464(%rip), %rax     # 0x148715
cmoveq %rax, %r13
movq 0x18(%rsp), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x4144c(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
movq %rax, (%rsp)
leaq 0x446a1(%rip), %rdi     # 0x14b979
leaq 0x44368(%rip), %rsi     # 0x14b647
movl $0x280, %edx            # imm = 0x280
leaq 0x447fc(%rip), %rcx     # 0x14bae7
movq %r14, %r8
movq 0x8(%rsp), %r14
movq %r13, %r9
movq 0x48(%rsp), %r13
xorl %eax, %eax
callq 0xbe592
movq 0x40(%rsp), %rax
testq %rax, %rax
jne 0x107392
movq 0x8(%r14), %rdi
callq 0xd6ec4
movq %rax, %r14
testq %rax, %rax
leaq 0x413ef(%rip), %rax     # 0x148715
cmoveq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0xd6ec4
movq %rax, %r13
testq %rax, %rax
leaq 0x413d4(%rip), %rax     # 0x148715
cmoveq %rax, %r13
movq 0x18(%rsp), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x413bc(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
movq %rax, (%rsp)
leaq 0x44611(%rip), %rdi     # 0x14b979
leaq 0x442d8(%rip), %rsi     # 0x14b647
movl $0x281, %edx            # imm = 0x281
leaq 0x447a1(%rip), %rcx     # 0x14bb1c
movq %r14, %r8
movq 0x8(%rsp), %r14
movq %r13, %r9
movq 0x48(%rsp), %r13
xorl %eax, %eax
callq 0xbe592
movq %r12, %rdi
callq 0xd6647
movq 0x30(%r14), %rax
cmpq 0x50(%rsp), %r15
jne 0x1073ce
leaq (%r15,%r15), %rcx
testq %r15, %r15
movl $0x1, %edx
cmoveq %rdx, %rcx
movl $0x38, %edi
movq %rax, %rsi
movq %r15, %rdx
leaq 0x50(%rsp), %r8
callq 0xbe7da
movq %rax, 0x30(%r14)
imulq $0x38, %r15, %rcx
incq %r15
movq 0x40(%rsp), %rdx
movq %rdx, 0x30(%rax,%rcx)
movups 0x10(%rsp), %xmm0
movups 0x20(%rsp), %xmm1
movups 0x30(%rsp), %xmm2
movups %xmm2, 0x20(%rax,%rcx)
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %rbp
cmpq 0x60(%rsp), %rbp
jne 0x106f28
movq %r15, 0x20(%r14)
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq