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

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

    idx = tpaw_set( o, ( bcore_hnode_tpaw_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_tpaw_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_tpaw_s ), NULL, o->size );
        for( uz_t i = 0; i < buf_size; i++ )
        {
            if( buf_nodes[ i ].key ) bcore_hmap_tpaw_s_set_d( 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_tpaw_s_set_d( o, key, val );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %r15, %r15
je 0xcc648
movq %r14, %rdi
movq %r15, %rsi
callq 0xcc494
movq %rax, %r12
movq 0x18(%r14), %rax
cmpq %rax, %r12
jb 0xcc70d
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xcc252
cmpq 0x18(%r14), %rax
jb 0xcc6f9
movq 0x10(%r14), %rsi
movl $0x1, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbe7d5
movq %rax, 0x10(%r14)
movq 0x8(%r14), %r12
movq 0x18(%r14), %r13
testq %r13, %r13
je 0xcc6c5
incq 0x20(%r14)
leaq (,%r13,2), %rdx
movq %rdx, 0x18(%r14)
movl $0x10, %edi
xorl %esi, %esi
callq 0xbe825
movq %rax, 0x8(%r14)
leaq 0x8(%r12), %rbp
movq -0x8(%rbp), %rsi
testq %rsi, %rsi
je 0xcc63a
movq (%rbp), %rdx
movq %r14, %rdi
callq 0xcc584
addq $0x10, %rbp
decq %r13
jne 0xcc625
jmp 0xcc6ea
leaq 0x79024(%rip), %rdi     # 0x145673
leaq 0x78e8e(%rip), %rsi     # 0x1454e4
movl $0xe42, %edx            # imm = 0xE42
leaq 0x78ebe(%rip), %rcx     # 0x145520
xorl %eax, %eax
callq 0xbe592
movq 0x18(%r14), %rax
testq %rax, %rax
je 0xcc5bc
leaq -0x1(%rax), %rcx
movq %rcx, %r12
movabsq $0x4c04e557831f75b5, %rdx # imm = 0x4C04E557831F75B5
andq %rdx, %r12
movq 0x8(%r14), %rdx
movq %r12, %rsi
shlq $0x4, %rsi
cmpq $0x0, (%rdx,%rsi)
je 0xcc5b3
movabsq $0x42c60dee75c083c3, %rsi # imm = 0x42C60DEE75C083C3
andq %rsi, %rcx
movq %rcx, %rsi
shlq $0x4, %rsi
cmpq $0x0, (%rdx,%rsi)
cmovneq %rax, %rcx
movq %rcx, %r12
jmp 0xcc5b3
movq $0x4, 0x20(%r14)
movq $0x8, 0x18(%r14)
movl $0x10, %edi
movl $0x8, %edx
xorl %esi, %esi
callq 0xbe825
movq %rax, 0x8(%r14)
movq %r12, %rdi
xorl %esi, %esi
callq 0xbe7b1
jmp 0xcc598
movq 0x8(%r14), %rcx
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
jmp 0xcc7cd
movq 0x8(%r14), %rax
shlq $0x4, %r12
movq 0x8(%rax,%r12), %r15
testq %r15, %r15
je 0xcc7c3
movq (%r15), %r13
leaq 0xcfd3b(%rip), %rax     # 0x19c468
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r13, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0xcc783
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0xcc783
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0xcc783
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0xcc78c
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0xcc7b3
movabsq $0x782b96602f424981, %rdi # imm = 0x782B96602F424981
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0xcfcc0(%rip), %rdi     # 0x19c468
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbp, %rdi
movq %r15, %rsi
callq *0xb8(%rbp)
movq 0x8(%r14), %rax
addq %r12, %rax
addq $0x8, %rax
movq %rbx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq