// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xd21dc
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd17a0
movq %rax, %rdi
callq 0xff550
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x3, 0x10(%rax)
jb 0xd2181
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x2, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5f, %eax
jne 0xd2181
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x73, %eax
je 0xd21aa
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
leaq 0x808b3(%rip), %rdi     # 0x152a43
leaq 0x8068f(%rip), %rsi     # 0x152826
movl $0x16c, %edx            # imm = 0x16C
leaq 0x808b9(%rip), %rcx     # 0x152a5c
movb $0x0, %al
callq 0x9d0f0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x2, %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd2340
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rdi
callq 0xff600
movq -0x8(%rbp), %rdi
callq 0xa54f0
movq %rax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xd230f
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa5530
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x6, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xd2230
movb $0x1, -0x29(%rbp)
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x5, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xd22fc
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x7, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xd22fc
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x8, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xd22fa
movq -0x40(%rbp), %rax
movw 0x14(%rax), %ax
shrw $0x7, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xd22f8
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xd22f8
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xd22de
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0xe, 0x10(%rax)
jne 0xd22dc
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rsi
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x1132d0
jmp 0xd22f6
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rax
movq (%rax), %rsi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x1132d0
jmp 0xd22f8
jmp 0xd22fa
jmp 0xd22fc
jmp 0xd22fe
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xd21f5
testb $0x1, -0x29(%rbp)
je 0xd231e
movq -0x18(%rbp), %rdi
callq 0x1132a0
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x1134f0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)