// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_hmap.c
// Function: tpaw_set
uz_t tpaw_set( bcore_hmap_tpaw_s* o, bcore_hnode_tpaw_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( tpaw_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( tpaw_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 0xcc43d
movq %rcx, %r13
movq %rdi, %r12
cmpq %rcx, 0x20(%rdi)
je 0xcc456
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 0xcc441
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, %rcx
shlq $0x4, %rcx
cmpq $0x0, (%rax,%rcx)
je 0xcc446
movq 0x10(%r12), %rax
testq %rax, %rax
jne 0xcc39c
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r9, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rcx, (%rsp)
callq 0xbe825
movq (%rsp), %rcx
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r9
movq %rax, 0x10(%r12)
cmpb $0x0, (%rax,%r15)
jne 0xcc3ec
movb $0x1, (%rax,%r15)
movq 0x8(%r12), %rax
movq %rcx, (%rsp)
leaq 0x1(%r13), %rcx
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
movq %r12, %rdi
movq %r9, 0x8(%rsp)
movq %r10, %rbp
callq 0xcc252
movq %rbp, %r10
movq 0x8(%rsp), %r9
movq %rax, %rcx
movq 0x10(%r12), %rax
movb $0x0, (%rax,%r15)
cmpq %rbx, %rcx
movq (%rsp), %rcx
jb 0xcc42f
cmpb $0x0, (%rax,%r10)
jne 0xcc456
movb $0x1, (%rax,%r10)
movq 0x8(%r12), %rax
incq %r13
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r12, %rdi
movq %r13, %rcx
movq %r9, %r15
movq %r10, %r13
callq 0xcc252
movq %r15, %r9
movq 0x10(%r12), %rcx
movb $0x0, (%rcx,%r13)
movq %r13, %r15
cmpq %rbx, %rax
jae 0xcc456
movq %r15, %rax
shlq $0x4, %rax
addq 0x8(%r12), %rax
jmp 0xcc44c
xorl %ebx, %ebx
jmp 0xcc456
addq %rbp, %rax
jmp 0xcc44c
addq %rcx, %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