// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1139c7
movb $0x1, -0x1(%rbp)
jmp 0x113c6b
movq -0x10(%rbp), %rdi
callq 0x113640
testb $0x1, %al
jne 0x113a0a
cmpq $0x0, -0x20(%rbp)
je 0x113a01
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1135f0
movq -0x60(%rbp), %rdi
movq %rax, %rdx
leaq 0x44d18(%rip), %rsi     # 0x158712
movb $0x0, %al
callq 0x100120
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
movq -0x10(%rbp), %rdi
callq 0x113680
movq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x1139a0
testb $0x1, %al
jne 0x113a30
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
callq 0x114410
movq 0x9fe44(%rip), %rdi     # 0x1b3880
addq $0x28, %rdi
movq -0x10(%rbp), %rsi
callq 0xb11b0
movq %rax, -0x28(%rbp)
callq 0x114430
cmpq $0x0, -0x28(%rbp)
jne 0x113a62
movb $0x1, -0x1(%rbp)
jmp 0x113c6b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x113aaf
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1136d0
testb $0x1, %al
jne 0x113aad
cmpq $0x0, -0x20(%rbp)
je 0x113aa4
movq -0x20(%rbp), %rdi
leaq 0x44c90(%rip), %rsi     # 0x15872d
movb $0x0, %al
callq 0x100120
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
jmp 0x113aaf
movq -0x30(%rbp), %rax
testb $0x1, 0x1(%rax)
je 0x113aea
movq -0x18(%rbp), %rdi
callq 0xa6c40
testb $0x1, %al
jne 0x113ae8
cmpq $0x0, -0x20(%rbp)
je 0x113adf
movq -0x20(%rbp), %rdi
leaq 0x44c6f(%rip), %rsi     # 0x158747
movb $0x0, %al
callq 0x100120
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
jmp 0x113aea
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x113c0e
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xa6a30
cmpq $0x0, %rax
jne 0x113bfb
cmpq $0x0, -0x20(%rbp)
je 0x113bf5
cmpq $0x0, -0x48(%rbp)
je 0x113b93
cmpq $0x0, -0x40(%rbp)
je 0x113b93
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1135f0
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1135f0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq %rax, %rcx
leaq 0x44bd5(%rip), %rsi     # 0x15875f
movb $0x0, %al
callq 0x100120
jmp 0x113bf3
cmpq $0x0, -0x48(%rbp)
je 0x113bc2
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1135f0
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x44bca(%rip), %rsi     # 0x158783
movb $0x0, %al
callq 0x100120
jmp 0x113bf1
cmpq $0x0, -0x40(%rbp)
je 0x113bef
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1135f0
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0x44b9b(%rip), %rsi     # 0x158783
movb $0x0, %al
callq 0x100120
jmp 0x113bf1
jmp 0x113bf3
jmp 0x113bf5
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
jmp 0x113bfd
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x113af2
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x113c67
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x113c57
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
testb $0x1, %al
jne 0x113c57
movb $0x0, -0x1(%rbp)
jmp 0x113c6b
jmp 0x113c59
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x113c16
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)