// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: tpuz_set
uz_t tpuz_set( bcore_hmap_tpuz_s* o, bcore_hnode_tpuz_s node, 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( node.key ) & mask;
    if( !o->nodes[ idx1 ].key )
    {
        o->nodes[ idx1 ] = node;
        return idx1;
    }

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

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

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

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

    return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0xd2a35
movq %rcx, %r11
movq %rdi, %r12
cmpq %rcx, 0x20(%rdi)
je 0xd2a4e
movq %rdx, %r9
movq %rsi, %r14
leaq -0x1(%rbx), %r10
movl $0xffff, %eax           # imm = 0xFFFF
movq %rsi, %rcx
andq %rax, %rcx
movabsq $-0x6fc95bdab4c873e1, %rsi # imm = 0x9036A4254B378C1F
xorq %rcx, %rsi
movabsq $0x1000000109f, %r15    # imm = 0x1000000109F
imulq %r15, %rsi
movl %r14d, %edx
shrl $0x10, %edx
xorq %rdx, %rsi
leaq 0x80(%r15), %rdi
imulq %rsi, %rdi
movq %r14, %rsi
shrq $0x20, %rsi
andq %rax, %rsi
xorq %rsi, %rdi
leaq 0x2ba(%r15), %rax
imulq %rdi, %rax
movq %r14, %rdi
shrq $0x30, %rdi
xorq %rdi, %rax
addq $0x344, %r15            # imm = 0x344
imulq %rax, %r15
andq %r10, %r15
movq 0x8(%r12), %rax
movq %r15, %rbp
shlq $0x4, %rbp
cmpq $0x0, (%rax,%rbp)
je 0xd2a39
movabsq $0x37651f84128a9b31, %r8 # imm = 0x37651F84128A9B31
xorq %r8, %rcx
movabsq $0x1000001000011, %r8   # imm = 0x1000001000011
imulq %r8, %rcx
xorq %rdx, %rcx
leaq 0xbe(%r8), %rdx
imulq %rcx, %rdx
xorq %rsi, %rdx
leaq 0x1cc(%r8), %rcx
imulq %rdx, %rcx
xorq %rdi, %rcx
orq $0x360, %r8             # imm = 0x360
imulq %rcx, %r8
andq %r8, %r10
movq %r10, %r13
shlq $0x4, %r13
cmpq $0x0, (%rax,%r13)
je 0xd2a3e
cmpq $0x0, 0x10(%r12)
jne 0xd298d
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r9, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %r11, (%rsp)
callq 0xc8389
movq (%rsp), %r11
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r9
movq %rax, 0x10(%r12)
movq 0x10(%r12), %rax
cmpb $0x0, (%rax,%r15)
jne 0xd29df
movb $0x1, (%rax,%r15)
movq 0x8(%r12), %rax
leaq 0x1(%r11), %rcx
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
movq %r12, %rdi
movq %r9, 0x8(%rsp)
movq %r10, %rbp
movq %r11, (%rsp)
callq 0xd2845
movq (%rsp), %r11
movq %rbp, %r10
movq 0x8(%rsp), %r9
movq 0x10(%r12), %rcx
movb $0x0, (%rcx,%r15)
cmpq %rbx, %rax
jb 0xd2a27
movq 0x10(%r12), %rax
cmpb $0x0, (%rax,%r10)
jne 0xd2a4e
movb $0x1, (%rax,%r10)
movq 0x8(%r12), %rax
incq %r11
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
movq %r12, %rdi
movq %r11, %rcx
movq %r9, %r15
movq %r10, %r13
callq 0xd2845
movq %r15, %r9
movq 0x10(%r12), %rcx
movb $0x0, (%rcx,%r13)
movq %r13, %r15
cmpq %rbx, %rax
jae 0xd2a4e
movq %r15, %rax
shlq $0x4, %rax
addq 0x8(%r12), %rax
jmp 0xd2a44
xorl %ebx, %ebx
jmp 0xd2a4e
addq %rbp, %rax
jmp 0xd2a44
addq %r13, %rax
movq %r10, %r15
movq %r14, (%rax)
movq %r9, 0x8(%rax)
movq %r15, %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq