// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %rsi
movq %rbx, %rdi
callq 0xc8366
cmpb $0x1, 0x28(%r14)
movq %rbx, (%rsp)
jne 0x104cbf
movq 0x8(%r14), %rax
movq %rax, (%rbx)
movl $0x1, %ebp
jmp 0x104cc1
xorl %ebp, %ebp
movq 0x10(%r14), %rax
cmpq 0x8(%rax), %rbp
jae 0x10530f
movq (%rax), %rax
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
shlq $0x4, %rdx
movq 0x18(%rax,%rdx), %rbx
movl 0x10(%rbx), %edi
leal -0x1(%rdi), %esi
cmpl $0xc, %esi
ja 0x104e97
leaq (%rax,%rdx), %rcx
movq (%rax,%rdx), %r13
addq (%rsp), %r13
leaq 0x503d4(%rip), %rdx     # 0x1550dc
movslq (%rdx,%rsi,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %rbp
jmp 0x104cc1
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x104d11
movl 0xa4743(%rip), %eax     # 0x1a9468
cltq
leaq (%rax,%rax,2), %rax
leaq 0xa4736(%rip), %rdx     # 0x1a9468
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %r15, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x104d83
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x104d83
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x104d83
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x105246
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x104db3
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0xa46c0(%rip), %rdi     # 0x1a9468
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r12, %rdi
callq *0xa8(%r12)
jmp 0x105050
movq 0x20(%rcx), %r15
cmpb $0x0, 0x29(%r15)
jne 0x104d11
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0x104d11
movq 0x18(%r15), %r12
movq %r15, %rdi
movq %r13, %rsi
callq *0x80(%r15)
addq %r12, %r13
decq %rbx
jne 0x104de3
jmp 0x104d11
movq 0x20(%rcx), %rdi
cmpb $0x0, 0x29(%rdi)
jne 0x104e10
movq %r13, %rsi
callq *0x80(%rdi)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x104d11
movq (%rbx), %rax
movabsq $-0x3f1363e6d8155aee, %rcx # imm = 0xC0EC9C1927EAA512
cmpq %rcx, %rax
jle 0x104f7c
movabsq $0x585a3b17ca3de1ff, %rcx # imm = 0x585A3B17CA3DE1FF
cmpq %rcx, %rax
jg 0x105059
movabsq $-0x84b14e74a9e1ff1, %rcx # imm = 0xF7B4EB18B561E00F
cmpq %rcx, %rax
jle 0x1051e5
movabsq $-0x84b14e74a9e1ff0, %rcx # imm = 0xF7B4EB18B561E010
cmpq %rcx, %rax
je 0x10525b
movabsq $0x47b8ff5cd069fea1, %rcx # imm = 0x47B8FF5CD069FEA1
cmpq %rcx, %rax
je 0x105234
movabsq $0x510c2417c67dabeb, %rcx # imm = 0x510C2417C67DABEB
cmpq %rcx, %rax
je 0x10523d
jmp 0x105265
callq 0xc9380
leaq 0x508d1(%rip), %rdi     # 0x155774
leaq 0x502ec(%rip), %rsi     # 0x155196
movl $0x155, %edx            # imm = 0x155
leaq 0x50933(%rip), %rcx     # 0x1557e9
movq %rax, %r8
xorl %eax, %eax
callq 0xc825d
jmp 0x104d11
testb $0x8, 0x15(%rbx)
je 0x104fe6
movq (%rbx), %r15
testq %r15, %r15
je 0x104fe0
movl 0xa4587(%rip), %eax     # 0x1a9468
cltq
leaq (%rax,%rax,2), %rax
leaq 0xa457a(%rip), %rdx     # 0x1a9468
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %r15, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x104f3f
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x104f3f
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x104f3f
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x105299
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x104f6f
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0xa4504(%rip), %rdi     # 0x1a9468
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r12, %rdi
callq *0xa8(%r12)
jmp 0x104fe2
movabsq $-0x5aa4411ac4e2880f, %rcx # imm = 0xA55BBEE53B1D77F1
cmpq %rcx, %rax
jle 0x10513b
movabsq $-0x503db0e6e1c2e705, %rcx # imm = 0xAFC24F191E3D18FB
cmpq %rcx, %rax
jle 0x1051b0
movabsq $-0x503db0e6e1c2e704, %rcx # imm = 0xAFC24F191E3D18FC
cmpq %rcx, %rax
je 0x10524e
movabsq $-0x4db4989f9014f113, %rcx # imm = 0xB24B67606FEB0EED
cmpq %rcx, %rax
je 0x105234
movabsq $-0x4882601bdca6aefb, %rcx # imm = 0xB77D9FE423595105
cmpq %rcx, %rax
je 0x105234
jmp 0x105265
xorl %eax, %eax
movq %rax, (%r13)
movq 0x18(%rbx), %rsi
movzwl 0x14(%rbx), %eax
testq %rsi, %rsi
je 0x10503c
movq (%rbx), %rdi
testb $0x8, %al
jne 0x10504b
movabsq $-0x503db0e6e1c2e704, %rax # imm = 0xAFC24F191E3D18FC
cmpq %rax, %rdi
jne 0x1050ff
cmpq $0x0, (%r13)
jne 0x10501f
xorl %eax, %eax
callq 0x114bbb
movq %rax, (%r13)
movq (%r13), %r15
movq 0x18(%rbx), %rdi
callq 0x133fe6
movq %r15, %rdi
movq %rax, %rsi
callq 0x114440
jmp 0x104d11
testb $0x8, %al
je 0x104d11
movq (%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0xf3f85
movq %rax, (%r13)
jmp 0x104d11
movabsq $0x69849117d3eb7d61, %rcx # imm = 0x69849117D3EB7D61
cmpq %rcx, %rax
jle 0x10520d
movabsq $0x69849117d3eb7d62, %rcx # imm = 0x69849117D3EB7D62
cmpq %rcx, %rax
je 0x105170
movabsq $0x6d07f9ef5b68e8a2, %rcx # imm = 0x6D07F9EF5B68E8A2
cmpq %rcx, %rax
je 0x105234
movabsq $0x6db6f178cd6db4b8, %rcx # imm = 0x6DB6F178CD6DB4B8
cmpq %rcx, %rax
jne 0x105265
callq 0xd103c
movq %rax, %r15
testq %rax, %rax
jne 0x105306
movq 0x8(%r14), %rdi
callq 0xe0cbc
movq %rax, %r12
testq %rax, %rax
leaq 0x4e623(%rip), %rax     # 0x1536ef
cmoveq %rax, %r12
movq 0x18(%rbx), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x4e60c(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
leaq 0x50686(%rip), %rdi     # 0x155774
leaq 0x500a1(%rip), %rsi     # 0x155196
movl $0xe6, %edx
jmp 0x1052f2
callq 0xe0cbc
testq %rax, %rax
leaq 0x4e5e1(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
leaq 0x5065b(%rip), %rdi     # 0x155774
leaq 0x50076(%rip), %rsi     # 0x155196
movl $0x120, %edx            # imm = 0x120
leaq 0x50693(%rip), %rcx     # 0x1557bf
movq %rax, %r8
xorl %eax, %eax
callq 0xc80f6
jmp 0x104d11
movabsq $-0x6119581ac7eacd64, %rcx # imm = 0x9EE6A7E53815329C
cmpq %rcx, %rax
jg 0x10517a
movabsq $-0x73f6ae1ad309fd45, %rcx # imm = 0x8C0951E52CF602BB
cmpq %rcx, %rax
je 0x10522b
movabsq $-0x6bce971ace902370, %rcx # imm = 0x943168E5316FDC90
cmpq %rcx, %rax
jne 0x105265
movw %di, (%r13)
jmp 0x104d11
movabsq $-0x6119581ac7eacd63, %rcx # imm = 0x9EE6A7E53815329D
cmpq %rcx, %rax
je 0x10523d
movabsq $-0x5fc2af85f419929b, %rcx # imm = 0xA03D507A0BE66D65
cmpq %rcx, %rax
jne 0x105265
movsd 0x18(%rbx), %xmm0
movsd %xmm0, (%r13)
jmp 0x104d11
movabsq $-0x5aa4411ac4e2880e, %rcx # imm = 0xA55BBEE53B1D77F2
cmpq %rcx, %rax
je 0x105234
movabsq $-0x58737885f0577326, %rcx # imm = 0xA78C877A0FA88CDA
cmpq %rcx, %rax
jne 0x105265
xorps %xmm0, %xmm0
cvtsd2ss 0x18(%rbx), %xmm0
movss %xmm0, (%r13)
jmp 0x104d11
movabsq $-0x3f1363e6d8155aed, %rcx # imm = 0xC0EC9C1927EAA513
cmpq %rcx, %rax
je 0x105234
movabsq $-0x3ac242643d9c35a8, %rcx # imm = 0xC53DBD9BC263CA58
cmpq %rcx, %rax
jne 0x105265
movb $0x1, (%r13)
jmp 0x104d11
movabsq $0x585a3b17ca3de200, %rcx # imm = 0x585A3B17CA3DE200
cmpq %rcx, %rax
je 0x105234
movabsq $0x62367a17d02b474d, %rcx # imm = 0x62367A17D02B474D
cmpq %rcx, %rax
jne 0x105265
movb %dil, (%r13)
jmp 0x104d11
movq %rdi, (%r13)
jmp 0x104d11
movl %edi, (%r13)
jmp 0x104d11
xorl %r12d, %r12d
jmp 0x104d87
callq 0x133fe6
movq %r13, %rdi
jmp 0x10502f
callq 0x133fa6
jmp 0x105050
testb $0x1, 0x15(%rbx)
jne 0x1052a1
movq %rax, %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x4e472(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
leaq 0x504ec(%rip), %rdi     # 0x155774
leaq 0x4ff07(%rip), %rsi     # 0x155196
movl $0xf9, %edx
jmp 0x105125
xorl %r12d, %r12d
jmp 0x104f43
callq 0xd103c
movq %rax, %r15
testq %rax, %rax
jne 0x105306
movq 0x8(%r14), %rdi
callq 0xe0cbc
movq %rax, %r12
testq %rax, %rax
leaq 0x4e42b(%rip), %rax     # 0x1536ef
cmoveq %rax, %r12
movq 0x18(%rbx), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x4e414(%rip), %rcx     # 0x1536ef
cmoveq %rcx, %rax
leaq 0x5048e(%rip), %rdi     # 0x155774
leaq 0x4fea9(%rip), %rsi     # 0x155196
movl $0xf3, %edx
leaq 0x50488(%rip), %rcx     # 0x155781
movq %r12, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc825d
movq %r15, (%r13)
jmp 0x104d11
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq