// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: bcore_hmap_tpuz_s_from_array
sz_t bcore_hmap_tpuz_s_from_array( bcore_hmap_tpuz_s* o, bcore_array* array, tp_t member_name )
{
    bcore_hmap_tpuz_s_clear( o );
    sz_t dup_count = 0;
    const bcore_array_s* array_p = bcore_array_s_get_aware( array );
    sz_t size = bcore_array_p_get_size( array_p, array );
    if( size == 0 ) return 0;

    if( bcore_array_p_is_mono_typed( array_p ) ) // faster code for mono-typed arrays
    {
        const bcore_via_s* via_p = bcore_via_s_get_typed( bcore_array_p_get_mono_type( array_p, array ) );
        if( bcore_via_p_nexists( via_p, NULL, member_name ) )
        {
            uz_t member_index = bcore_via_p_nget_index( via_p, NULL, member_name );

            for( sz_t i = 0; i < size; i++ )
            {
                sr_s element = bcore_array_p_get( array_p, array, i );
                tp_t key = bcore_hash_x_get_tp( bcore_via_p_iget( via_p, element.o, member_index ) );
                if( bcore_hmap_tpuz_s_exists( o, key ) )
                {
                    dup_count++;
                }
                else
                {
                    bcore_hmap_tpuz_s_set( o, key, i );
                }
                sr_down( element );
            }
        }
    }
    else // generic code for all array types
    {
        for( sz_t i = 0; i < size; i++ )
        {
            sr_s element = bcore_array_p_get( array_p, array, i );
            const bcore_via_s* via_p = bcore_via_s_get_typed( sr_s_type( &element ) );

            if( bcore_via_p_nexists( via_p, element.o, member_name ) )
            {
                tp_t key = bcore_hash_x_get_tp( bcore_via_p_nget( via_p, element.o, member_name ) );
                if( bcore_hmap_tpuz_s_exists( o, key ) )
                {
                    dup_count++;
                }
                else
                {
                    bcore_hmap_tpuz_s_set( o, key, i );
                }
            }

            sr_down( element );
        }
    }
    return dup_count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x67b03
movq (%rbx), %rdi
callq 0x6e1a1
movq %rax, %r15
movq %rax, %rdi
movq %rbx, 0x30(%rsp)
movq %rbx, %rsi
callq 0x7c954
testq %rax, %rax
je 0x69177
movq %rax, %r12
cmpb $0x0, 0x43(%r15)
movq %r14, 0x50(%rsp)
je 0x6917f
movq %r15, %rdi
movq 0x30(%rsp), %rsi
callq 0x7ccc9
movq %rax, %rdi
callq 0x69282
movq %rax, %rbx
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x8ae5c
testb %al, %al
je 0x6926d
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x8ae97
testq %r12, %r12
cmovleq %r13, %r12
movq %rax, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, %r14
movq 0x50(%rsp), %rbp
cmpq %r13, %r12
je 0x69268
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movq %r13, %rcx
callq 0x7c97c
movq 0x38(%rsp), %rdx
leaq 0x70(%rsp), %rdi
movq %r14, %rbx
movq %r14, %rsi
movq 0x28(%rsp), %rcx
callq 0x8a459
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x692d2
movq %rax, %r14
movq %rbp, %rdi
movq %rax, %rsi
callq 0x67ae9
testb %al, %al
je 0x6913f
incq 0x20(%rsp)
jmp 0x6914d
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x67989
testb $0x2, 0x48(%rsp)
movq %rbx, %r14
je 0x6916f
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %r13
jmp 0x690d3
xorl %r14d, %r14d
jmp 0x6926d
xorl %r13d, %r13d
testq %r12, %r12
cmovleq %r13, %r12
movq $0x0, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq 0x50(%rsp), %rbx
cmpq %r13, %r12
je 0x69268
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rdx
movq %r13, %rcx
callq 0x7c97c
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x691ca
movq 0x8(%rax), %rdi
jmp 0x691cc
xorl %edi, %edi
callq 0x69282
movq %rax, %r14
movq 0x38(%rsp), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x8ae5c
testb %al, %al
je 0x69241
movq %rbp, %rcx
movq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x8aec5
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x692d2
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x67ae9
testb %al, %al
je 0x6922e
incq 0x20(%rsp)
jmp 0x6923c
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x67989
movq 0x28(%rsp), %r12
testb $0x2, 0x48(%rsp)
je 0x69260
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %r13
jmp 0x6919c
movq 0x20(%rsp), %r14
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq