// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_trait.c
// Function: bcore_trait_supported
bl_t bcore_trait_supported( tp_t trait, const bcore_self_s* self, st_s* log )
{
    if( !trait ) return true;
    if( !bcore_trait_exists( trait ) )
    {
        if( log )
        {
            st_s_pushf( log, "Trait '%s' is not defined.", ifnameof( trait ) );
        }
        return false;
    }
    if( !bcore_trait_supported( bcore_trait_parent( trait ), self, log ) ) return false;

    system_s_g_lock();
    vd_t* trait_p = bcore_hmap_tpto_s_get( &system_s_g->trait_map, trait );
    system_s_g_unlock();

    if( !trait_p ) return true; // no restrictions

    bcore_trait_s* trait_o = *trait_p;

    if( trait_o->in_ancestry )
    {
        if( !bcore_trait_is_of( self->trait, trait ) )
        {
            if( log )
            {
                st_s_pushf( log, "Trait is not in ancestry." );
            }
            return false;
        }
    }

    if( trait_o->awareness )
    {
        if( !bcore_self_s_is_aware( self ) )
        {
            if( log )
            {
                st_s_pushf( log, "Self awareness missing." );
            }
            return false;
        }
    }

    for( uz_t i = 0; i < trait_o->ft_size; i++ )
    {
        bcore_trait_ft_s ft_o = trait_o->ft_data[ i ];
        if( !bcore_self_s_try_external_fp( self, ft_o.type, ft_o.name ) )
        {
            if( log )
            {
                if( ft_o.type && ft_o.name )
                {
                    st_s_pushf( log, "Missing function '%s' of name '%s'.", ifnameof( ft_o.type ), ifnameof( ft_o.name ) );
                }
                else if( ft_o.type )
                {
                    st_s_pushf( log, "Missing function '%s'.", ifnameof( ft_o.type ) );
                }
                else if( ft_o.name )
                {
                    st_s_pushf( log, "Missing function '%s'.", ifnameof( ft_o.name ) );
                }
            }
            return false;
        }
    }

    for( uz_t i = 0; i < trait_o->fp_size; i++ )
    {
        bcore_trait_fp_supports fp_o = trait_o->fp_data[ i ];
        if( fp_o && !fp_o( self, log ) ) return false;
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $0x1, %bpl
testq %rdi, %rdi
je 0x116ee2
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x11696d
testb %al, %al
je 0x116de0
movq %r15, %rdi
callq 0x1169a6
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x116c98
testb %al, %al
je 0x116ee0
movq 0x86636(%rip), %rdi     # 0x19d320
addq $0x58, %rdi
callq 0x1142c9
movq 0x86626(%rip), %rdi     # 0x19d320
addq $0x28, %rdi
movq %r15, %rsi
callq 0xcb753
movq %rax, %r12
movq 0x86610(%rip), %rdi     # 0x19d320
addq $0x58, %rdi
callq 0x1142fb
testq %r12, %r12
je 0x116ee2
movq (%r12), %r13
cmpb $0x1, (%r13)
jne 0x116d41
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x1169ea
testb %al, %al
je 0x116e17
cmpb $0x1, 0x1(%r13)
jne 0x116d58
movq %r14, %rdi
callq 0xc48f3
testb %al, %al
je 0x116e29
movq %rbx, (%rsp)
cmpq $0x0, 0x10(%r13)
je 0x116d9b
movl $0x8, %ebx
xorl %ebp, %ebp
movq 0x8(%r13), %rax
movq -0x8(%rax,%rbx), %r12
movq (%rax,%rbx), %r15
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xc473a
testq %rax, %rax
je 0x116e4a
incq %rbp
addq $0x10, %rbx
cmpq 0x10(%r13), %rbp
jb 0x116d6a
movq 0x28(%r13), %rax
testq %rax, %rax
je 0x116eaa
xorl %r15d, %r15d
movq (%rsp), %rbx
movb $0x1, %bpl
movq 0x20(%r13), %rcx
movq (%rcx,%r15,8), %rcx
testq %rcx, %rcx
je 0x116dd3
movq %r14, %rdi
movq %rbx, %rsi
callq *%rcx
testb %al, %al
je 0x116ee0
movq 0x28(%r13), %rax
incq %r15
cmpq %rax, %r15
jb 0x116db2
jmp 0x116ee2
testq %rbx, %rbx
je 0x116ee0
movq %r15, %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x3191a(%rip), %rdx     # 0x148715
cmovneq %rax, %rdx
leaq 0x37163(%rip), %rsi     # 0x14df69
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a7d0
jmp 0x116ee2
testq %rbx, %rbx
je 0x116ee0
leaq 0x3715d(%rip), %rsi     # 0x14df84
jmp 0x116e39
testq %rbx, %rbx
je 0x116ee0
leaq 0x37165(%rip), %rsi     # 0x14df9e
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10a7d0
jmp 0x116ee2
movq (%rsp), %rbx
testq %rbx, %rbx
je 0x116ee0
testq %r12, %r12
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x116eaf
movq %r12, %rdi
callq 0xd6ec4
movq %rax, %r14
testq %rax, %rax
leaq 0x31899(%rip), %r12     # 0x148715
cmoveq %r12, %r14
movq %r15, %rdi
callq 0xd6ec4
testq %rax, %rax
cmovneq %rax, %r12
leaq 0x37120(%rip), %rsi     # 0x14dfb6
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x10a7d0
jmp 0x116ee2
movb $0x1, %bpl
jmp 0x116ee2
testq %r12, %r12
je 0x116eb9
movq %r12, %rdi
jmp 0x116ec1
testq %r15, %r15
je 0x116ee0
movq %r15, %rdi
callq 0xd6ec4
testq %rax, %rax
leaq 0x31845(%rip), %rdx     # 0x148715
cmovneq %rax, %rdx
leaq 0x370ff(%rip), %rsi     # 0x14dfda
jmp 0x116e06
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq