// File: /workspace/github_c_makefile_star2_O1/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, %rbx
leaq 0x4036b(%rip), %rdi     # 0x151f0a
callq 0xe1270
testq %rax, %rax
je 0x111c50
movq %rax, %r14
leaq 0x978b1(%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 %r14, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r14, %rdx
je 0x111c11
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x111c11
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x111c11
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x112302
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0x111c41
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r14, %rsi
callq 0xf3f85
movq %rax, %r15
leaq 0x97832(%rip), %rdi     # 0x1a9468
movq %r14, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r15, %rdi
callq *0xa8(%r15)
movq %rax, %r14
jmp 0x111c53
xorl %r14d, %r14d
movabsq $0x541d0401d4dcff33, %rax # imm = 0x541D0401D4DCFF33
movq %rax, (%r14)
movq 0x8(%rbx), %rdi
movq %rdi, 0x8(%r14)
callq 0xe4075
movb %al, 0x28(%r14)
movq 0x8(%rbx), %r15
leaq 0x977ec(%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 %r15, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x111cd6
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x111cd6
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x111cd6
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x1122f2
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x111d06
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0x9776d(%rip), %rdi     # 0x1a9468
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r12, 0x60(%rsp)
movq %r12, 0x10(%r14)
movq 0x8(%rbx), %r15
leaq 0x92f96(%rip), %rax     # 0x1a4cb0
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 0x111d74
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x111d74
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x111d74
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x1122fa
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x111da4
movabsq $-0x220988275314685e, %rdi # imm = 0xDDF677D8ACEB97A2
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r13
leaq 0x92f17(%rip), %rdi     # 0x1a4cb0
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r13, 0x18(%r14)
xorl %eax, %eax
movq %rax, 0x30(%r14)
movq $0x0, 0x10(%rsp)
movq %rax, 0x58(%rsp)
movq %rbx, %rdi
callq 0xcd3df
testq %rax, %rax
je 0x1122d7
movq %rax, %r12
movabsq $0x100000001b3, %r13    # imm = 0x100000001B3
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movq %r14, 0x50(%rsp)
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xcd3f0
testb $0x14, 0x14(%rax)
jne 0x1122c1
movq %rax, %rbp
testq %r15, %r15
jne 0x111e27
movabsq $-0x388c46b188de83fe, %rax # imm = 0xC773B94E77217C02
cmpq %rax, (%rbp)
jne 0x111e27
movb $0x1, 0x29(%r14)
jmp 0x1122c1
movq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0x1019ea
movq %rax, %r12
testq %rax, %rax
je 0x111e4e
cmpb $0x0, 0x28(%r12)
je 0x111e4e
movq 0x8(%rsp), %r12
jmp 0x1122c1
movl $0x38, %esi
leaq 0x18(%rsp), %rdi
callq 0xc8366
movq 0x8(%rbp), %rax
movq %rax, 0x20(%rsp)
movl 0x10(%rbp), %edi
movl %edi, 0x28(%rsp)
testq %r12, %r12
je 0x111e78
movq (%r12), %rax
jmp 0x111e7a
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movl 0x14(%rbp), %eax
movl %eax, 0x2c(%rsp)
leal -0x1(%rdi), %eax
cmpl $0xd, %eax
movq 0x8(%rsp), %r12
ja 0x111eee
leaq 0x44726(%rip), %rcx     # 0x1565c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbp), %rax
jmp 0x111f46
movq $0x0, 0x18(%rsp)
jmp 0x111f4b
movq (%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0xf834e
jmp 0x111f46
movq 0x18(%rbp), %rdi
callq 0xf836c
jmp 0x111f46
movq (%rbp), %rdi
callq 0xf8330
jmp 0x111f46
movq (%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0xf835d
jmp 0x111f46
callq 0xc9380
leaq 0x44a57(%rip), %rdi     # 0x156951
leaq 0x4471e(%rip), %rsi     # 0x15661f
movl $0x268, %edx            # imm = 0x268
leaq 0x44b8f(%rip), %rcx     # 0x156a9c
movq %rax, %r8
xorl %eax, %eax
callq 0xc80f6
jmp 0x111f4b
movabsq $0x72d477d53e64ab9, %rax # imm = 0x72D477D53E64AB9
jmp 0x111f46
movq (%rbp), %rdi
callq 0xf833f
jmp 0x111f46
movabsq $-0x1f264e2c468e2e92, %rax # imm = 0xE0D9B1D3B971D16E
jmp 0x111f46
movabsq $0x21249c2761f660b4, %rax # imm = 0x21249C2761F660B4
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rbp
testq %rbp, %rbp
je 0x112007
cmpq 0x8(%r14), %rbp
jne 0x111f69
movq %r14, 0x38(%rsp)
jmp 0x112007
movl 0x98189(%rip), %eax     # 0x1aa0f8
cltq
leaq (%rax,%rax,2), %rax
leaq 0x9817c(%rip), %rdx     # 0x1aa0f8
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x111fcd
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x111fcd
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x111fcd
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x1122cf
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x111ffd
movabsq $0x541d0401d4dcff33, %rdi # imm = 0x541D0401D4DCFF33
movq %rbp, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0x98106(%rip), %rdi     # 0x1aa0f8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r12, 0x38(%rsp)
movq 0x8(%rsp), %r12
xorl %eax, %eax
callq 0xe03d4
movq %rax, %rbp
movq 0x20(%rsp), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x416ca(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
movq %rbp, %rdi
leaq 0x44a7e(%rip), %rsi     # 0x156ab1
movq %rax, %rdx
xorl %eax, %eax
callq 0x114f76
movq 0x8(%rax), %rax
movabsq $-0x509c42b379fe4821, %rdx # imm = 0xAF63BD4C8601B7DF
testq %rax, %rax
je 0x112083
movb (%rax), %cl
movabsq $-0x340d631b7bdddcdb, %rdx # imm = 0xCBF29CE484222325
testb %cl, %cl
je 0x112083
incq %rax
movabsq $-0x340d631b7bdddcdb, %rsi # imm = 0xCBF29CE484222325
movzbl %cl, %edx
xorq %rsi, %rdx
imulq %r13, %rdx
movb (%rax), %cl
incq %rax
movq %rdx, %rsi
testb %cl, %cl
jne 0x11206d
movq %rbx, %rdi
movabsq $-0x48eadf26356e3b8e, %rsi # imm = 0xB71520D9CA91C472
callq 0xce882
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x41641(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
movq %rbp, %rdi
leaq 0x449fc(%rip), %rsi     # 0x156ab8
movq %rax, %rdx
xorl %eax, %eax
callq 0x114f76
movq 0x8(%rax), %rax
movabsq $-0x509c42b379fe4821, %rdx # imm = 0xAF63BD4C8601B7DF
testq %rax, %rax
je 0x11210c
movb (%rax), %cl
movabsq $-0x340d631b7bdddcdb, %rdx # imm = 0xCBF29CE484222325
testb %cl, %cl
je 0x11210c
incq %rax
movabsq $-0x340d631b7bdddcdb, %rsi # imm = 0xCBF29CE484222325
movzbl %cl, %edx
xorq %rsi, %rdx
imulq %r13, %rdx
movb (%rax), %cl
incq %rax
movq %rdx, %rsi
testb %cl, %cl
jne 0x1120f6
movq %rbx, %rdi
movabsq $0x4f0844d98f9ae3ee, %rsi # imm = 0x4F0844D98F9AE3EE
callq 0xce882
movq %rax, 0x48(%rsp)
testb $0x2, 0x2c(%rsp)
je 0x11224a
cmpq $0x0, 0x40(%rsp)
jne 0x1121bc
movq 0x8(%r14), %rdi
callq 0xe0cbc
movq %rax, %r12
testq %rax, %rax
leaq 0x4159f(%rip), %rax     # 0x1536ef
cmoveq %rax, %r12
movq 0x20(%rsp), %rdi
callq 0xe0cbc
movq %rax, %r14
testq %rax, %rax
leaq 0x41584(%rip), %rax     # 0x1536ef
cmoveq %rax, %r14
movq 0x20(%rsp), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x4156c(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
movq %rax, (%rsp)
leaq 0x447bf(%rip), %rdi     # 0x156951
leaq 0x44486(%rip), %rsi     # 0x15661f
movl $0x280, %edx            # imm = 0x280
leaq 0x4491a(%rip), %rcx     # 0x156abf
movq %r12, %r8
movq 0x8(%rsp), %r12
movq %r14, %r9
movq 0x50(%rsp), %r14
xorl %eax, %eax
callq 0xc80f6
cmpq $0x0, 0x48(%rsp)
jne 0x11224a
movq 0x8(%r14), %rdi
callq 0xe0cbc
movq %rax, %r14
testq %rax, %rax
leaq 0x41511(%rip), %rax     # 0x1536ef
cmoveq %rax, %r14
movq 0x20(%rsp), %rdi
callq 0xe0cbc
movq %rax, %r12
testq %rax, %rax
leaq 0x414f6(%rip), %rax     # 0x1536ef
cmoveq %rax, %r12
movq 0x20(%rsp), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x414de(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
movq %rax, (%rsp)
leaq 0x44731(%rip), %rdi     # 0x156951
leaq 0x443f8(%rip), %rsi     # 0x15661f
movl $0x281, %edx            # imm = 0x281
leaq 0x448c1(%rip), %rcx     # 0x156af4
movq %r14, %r8
movq 0x50(%rsp), %r14
movq %r12, %r9
movq 0x8(%rsp), %r12
xorl %eax, %eax
callq 0xc80f6
movq %rbp, %rdi
callq 0xe0403
movq 0x58(%rsp), %rdx
cmpq %rdx, 0x10(%rsp)
jne 0x112285
movq 0x30(%r14), %rsi
leaq (%rdx,%rdx), %rcx
testq %rdx, %rdx
movl $0x1, %eax
cmoveq %rax, %rcx
movl $0x38, %edi
leaq 0x58(%rsp), %r8
callq 0xc833e
movq %rax, 0x30(%r14)
movq 0x30(%r14), %rax
movq 0x10(%rsp), %rdx
imulq $0x38, %rdx, %rcx
incq %rdx
movq %rdx, 0x10(%rsp)
movq 0x48(%rsp), %rdx
movq %rdx, 0x30(%rax,%rcx)
movups 0x18(%rsp), %xmm0
movups 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
movups %xmm2, 0x20(%rax,%rcx)
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %r15
cmpq %r12, %r15
jne 0x111df0
jmp 0x1122d7
xorl %r12d, %r12d
jmp 0x111fd1
movq 0x10(%rsp), %rax
movq %rax, 0x20(%r14)
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x111cda
xorl %r13d, %r13d
jmp 0x111d78
xorl %r15d, %r15d
jmp 0x111c15
nop