// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_spect_inst.c
// Function: init_generic
static void init_generic( const bcore_inst_s* p, vd_t o )
{
    assert( o != NULL );
    bcore_memzero( o, p->size );
    uz_t first = 0;
    if( p->aware )
    {
        *( aware_t* )o = p->header.o_type;
        first = 1;
    }
    for( uz_t i = first; i < p->body->size; i++ )
    {
        const bcore_inst_item_s* inst_item = &p->body->data[ i ];
        const bcore_self_item_s* self_item = inst_item->self_item;
        vd_t dst_obj = ( u0_t* )o + inst_item->offset;

        switch( self_item->caps )
        {
            case BCORE_CAPS_SOLID_STATIC:
            {
                const bcore_inst_s* inst_p = inst_item->inst_p;
                if( !inst_p->init_flat ) inst_p->init( inst_p, dst_obj );
                if( self_item->default_u3 )
                {
                    switch( self_item->type )
                    {
                        case TYPEOF_u0_t: *( u0_t* )dst_obj = self_item->default_u3; break;
                        case TYPEOF_u1_t: *( u1_t* )dst_obj = self_item->default_u3; break;
                        case TYPEOF_u2_t: *( u2_t* )dst_obj = self_item->default_u3; break;
                        case TYPEOF_u3_t: *( u3_t* )dst_obj = self_item->default_u3; break;
                        case TYPEOF_s0_t: *( s0_t* )dst_obj = self_item->default_s3; break;
                        case TYPEOF_s1_t: *( s1_t* )dst_obj = self_item->default_s3; break;
                        case TYPEOF_s2_t: *( s2_t* )dst_obj = self_item->default_s3; break;
                        case TYPEOF_s3_t: *( s3_t* )dst_obj = self_item->default_s3; break;
                        case TYPEOF_f2_t: *( f2_t* )dst_obj = self_item->default_f3; break;
                        case TYPEOF_f3_t: *( f3_t* )dst_obj = self_item->default_f3; break;
                        case TYPEOF_sz_t: *( sz_t* )dst_obj = self_item->default_sz; break;
                        case TYPEOF_uz_t: *( uz_t* )dst_obj = self_item->default_uz; break;
                        case TYPEOF_tp_t: *( tp_t* )dst_obj = self_item->default_tp; break;
                        case TYPEOF_er_t: *( er_t* )dst_obj = self_item->default_tp; break;
                        case TYPEOF_bl_t: *( bl_t* )dst_obj = self_item->default_bl; break;
                        case TYPEOF_offset_t: *( offset_t* )dst_obj = self_item->default_uz; break;
                        case TYPEOF_sc_t: *( sc_t* )dst_obj = bcore_const_string_get_sc( self_item->default_tp ); break;
                        case TYPEOF_st_s: st_s_copy( ( st_s* )dst_obj, bcore_const_string_get_st( self_item->default_tp ) ); break;

                        case TYPEOF_fp_t: // expect a function registered in function_manager
                        {
                            fp_t fp = bcore_function_get( self_item->default_tp );
                            if( !fp )
                            {
                                ERR_fa( "Initializing '#<sc_t>': Default function '#<sc_t>' not found.", ifnameof( p->header.o_type ), ifnameof( self_item->default_tp ) );
                            }
                            *( fp_t* )dst_obj = fp;
                        }
                        break;

                        default:
                        {
                            if( self_item->flags.f_fp ) // expect a function registered in function_manager
                            {
                                fp_t fp = bcore_function_get( self_item->default_tp );
                                if( !fp )
                                {
                                    ERR_fa( "Initializing '#<sc_t>': Default function '#<sc_t>' not found.", ifnameof( p->header.o_type ), ifnameof( self_item->default_tp ) );
                                }
                                *( fp_t* )dst_obj = fp;
                            }
                            else
                            {
                                ERR( "Default value not supported for type '%s'", ifnameof( self_item->type ) );
                            }
                        }
                        break;

                    }
                }
            }
            break;

            case BCORE_CAPS_LINK_STATIC:
            {
                if( self_item->flags.f_create_on_init )
                {
                    assert( !self_item->flags.f_spect );
                    bcore_inst** p_inst = ( bcore_inst** )dst_obj;
                    *p_inst = bcore_inst_t_create( self_item->type );
                }

                if( self_item->default_u3 )
                {
                    if( self_item->flags.f_spect )
                    {
                        *( vc_t* )dst_obj = bcore_spect_get_typed( self_item->type, self_item->default_tp );
                    }
                    else
                    {
                        switch( self_item->type )
                        {
                            case TYPEOF_st_s:
                            {
                                st_s** p_st = ( st_s** )dst_obj;
                                if( !*p_st ) *p_st = st_s_create();
                                st_s_copy( *p_st, bcore_const_string_get_st( self_item->default_tp ) );
                            }
                            break;

                            default:
                            {
                                ERR( "Default value not supported for type '%s'", ifnameof( self_item->type ) );
                            }
                            break;
                        }
                    }

                }
                else
                {
                    if( self_item->flags.f_spect )
                    {
                        *( vc_t* )dst_obj = bcore_spect_get_typed( self_item->type, p->header.o_type );
                    }
                }
            }
            break;

            // aware links can evaluate default types
            case BCORE_CAPS_LINK_AWARE:
            {
                if( self_item->default_tp ) *( vd_t* )dst_obj = bcore_inst_t_create( self_item->default_tp );
            }
            break;

            case BCORE_CAPS_ARRAY_FIX_SOLID_STATIC:
            {
                const bcore_inst_s* inst_p = inst_item->inst_p;
                if( !inst_p->init_flat )
                {
                    uz_t arr_size = bcore_inst_item_s_array_fix_size( inst_item );
                    uz_t element_size = inst_p->size;
                    for( uz_t i = 0; i < arr_size; i++ )
                    {
                        inst_p->init( inst_p, ( u0_t* )dst_obj + element_size * i );
                    }
                }
            }
            break;

            case BCORE_CAPS_LINK_TYPED:
            case BCORE_CAPS_POINTER:
            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_LINK_STATIC:
            case BCORE_CAPS_ARRAY_FIX_LINK_AWARE:
            break;

            default:
            {
                ERR_fa( "Unhandled nesting '#<sc_t>'", bcore_flect_caps_e_sc( self_item->caps ) );
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x9d4f0
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x28(%rax)
je 0xe799d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq $0x1, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jae 0xe818f
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x88(%rbp)
subl $0xc, %eax
ja 0xe814c
movq -0x88(%rbp), %rax
leaq 0x6ca68(%rip), %rcx     # 0x154488
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0x29(%rax)
jne 0xe7a54
movq -0x40(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq *%rax
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xe7f52
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movabsq $-0x73f6ae1ad309fd45, %rcx # imm = 0x8C0951E52CF602BB
subq %rcx, %rax
je 0xe7c81
jmp 0xe7a86
movq -0x90(%rbp), %rax
movabsq $-0x6bce971ace902370, %rcx # imm = 0x943168E5316FDC90
subq %rcx, %rax
je 0xe7c96
jmp 0xe7aa2
movq -0x90(%rbp), %rax
movabsq $-0x6119581ac7eacd63, %rcx # imm = 0x9EE6A7E53815329D
subq %rcx, %rax
je 0xe7cad
jmp 0xe7abe
movq -0x90(%rbp), %rax
movabsq $-0x5fc2af85f419929b, %rcx # imm = 0xA03D507A0BE66D65
subq %rcx, %rax
je 0xe7d45
jmp 0xe7ada
movq -0x90(%rbp), %rax
movabsq $-0x5aa4411ac4e2880e, %rcx # imm = 0xA55BBEE53B1D77F2
subq %rcx, %rax
je 0xe7cc2
jmp 0xe7af6
movq -0x90(%rbp), %rax
movabsq $-0x58737885f0577326, %rcx # imm = 0xA78C877A0FA88CDA
subq %rcx, %rax
je 0xe7d2b
jmp 0xe7b12
movq -0x90(%rbp), %rax
movabsq $-0x503db0e6e1c2e704, %rcx # imm = 0xAFC24F191E3D18FC
subq %rcx, %rax
je 0xe7df5
jmp 0xe7b2e
movq -0x90(%rbp), %rax
movabsq $-0x4db4989f9014f113, %rcx # imm = 0xB24B67606FEB0EED
subq %rcx, %rax
je 0xe7d97
jmp 0xe7b4a
movq -0x90(%rbp), %rax
movabsq $-0x4882601bdca6aefb, %rcx # imm = 0xB77D9FE423595105
subq %rcx, %rax
je 0xe7d6f
jmp 0xe7b66
movq -0x90(%rbp), %rax
movabsq $-0x3f1363e6d8155aed, %rcx # imm = 0xC0EC9C1927EAA513
subq %rcx, %rax
je 0xe7d5b
jmp 0xe7b82
movq -0x90(%rbp), %rax
movabsq $-0x3ac242643d9c35a8, %rcx # imm = 0xC53DBD9BC263CA58
subq %rcx, %rax
je 0xe7dab
jmp 0xe7b9e
movq -0x90(%rbp), %rax
movabsq $-0x84b14e74a9e1ff0, %rcx # imm = 0xF7B4EB18B561E010
subq %rcx, %rax
je 0xe7dd9
jmp 0xe7bba
movq -0x90(%rbp), %rax
movabsq $0x47b8ff5cd069fea1, %rcx # imm = 0x47B8FF5CD069FEA1
subq %rcx, %rax
je 0xe7dc5
jmp 0xe7bd6
movq -0x90(%rbp), %rax
movabsq $0x510c2417c67dabeb, %rcx # imm = 0x510C2417C67DABEB
subq %rcx, %rax
je 0xe7d02
jmp 0xe7bf2
movq -0x90(%rbp), %rax
movabsq $0x585a3b17ca3de200, %rcx # imm = 0x585A3B17CA3DE200
subq %rcx, %rax
je 0xe7d17
jmp 0xe7c0e
movq -0x90(%rbp), %rax
movabsq $0x62367a17d02b474d, %rcx # imm = 0x62367A17D02B474D
subq %rcx, %rax
je 0xe7cd6
jmp 0xe7c2a
movq -0x90(%rbp), %rax
movabsq $0x69849117d3eb7d62, %rcx # imm = 0x69849117D3EB7D62
subq %rcx, %rax
je 0xe7ceb
jmp 0xe7c46
movq -0x90(%rbp), %rax
movabsq $0x6d07f9ef5b68e8a2, %rcx # imm = 0x6D07F9EF5B68E8A2
subq %rcx, %rax
je 0xe7d83
jmp 0xe7c62
movq -0x90(%rbp), %rax
movabsq $0x6db6f178cd6db4b8, %rcx # imm = 0x6DB6F178CD6DB4B8
subq %rcx, %rax
je 0xe7e21
jmp 0xe7e95
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movsd 0x18(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
setne %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x12bab0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x12bb20
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0xfe850
jmp 0xe7f50
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xaa6d0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xe7e85
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xe7770
movq %rax, -0xa0(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xe7770
movq -0xa0(%rbp), %r8
movq %rax, %r9
leaq 0x6ccc6(%rip), %rdi     # 0x154b31
leaq 0x6c6d0(%rip), %rsi     # 0x154542
movl $0xe6, %edx
leaq 0x6ccc0(%rip), %rcx     # 0x154b3e
movb $0x0, %al
callq 0x9d0f0
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f50
movq -0x30(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x8, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xe7f1e
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xaa6d0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xe7f11
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xe7770
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xe7770
movq -0xa8(%rbp), %r8
movq %rax, %r9
leaq 0x6cc3a(%rip), %rdi     # 0x154b31
leaq 0x6c644(%rip), %rsi     # 0x154542
movl $0xf3, %edx
leaq 0x6cc34(%rip), %rcx     # 0x154b3e
movb $0x0, %al
callq 0x9d0f0
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe7f4e
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xe7770
movq %rax, %r8
leaq 0x6cbfd(%rip), %rdi     # 0x154b31
leaq 0x6c607(%rip), %rsi     # 0x154542
movl $0xf9, %edx
leaq 0x6cc35(%rip), %rcx     # 0x154b7c
movb $0x0, %al
callq 0x9cf40
jmp 0xe7f50
jmp 0xe7f52
jmp 0xe817c
movq -0x30(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0xb, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xe7f8d
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xee030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xe8072
movq -0x30(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x3, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xe7fd7
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xd1550
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe8070
movq -0x30(%rbp), %rax
movq (%rax), %rax
movabsq $-0x503db0e6e1c2e704, %rcx # imm = 0xAFC24F191E3D18FC
subq %rcx, %rax
jne 0xe803e
jmp 0xe7fef
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xe8012
movb $0x0, %al
callq 0xff2e0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x12bb20
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0xfe850
jmp 0xe806e
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xe7770
movq %rax, %r8
leaq 0x6cadd(%rip), %rdi     # 0x154b31
leaq 0x6c4e7(%rip), %rsi     # 0x154542
movl $0x120, %edx            # imm = 0x120
leaq 0x6cb15(%rip), %rcx     # 0x154b7c
movb $0x0, %al
callq 0x9cf40
jmp 0xe8070
jmp 0xe80aa
movq -0x30(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x3, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xe80a8
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0xd1550
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe80aa
jmp 0xe817c
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xe80d1
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xee030
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe817c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
testb $0x1, 0x29(%rax)
jne 0xe8148
movq -0x28(%rbp), %rdi
callq 0xee070
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0xe8146
movq -0x68(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x78(%rbp), %rcx
imulq -0x80(%rbp), %rcx
addq %rcx, %rsi
callq *%rax
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0xe810d
jmp 0xe8148
jmp 0xe817c
jmp 0xe817c
movq -0x30(%rbp), %rax
movl 0x10(%rax), %edi
callq 0xa0650
movq %rax, %r8
leaq 0x6c9cf(%rip), %rdi     # 0x154b31
leaq 0x6c3d9(%rip), %rsi     # 0x154542
movl $0x155, %edx            # imm = 0x155
leaq 0x6ca31(%rip), %rcx     # 0x154ba6
movb $0x0, %al
callq 0x9d0f0
jmp 0xe817e
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xe79a5
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)