// File: /workspace/github_c_makefile_star2_O2/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 0x7a336
movq 0x8(%rbx), %rdi
callq 0x79d59
movq %rax, %rdi
callq 0x8ed62
movq %rax, %r15
movq 0x8(%rax), %r8
movq 0x10(%rax), %rax
cmpq $0x3, %rax
jb 0x7a2f3
cmpb $0x5f, -0x2(%r8,%rax)
jne 0x7a2f3
cmpb $0x73, -0x1(%r8,%rax)
je 0x7a31c
leaq 0x4c2f3(%rip), %rdi     # 0xc65ed
leaq 0x4c0cf(%rip), %rsi     # 0xc63d0
leaq 0x4c2fe(%rip), %rcx     # 0xc6606
movl $0x16c, %edx            # imm = 0x16C
xorl %eax, %eax
callq 0x60186
movq 0x8(%r15), %r8
movq 0x10(%r15), %rax
movb $0x0, -0x2(%r8,%rax)
movq 0x8(%r15), %rdi
callq 0x7227a
movq %rax, %r14
movq %r15, %rdi
callq 0x8edd4
movq %rbx, %rdi
callq 0x6389b
movq %rax, %r15
xorl %r12d, %r12d
testq %rax, %rax
cmovleq %r12, %r15
xorl %r13d, %r13d
cmpq %r12, %r15
je 0x7a3a6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x638ac
movzwl 0x14(%rax), %ebp
movl %ebp, %ecx
notl %ecx
testw $0x1a0, %cx             # imm = 0x1A0
jne 0x7a395
cmpq $0x0, 0x18(%rax)
jne 0x7a395
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x7a386
cmpl $0xe, 0x10(%rcx)
movq %rcx, %rax
jne 0x7a395
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x99335
andl $0x40, %ebp
shrl $0x6, %ebp
orb %r13b, %bpl
incq %r12
movl %ebp, %r13d
jmp 0x7a34e
testb $0x1, %r13b
je 0x7a3b4
movq %r14, %rdi
callq 0x9931a
movq 0x18(%rbx), %rsi
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x99410