// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
leaq 0x581d1(%rip), %rdi     # 0x1512d7
callq 0xf8d30
movq %rax, %rdi
callq 0xfa5a0
movq %rax, -0x10(%rbp)
leaq 0x581b9(%rip), %rdi     # 0x1512d7
callq 0xf8a60
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xc2a90
movb %al, %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xf6c70
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xfa5e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa54f0
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xf96aa
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa5530
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x2, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xf91f8
jmp 0xf9699
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x4, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xf9215
jmp 0xf9699
cmpq $0x0, -0x38(%rbp)
jne 0xf923c
movq -0x40(%rbp), %rax
movabsq $-0x388c46b188de83fe, %rcx # imm = 0xC773B94E77217C02
cmpq %rcx, (%rax)
jne 0xf923c
movq -0x10(%rbp), %rax
movb $0x1, 0x29(%rax)
jmp 0xf9699
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xe4e10
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xf9263
movq -0x48(%rbp), %rax
testb $0x1, 0x28(%rax)
je 0xf9263
jmp 0xf9699
leaq -0x80(%rbp), %rdi
movl $0x38, %esi
callq 0x9d4f0
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x70(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xf929e
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0xf92a9
xorl %eax, %eax
movq %rax, -0x90(%rbp)
jmp 0xf92a9
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x70(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x98(%rbp)
subl $0xd, %eax
ja 0xf93bb
movq -0x98(%rbp), %rax
leaq 0x5c7dd(%rip), %rcx     # 0x155ac0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0xf93e7
movq $0x0, -0x80(%rbp)
jmp 0xf93e7
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0xd7b90
movq %rax, -0x80(%rbp)
jmp 0xf93e7
leaq 0x55090(%rip), %rdi     # 0x14e3b5
callq 0xf8a60
movq %rax, -0x80(%rbp)
jmp 0xf93e7
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0xd7bc0
movq %rax, -0x80(%rbp)
jmp 0xf93e7
leaq 0x550a2(%rip), %rdi     # 0x14e3f1
callq 0xf8a60
movq %rax, -0x80(%rbp)
jmp 0xf93e7
leaq 0x550aa(%rip), %rdi     # 0x14e40e
callq 0xf8a60
movq %rax, -0x80(%rbp)
jmp 0xf93e7
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xd7bf0
movq %rax, -0x80(%rbp)
jmp 0xf93e7
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xd7c20
movq %rax, -0x80(%rbp)
jmp 0xf93e7
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xd7c50
movq %rax, -0x80(%rbp)
jmp 0xf93e7
jmp 0xf9699
movl -0x70(%rbp), %edi
callq 0xa0650
movq %rax, %r8
leaq 0x5cac2(%rip), %rdi     # 0x155e8f
leaq 0x5c74b(%rip), %rsi     # 0x155b1f
movl $0x268, %edx            # imm = 0x268
leaq 0x5cbdd(%rip), %rcx     # 0x155fbd
movb $0x0, %al
callq 0x9cf40
cmpq $0x0, -0x80(%rbp)
je 0xf9415
movq -0x80(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xf9406
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0xf9413
movq -0x80(%rbp), %rdi
callq 0xfa280
movq %rax, -0x60(%rbp)
jmp 0xf9415
movb $0x0, %al
callq 0xbfdd0
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq 0x54962(%rip), %rdi     # 0x14dd97
callq 0xf8a60
movq %rax, -0xb8(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq -0xc8(%rbp), %rdi
movq %rax, %rdx
leaq 0x5cb69(%rip), %rsi     # 0x155fd2
movb $0x0, %al
callq 0xff630
movq 0x8(%rax), %rdi
callq 0xf8a60
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq %rax, %rdx
callq 0xa6a30
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq 0x548e5(%rip), %rdi     # 0x14dd8a
callq 0xf8a60
movq %rax, -0xa0(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
leaq 0x5cb00(%rip), %rsi     # 0x155fd9
movb $0x0, %al
callq 0xff630
movq 0x8(%rax), %rdi
callq 0xf8a60
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq %rax, %rdx
callq 0xa6a30
movq %rax, -0x50(%rbp)
movw -0x6c(%rbp), %ax
shrw %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xf95ea
cmpq $0x0, -0x58(%rbp)
jne 0xf9581
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xf6ce0
movq %rax, -0xd8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq %rax, -0xd0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq -0xd8(%rbp), %r8
movq -0xd0(%rbp), %r9
leaq 0x5c92c(%rip), %rdi     # 0x155e8f
leaq 0x5c5b5(%rip), %rsi     # 0x155b1f
movl $0x280, %edx            # imm = 0x280
leaq 0x5ca6a(%rip), %rcx     # 0x155fe0
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9cf40
cmpq $0x0, -0x50(%rbp)
jne 0xf95e8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xf6ce0
movq %rax, -0xe8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xf6ce0
movq -0xe8(%rbp), %r8
movq -0xe0(%rbp), %r9
leaq 0x5c8c5(%rip), %rdi     # 0x155e8f
leaq 0x5c54e(%rip), %rsi     # 0x155b1f
movl $0x281, %edx            # imm = 0x281
leaq 0x5ca38(%rip), %rcx     # 0x156015
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9cf40
jmp 0xf95ea
movq -0x88(%rbp), %rdi
callq 0xbfe00
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0xf966d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xf8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0x28(%rbp)
jbe 0xf9631
movq -0x28(%rbp), %rax
shlq %rax
movq %rax, -0x100(%rbp)
jmp 0xf963f
movl $0x1, %eax
movq %rax, -0x100(%rbp)
jmp 0xf963f
movq -0xf0(%rbp), %rdx
movq -0xf8(%rbp), %rsi
movq -0x100(%rbp), %rcx
movl $0x38, %edi
leaq -0x28(%rbp), %r8
callq 0x9d370
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
imulq $0x38, %rax, %rax
addq %rax, %rdi
leaq -0x80(%rbp), %rsi
movl $0x38, %edx
callq 0x4450
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xf91bc
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)