// File: /workspace/github_c_makefile_star2_O1/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 0xde373
movq %rsi, %r11
movq %rdi, %r14
cmpq %rsi, 0x20(%rdi)
je 0xde395
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 0xde377
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, %r15
shlq $0x5, %r15
cmpq $0x0, (%rdx,%r15)
je 0xde37c
cmpq $0x0, 0x10(%r14)
jne 0xde2cf
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r11, 0x20(%rsp)
callq 0xc8389
movq 0x20(%rsp), %r11
leaq 0x60(%rsp), %r10
movq %rax, 0x10(%r14)
movq 0x10(%r14), %rax
cmpb $0x0, (%rax,%r13)
jne 0xde31c
movb $0x1, (%rax,%r13)
movq 0x8(%r14), %rax
leaq 0x1(%r11), %rsi
movups (%rax,%r12), %xmm0
movups 0x10(%rax,%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r11, %r12
callq 0xde199
movq %r12, %r11
leaq 0x60(%rsp), %r10
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%r13)
cmpq %rbx, %rax
jb 0xde366
movq 0x10(%r14), %rax
cmpb $0x0, (%rax,%rbp)
jne 0xde395
movb $0x1, (%rax,%rbp)
movq 0x8(%r14), %rax
incq %r11
movups (%rax,%r15), %xmm0
movups 0x10(%rax,%r15), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r11, %rsi
movq %r10, %r15
callq 0xde199
movq %r15, %r10
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rbp)
movq %rbp, %r13
cmpq %rbx, %rax
jae 0xde395
movq %r13, %rdx
shlq $0x5, %rdx
addq 0x8(%r14), %rdx
jmp 0xde382
xorl %ebx, %ebx
jmp 0xde395
addq %r12, %rdx
jmp 0xde382
addq %r15, %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