// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: tp_set
static uz_t tp_set( bcore_hmap_tp_s* o, tp_t key, uz_t depth ) // sets new node, returns valid index on success; o->size otherwise
{
    uz_t size = o->size;
    if( size == 0 ) return size;
    uz_t mask = o->size - 1;

    if( depth == o->depth_limit ) return size;

    uz_t idx1 = hash_tpu3_1( key ) & mask;
    if( !o->keys[ idx1 ] )
    {
        o->keys[ idx1 ] = key;
        return idx1;
    }

    uz_t idx2 = hash_tpu3_2( key ) & mask;
    if( !o->keys[ idx2 ] )
    {
        o->keys[ idx2 ] = key;
        return idx2;
    }

    if( !o->flags ) o->flags = bcore_u_memzero( sizeof( bl_t ), NULL, size );

    if( !o->flags[ idx1 ] )
    {
        o->flags[ idx1 ] = true;
        if( tp_set( o, o->keys[ idx1 ], depth + 1 ) < size )
        {
            o->flags[ idx1 ] = false;
            o->keys[  idx1 ] = key;
            return idx1;
        }
        o->flags[ idx1 ] = false;
    }

    if( !o->flags[ idx2 ] )
    {
        o->flags[ idx2 ] = true;
        if( tp_set( o, o->keys[ idx2 ], depth + 1 ) < size )
        {
            o->flags[ idx2 ] = false;
            o->keys[  idx2 ] = key;
            return idx2;
        }
        o->flags[ idx2 ] = false;
    }

    return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x18(%rdi), %r14
testq %r14, %r14
je 0xd6f4a
movq %rdx, %r12
movq %rdi, %r15
cmpq %rdx, 0x20(%rdi)
je 0xd6f62
movq %rsi, %rbx
leaq -0x1(%r14), %r13
movl $0xffff, %esi           # imm = 0xFFFF
movq %rbx, %rax
andq %rsi, %rax
movabsq $-0x6fc95bdab4c873e1, %rdx # imm = 0x9036A4254B378C1F
xorq %rax, %rdx
movabsq $0x1000000109f, %rbp    # imm = 0x1000000109F
imulq %rbp, %rdx
movl %ebx, %ecx
shrl $0x10, %ecx
xorq %rcx, %rdx
leaq 0x80(%rbp), %rdi
imulq %rdx, %rdi
movq %rbx, %rdx
shrq $0x20, %rdx
andq %rsi, %rdx
xorq %rdx, %rdi
leaq 0x2ba(%rbp), %rsi
imulq %rdi, %rsi
movq %rbx, %rdi
shrq $0x30, %rdi
xorq %rdi, %rsi
addq $0x344, %rbp            # imm = 0x344
imulq %rsi, %rbp
andq %r13, %rbp
movq 0x8(%r15), %rsi
cmpq $0x0, (%rsi,%rbp,8)
je 0xd6f4f
movabsq $0x37651f84128a9b31, %r8 # imm = 0x37651F84128A9B31
xorq %r8, %rax
movabsq $0x1000001000011, %r8   # imm = 0x1000001000011
imulq %r8, %rax
xorq %rcx, %rax
leaq 0xbe(%r8), %rcx
imulq %rax, %rcx
xorq %rdx, %rcx
leaq 0x1cc(%r8), %rax
imulq %rcx, %rax
xorq %rdi, %rax
orq $0x360, %r8             # imm = 0x360
imulq %rax, %r8
andq %r8, %r13
cmpq $0x0, (%rsi,%r13,8)
je 0xd6f55
cmpq $0x0, 0x10(%r15)
jne 0xd6ed5
movl $0x1, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0xc8389
movq %rax, 0x10(%r15)
movq 0x10(%r15), %rax
cmpb $0x0, (%rax,%rbp)
jne 0xd6f05
movb $0x1, (%rax,%rbp)
movq 0x8(%r15), %rax
movq (%rax,%rbp,8), %rsi
leaq 0x1(%r12), %rdx
movq %r15, %rdi
callq 0xd6dc1
movq 0x10(%r15), %rcx
movb $0x0, (%rcx,%rbp)
cmpq %r14, %rax
jb 0xd6f3c
movq 0x10(%r15), %rax
cmpb $0x0, (%rax,%r13)
jne 0xd6f62
movb $0x1, (%rax,%r13)
movq 0x8(%r15), %rax
movq (%rax,%r13,8), %rsi
incq %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0xd6dc1
movq 0x10(%r15), %rcx
movb $0x0, (%rcx,%r13)
movq %r13, %rbp
cmpq %r14, %rax
jae 0xd6f62
leaq (,%rbp,8), %rax
addq 0x8(%r15), %rax
jmp 0xd6f5c
xorl %r14d, %r14d
jmp 0xd6f62
leaq (%rsi,%rbp,8), %rax
jmp 0xd6f5c
leaq (%rsi,%r13,8), %rax
movq %r13, %rbp
movq %rbx, (%rax)
movq %rbp, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq