// File: /workspace/github_c_makefile_star2_O3/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 0xbe802
cmpb $0x1, 0x28(%r14)
movq %rbx, (%rsp)
jne 0xfa3d7
movq 0x8(%r14), %rax
movq %rax, (%rbx)
movl $0x1, %ebp
jmp 0xfa3d9
xorl %ebp, %ebp
movq 0x10(%r14), %rax
cmpq 0x8(%rax), %rbp
jae 0xfaa00
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 0xfa5ab
leaq (%rax,%rdx), %rcx
movq (%rax,%rdx), %r13
addq (%rsp), %r13
leaq 0x4fce4(%rip), %rdx     # 0x14a104
movslq (%rdx,%rsi,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %rbp
jmp 0xfa3d9
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0xfa429
movl 0xa202b(%rip), %eax     # 0x19c468
cltq
leaq (%rax,%rax,2), %rax
leaq 0xa201e(%rip), %rdx     # 0x19c468
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 0xfa497
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0xfa497
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0xfa497
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0xfa4a0
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0xfa4c7
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0xa1fac(%rip), %rdi     # 0x19c468
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r12, %rdi
callq *0xa8(%r12)
jmp 0xfa75b
movq 0x20(%rcx), %r15
cmpb $0x0, 0x29(%r15)
jne 0xfa429
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
je 0xfa429
movq 0x18(%r15), %r12
movq %r15, %rdi
movq %r13, %rsi
callq *0x80(%r15)
addq %r12, %r13
decq %rbx
jne 0xfa4f7
jmp 0xfa429
movq 0x20(%rcx), %rdi
cmpb $0x0, 0x29(%rdi)
jne 0xfa524
movq %r13, %rsi
callq *0x80(%rdi)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xfa429
movq (%rbx), %rax
movabsq $-0x3f1363e6d8155aee, %rcx # imm = 0xC0EC9C1927EAA512
cmpq %rcx, %rax
jle 0xfa68c
movabsq $0x585a3b17ca3de1ff, %rcx # imm = 0x585A3B17CA3DE1FF
cmpq %rcx, %rax
jg 0xfa764
movabsq $-0x84b14e74a9e1ff1, %rcx # imm = 0xF7B4EB18B561E00F
cmpq %rcx, %rax
jle 0xfa8e6
movabsq $-0x84b14e74a9e1ff0, %rcx # imm = 0xF7B4EB18B561E010
cmpq %rcx, %rax
je 0xfa954
movabsq $0x47b8ff5cd069fea1, %rcx # imm = 0x47B8FF5CD069FEA1
cmpq %rcx, %rax
je 0xfa935
movabsq $0x510c2417c67dabeb, %rcx # imm = 0x510C2417C67DABEB
cmpq %rcx, %rax
je 0xfa93e
jmp 0xfa95e
callq 0xbf808
leaq 0x501e5(%rip), %rdi     # 0x14a79c
leaq 0x4fc00(%rip), %rsi     # 0x14a1be
movl $0x155, %edx            # imm = 0x155
leaq 0x50247(%rip), %rcx     # 0x14a811
movq %rax, %r8
xorl %eax, %eax
callq 0xbe6f9
jmp 0xfa429
testb $0x8, 0x15(%rbx)
je 0xfa6ed
movq (%rbx), %r15
testq %r15, %r15
je 0xfa6e7
movl 0xa1e73(%rip), %eax     # 0x19c468
cltq
leaq (%rax,%rax,2), %rax
leaq 0xa1e66(%rip), %rdx     # 0x19c468
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 0xfa64f
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0xfa64f
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0xfa64f
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0xfa658
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0xfa67f
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0xa1df4(%rip), %rdi     # 0x19c468
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r12, %rdi
callq *0xa8(%r12)
jmp 0xfa6e9
movabsq $-0x5aa4411ac4e2880f, %rcx # imm = 0xA55BBEE53B1D77F1
cmpq %rcx, %rax
jle 0xfa846
movabsq $-0x503db0e6e1c2e705, %rcx # imm = 0xAFC24F191E3D18FB
cmpq %rcx, %rax
jle 0xfa8b0
movabsq $-0x503db0e6e1c2e704, %rcx # imm = 0xAFC24F191E3D18FC
cmpq %rcx, %rax
je 0xfa947
movabsq $-0x4db4989f9014f113, %rcx # imm = 0xB24B67606FEB0EED
cmpq %rcx, %rax
je 0xfa935
movabsq $-0x4882601bdca6aefb, %rcx # imm = 0xB77D9FE423595105
jmp 0xfa8a2
xorl %eax, %eax
movq %rax, (%r13)
movq 0x18(%rbx), %rsi
movzwl 0x14(%rbx), %eax
testq %rsi, %rsi
je 0xfa747
movq (%rbx), %rdi
testb $0x8, %al
jne 0xfa756
movabsq $-0x503db0e6e1c2e704, %rax # imm = 0xAFC24F191E3D18FC
cmpq %rax, %rdi
jne 0xfa80a
movq (%r13), %r15
testq %r15, %r15
jne 0xfa72f
xorl %eax, %eax
callq 0x109c82
movq %rax, %r15
movq %rax, (%r13)
movq 0x18(%rbx), %rsi
movq %rsi, %rdi
callq 0x128aeb
movq %r15, %rdi
movq %rax, %rsi
callq 0x1094fa
jmp 0xfa429
testb $0x8, %al
je 0xfa429
movq (%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0xe9bc5
movq %rax, (%r13)
jmp 0xfa429
movabsq $0x69849117d3eb7d61, %rcx # imm = 0x69849117D3EB7D61
cmpq %rcx, %rax
jle 0xfa90e
movabsq $0x69849117d3eb7d62, %rcx # imm = 0x69849117D3EB7D62
cmpq %rcx, %rax
je 0xfa87b
movabsq $0x6d07f9ef5b68e8a2, %rcx # imm = 0x6D07F9EF5B68E8A2
cmpq %rcx, %rax
je 0xfa935
movabsq $0x6db6f178cd6db4b8, %rcx # imm = 0x6DB6F178CD6DB4B8
cmpq %rcx, %rax
jne 0xfa95e
callq 0xc6e3c
movq %rax, %r15
testq %rax, %rax
jne 0xfa9f7
movq 0x8(%r14), %rdi
callq 0xd6ec4
movq %rax, %r12
testq %rax, %rax
leaq 0x4df3e(%rip), %rax     # 0x148715
cmoveq %rax, %r12
movq 0x18(%rbx), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x4df27(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
leaq 0x4ffa3(%rip), %rdi     # 0x14a79c
leaq 0x4f9be(%rip), %rsi     # 0x14a1be
movl $0xe6, %edx
jmp 0xfa9e3
callq 0xd6ec4
testq %rax, %rax
leaq 0x4defc(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
leaq 0x4ff78(%rip), %rdi     # 0x14a79c
leaq 0x4f993(%rip), %rsi     # 0x14a1be
movl $0x120, %edx            # imm = 0x120
leaq 0x4ffb0(%rip), %rcx     # 0x14a7e7
movq %rax, %r8
xorl %eax, %eax
callq 0xbe592
jmp 0xfa429
movabsq $-0x6119581ac7eacd64, %rcx # imm = 0x9EE6A7E53815329C
cmpq %rcx, %rax
jg 0xfa885
movabsq $-0x73f6ae1ad309fd45, %rcx # imm = 0x8C0951E52CF602BB
cmpq %rcx, %rax
je 0xfa92c
movabsq $-0x6bce971ace902370, %rcx # imm = 0x943168E5316FDC90
cmpq %rcx, %rax
jne 0xfa95e
movw %di, (%r13)
jmp 0xfa429
movabsq $-0x6119581ac7eacd63, %rcx # imm = 0x9EE6A7E53815329D
cmpq %rcx, %rax
je 0xfa93e
movabsq $-0x5fc2af85f419929b, %rcx # imm = 0xA03D507A0BE66D65
cmpq %rcx, %rax
je 0xfa935
jmp 0xfa95e
movabsq $-0x5aa4411ac4e2880e, %rcx # imm = 0xA55BBEE53B1D77F2
cmpq %rcx, %rax
je 0xfa935
movabsq $-0x58737885f0577326, %rcx # imm = 0xA78C877A0FA88CDA
cmpq %rcx, %rax
jne 0xfa95e
movq %rdi, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%r13)
jmp 0xfa429
movabsq $-0x3f1363e6d8155aed, %rcx # imm = 0xC0EC9C1927EAA513
cmpq %rcx, %rax
je 0xfa935
movabsq $-0x3ac242643d9c35a8, %rcx # imm = 0xC53DBD9BC263CA58
cmpq %rcx, %rax
jne 0xfa95e
movb $0x1, (%r13)
jmp 0xfa429
movabsq $0x585a3b17ca3de200, %rcx # imm = 0x585A3B17CA3DE200
cmpq %rcx, %rax
je 0xfa935
movabsq $0x62367a17d02b474d, %rcx # imm = 0x62367A17D02B474D
cmpq %rcx, %rax
jne 0xfa95e
movb %dil, (%r13)
jmp 0xfa429
movq %rdi, (%r13)
jmp 0xfa429
movl %edi, (%r13)
jmp 0xfa429
callq 0x128aeb
movq %r13, %rdi
jmp 0xfa73a
callq 0x128aab
jmp 0xfa75b
testb $0x1, 0x15(%rbx)
jne 0xfa992
movq %rax, %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x4dd9f(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
leaq 0x4fe1b(%rip), %rdi     # 0x14a79c
leaq 0x4f836(%rip), %rsi     # 0x14a1be
movl $0xf9, %edx
jmp 0xfa830
callq 0xc6e3c
movq %rax, %r15
testq %rax, %rax
jne 0xfa9f7
movq 0x8(%r14), %rdi
callq 0xd6ec4
movq %rax, %r12
testq %rax, %rax
leaq 0x4dd60(%rip), %rax     # 0x148715
cmoveq %rax, %r12
movq 0x18(%rbx), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x4dd49(%rip), %rcx     # 0x148715
cmoveq %rcx, %rax
leaq 0x4fdc5(%rip), %rdi     # 0x14a79c
leaq 0x4f7e0(%rip), %rsi     # 0x14a1be
movl $0xf3, %edx
leaq 0x4fdbf(%rip), %rcx     # 0x14a7a9
movq %r12, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xbe6f9
movq %r15, (%r13)
jmp 0xfa429
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq