// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_hmap_tp_sr.c
// Function: tp_sr_set
static uz_t tp_sr_set( bcore_hmap_tp_sr_s* o, bcore_hnode_tp_sr_s node, uz_t depth ) // sets new node
{
    uz_t size = o->size;
    if( size == 0 ) return size;
    u3_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( tp_sr_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( tp_sr_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 $0x28, %rsp
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0xd45ff
movq %rsi, %r15
movq %rdi, %r14
cmpq %rsi, 0x20(%rdi)
je 0xd4621
leaq 0x60(%rsp), %r10
leaq -0x1(%rbx), %rax
movq (%r10), %rcx
movl $0xffff, %edx           # imm = 0xFFFF
movq %rcx, %rsi
andq %rdx, %rsi
movabsq $-0x6fc95bdab4c873e1, %r8 # imm = 0x9036A4254B378C1F
xorq %rsi, %r8
movabsq $0x1000000109f, %r13    # imm = 0x1000000109F
imulq %r13, %r8
movl %ecx, %edi
shrl $0x10, %edi
xorq %rdi, %r8
leaq 0x80(%r13), %r9
imulq %r8, %r9
movq %rcx, %r8
shrq $0x20, %r8
andq %rdx, %r8
xorq %r8, %r9
leaq 0x2ba(%r13), %rdx
imulq %r9, %rdx
shrq $0x30, %rcx
xorq %rcx, %rdx
addq $0x344, %r13            # imm = 0x344
imulq %rdx, %r13
andq %rax, %r13
movq 0x8(%r14), %rdx
movq %r13, %r12
shlq $0x5, %r12
cmpq $0x0, (%rdx,%r12)
je 0xd4603
movabsq $0x37651f84128a9b31, %r9 # imm = 0x37651F84128A9B31
xorq %r9, %rsi
movabsq $0x1000001000011, %rbp  # imm = 0x1000001000011
imulq %rbp, %rsi
xorq %rdi, %rsi
leaq 0xbe(%rbp), %rdi
imulq %rsi, %rdi
xorq %r8, %rdi
leaq 0x1cc(%rbp), %rsi
imulq %rdi, %rsi
xorq %rcx, %rsi
orq $0x360, %rbp            # imm = 0x360
imulq %rsi, %rbp
andq %rax, %rbp
movq %rbp, %rax
shlq $0x5, %rax
cmpq $0x0, (%rdx,%rax)
je 0xd4608
movq %rax, 0x20(%rsp)
movq 0x10(%r14), %rax
testq %rax, %rax
jne 0xd4562
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xbe825
leaq 0x60(%rsp), %r10
movq %rax, 0x10(%r14)
cmpb $0x0, (%rax,%r13)
jne 0xd45a9
movb $0x1, (%rax,%r13)
movq 0x8(%r14), %rax
leaq 0x1(%r15), %rsi
movups (%rax,%r12), %xmm0
movups 0x10(%rax,%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r10, %r12
callq 0xd442f
movq %r12, %r10
movq %rax, %rcx
movq 0x10(%r14), %rax
movb $0x0, (%rax,%r13)
cmpq %rbx, %rcx
jb 0xd45f2
cmpb $0x0, (%rax,%rbp)
jne 0xd4621
movb $0x1, (%rax,%rbp)
movq 0x8(%r14), %rax
incq %r15
movq 0x20(%rsp), %rcx
movups (%rax,%rcx), %xmm0
movups 0x10(%rax,%rcx), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r10, %r15
callq 0xd442f
movq %r15, %r10
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rbp)
movq %rbp, %r13
cmpq %rbx, %rax
jae 0xd4621
movq %r13, %rdx
shlq $0x5, %rdx
addq 0x8(%r14), %rdx
jmp 0xd460e
xorl %ebx, %ebx
jmp 0xd4621
addq %r12, %rdx
jmp 0xd460e
addq %rax, %rdx
movq %rbp, %r13
movups (%r10), %xmm0
movups 0x10(%r10), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movq %r13, %rbx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq