// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_name.c
// Function: set
static uz_t set( bcore_name_map_s* o, bcore_name_s name, 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( name.key ) & mask;
    if( !o->data[ idx1 ].key )
    {
        o->data[ idx1 ] = name;
        return idx1;
    }

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

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

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

    if( !o->flags[ idx2 ] )
    {
        o->flags[ idx2 ] = true;
        if( set( o, o->data[ idx2 ], depth + 1 ) < size )
        {
            o->flags[ idx2 ] = false;
            o->data[  idx2 ] = name;
            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 0x12bb3a
movq %rsi, %r15
movq %rdi, %r14
cmpq %rsi, 0x20(%rdi)
je 0x12bb5d
leaq 0x60(%rsp), %r10
leaq -0x1(%rbx), %rax
movq (%r10), %rcx
movl $0xffff, %r8d           # imm = 0xFFFF
movq %rcx, %rdx
andq %r8, %rdx
movabsq $-0x6fc95bdab4c873e1, %rdi # imm = 0x9036A4254B378C1F
xorq %rdx, %rdi
movabsq $0x1000000109f, %r13    # imm = 0x1000000109F
imulq %r13, %rdi
movl %ecx, %esi
shrl $0x10, %esi
xorq %rsi, %rdi
leaq 0x80(%r13), %r9
imulq %rdi, %r9
movq %rcx, %rdi
shrq $0x20, %rdi
andq %r8, %rdi
xorq %rdi, %r9
leaq 0x2ba(%r13), %r8
imulq %r9, %r8
shrq $0x30, %rcx
xorq %rcx, %r8
addq $0x344, %r13            # imm = 0x344
imulq %r8, %r13
andq %rax, %r13
movq 0x8(%r14), %r8
leaq (,%r13,2), %r12
addq %r13, %r12
cmpq $0x0, (%r8,%r12,8)
je 0x12bb3e
movabsq $0x37651f84128a9b31, %r9 # imm = 0x37651F84128A9B31
xorq %r9, %rdx
movabsq $0x1000001000011, %rbp  # imm = 0x1000001000011
imulq %rbp, %rdx
xorq %rsi, %rdx
leaq 0xbe(%rbp), %rsi
imulq %rdx, %rsi
xorq %rdi, %rsi
leaq 0x1cc(%rbp), %rdx
imulq %rsi, %rdx
xorq %rcx, %rdx
orq $0x360, %rbp            # imm = 0x360
imulq %rdx, %rbp
andq %rax, %rbp
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpq $0x0, (%r8,%rax,8)
je 0x12bb44
movq %rax, 0x20(%rsp)
movq 0x10(%r14), %rax
testq %rax, %rax
jne 0x12ba96
movl $0x1, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xbe825
leaq 0x60(%rsp), %r10
movq %rax, 0x10(%r14)
cmpb $0x0, (%rax,%r13)
jne 0x12badc
movb $0x1, (%rax,%r13)
movq 0x8(%r14), %rax
leaq 0x1(%r15), %rsi
movq 0x10(%rax,%r12,8), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax,%r12,8), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r10, %r12
callq 0x12b95a
movq %r12, %r10
movq %rax, %rcx
movq 0x10(%r14), %rax
movb $0x0, (%rax,%r13)
cmpq %rbx, %rcx
jb 0x12bb25
cmpb $0x0, (%rax,%rbp)
jne 0x12bb5d
movb $0x1, (%rax,%rbp)
movq 0x8(%r14), %rax
incq %r15
movq 0x20(%rsp), %rdx
movq 0x10(%rax,%rdx,8), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax,%rdx,8), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r10, %r15
callq 0x12b95a
movq %r15, %r10
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rbp)
movq %rbp, %r13
cmpq %rbx, %rax
jae 0x12bb5d
leaq (,%r13,2), %rax
addq %r13, %rax
shlq $0x3, %rax
addq 0x8(%r14), %rax
jmp 0x12bb4b
xorl %ebx, %ebx
jmp 0x12bb5d
leaq (%r8,%r12,8), %rax
jmp 0x12bb4b
leaq (%r8,%rax,8), %rax
movq %rbp, %r13
movq 0x10(%r10), %rcx
movq %rcx, 0x10(%rax)
movups (%r10), %xmm0
movups %xmm0, (%rax)
movq %r13, %rbx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq