// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: bcore_hmap_tpvd_s_set
vd_t* bcore_hmap_tpvd_s_set( bcore_hmap_tpvd_s* o, tp_t key, vd_t val )
{
    if( !key ) ERR( "key is zero" );

    uz_t idx = tpvd_find( o, key );
    if( idx < o->size )
    {
        o->nodes[ idx ].val = val;
        return &o->nodes[ idx ].val;
    }

    idx = tpvd_set( o, ( bcore_hnode_tpvd_s ){ .key = key, .val = val }, 1 );
    if( idx < o->size ) return &o->nodes[ idx ].val;

    // rehash
    {
        o->flags = bcore_u_alloc( sizeof( bl_t ), o->flags, 0, NULL );
        bcore_hnode_tpvd_s* buf_nodes = o->nodes;
        uz_t  buf_size = o->size;
        o->depth_limit = ( o->size > 0 ) ? o->depth_limit + 1 : 4;
        o->size        = ( o->size > 0 ) ? o->size * 2        : 8;
        o->nodes = bcore_u_memzero( sizeof( bcore_hnode_tpvd_s ), NULL, o->size );
        for( uz_t i = 0; i < buf_size; i++ )
        {
            if( buf_nodes[ i ].key ) bcore_hmap_tpvd_s_set( o, buf_nodes[ i ].key, buf_nodes[ i ].val );
        }
        bcore_alloc( buf_nodes, 0 ); // rehashing does not destroy any object (only rearranges nodes)
    }

    return bcore_hmap_tpvd_s_set( o, key, val );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xafdbc
leaq 0x9fb2b(%rip), %rdi     # 0x14f8cd
leaq 0x9f9fa(%rip), %rsi     # 0x14f7a3
movl $0xa5d, %edx            # imm = 0xA5D
leaq 0x9fa2a(%rip), %rcx     # 0x14f7df
movb $0x0, %al
callq 0x9cf40
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xaffd0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xafe16
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0xaffb9
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl $0x1, %ecx
callq 0xafae0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xafe6e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0xaffb9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x9d330
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jbe 0xafec7
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xafed2
movl $0x4, %eax
movq %rax, -0x58(%rbp)
jmp 0xafed2
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jbe 0xafefa
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
shlq %rax
movq %rax, -0x60(%rbp)
jmp 0xaff05
movl $0x8, %eax
movq %rax, -0x60(%rbp)
jmp 0xaff05
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movl $0x10, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x9d540
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0xaff97
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0xaff87
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
callq 0xafd80
jmp 0xaff89
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xaff3a
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9d210
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xafd80
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)