LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_create
struct chainmap *
chainmap_create(const struct kvmap_mm * const mm)
{
  struct chainmap * const map = (typeof(map))malloc(sizeof(*map));
  debug_assert(map);
  memset(map, 0, sizeof(*map));
  map->mm = mm ? (*mm) : __kvmap_mm_default;
  atomic_store(&(map->nr_kv), 0);
  map->fixed_power = 0;
  //if (map->fixed_power && (map->fixed_power < KVMAP_MIN_LEVEL)) {
  //  map->fixed_power = KVMAP_MIN_LEVEL;
  //}
  map->power = map->fixed_power ? map->fixed_power : KVMAP_MIN_LEVEL;
  map->trigger = UINT64_C(2) << map->power;
  const u64 table_size = sizeof(map->table[0]) * (UINT64_C(1) << map->power);
  map->table = (typeof(map->table))pages_alloc_best(table_size, true, &(map->alloc_size));
  mutexlock_init(&(map->expand_lock));
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_init(&(map->hlocks[i]));
  }
  return map;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movl $0x1, %edi
movl $0x10138, %esi          # imm = 0x10138
callq 0x62d0
movq %rax, %rbx
testq %rax, %rax
je 0xf6c4
testq %r14, %r14
je 0xf5f9
vmovups (%r14), %ymm0
vmovups 0x20(%r14), %ymm1
vmovups 0x30(%r14), %ymm2
vmovups %ymm2, 0x30(%rbx)
vmovups %ymm1, 0x20(%rbx)
jmp 0xf61b
vmovups 0xa7b7(%rip), %ymm0     # 0x19db8
vmovups %ymm0, 0x30(%rbx)
vmovups 0xa79a(%rip), %ymm0     # 0x19da8
vmovups %ymm0, 0x20(%rbx)
vmovups 0xa76d(%rip), %ymm0     # 0x19d88
vmovups %ymm0, (%rbx)
xorl %eax, %eax
xchgq %rax, 0x88(%rbx)
xorl %r14d, %r14d
movq $0x0, 0xc8(%rbx)
movq $0x10, 0xd0(%rbx)
movq $0x20000, 0xd8(%rbx) # imm = 0x20000
movl $0x80000, %esi          # imm = 0x80000
xorl %edi, %edi
movl $0x3, %edx
movl $0x2022, %ecx           # imm = 0x2022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
vzeroupper
callq 0x6190
leaq 0x1(%rax), %rcx
cmpq $0x2, %rcx
jb 0xf686
movq $0x80000, 0xf0(%rbx) # imm = 0x80000
movq %rax, %r14
movq %r14, 0xe8(%rbx)
leaq 0xf8(%rbx), %rdi
xorl %esi, %esi
callq 0x65d0
movl $0x138, %r14d           # imm = 0x138
leaq (%rbx,%r14), %rdi
movl $0x1, %esi
callq 0x62e0
addq $0x40, %r14
cmpq $0x10138, %r14          # imm = 0x10138
jne 0xf6a1
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x66ef
jmp 0xf5d7
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_get
struct kv *
chainmap_get(struct chainmap * const map, const struct kv * const key, struct kv * const out)
{
  const u64 hash = key->hash;
  const u64 lidx = kvmap_hlocks_index(hash);
  const u64 pkey = kvmap_pkey(hash);
  spinlock_lock(&(map->hlocks[lidx]));
  const u64 cid = (hash >> KVMAP_BASE_LEVEL) & ((UINT64_C(1) << map->power) - UINT64_C(1));
  struct chainnode * iter = map->table[cid];
  while (iter) {
    if (iter->e.pkey == pkey) {
      const struct kv * const curr = __u64_to_ptr(iter->e.ptr);
      if (kv_keymatch(key, curr)) {
        if (map->mm.hf) map->mm.hf(curr, map->mm.hp);
        struct kv * const ret = kv_dup2(curr, out);
        spinlock_unlock(&(map->hlocks[lidx]));
        return ret;
      }
    }
    iter = iter->next;
  }
  spinlock_unlock(&(map->hlocks[lidx]));
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x40(%rbp)
movq %rsi, %r12
movq %rdi, %r15
movq (%rsi), %r14
movq %r14, %rbx
shrq $0x6, %rbx
movl %ebx, %eax
andl $0x3ff, %eax            # imm = 0x3FF
shll $0x6, %eax
leaq (%rdi,%rax), %r13
addq $0x138, %r13            # imm = 0x138
movq %r13, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xf81a
movb 0xd0(%r15), %al
bzhiq %rax, %rbx, %rax
movq %r15, -0x38(%rbp)
movq 0xe8(%r15), %rcx
movq (%rcx,%rax,8), %rbx
testq %rbx, %rbx
je 0xf7ae
movq %r13, -0x30(%rbp)
movq %r14, %rax
shrq $0x20, %rax
xorq %r14, %rax
movq %rax, %r15
shrq $0x10, %r15
xorq %rax, %r15
leaq 0x10(%r12), %rax
movq %rax, -0x48(%rbp)
movq (%rbx), %r13
movl %r15d, %eax
xorw %r13w, %ax
jne 0xf79c
cmpq $0x10000, %r13          # imm = 0x10000
jb 0xf79c
shrq $0x10, %r13
movq (%r12), %rax
cmpq (%r13), %rax
jne 0xf79c
movl 0x8(%r12), %r14d
cmpl 0x8(%r13), %r14d
jne 0xf79c
leaq 0x10(%r13), %rsi
movq -0x48(%rbp), %rdi
movq %r14, %rdx
callq 0x63d0
testl %eax, %eax
je 0xf7cb
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0xf75a
xorl %r14d, %r14d
movq -0x30(%rbp), %r13
jmp 0xf7b1
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x6320
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rax
testq %rax, %rax
je 0xf7e5
movq 0x28(%rcx), %rsi
movq %r13, %rdi
callq *%rax
movl 0x8(%r13), %r14d
movl 0xc(%r13), %eax
leaq (%r14,%rax), %rbx
addq $0x10, %rbx
movq -0x40(%rbp), %r14
testq %r14, %r14
jne 0xf80a
movq %rbx, %rdi
callq 0x63a0
movq %rax, %r14
testq %rax, %rax
je 0xf7a5
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6340
jmp 0xf7a8
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_probe
bool
chainmap_probe(struct chainmap * const map, const struct kv * const key)
{
  const u64 hash = key->hash;
  const u64 lidx = kvmap_hlocks_index(hash);
  const u64 pkey = kvmap_pkey(hash);
  spinlock_lock(&(map->hlocks[lidx]));
  const u64 cid = (hash >> KVMAP_BASE_LEVEL) & ((UINT64_C(1) << map->power) - UINT64_C(1));
  struct chainnode * iter = map->table[cid];
  while (iter) {
    if (iter->e.pkey == pkey) {
      const struct kv * const curr = __u64_to_ptr(iter->e.ptr);
      if (kv_keymatch(key, curr)) {
        if (map->mm.hf) map->mm.hf(curr, map->mm.hp);
        spinlock_unlock(&(map->hlocks[lidx]));
        return true;
      }
    }
    iter = iter->next;
  }
  spinlock_unlock(&(map->hlocks[lidx]));
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rbx
movq %rbx, %r12
shrq $0x6, %r12
movl %r12d, %eax
andl $0x3ff, %eax            # imm = 0x3FF
shll $0x6, %eax
leaq (%rdi,%rax), %r13
addq $0x138, %r13            # imm = 0x138
movq %r13, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xf929
movb 0xd0(%r14), %al
bzhiq %rax, %r12, %rax
movq 0xe8(%r14), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0xf8f5
movq %r13, -0x30(%rbp)
movq %rbx, %rax
shrq $0x20, %rax
xorq %rbx, %rax
movq %rax, %rbx
shrq $0x10, %rbx
xorq %rax, %rbx
leaq 0x10(%r15), %rax
movq %rax, -0x38(%rbp)
movq (%r12), %r13
movl %ebx, %eax
xorw %r13w, %ax
jne 0xf8e2
cmpq $0x10000, %r13          # imm = 0x10000
jb 0xf8e2
shrq $0x10, %r13
movq (%r15), %rax
cmpq (%r13), %rax
jne 0xf8e2
movl 0x8(%r15), %edx
cmpl 0x8(%r13), %edx
jne 0xf8e2
leaq 0x10(%r13), %rsi
movq -0x38(%rbp), %rdi
callq 0x63d0
testl %eax, %eax
je 0xf912
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0xf8a5
xorl %r15d, %r15d
movq -0x30(%rbp), %r13
jmp 0xf8f8
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x6320
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %rax
movb $0x1, %r15b
testq %rax, %rax
je 0xf8ef
movq 0x28(%r14), %rsi
movq %r13, %rdi
callq *%rax
jmp 0xf8ef
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_del
bool
chainmap_del(struct chainmap * const map, const struct kv * const key)
{
  const u64 hash = key->hash;
  const u64 lidx = kvmap_hlocks_index(hash);
  const u64 pkey = kvmap_pkey(hash);
  spinlock_lock(&(map->hlocks[lidx]));
  const u64 cid = (hash >> KVMAP_BASE_LEVEL) & ((UINT64_C(1) << map->power) - UINT64_C(1));
  struct chainnode ** piter = &(map->table[cid]);
  while (*piter) {
    struct chainnode * const iter = *piter;
    if (iter->e.pkey == pkey) {
      const struct kv * const curr = __u64_to_ptr(iter->e.ptr);
      if (kv_keymatch(key, curr)) {
        kvmap_put_entry(&(map->mm), &(iter->e), NULL);
        *piter = iter->next;
        free(iter);
        atomic_fetch_sub(&(map->nr_kv), 1);
        spinlock_unlock(&(map->hlocks[lidx]));
        return true;
      }
    }
    piter = &(iter->next);
  }
  spinlock_unlock(&(map->hlocks[lidx]));
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %r13
movq (%rsi), %r14
movq %r14, %rbx
shrq $0x6, %rbx
movl %ebx, %eax
andl $0x3ff, %eax            # imm = 0x3FF
shll $0x6, %eax
leaq (%rdi,%rax), %r12
addq $0x138, %r12            # imm = 0x138
movq %r12, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xfd16
movb 0xd0(%r13), %al
bzhiq %rax, %rbx, %rax
movq 0xe8(%r13), %rcx
movq (%rcx,%rax,8), %rbx
testq %rbx, %rbx
je 0xfcbf
movq %r13, -0x38(%rbp)
movq %r12, -0x30(%rbp)
movq %r14, %rdx
shrq $0x20, %rdx
xorq %r14, %rdx
movq %rdx, %r14
shrq $0x10, %r14
xorq %rdx, %r14
leaq (%rcx,%rax,8), %r12
leaq 0x10(%r15), %rax
movq %rax, -0x40(%rbp)
movq (%rbx), %r13
movl %r14d, %eax
xorw %r13w, %ax
jne 0xfca3
cmpq $0x10000, %r13          # imm = 0x10000
jb 0xfca3
shrq $0x10, %r13
movq (%r15), %rax
cmpq (%r13), %rax
jne 0xfca3
movl 0x8(%r15), %edx
cmpl 0x8(%r13), %edx
jne 0xfca3
leaq 0x10(%r13), %rsi
movq -0x40(%rbp), %rdi
callq 0x63d0
testl %eax, %eax
je 0xfcdc
movq %rbx, %r12
movq 0x8(%rbx), %rax
addq $0x8, %r12
movq %rax, %rbx
testq %rax, %rax
jne 0xfc66
xorl %r14d, %r14d
movq -0x30(%rbp), %r12
jmp 0xfcc2
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x6320
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %r14
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xfcf2
movq 0x18(%r14), %rsi
movq %r13, %rdi
callq *%rax
movq $0x0, (%rbx)
movq 0x8(%rbx), %rax
movq %rax, (%r12)
movq %rbx, %rdi
callq 0x6060
lock
decq 0x88(%r14)
movb $0x1, %r14b
jmp 0xfcb9
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_clean
inline void
chainmap_clean(struct chainmap * const map)
{
  mutexlock_lock(&(map->expand_lock));
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_lock(&(map->hlocks[i]));
  }
  const u64 nr = UINT64_C(1) << map->power;
  for (u64 i = 0; i < nr; i++) {
    struct chainnode * iter = map->table[i];
    while (iter) {
      kvmap_put_entry(&(map->mm), &(iter->e), NULL);
      atomic_fetch_sub(&(map->nr_kv), 1);
      struct chainnode * const next = iter->next;
      free(iter);
      iter = next;
    }
    map->table[i] = NULL;
  }
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_unlock(&(map->hlocks[i]));
  }
  mutexlock_unlock(&(map->expand_lock));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0xf8(%rdi), %rbx
movq %rbx, %rdi
callq 0x65f0
cmpl $0xb, %eax
je 0xfd38
testl %eax, %eax
jne 0xfe37
leaq 0x138(%r14), %r12
xorl %r15d, %r15d
leaq (%r12,%r15), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xfe37
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0xfd57
movq %rbx, -0x30(%rbp)
movq 0xd0(%r14), %rax
movq %rax, -0x38(%rbp)
xorl %r13d, %r13d
movq 0xe8(%r14), %rax
movq (%rax,%r13,8), %r15
testq %r15, %r15
je 0xfde1
movq (%r15), %rdi
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0xfdb7
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xfdb7
shrq $0x10, %rdi
movq 0x18(%r14), %rsi
callq *%rax
movq $0x0, (%r15)
lock
decq 0x88(%r14)
movq 0x8(%r15), %rbx
movq %r15, %rdi
callq 0x6060
movq %rbx, %r15
testq %rbx, %rbx
jne 0xfd98
movq 0xe8(%r14), %rax
movq $0x0, (%rax,%r13,8)
incq %r13
movq -0x38(%rbp), %rax
shrxq %rax, %r13, %rax
testq %rax, %rax
je 0xfd88
xorl %r14d, %r14d
leaq (%r12,%r14), %rdi
callq 0x6320
addq $0x40, %r14
cmpq $0x10000, %r14          # imm = 0x10000
jne 0xfdfd
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x6390
cmpl $0xb, %eax
je 0xfe17
testl %eax, %eax
jne 0xfe37
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_iter_create
struct chainmap_iter *
chainmap_iter_create(struct chainmap * const map)
{
  mutexlock_lock(&(map->expand_lock));
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_lock(&(map->hlocks[i]));
  }
  struct chainmap_iter * const iter = (typeof(iter))malloc(sizeof(*iter));
  iter->map = map;
  u64 cid = 0;
  while (map->table[cid] == NULL) cid++;
  iter->curr = map->table[cid];
  iter->cid = cid;
  return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0xf8(%rdi), %r14
movq %r14, %rdi
callq 0x65f0
cmpl $0xb, %eax
je 0xfea5
testl %eax, %eax
jne 0xff0c
movl $0x138, %r14d           # imm = 0x138
leaq (%rbx,%r14), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xff0c
addq $0x40, %r14
cmpq $0x10138, %r14          # imm = 0x10138
jne 0xfebc
movl $0x18, %edi
callq 0x63a0
movq %rbx, (%rax)
movq 0xe8(%rbx), %rdx
movq $-0x1, %rcx
movq 0x8(%rdx,%rcx,8), %rsi
incq %rcx
testq %rsi, %rsi
je 0xfef2
movq %rsi, 0x10(%rax)
movq %rcx, 0x8(%rax)
popq %rbx
popq %r14
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_iter_next
struct kv *
chainmap_iter_next(struct chainmap_iter * const iter, struct kv * const out)
{
  struct chainnode * curr = iter->curr;
  if (iter->curr == NULL) return NULL;
  struct kv * const ret = kv_dup2(__u64_to_ptr(curr->e.ptr), out);
  curr = curr->next;
  if (curr == NULL) {
    const u64 dirsize = UINT64_C(1) << iter->map->power;
    for (u64 cid = iter->cid + 1; cid < dirsize; cid++) {
      if (iter->map->table[cid]) {
        curr = iter->map->table[cid];
        iter->cid = cid;
        break;
      }
    }
  }
  iter->curr = curr;
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x10(%rdi), %r13
testq %r13, %r13
je 0xff3e
movq %rdi, %r14
movq (%r13), %r15
cmpq $0x10000, %r15          # imm = 0x10000
jae 0xff42
xorl %ebx, %ebx
jmp 0xff7c
xorl %ebx, %ebx
jmp 0xffbc
movq %rsi, %rbx
shrq $0x10, %r15
movl 0x8(%r15), %eax
movl 0xc(%r15), %ecx
leaq (%rax,%rcx), %r12
addq $0x10, %r12
testq %rsi, %rsi
jne 0xff6e
movq %r12, %rdi
callq 0x63a0
movq %rax, %rbx
testq %rax, %rax
je 0xff3a
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6340
movq 0x8(%r13), %rsi
testq %rsi, %rsi
jne 0xffb8
movq (%r14), %rcx
movq 0x8(%r14), %rax
movq 0xd0(%rcx), %rdx
incq %rax
shrxq %rdx, %rax, %rsi
testq %rsi, %rsi
jne 0xffb6
movq 0xe8(%rcx), %rsi
movq (%rsi,%rax,8), %rsi
testq %rsi, %rsi
je 0xff93
movq %rax, 0x8(%r14)
jmp 0xffb8
xorl %esi, %esi
movq %rsi, 0x10(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: chainmap_iter_destroy
void
chainmap_iter_destroy(struct chainmap_iter * const iter)
{
  struct chainmap * const map = iter->map;
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_unlock(&(map->hlocks[i]));
  }
  mutexlock_unlock(&(map->expand_lock));
  free(iter);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0x138(%r14), %r15
xorl %r12d, %r12d
leaq (%r15,%r12), %rdi
callq 0x6320
addq $0x40, %r12
cmpq $0x10000, %r12          # imm = 0x10000
jne 0xffe9
addq $0xf8, %r14
movq %r14, %rdi
callq 0x6390
cmpl $0xb, %eax
je 0x10006
testl %eax, %eax
jne 0x10027
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6060
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_create
struct bptree *
bptree_create(const struct kvmap_mm * const mm)
{
  debug_assert(sizeof(struct bpnode) < PGSZ);
  struct bptree * const tree = (typeof(tree))malloc(sizeof(*tree));
  if (tree == NULL) return NULL;
  tree->mm = mm ? (*mm) : __kvmap_mm_default;
  struct bpnode * const root = bptree_alloc_node(true);
  if (root == NULL) {
    free(tree);
    return NULL;
  }
  root->nr = 1;
  tree->root = root;
  return tree;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movl $0x58, %edi
callq 0x63a0
movq %rax, %rbx
testq %rax, %rax
je 0x10147
testq %r14, %r14
leaq 0x9c9d(%rip), %rax      # 0x19d88
cmovneq %r14, %rax
vmovups (%rax), %ymm0
vmovups 0x20(%rax), %ymm1
vmovups 0x30(%rax), %ymm2
vmovups %ymm2, 0x30(%rbx)
vmovups %ymm1, 0x20(%rbx)
vmovups %ymm0, (%rbx)
xorl %r14d, %r14d
movl $0x1000, %esi           # imm = 0x1000
xorl %edi, %edi
movl $0x3, %edx
movl $0x2022, %ecx           # imm = 0x2022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
vzeroupper
callq 0x6190
cmpq $-0x1, %rax
cmoveq %r14, %rax
movb $0x1, (%rax)
movq $0x1, 0x8(%rax)
movq %rax, 0x50(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_raw_balance_leaf
bool
bptree_raw_balance_leaf(struct bpnode * const left, struct bpnode * const right)
{
  const u64 nr_r = (left->nr + right->nr) >> 1;
  const u64 nr_l = (left->nr + right->nr) - nr_r;
  if (nr_l == left->nr) {
    return false;
  } else if (nr_l < left->nr) { // shift right
    const u64 rmore = nr_r - right->nr;
    memmove(&(right->karray[rmore]), &(right->karray[0]), sizeof(right->karray[0]) * right->nr);
    memmove(&(right->karray[0]), &(left->karray[nr_l]), sizeof(right->karray[0]) * rmore);
  } else { // shift left
    const u64 rless = nr_l - left->nr;
    memmove(&(left->karray[left->nr]), &(right->karray[0]), sizeof(right->karray[0]) * rless);
    memmove(&(right->karray[0]), &(right->karray[rless]), sizeof(right->karray[0]) * nr_r);
  }
  left->nr = nr_l;
  right->nr = nr_r;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x8(%rdi), %r13
movq 0x8(%rsi), %rdx
leaq (%rdx,%r13), %r15
movq %r15, %r14
shrq %r14
subq %r14, %r15
movq %r15, %r12
subq %r13, %r12
je 0x10378
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
jae 0x10336
movq %r14, %r12
subq %rdx, %r12
leaq 0x20(%rbx), %rsi
movq %rsi, -0x30(%rbp)
leaq (%rbx,%r12,8), %rdi
addq $0x20, %rdi
shlq $0x3, %rdx
callq 0x6450
movq -0x38(%rbp), %rax
leaq (%rax,%r15,8), %rsi
addq $0x20, %rsi
shlq $0x3, %r12
movq -0x30(%rbp), %rdi
movq %r12, %rdx
jmp 0x10367
leaq (%rdi,%r13,8), %rdi
addq $0x20, %rdi
leaq 0x20(%rbx), %rsi
movq %rsi, -0x30(%rbp)
leaq (,%r12,8), %rdx
callq 0x6450
leaq (%rbx,%r12,8), %rsi
addq $0x20, %rsi
leaq (,%r14,8), %rdx
movq -0x30(%rbp), %rdi
callq 0x6450
movq -0x38(%rbp), %rax
movq %r15, 0x8(%rax)
movq %r14, 0x8(%rbx)
cmpq %r13, %r15
setne %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_set_leaf
static bool
bptree_set_leaf(struct bptree * const tree, struct bpnode * const leaf, const struct kv * const kv)
{
  debug_assert(leaf->nr < BPTREE_LEAF_FO);

  const u64 idx = bptree_leaf_locate(leaf, kv);
  if (kv_keymatch(kv, leaf->karray[idx])) {
    struct kv * const victim = (typeof(victim))(leaf->karray[idx]);
    if (victim && tree->mm.xf) tree->mm.xf(victim, kv, tree->mm.xp);
    else if (victim && tree->mm.rf) tree->mm.rf(victim, tree->mm.rp);
    leaf->karray[idx] = kv;
  } else {
    const u64 insert = idx + 1;
    bptree_raw_insert_leaf(leaf, insert, kv);
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, -0x30(%rbp)
movq 0x8(%rsi), %rax
cmpq $0x1f4, %rax            # imm = 0x1F4
jae 0x109f9
cmpq $0x2, %rax
movq %rax, -0x38(%rbp)
jae 0x10944
xorl %r13d, %r13d
jmp 0x1097e
leaq -0x1(%rax), %r15
xorl %r12d, %r12d
leaq (%r12,%r15), %r13
incq %r13
shrq %r13
movq 0x20(%r14,%r13,8), %rsi
movq %rbx, %rdi
callq 0xb998
testl %eax, %eax
js 0x1096a
jne 0x10973
jmp 0x1097e
decq %r13
movq %r13, %r15
movq %r12, %r13
movq %r13, %r12
cmpq %r15, %r13
movq %r15, %r13
jb 0x1094b
leaq 0x20(%r14), %rsi
testq %rbx, %rbx
je 0x109bc
movq 0x20(%r14,%r13,8), %r12
testq %r12, %r12
je 0x109bc
movq (%rbx), %rax
cmpq (%r12), %rax
jne 0x109bc
movl 0x8(%rbx), %edx
cmpl 0x8(%r12), %edx
jne 0x109bc
leaq 0x10(%rbx), %rdi
movq %rsi, %r15
leaq 0x10(%r12), %rsi
callq 0x63d0
movq %r15, %rsi
testl %eax, %eax
je 0x10a18
leaq 0x1(%r13), %r15
movq -0x38(%rbp), %rdx
cmpq %r13, %rdx
jbe 0x10a07
leaq (%rsi,%r13,8), %rdi
addq $0x10, %rdi
leaq (%rsi,%r15,8), %rsi
subq %r15, %rdx
shlq $0x3, %rdx
callq 0x6450
movq %rbx, 0x28(%r14,%r13,8)
incq 0x8(%r14)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
movq 0x8(%r14), %rax
jmp 0x10935
movq %rsi, %r12
callq 0x66ef
movq %r12, %rsi
movq 0x8(%r14), %rdx
jmp 0x109c9
movq -0x30(%rbp), %rcx
movq 0x40(%rcx), %rax
testq %rax, %rax
je 0x10a33
movq 0x48(%rcx), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq *%rax
jmp 0x10a45
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x10a48
movq 0x18(%rcx), %rsi
movq %r12, %rdi
callq *%rax
movq %r15, %rsi
movq %rbx, (%rsi,%r13,8)
jmp 0x109ea
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_intm_locate
static u64
bptree_intm_locate(struct bpnode * const node, const struct kv * const key)
{
  if (node->nr < 2) {
    return 0;
  }
  u64 l = 0;
  u64 r = node->nr - 1;
  while (l < r) {
    const u64 m = (l + r + 1) >> 1;
    const int cmp = kv_keycompare(key, node->iarray[m].key);
    if (cmp < 0) {
      r = m - 1;
    } else if (cmp > 0) {
      l = m;
    } else {
      return m;
    }
  }
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x8(%rdi), %r12
cmpq $0x2, %r12
jae 0x10a6b
xorl %r15d, %r15d
jmp 0x10ab4
movq %rsi, %rbx
movq %rdi, %r14
decq %r12
addq $0x20, %r14
xorl %r13d, %r13d
leaq (%r12,%r13), %r15
incq %r15
shrq %r15
movq %r15, %rax
shlq $0x4, %rax
movq (%r14,%rax), %rsi
movq %rbx, %rdi
callq 0xb998
testl %eax, %eax
js 0x10aa0
jne 0x10aa9
jmp 0x10ab4
decq %r15
movq %r15, %r12
movq %r13, %r15
movq %r15, %r13
cmpq %r12, %r15
movq %r12, %r15
jb 0x10a7b
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_clean_rec
void
bptree_clean_rec(struct bptree * const tree, struct bpnode * const node)
{
  if (node->leaf) {
    for (u64 i = 0; i < node->nr; i++) {
      struct kv * const victim = (typeof(victim))(node->karray[i]);
      if (victim && tree->mm.rf) tree->mm.rf(victim, tree->mm.rp);
    }
  } else {
    for (u64 i = 0; i < node->nr; i++) {
      struct kv * const victim = (typeof(victim))(node->iarray[i].key);
      free(victim);
      bptree_clean_rec(tree, node->iarray[i].sub);
    }
  }
  pages_unmap(node, PGSZ);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %rax
cmpb $0x0, (%rsi)
je 0x10b39
testq %rax, %rax
je 0x10b66
xorl %r15d, %r15d
movq 0x20(%rbx,%r15,8), %rdi
testq %rdi, %rdi
je 0x10b2f
movq 0x10(%r14), %rcx
testq %rcx, %rcx
je 0x10b2f
movq 0x18(%r14), %rsi
callq *%rcx
movq 0x8(%rbx), %rax
incq %r15
cmpq %rax, %r15
jb 0x10b12
jmp 0x10b66
testq %rax, %rax
je 0x10b66
leaq 0x28(%rbx), %r15
xorl %r12d, %r12d
movq -0x8(%r15), %rdi
callq 0x6060
movq (%r15), %rsi
movq %r14, %rdi
callq 0x10af0
incq %r12
addq $0x10, %r15
cmpq 0x8(%rbx), %r12
jb 0x10b45
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6410
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_iter_create
struct bptree_iter *
bptree_iter_create(struct bptree * const tree)
{
  struct bptree_iter * const iter = (typeof(iter))malloc(sizeof(*iter));
  struct bpnode * node = tree->root;
  while (node->leaf == false) {
    node = node->iarray[0].sub;
  }
  u64 i = 1;
  while (i >= node->nr) {
    i = 0;
    node = node->next;
  }
  iter->curr = node;
  iter->i = i;
  debug_assert(node->karray[0] == NULL);
  return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movl $0x10, %edi
callq 0x63a0
movq %rax, %rbx
addq $0x50, %r14
movq (%r14), %rax
leaq 0x28(%rax), %r14
cmpb $0x0, (%rax)
je 0x10c17
movl $0x1, %ecx
cmpq $0x1, 0x8(%rax)
ja 0x10c3c
xorl %ecx, %ecx
movq 0x10(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x10c31
movq %rax, (%rbx)
movq %rcx, 0x8(%rbx)
cmpq $0x0, 0x20(%rax)
jne 0x10c52
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x66ef
jmp 0x10c4a
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: bptree_iter_next
struct kv *
bptree_iter_next(struct bptree_iter * const iter, struct kv * const out)
{
  struct bpnode * curr = iter->curr;
  if (curr == NULL) {
    return NULL;
  }
  debug_assert(curr->nr);
  u64 i = iter->i;
  struct kv * const ret = kv_dup2(curr->karray[i], out);
  i++;
  if (i >= curr->nr) {
    i = 0;
    curr = curr->next;
    iter->curr = curr;
  }
  iter->i = i;
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r13
testq %r13, %r13
je 0x10cc2
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, 0x8(%r13)
je 0x10cf1
movq 0x8(%r14), %r12
movq 0x20(%r13,%r12,8), %r15
testq %r15, %r15
je 0x10cc6
movl 0x8(%r15), %eax
movl 0xc(%r15), %ecx
leaq (%rax,%rcx), %rdx
addq $0x10, %rdx
testq %rbx, %rbx
jne 0x10cb5
movq %rdx, %rdi
movq %rdx, %rbx
callq 0x63a0
movq %rbx, %rdx
movq %rax, %rbx
testq %rax, %rax
je 0x10cc6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6340
jmp 0x10cc8
xorl %ebx, %ebx
jmp 0x10cdf
xorl %ebx, %ebx
incq %r12
cmpq 0x8(%r13), %r12
jb 0x10cdb
movq 0x10(%r13), %rax
movq %rax, (%r14)
xorl %r12d, %r12d
movq %r12, 0x8(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
jmp 0x10c7c
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: tcpmap_create
struct tcpmap *
tcpmap_create(const char * const host, const int port)
{
  struct stream2 * const s = stream2_create(host, port);
  if (s == NULL) {
    return NULL;
  }

  struct tcpmap * const tcpmap = (typeof(tcpmap))malloc(sizeof(*tcpmap));
  tcpmap->stream2 = s;
  tcpmap->ok = true;
  return tcpmap;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
callq 0xb3ca
testq %rax, %rax
je 0x10dbf
movq %rax, %rbx
movl $0x10, %edi
callq 0x63a0
movq %rbx, (%rax)
movb $0x1, 0x8(%rax)
jmp 0x10dc1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: tcpmap_get
struct kv *
tcpmap_get(struct tcpmap * const map, const struct kv * const key, struct kv * const out)
{
  bool ret = false;
  const bool req = __tcpmap_request('G', map, key, &ret);
  if (req == false || ret == false) {
    return NULL;
  }

  struct kv head = {};
  if (fread(&head, sizeof(head), 1, map->stream2->r) != 1) {
    map->ok = false;
    return NULL;
  }
  const bool alloc = (out == NULL) ? true : false;
  struct kv * const kv = alloc ? (typeof(kv))malloc(kv_size(&head)) : out;
  if (kv == NULL) {
    return NULL;
  }
  memcpy(kv, &head, sizeof(head));
  if (fread(kv->kv, kv->klen + kv->vlen, 1, map->stream2->r) != 1) {
    map->ok = false;
    if (alloc) free(kv);
    return NULL;
  }
  return kv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %rdx
movq %rdi, %r14
leaq -0x19(%rbp), %rcx
movb $0x0, (%rcx)
movl $0x47, %edi
movq %r14, %rsi
callq 0x10ea9
xorl %r15d, %r15d
testb %al, %al
je 0x10e9b
cmpb $0x0, -0x19(%rbp)
je 0x10e9b
vxorps %xmm0, %xmm0, %xmm0
leaq -0x30(%rbp), %rdi
vmovaps %xmm0, (%rdi)
movq (%r14), %rax
movq 0x8(%rax), %rcx
movl $0x10, %esi
movl $0x1, %edx
callq 0x60f0
cmpq $0x1, %rax
jne 0x10e93
movq %rbx, %r15
testq %rbx, %rbx
jne 0x10e52
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
leaq (%rax,%rcx), %rdi
addq $0x10, %rdi
callq 0x63a0
movq %rax, %r15
testq %rax, %rax
je 0x10e98
vmovaps -0x30(%rbp), %xmm0
vmovups %xmm0, (%r15)
leaq 0x10(%r15), %rdi
movl 0xc(%r15), %esi
addl 0x8(%r15), %esi
movq (%r14), %rax
movq 0x8(%rax), %rcx
movl $0x1, %edx
callq 0x60f0
cmpq $0x1, %rax
je 0x10e9b
movb $0x0, 0x8(%r14)
testq %rbx, %rbx
jne 0x10e98
movq %r15, %rdi
callq 0x6060
jmp 0x10e98
movb $0x0, 0x8(%r14)
xorl %r15d, %r15d
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: _tcpmap_request
static bool
__tcpmap_request(const char op, struct tcpmap * const map, const struct kv * const kv, bool * const ret)
{
  if (map->ok == false) {
    return false;
  }
  if (fwrite(&op, sizeof(op), 1, map->stream2->w) != 1) {
    map->ok = false;
    return false;
  }
  const size_t sz = (op == 'S') ? kv_size(kv) : key_size(kv);
  if (fwrite(kv, sz, 1, map->stream2->w) != 1) {
    map->ok = false;
    return false;
  }
  fflush(map->stream2->w);

  if (fread(ret, sizeof(*ret), 1, map->stream2->r) != 1) {
    map->ok = false;
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movb %dil, -0x19(%rbp)
cmpb $0x0, 0x8(%rsi)
je 0x10f4a
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq (%rsi), %rax
movq (%rax), %rcx
leaq -0x19(%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x6550
cmpq $0x1, %rax
jne 0x10f46
movl 0x8(%r15), %esi
addq $0x10, %rsi
cmpb $0x53, -0x19(%rbp)
jne 0x10efe
movl 0xc(%r15), %eax
addq %rax, %rsi
movq (%rbx), %rax
movq (%rax), %rcx
movl $0x1, %edx
movq %r15, %rdi
callq 0x6550
cmpq $0x1, %rax
jne 0x10f46
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x63b0
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x60f0
movq %rax, %rcx
movb $0x1, %al
cmpq $0x1, %rcx
je 0x10f4c
movb $0x0, 0x8(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: tcpmap_clean
void
tcpmap_clean(struct tcpmap * const map)
{
  if (map->ok == false) return;
  const char op = 'C';
  if (fwrite(&op, sizeof(op), 1, map->stream2->w) != 1) {
    map->ok = false;
    return;
  }
  fflush(map->stream2->w);
  bool ret = false;
  if (fread(&ret, sizeof(ret), 1, map->stream2->r) != 1) {
    map->ok = false;
  }
}

// Assembly:
cmpb $0x0, 0x8(%rdi)
je 0x1103b
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0xa(%rbp), %rdi
movb $0x43, (%rdi)
movq (%rbx), %rax
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1, %edx
callq 0x6550
cmpq $0x1, %rax
jne 0x11031
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x63b0
leaq -0x9(%rbp), %rdi
movb $0x0, (%rdi)
movq (%rbx), %rax
movq 0x8(%rax), %rcx
movl $0x1, %esi
movl $0x1, %edx
callq 0x60f0
cmpq $0x1, %rax
je 0x11035
movb $0x0, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rdx, -0x38(%rbp)
movq %rsi, %r13
movq (%rsi), %r15
movq %r15, %rcx
shrq $0x6, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdx, %rbx
movq 0x10130(%rdi), %r14
shlq $0x6, %rbx
prefetcht0 (%r14,%rbx)
andl $0x3ff, %ecx            # imm = 0x3FF
shll $0x6, %ecx
movq %rdi, -0x48(%rbp)
addq %rcx, %rdi
addq $0xe0, %rdi
movq %rdi, -0x30(%rbp)
callq 0x6050
cmpl $0x23, %eax
je 0x1127f
addq %rbx, %r14
movq %r15, %rax
shrq $0x20, %rax
xorq %r15, %rax
movq %rax, %r15
shrq $0x10, %r15
xorq %rax, %r15
leaq 0x10(%r13), %rax
movq %rax, -0x50(%rbp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r13, %rsi
movq %r13, -0x58(%rbp)
movq 0x8(%r14,%rbx,8), %r13
movl %r15d, %eax
xorw %r13w, %ax
jne 0x111b1
cmpq $0x10000, %r13          # imm = 0x10000
jb 0x111b1
shrq $0x10, %r13
movq (%r13), %rax
cmpq (%rsi), %rax
jne 0x111b1
movl 0x8(%r13), %eax
cmpl 0x8(%rsi), %eax
jne 0x111b1
leaq 0x10(%r13), %rdi
movq -0x50(%rbp), %rsi
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdx
callq 0x63d0
movq -0x40(%rbp), %rdx
movq -0x58(%rbp), %rsi
testl %eax, %eax
je 0x111f4
incq %rbx
addq $0x4, %r12
cmpq $0x1c, %r12
jne 0x11163
movq -0x48(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
callq *0x8(%rax)
movq %rax, %r14
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x6320
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rax
movb $0x3c, %cl
bzhiq %rcx, %rax, %rcx
shrxq %r12, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x1123b
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
movl $0x1, %edx
shlxq %r12, %rdx, %rdx
addq %rax, %rdx
andq %rcx, %rdx
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
andq %rax, %rcx
orq %rdx, %rcx
movq %rcx, (%r14)
movl 0x8(%r13), %edx
movl 0xc(%r13), %eax
leaq (%rdx,%rax), %rbx
addq $0x10, %rbx
movq -0x38(%rbp), %r14
testq %r14, %r14
movq -0x30(%rbp), %r15
jne 0x11264
movq %rbx, %rdi
callq 0x63a0
movq %rax, %r14
testq %rax, %rax
je 0x11277
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6340
jmp 0x111da
xorl %r14d, %r14d
jmp 0x111da
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: icache_clean
void
icache_clean(struct icache * const cache)
{
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_lock(&(cache->hlocks[i]));
  }
  if (cache->map_api) {
    cache->map_api->clean(cache->map_api->map);
  }
  for (u64 i = 0; i < cache->nr_slots; i++) {
    struct __icache_slot * const slot = &(cache->table[i]);
    memset(slot, 0, sizeof(*slot));
  }
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_unlock(&(cache->hlocks[i]));
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xe0(%rdi), %r14
xorl %r15d, %r15d
leaq (%r14,%r15), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x11535
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0x114ae
movq 0x10150(%rbx), %rax
testq %rax, %rax
je 0x114db
movq (%rax), %rdi
callq *0x28(%rax)
cmpq $0x0, 0x10120(%rbx)
je 0x1150f
xorl %eax, %eax
vxorps %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
movq 0x10130(%rbx), %rdx
vmovups %ymm0, 0x20(%rdx,%rax)
vmovups %ymm0, (%rdx,%rax)
incq %rcx
addq $0x40, %rax
cmpq 0x10120(%rbx), %rcx
jb 0x114ed
xorl %ebx, %ebx
leaq (%r14,%rbx), %rdi
vzeroupper
callq 0x6320
addq $0x40, %rbx
cmpq $0x10000, %rbx          # imm = 0x10000
jne 0x11511
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: icache_fprint
void
icache_fprint(struct icache * const cache, FILE * const out)
{
  const u64 cap = cache->nr_slots * ICACHE_ENTRY_NR;
  u64 nr = 0;
  for (u64 i = 0; i < cache->nr_slots; i++) {
    struct __icache_slot * const slot = &(cache->table[i]);
    for (u64 j = 0; j < ICACHE_ENTRY_NR; j++) {
      if (slot->e[j].ptr) nr++;
    }
  }
  //for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
  //  fprintf(out, "%"PRIu64"%c", cache->hlocks[i].padding[7], ((i % 32) == 31) ? '\n' : ' ');
  //}
  fprintf(out, "ICACHE CAP %"PRIu64"/%"PRIu64"\n", nr, cap);
  if (cache->map_api && cache->map_api->fprint) {
    cache->map_api->fprint(cache->map_api->map, out);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10120(%rdi), %rax
leaq (,%rax,8), %rcx
subq %rax, %rcx
testq %rax, %rax
je 0x11594
movq 0x10130(%r14), %rsi
xorl %edx, %edx
xorl %edi, %edi
movl $0x1, %r8d
cmpq $0x10000, (%rsi,%r8,8)  # imm = 0x10000
sbbq $-0x1, %rdx
incq %r8
cmpq $0x8, %r8
jne 0x11571
incq %rdi
addq $0x40, %rsi
cmpq %rax, %rdi
jne 0x1156b
jmp 0x11596
xorl %edx, %edx
leaq 0x3017(%rip), %rsi      # 0x145b4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6300
movq 0x10150(%r14), %rax
testq %rax, %rax
je 0x115c8
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x115c8
movq (%rax), %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmpq *%rcx
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: icache_iter_create
struct icache_iter *
icache_iter_create(struct icache * const cache)
{
  if (cache->map_api == NULL) return NULL;
  void * const map_iter = cache->map_api->iter_create(cache->map_api->map);
  struct icache_iter * const iter = (typeof(iter))malloc(sizeof(*iter));
  iter->map_api = cache->map_api;
  iter->map_iter = map_iter;
  return iter;
}

// Assembly:
movq 0x10150(%rdi), %rax
testq %rax, %rax
je 0x11609
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rax), %rdi
callq *0x40(%rax)
movq %rax, %r14
movl $0x10, %edi
callq 0x63a0
movq 0x10150(%rbx), %rcx
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: ucache_get
struct kv *
ucache_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);
  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);
        // cache hit
        return ret;
      }
    }
  }
  struct kv * const ret2 = cache->map_api->get(cache->map_api->map, key, out);
  return ret2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, -0x30(%rbp)
movq (%rsi), %rcx
movq %rcx, %rax
shrq $0x6, %rax
xorl %r13d, %r13d
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdi, -0x40(%rbp)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r12
prefetcht0 (%rax,%rdx)
movq %rcx, %rax
shrq $0x20, %rax
xorq %rcx, %rax
movq %rax, %r15
shrq $0x10, %r15
xorq %rax, %r15
leaq 0x10(%rsi), %rax
movq %rax, -0x48(%rbp)
xorl %ebx, %ebx
movq %rsi, -0x58(%rbp)
movq %rcx, -0x50(%rbp)
movq 0x8(%r12,%rbx,8), %r14
movl %r15d, %eax
xorw %r14w, %ax
jne 0x11f01
cmpq $0x10000, %r14          # imm = 0x10000
jb 0x11f01
shrq $0x10, %r14
cmpq %rcx, (%r14)
jne 0x11f01
movl 0x8(%r14), %eax
cmpl 0x8(%rsi), %eax
jne 0x11f01
leaq 0x10(%r14), %rdi
movq -0x48(%rbp), %rsi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdx
callq 0x63d0
movq -0x38(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rsi
testl %eax, %eax
je 0x11f34
incq %rbx
addq $0x4, %r13
cmpq $0x1c, %r13
jne 0x11eb3
movq -0x40(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq (%r12), %rax
movb $0x3c, %cl
bzhiq %rcx, %rax, %rcx
shrxq %r13, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x11f7d
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
movl $0x1, %edx
shlxq %r13, %rdx, %rdx
addq %rax, %rdx
andq %rcx, %rdx
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
andq %rax, %rcx
orq %rdx, %rcx
movq %rcx, (%r12)
movl 0x8(%r14), %edx
movl 0xc(%r14), %eax
leaq (%rdx,%rax), %rbx
addq $0x10, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
jne 0x11fa2
movq %rbx, %rdi
callq 0x63a0
movq %rax, %rdi
testq %rax, %rax
je 0x11fbb
movq %r14, %rsi
movq %rbx, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6340
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: ucache_probe
bool
ucache_probe(struct icache * const cache, const struct kv * const key)
{
  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);
  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);
        // cache hit
        return true;
      }
    }
  }
  const bool r = cache->map_api->probe(cache->map_api->map, key);
  // index hit/miss
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq (%rsi), %r15
movq %r15, %rax
shrq $0x6, %rax
xorl %r12d, %r12d
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdi, -0x30(%rbp)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r13
prefetcht0 (%rax,%rdx)
movq %r15, %rax
shrq $0x20, %rax
xorq %r15, %rax
movq %rax, %r14
shrq $0x10, %r14
xorq %rax, %r14
leaq 0x10(%rsi), %rax
movq %rax, -0x38(%rbp)
xorl %ebx, %ebx
movq %rsi, -0x40(%rbp)
movq 0x8(%r13,%rbx,8), %rdi
movl %r14d, %eax
xorw %di, %ax
jne 0x12068
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0x12068
shrq $0x10, %rdi
cmpq %r15, (%rdi)
jne 0x12068
movl 0x8(%rdi), %edx
cmpl 0x8(%rsi), %edx
jne 0x12068
addq $0x10, %rdi
movq -0x38(%rbp), %rsi
callq 0x63d0
movq -0x40(%rbp), %rsi
testl %eax, %eax
je 0x12097
incq %rbx
addq $0x4, %r12
cmpq $0x1c, %r12
jne 0x1202c
movq -0x30(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq 0x10(%rax), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq (%r13), %rax
movb $0x3c, %cl
bzhiq %rcx, %rax, %rcx
shrxq %r12, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x120dc
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
movl $0x1, %edx
shlxq %r12, %rdx, %rdx
addq %rax, %rdx
andq %rcx, %rdx
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
andq %rax, %rcx
orq %rdx, %rcx
movq %rcx, (%r13)
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: rcache_create
struct rcache *
rcache_create(const u64 nr_mb, rcache_match_func match, rcache_hash_func hash_key, rcache_hash_func hash_kv)
{
  debug_assert(ICACHE_ENTRY_NR == 15 || ICACHE_ENTRY_NR == 7);
  debug_assert((sizeof(struct __icache_slot) % 64) == 0);
  debug_assert((sizeof(struct __icache_hist) % 8) == 0);

  if (match == NULL || hash_key == NULL || hash_kv == NULL) {
    return NULL;
  }

  struct rcache * const cache = (typeof(cache))malloc(sizeof(*cache));
  memset(cache, 0, sizeof(*cache));

  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_init(&(cache->hlocks[i]));
  }

  const u64 table_size = nr_mb << 20;
  const u64 nr_slots = table_size / sizeof(cache->table[0]);
  struct __icache_slot * const table = pages_alloc_best(table_size, false, &(cache->slots_alloc_size));
  if (table == NULL) {
    free(cache);
    return NULL;
  }
  debug_assert(nr_slots % KVMAP_HLOCK_NR == 0);
  cache->table = table;
  cache->nr_slots = nr_slots;

  const u64 nr_hists = nr_slots * 16;
  const u64 hists_size = nr_hists * sizeof(cache->hists[0]);
  struct __icache_hist * const hists = pages_alloc_best(hists_size, false, &(cache->hists_alloc_size));
  if (hists == NULL) {
    pages_unmap(table, cache->slots_alloc_size);
    free(cache);
    return NULL;
  }

  cache->nr_hists = nr_hists;
  cache->hists = hists;

  cache->match = match;
  cache->hash_key = hash_key;
  cache->hash_kv = hash_kv;
  return cache;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %sil
orb %al, %sil
testq %rcx, %rcx
sete %al
orb %sil, %al
jne 0x1221f
movq %rdi, %r14
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movl $0x1, %edi
movl $0x10080, %esi          # imm = 0x10080
callq 0x62d0
movq %rax, %rbx
xorl %r15d, %r15d
leaq (%rbx,%r15), %rdi
movl $0x1, %esi
callq 0x62e0
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0x1216a
movq %r14, %r13
shlq $0x14, %r13
leaq 0x10040(%rbx), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x82a0
testq %rax, %rax
je 0x12217
movq %rax, %r15
movq %r13, %rax
shrq $0x6, %rax
movq %r15, 0x10048(%rbx)
movq %rax, 0x10038(%rbx)
shlq $0x16, %r14
movq %rbx, %rdx
addq $0x10058, %rdx          # imm = 0x10058
movq %r14, %rdi
xorl %esi, %esi
callq 0x82a0
testq %rax, %rax
je 0x12208
shrq $0x2, %r13
movq %r13, 0x10050(%rbx)
movq %rax, 0x10060(%rbx)
movq %r12, 0x10068(%rbx)
movq -0x30(%rbp), %rax
movq %rax, 0x10070(%rbx)
movq -0x38(%rbp), %rax
movq %rax, 0x10078(%rbx)
jmp 0x12221
movq 0x10040(%rbx), %rsi
movq %r15, %rdi
callq 0x6410
movq %rbx, %rdi
callq 0x6060
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: rcache_get_hash
void *
rcache_get_hash(struct rcache * const cache, const void * const key, const u64 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);
  rcache_lock_hash(cache, hash);
  for (u64 i = 0; i < ICACHE_ENTRY_NR; i++) {
    if (slot->e[i].pkey == pkey) {
      void * const curr = (void *)(u64)(slot->e[i].ptr);
      if (curr && cache->match(curr, key)) {
        icache_amap_inc(slot, i);
        rcache_unlock_hash(cache, hash);
        return curr;
      }
    }
  }
  rcache_unlock_hash(cache, hash);
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, -0x40(%rbp)
movq %rdx, %rcx
shrq $0x6, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x10038(%rdi)
movq %rdx, %r13
movq 0x10048(%rdi), %rbx
shlq $0x6, %r13
prefetcht0 (%rbx,%r13)
andl $0x3ff, %ecx            # imm = 0x3FF
shll $0x6, %ecx
movq %rdi, -0x38(%rbp)
addq %rdi, %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x1235c
addq %r13, %rbx
movq %r12, %rax
shrq $0x20, %rax
xorq %r12, %rax
movq %rax, %r14
shrq $0x10, %r14
xorq %rax, %r14
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x8(%rbx,%r15,8), %r12
movl %r14d, %eax
xorw %r12w, %ax
jne 0x122e3
cmpq $0x10000, %r12          # imm = 0x10000
jb 0x122e3
shrq $0x10, %r12
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
callq *0x10068(%rax)
testb %al, %al
jne 0x122fe
incq %r15
addq $0x4, %r13
cmpq $0x1c, %r13
jne 0x122b3
movq -0x30(%rbp), %rdi
callq 0x6320
xorl %r12d, %r12d
jmp 0x1234a
movq (%rbx), %rax
movb $0x3c, %cl
bzhiq %rcx, %rax, %rcx
shrxq %r13, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x12341
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
movl $0x1, %edx
shlxq %r13, %rdx, %rdx
addq %rax, %rdx
andq %rcx, %rdx
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
andq %rax, %rcx
orq %rdx, %rcx
movq %rcx, (%rbx)
movq -0x30(%rbp), %rdi
callq 0x6320
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530