// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x54(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movl -0x54(%rbp), %eax
movl 0x78(%rcx), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl 0x78(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jae 0x68b96
movl -0x38(%rbp), %eax
movl -0x30(%rbp,%rax,4), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
cmpl -0x30(%rbp,%rcx,4), %eax
jae 0x68b86
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x70(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq -0x50(%rbp), %rax
jne 0x68ab4
xorl %eax, %eax
cmpq -0x48(%rbp), %rax
jne 0x68aaf
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x70(%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x68b98
leaq 0x2f251(%rip), %rax     # 0x97d0c
cmpq -0x50(%rbp), %rax
jne 0x68aef
cmpq $0x0, -0x48(%rbp)
jne 0x68aea
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x70(%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x68b78
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x649b0
cmpl $0x0, %eax
je 0x68b76
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
cmpq $0x0, -0x48(%rbp)
je 0x68b52
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x70(%rax), %rax
movl -0x34(%rbp), %ecx
leaq 0x2f1cb(%rip), %rdx     # 0x97d0c
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x68be5
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x70(%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x68be5
jmp 0x68b78
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x68a49
jmp 0x68b88
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x68a35
jmp 0x68b98
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x48(%rbp)
jne 0x68bdb
jmp 0x68bab
movq 0x4743e(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x18458(%rip), %rsi     # 0x81014
movl $0x6f, %edx
leaq 0x2f112(%rip), %rcx     # 0x97cda
leaq 0x2f11f(%rip), %r8      # 0x97cee
movb $0x0, %al
callq 0x125f0
callq 0x12100
jmp 0x68bdd
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop