// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: bcore_hmap_u3vd_s_setf
void bcore_hmap_u3vd_s_setf( bcore_hmap_u3vd_s* o, u3_t key, fp_t func )
{
    if( !key ) ERR( "key is zero" );

    {
        uz_t idx = u3vd_find( o, key );
        if( idx < o->size )
        {
            bcore_hnode_u3vd_s_set_func( &o->data[ idx ], func );
            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_func( p_node, func );
            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_setf( o, key, func );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
jne 0x66fbe
leaq 0x5c428(%rip), %rdi     # 0xc33cc
leaq 0x5c3d9(%rip), %rsi     # 0xc3384
leaq 0x5c40e(%rip), %rcx     # 0xc33c0
movl $0x1ac, %edx            # imm = 0x1AC
xorl %eax, %eax
callq 0x60031
movq %r14, %rdi
movq %r15, %rsi
callq 0x66b42
cmpq 0x10(%r14), %rax
jae 0x66fed
imulq $0x18, %rax, %rdi
addq 0x8(%r14), %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x670e9
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x66a67
movq %r15, (%r12)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x66d9d
testq %rax, %rax
je 0x67031
movq %rax, %rdi
movq %rbx, %rsi
callq 0x670e9
jmp 0x670da
movq 0x8(%r14), %r12
movq 0x10(%r14), %rbp
leaq 0x18(%r14), %rcx
testq %rbp, %rbp
je 0x6704b
movq 0x20(%r14), %rax
incq %rax
jmp 0x6704e
pushq $0x4
popq %rax
movq 0x18(%r14), %rdx
movq %rdx, 0x18(%rsp)
leaq (,%rbp,2), %rsi
testq %rbp, %rbp
movq %rax, 0x20(%r14)
pushq $0x8
popq %rdx
cmovneq %rsi, %rdx
movq %rdx, 0x10(%r14)
pushq $0x18
popq %rdi
xorl %esi, %esi
callq 0x6025e
movq %rax, 0x8(%r14)
imulq $0x18, 0x10(%r14), %rsi
movq %rax, %rdi
callq 0x6028b
leaq 0x10(%r12), %r13
subq $0x1, %rbp
jb 0x670b7
movq -0x10(%r13), %rsi
testq %rsi, %rsi
je 0x670b1
movq (%r13), %rdx
movzbl -0x7(%r13), %ecx
movq %r14, %rdi
callq 0x66bf0
addq $0x18, %r13
jmp 0x67091
pushq $0x18
popq %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x60263
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x66f81
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq