// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/symcache.c
// Function: janet_symcache_findmem
static const uint8_t **janet_symcache_findmem(
    const uint8_t *str,
    int32_t len,
    int32_t hash,
    int *success) {
    uint32_t bounds[4];
    uint32_t i, j, index;
    const uint8_t **firstEmpty = NULL;

    /* We will search two ranges - index to the end,
     * and 0 to the index. */
    index = (uint32_t)hash & (janet_vm.cache_capacity - 1);
    bounds[0] = index;
    bounds[1] = janet_vm.cache_capacity;
    bounds[2] = 0;
    bounds[3] = index;
    for (j = 0; j < 4; j += 2)
        for (i = bounds[j]; i < bounds[j + 1]; ++i) {
            const uint8_t *test = janet_vm.cache[i];
            /* Check empty spots */
            if (NULL == test) {
                if (NULL == firstEmpty)
                    firstEmpty = janet_vm.cache + i;
                goto notfound;
            }
            /* Check for marked deleted */
            if (JANET_SYMCACHE_DELETED == test) {
                if (firstEmpty == NULL)
                    firstEmpty = janet_vm.cache + i;
                continue;
            }
            if (janet_string_equalconst(test, str, len, hash)) {
                /* Replace first deleted */
                *success = 1;
                if (firstEmpty != NULL) {
                    *firstEmpty = test;
                    janet_vm.cache[i] = JANET_SYMCACHE_DELETED;
                    return firstEmpty;
                }
                return janet_vm.cache + i;
            }
        }
notfound:
    *success = 0;
    janet_assert(firstEmpty != NULL, "symcache failed to get memory");
    return firstEmpty;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, -0x50(%rbp)
movl %edx, %ebx
movl %esi, -0x2c(%rbp)
movq %rdi, -0x68(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rsi
movl 0x78(%rax), %eax
leal -0x1(%rax), %ecx
movl %ebx, -0x30(%rbp)
andl %ebx, %ecx
movl %ecx, -0x40(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl %ecx, -0x34(%rbp)
xorl %eax, %eax
leaq 0x23f2c(%rip), %r13     # 0x6b93c
xorl %ebx, %ebx
movq %rsi, -0x58(%rbp)
movl -0x40(%rbp,%rax,4), %r14d
movq %rax, -0x60(%rbp)
movl -0x3c(%rbp,%rax,4), %r12d
cmpl %r12d, %r14d
jae 0x47ad4
subq %r14, %r12
shlq $0x3, %r14
movq 0x70(%rsi), %rax
movq (%rax,%r14), %r15
addq %r14, %rax
testq %r15, %r15
je 0x47a88
cmpq %r13, %r15
je 0x47a96
movq %r15, %rdi
movq -0x68(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
callq 0x4512e
testl %eax, %eax
je 0x47aa4
movq -0x50(%rbp), %rax
movl $0x1, (%rax)
testq %rbx, %rbx
movq -0x58(%rbp), %rsi
je 0x47aac
movq %r15, (%rbx)
movq 0x70(%rsi), %rax
movq %r13, (%rax,%r14)
movl $0x1, %eax
movq %rbx, -0x48(%rbp)
jmp 0x47abe
testq %rbx, %rbx
cmoveq %rax, %rbx
movl $0x8, %eax
jmp 0x47abe
testq %rbx, %rbx
cmoveq %rax, %rbx
movl $0x7, %eax
jmp 0x47abe
xorl %eax, %eax
movq -0x58(%rbp), %rsi
jmp 0x47abe
movq 0x70(%rsi), %rax
addq %r14, %rax
movq %rax, -0x48(%rbp)
movl $0x1, %eax
xorl %ebx, %ebx
testl %eax, %eax
je 0x47ac7
cmpl $0x7, %eax
jne 0x47ae7
addq $0x8, %r14
decq %r12
jne 0x47a34
movq -0x60(%rbp), %rcx
leaq 0x2(%rcx), %rax
testq %rcx, %rcx
je 0x47a16
jmp 0x47aec
cmpl $0x8, %eax
jne 0x47b03
movq -0x50(%rbp), %rax
movl $0x0, (%rax)
movq %rbx, %rax
testq %rbx, %rbx
jne 0x47b07
callq 0x140c8
movq -0x48(%rbp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq