// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: bcore_hmap_u3vd_s_set
void bcore_hmap_u3vd_s_set( bcore_hmap_u3vd_s* o, u3_t key, vd_t val, bool hold )
{
    if( !key ) ERR( "key is zero" );

    {
        uz_t idx = u3vd_find( o, key );
        if( idx < o->size )
        {
            bcore_hnode_u3vd_s_set_val( &o->data[ idx ], val, hold );
            return;
        }
    }

    {
        bcore_hnode_u3vd_s node;
        bcore_hnode_u3vd_s_init( &node );
        node.key = key;
        bcore_hnode_u3vd_s* p_node = u3vd_set( o, node, 1 );
        if( p_node )
        {
            bcore_hnode_u3vd_s_set_val( p_node, val, hold );
            return;
        }
    }

    // rehash
    {
        bcore_hnode_u3vd_s* buf_data  = o->data;
        uz_t         buf_size  = o->size;
        uz_t         buf_space = o->space;
        o->depth_limit = ( o->size > 0 ) ? o->depth_limit + 1 : 4;
        o->size        = ( o->size > 0 ) ? o->size * 2        : 8;
        o->data = bcore_u_alloc( sizeof( bcore_hnode_u3vd_s ), NULL, o->size, &o->space );
        bcore_memzero( o->data, sizeof( bcore_hnode_u3vd_s ) * o->size );
        for( uz_t i = 0; i < buf_size; i++ )
        {
            bcore_hnode_u3vd_s* p_node = &buf_data[ i ];
            if( p_node->key ) bcore_hmap_u3vd_s_set( o, p_node->key, p_node->dp, p_node->flag_holds );
        }
        bcore_un_alloc( sizeof( bcore_hnode_u3vd_s ), buf_data, buf_space, 0, NULL );
    }

    bcore_hmap_u3vd_s_set( o, key, val, hold );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %r12
testq %rsi, %rsi
jne 0xc7829
leaq 0x7dcfe(%rip), %rdi     # 0x14550a
leaq 0x7dcd1(%rip), %rsi     # 0x1454e4
leaq 0x7dd06(%rip), %rcx     # 0x145520
xorl %r12d, %r12d
movl $0x17d, %edx            # imm = 0x17D
xorl %eax, %eax
callq 0xbe592
movq %r14, %rdi
movq %r12, %rsi
callq 0xc7735
cmpq 0x10(%r14), %rax
jae 0xc7860
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
addq 0x8(%r14), %rdi
movzbl %bpl, %edx
movq %rbx, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc79a0
leaq 0x30(%rsp), %r12
movl $0x18, %esi
movq %r12, %rdi
callq 0xbe802
movq %r15, (%r12)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
movl $0x1, %esi
movq %r14, %rdi
callq 0xc7a7e
testq %rax, %rax
je 0xc78af
movzbl %bpl, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xc79a0
jmp 0xc7991
movq 0x8(%r14), %r12
movq 0x10(%r14), %r13
leaq 0x18(%r14), %rcx
movq 0x18(%r14), %rax
movq %rax, 0x20(%rsp)
testq %r13, %r13
movq %r12, 0x28(%rsp)
je 0xc792d
incq 0x20(%r14)
leaq (,%r13,2), %rdx
movq %rdx, 0x10(%r14)
movl $0x18, %edi
xorl %esi, %esi
callq 0xbe7d5
movq %rax, 0x8(%r14)
movq 0x10(%r14), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0xbe802
addq $0x10, %r12
movq -0x10(%r12), %rsi
testq %rsi, %rsi
je 0xc7922
movq (%r12), %rdx
movzbl -0x7(%r12), %ecx
movq %r14, %rdi
callq 0xc77e4
addq $0x18, %r12
decq %r13
jne 0xc7906
jmp 0xc7966
movq $0x4, 0x20(%r14)
movq $0x8, 0x10(%r14)
movl $0x18, %edi
movl $0x8, %edx
xorl %esi, %esi
callq 0xbe7d5
movq %rax, 0x8(%r14)
movq 0x10(%r14), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0xbe802
movl $0x18, %edi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xbe7da
movzbl %bpl, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xc77e4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq