// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_get
struct kv *
icache_get(struct icache * const cache, const struct kv * const key, struct kv * const out)
{
  const u64 hash = key->hash;
  const u64 idx = (hash >> KVMAP_BASE_LEVEL) % cache->nr_slots;
  struct __icache_slot * const slot = &(cache->table[idx]);
  __builtin_prefetch(slot, 0, 3);
  const u64 pkey = kvmap_pkey(hash);
  icache_lock_hash(cache, hash);
  for (u64 i = 0; i < ICACHE_ENTRY_NR; i++) {
    if (slot->e[i].pkey == pkey) {
      struct kv * const curr = __u64_to_ptr(slot->e[i].ptr);
      if (kv_keymatch(curr, key)) {
        icache_amap_inc(slot, i);
        struct kv * const ret = kv_dup2(curr, out);
        icache_unlock_hash(cache, hash);
        // cache hit
        return ret;
      }
    }
  }
  struct kv * const ret2 = cache->map_api->get(cache->map_api->map, key, out);
  // index hit/miss
  icache_unlock_hash(cache, hash);
  return ret2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, -0x38(%rbp)
movq %rsi, %r15
movq (%rsi), %r14
movq %r14, %rcx
shrq $0x6, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdx, %rbx
movq 0x10130(%rdi), %r12
shlq $0x6, %rbx
prefetcht0 (%r12,%rbx)
andl $0x3ff, %ecx            # imm = 0x3FF
shll $0x6, %ecx
movq %rdi, -0x60(%rbp)
addq %rcx, %rdi
addq $0xe0, %rdi
movq %rdi, -0x48(%rbp)
callq 0x6050
cmpl $0x23, %eax
je 0x116a7
addq %rbx, %r12
movq %r14, %rax
shrq $0x20, %rax
xorq %r14, %rax
movq %rax, %rdi
shrq $0x10, %rdi
xorq %rax, %rdi
movq %r15, -0x40(%rbp)
leaq 0x10(%r15), %rax
movq %rax, -0x68(%rbp)
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %r14d, %r14d
movq %r12, %rsi
movq %r12, -0x58(%rbp)
movq %rdi, -0x50(%rbp)
movq 0x8(%rsi,%r14,8), %r15
movl %edi, %eax
xorw %r15w, %ax
jne 0x11647
movq %r15, %r12
shrq $0x10, %r12
cmpq $0x10000, %r15          # imm = 0x10000
jb 0x1158f
movq (%r12), %rax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x1158f
movl 0x8(%r12), %edx
cmpl 0x8(%rcx), %edx
jne 0x1158f
leaq 0x10(%r12), %rdi
movq -0x68(%rbp), %rsi
callq 0x63d0
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
testl %eax, %eax
sete %al
jmp 0x11591
xorl %eax, %eax
testb %al, %al
je 0x11643
movl %eax, -0x2c(%rbp)
movq (%rsi), %rax
movq %rax, %rcx
movabsq $0xfffffffffffffff, %rdx # imm = 0xFFFFFFFFFFFFFFF
andq %rdx, %rcx
shrxq %rbx, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x115de
movl $0x1, %ecx
shlxq %rbx, %rcx, %rcx
addq %rax, %rcx
andq %rdx, %rcx
movabsq $-0x1000000000000000, %rdx # imm = 0xF000000000000000
andq %rdx, %rax
orq %rcx, %rax
movq %rax, (%rsi)
cmpq $0x10000, %r15          # imm = 0x10000
jae 0x115ec
xorl %r15d, %r15d
jmp 0x1162b
movl 0x8(%r12), %eax
movl 0xc(%r12), %ecx
leaq (%rax,%rcx), %rdx
addq $0x10, %rdx
movq -0x38(%rbp), %rax
movq %rax, %r15
testq %rax, %rax
jne 0x11620
movq %rdx, %rdi
movq %rdx, %r15
callq 0x63a0
movq %r15, %rdx
movq %rax, %r15
testq %rax, %rax
je 0x1162b
movq %r15, %rdi
movq %r12, %rsi
callq 0x6340
movq %r15, -0x70(%rbp)
movq -0x48(%rbp), %rdi
callq 0x6320
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdi
movl -0x2c(%rbp), %eax
testb %al, %al
jne 0x11664
cmpq $0x6, %r14
leaq 0x1(%r14), %rax
setae %r13b
addq $0x4, %rbx
movq %rax, %r14
cmpq $0x7, %rax
jne 0x1153a
testb $0x1, %r13b
je 0x11694
movq -0x60(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq *0x8(%rax)
movq %rax, %rbx
movq -0x48(%rbp), %rdi
callq 0x6320
movq %rbx, %rax
jmp 0x11698
movq -0x70(%rbp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530