// File: /workspace/github_c_makefile_star2_O1/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 0xf4af7
movq 0x8(%rbx), %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x5ec66(%rip), %rdi     # 0x1536ef
cmovneq %rax, %rdi
callq 0x114e47
movq %rax, %r15
movq 0x10(%rax), %rax
cmpq $0x3, %rax
jb 0xf4ab1
movq 0x8(%r15), %rcx
cmpb $0x5f, -0x2(%rcx,%rax)
jne 0xf4ab1
cmpb $0x73, -0x1(%rcx,%rax)
je 0xf4ad6
movq 0x8(%r15), %r8
leaq 0x5ec54(%rip), %rdi     # 0x153710
leaq 0x5ea30(%rip), %rsi     # 0x1534f3
leaq 0x5ec5f(%rip), %rcx     # 0x153729
movl $0x16c, %edx            # imm = 0x16C
xorl %eax, %eax
callq 0xc825d
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movb $0x0, -0x2(%rax,%rcx)
movq 0x8(%r15), %rdi
callq 0xe1270
movq %rax, %r14
movq %r15, %rdi
callq 0x114f61
movq %rbx, %rdi
callq 0xcd3df
testq %rax, %rax
jle 0xf4b74
movq %rax, %r15
xorl %r13d, %r13d
movl $0x1, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xcd3f0
movzwl 0x14(%rax), %ecx
testb $0x40, %cl
movzbl %r13b, %r13d
cmovnel %ebp, %r13d
notl %ecx
testl $0x1a0, %ecx            # imm = 0x1A0
jne 0xf4b5e
cmpq $0x0, 0x18(%rax)
jne 0xf4b5e
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0xf4b4f
cmpl $0xe, 0x10(%rcx)
movq %rcx, %rax
jne 0xf4b5e
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x121a5c
incq %r12
cmpq %r12, %r15
jne 0xf4b12
testb $0x1, %r13b
je 0xf4b74
movq %r14, %rdi
callq 0x121a2b
movq 0x18(%rbx), %rsi
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x121b6d