// File: /workspace/github_c_makefile_star2_O1/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 0x1221eb
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x121c53
testb %al, %al
je 0x1220ee
movq %r15, %rdi
callq 0x121c8c
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x121fa6
testb %al, %al
je 0x1221e9
movq 0x88328(%rip), %rdi     # 0x1aa320
addq $0x58, %rdi
callq 0x11f515
movq 0x88318(%rip), %rdi     # 0x1aa320
addq $0x28, %rdi
movq %r15, %rsi
callq 0xd567e
movq %rax, %r12
movq 0x88302(%rip), %rdi     # 0x1aa320
addq $0x58, %rdi
callq 0x11f547
testq %r12, %r12
je 0x1221eb
movq (%r12), %r13
cmpb $0x1, (%r13)
jne 0x12204f
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x121cd0
testb %al, %al
je 0x122125
cmpb $0x1, 0x1(%r13)
jne 0x122066
movq %r14, %rdi
callq 0xcea67
testb %al, %al
je 0x122137
movq %rbx, (%rsp)
cmpq $0x0, 0x10(%r13)
je 0x1220a9
movl $0x8, %ebp
xorl %ebx, %ebx
movq 0x8(%r13), %rax
movq -0x8(%rax,%rbp), %r12
movq (%rax,%rbp), %r15
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xce882
testq %rax, %rax
je 0x122158
incq %rbx
addq $0x10, %rbp
cmpq 0x10(%r13), %rbx
jb 0x122078
cmpq $0x0, 0x28(%r13)
sete %bpl
je 0x1221eb
xorl %r15d, %r15d
movq (%rsp), %rbx
movq 0x20(%r13), %rax
movq (%rax,%r15,8), %rax
testq %rax, %rax
je 0x1220dc
movq %r14, %rdi
movq %rbx, %rsi
callq *%rax
testb %al, %al
je 0x1221eb
incq %r15
cmpq 0x28(%r13), %r15
setae %bpl
jb 0x1220bf
jmp 0x1221eb
testq %rbx, %rbx
je 0x1221e9
movq %r15, %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x315e6(%rip), %rdx     # 0x1536ef
cmovneq %rax, %rdx
leaq 0x36df5(%rip), %rsi     # 0x158f09
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1156f6
jmp 0x1221eb
testq %rbx, %rbx
je 0x1221e9
leaq 0x36def(%rip), %rsi     # 0x158f24
jmp 0x122147
testq %rbx, %rbx
je 0x1221e9
leaq 0x36df7(%rip), %rsi     # 0x158f3e
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1156f6
jmp 0x1221eb
movq (%rsp), %rbx
testq %rbx, %rbx
je 0x1221e9
testq %r12, %r12
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x1221b8
movq %r12, %rdi
callq 0xe0cbc
movq %rax, %r14
testq %rax, %rax
leaq 0x31565(%rip), %r12     # 0x1536ef
cmoveq %r12, %r14
movq %r15, %rdi
callq 0xe0cbc
testq %rax, %rax
cmovneq %rax, %r12
leaq 0x36db2(%rip), %rsi     # 0x158f56
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1156f6
jmp 0x1221eb
testq %r12, %r12
je 0x1221c2
movq %r12, %rdi
jmp 0x1221ca
testq %r15, %r15
je 0x1221e9
movq %r15, %rdi
callq 0xe0cbc
testq %rax, %rax
leaq 0x31516(%rip), %rdx     # 0x1536ef
cmovneq %rax, %rdx
leaq 0x36d96(%rip), %rsi     # 0x158f7a
jmp 0x122114
xorl %ebp, %ebp
andb $0x1, %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq