// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_spect.c
// Function: bcore_spect_define_trait
void bcore_spect_define_trait( const bcore_self_s* p_self, tp_t tp_trait_name )
{
    assert( p_self != NULL );

    tp_t trait = tp_trait_name;

    if( trait == 0 )
    {
        st_s* p_name = st_s_create_sc( ifnameof( p_self->type ) );
        if( p_name->size < 3 || p_name->sc[ p_name->size - 2 ] != '_' || p_name->sc[ p_name->size - 1 ] != 's' )
        {
            ERR_fa( "Name of perspective '#<sc_t>' should end in '_s'", p_name->sc );
        }
        p_name->data[ p_name->size - 2 ] = 0;
        trait = entypeof( p_name->sc );
        st_s_discard( p_name );
    }

    /// setup requirements
    sz_t size = bcore_self_s_items_size( p_self );

    bl_t trait_requires_awarenes = false;
    for( sz_t i = 0; i < size; i++ )
    {
        const bcore_self_item_s* item = bcore_self_s_get_item( p_self, i );

        if( item->flags.f_feature_requires_awarenes )
        {
            trait_requires_awarenes = true;
        }

        if( item->flags.f_feature && item->flags.f_strict )
        {
            if( item->flags.f_fp )
            {
                if( item->flags.f_strict && !item->default_tp )
                {
                    if( item->child_item )
                    {
                        const bcore_self_item_s* child_item = item->child_item;
                        if( child_item->caps == BCORE_CAPS_EXTERNAL_FUNC )
                        {
                            bcore_trait_require_function( trait, child_item->type, child_item->name );
                        }
                    }
                    else
                    {
                        bcore_trait_require_function( trait, item->type, item->name );
                    }
                }
            }
        }
    }

    if( trait_requires_awarenes )
    {
        bcore_trait_require_awareness( trait );
    }

    bcore_trait_set( trait, p_self->parent );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
jne 0xea6de
movq 0x8(%rbx), %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x5e0a4(%rip), %rdi     # 0x148715
cmovneq %rax, %rdi
callq 0x109f0e
movq %rax, %r15
movq 0x8(%rax), %r8
movq 0x10(%rax), %rax
cmpq $0x3, %rax
jb 0xea69b
cmpb $0x5f, -0x2(%r8,%rax)
jne 0xea69b
cmpb $0x73, -0x1(%r8,%rax)
je 0xea6c4
leaq 0x5e094(%rip), %rdi     # 0x148736
leaq 0x5de70(%rip), %rsi     # 0x148519
leaq 0x5e09f(%rip), %rcx     # 0x14874f
movl $0x16c, %edx            # imm = 0x16C
xorl %eax, %eax
callq 0xbe6f9
movq 0x8(%r15), %r8
movq 0x10(%r15), %rax
movb $0x0, -0x2(%r8,%rax)
movq 0x8(%r15), %rdi
callq 0xd7476
movq %rax, %r14
movq %r15, %rdi
callq 0x10a028
movq %rbx, %rdi
callq 0xc32f5
testq %rax, %rax
jle 0xea756
movq %rax, %r15
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc3306
movzwl 0x14(%rax), %ebp
movl %ebp, %ecx
notl %ecx
testl $0x1a0, %ecx            # imm = 0x1A0
jne 0xea737
cmpq $0x0, 0x18(%rax)
jne 0xea737
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0xea728
cmpl $0xe, 0x10(%rcx)
movq %rcx, %rax
jne 0xea737
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x116798
andl $0x40, %ebp
shrl $0x6, %ebp
orb %bpl, %r13b
incq %r12
cmpq %r12, %r15
jne 0xea6f4
testb $0x1, %r13b
je 0xea756
movq %r14, %rdi
callq 0x116767
movq 0x18(%rbx), %rsi
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1168a7