// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rcx, -0x30(%rbp)
movl %edx, %ebx
movl %esi, -0x38(%rbp)
movq %rdi, -0x58(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %r15
movl 0x78(%rax), %eax
leal -0x1(%rax), %ecx
movl %ebx, -0x3c(%rbp)
andl %ebx, %ecx
leaq -0x48(%rbp), %rdx
movl %ecx, -0x8(%rdx)
movl %eax, -0x4(%rdx)
movl $0x0, (%rdx)
movl %ecx, 0x4(%rdx)
movl $0x1, %eax
leaq -0x50(%rbp), %rcx
movb $0x1, %dl
xorl %ebx, %ebx
movl %edx, -0x34(%rbp)
movl (%rcx), %r14d
movl -0x50(%rbp,%rax,4), %r12d
cmpl %r12d, %r14d
jae 0x47027
subq %r14, %r12
shlq $0x3, %r14
movq 0x70(%r15), %rax
movq (%rax,%r14), %r13
addq %r14, %rax
testq %r13, %r13
je 0x4704f
leaq 0x23922(%rip), %rcx     # 0x6a91c
cmpq %rcx, %r13
je 0x47017
movq %r13, %rdi
movq -0x58(%rbp), %rsi
movl -0x38(%rbp), %edx
movl -0x3c(%rbp), %ecx
callq 0x447ee
testl %eax, %eax
je 0x4701e
jmp 0x47062
testq %rbx, %rbx
cmoveq %rax, %rbx
addq $0x8, %r14
decq %r12
jne 0x46fe3
movl $0x3, %eax
leaq -0x48(%rbp), %rcx
testb $0x1, -0x34(%rbp)
movl $0x0, %edx
jne 0x46fcc
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
testq %rbx, %rbx
jne 0x4708c
callq 0x140b8
testq %rbx, %rbx
cmoveq %rax, %rbx
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
jmp 0x4708c
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
testq %rbx, %rbx
je 0x47085
movq %r13, (%rbx)
movq 0x70(%r15), %rax
leaq 0x2389d(%rip), %rcx     # 0x6a91c
movq %rcx, (%rax,%r14)
jmp 0x4708c
addq 0x70(%r15), %r14
movq %r14, %rbx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq