LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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, -0x38(%rbp)
cmpq $0x1f4, 0x8(%rsi)       # imm = 0x1F4
jae 0x10c0c
movq 0x8(%r14), %rax
cmpq $0x2, %rax
movq %rax, -0x40(%rbp)
jae 0x10b48
movq $0x0, -0x30(%rbp)
jmp 0x10b92
leaq -0x1(%rax), %r15
xorl %r13d, %r13d
cmpq %r15, %r13
jae 0x10b8e
leaq (%r15,%r13), %r12
incq %r12
shrq %r12
movq 0x20(%r14,%r12,8), %rsi
movq %rbx, %rdi
callq 0xbb4e
testl %eax, %eax
js 0x10b78
je 0x10b82
movb $0x1, %al
movq %r12, %r13
jmp 0x10b88
decq %r12
movb $0x1, %al
movq %r12, %r15
jmp 0x10b88
xorl %eax, %eax
movq %r12, -0x30(%rbp)
testb %al, %al
jne 0x10b4f
jmp 0x10b92
movq %r15, -0x30(%rbp)
leaq 0x20(%r14), %r15
testq %rbx, %rbx
movq -0x30(%rbp), %r13
je 0x10bce
movq 0x20(%r14,%r13,8), %r12
testq %r12, %r12
je 0x10bce
movq (%rbx), %rax
cmpq (%r12), %rax
jne 0x10bce
movl 0x8(%rbx), %edx
cmpl 0x8(%r12), %edx
jne 0x10bce
leaq 0x10(%rbx), %rdi
leaq 0x10(%r12), %rsi
callq 0x63d0
testl %eax, %eax
je 0x10c1d
leaq 0x1(%r13), %r12
cmpq %r12, -0x40(%rbp)
jb 0x10c16
leaq (%r15,%r13,8), %rdi
addq $0x10, %rdi
leaq (%r15,%r12,8), %rsi
movq 0x8(%r14), %rdx
subq %r12, %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
jmp 0x10b30
callq 0x66ef
jmp 0x10bd8
movq -0x38(%rbp), %rcx
movq 0x40(%rcx), %rax
testq %rax, %rax
je 0x10c38
movq 0x48(%rcx), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq *%rax
jmp 0x10c4a
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x10c4a
movq 0x18(%rcx), %rsi
movq %r12, %rdi
callq *%rax
movq %rbx, (%r15,%r13,8)
jmp 0x10bfd
// File: /workspace/github_c_makefile_star2_O1/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 0x10c72
movq $0x0, -0x30(%rbp)
jmp 0x10ccb
movq %rsi, %rbx
movq %rdi, %r14
decq %r12
addq $0x20, %r14
xorl %r15d, %r15d
cmpq %r12, %r15
jae 0x10cc7
leaq (%r12,%r15), %r13
incq %r13
shrq %r13
movq %r13, %rax
shlq $0x4, %rax
movq (%r14,%rax), %rsi
movq %rbx, %rdi
callq 0xbb4e
testl %eax, %eax
js 0x10cb1
je 0x10cbb
movb $0x1, %al
movq %r13, %r15
jmp 0x10cc1
decq %r13
movb $0x1, %al
movq %r13, %r12
jmp 0x10cc1
xorl %eax, %eax
movq %r13, -0x30(%rbp)
testb %al, %al
jne 0x10c82
jmp 0x10ccb
movq %r12, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: bptree_set_rec
static bool
bptree_set_rec(struct bptree * const tree, struct bpnode * const parent, const u64 subidx, const struct kv * const kv)
{
  debug_assert(parent->leaf == false);

  struct bpnode * const sub = parent->iarray[subidx].sub;
  if (sub->leaf) {
    if (sub->nr == BPTREE_LEAF_FO) {
      bptree_split_leaf(parent, subidx);
      const u64 subidx1 = bptree_intm_locate(parent, kv);
      return bptree_set_rec(tree, parent, subidx1, kv);
    } else {
      return bptree_set_leaf(tree, sub, kv);
    }
  } else {
    if (sub->nr == BPTREE_INTM_FO) {
      bptree_split_intm(parent, subidx);
      const u64 subidx1 = bptree_intm_locate(parent, kv);
      return bptree_set_rec(tree, parent, subidx1, kv);
    } else {
      const u64 subsubidx = bptree_intm_locate(sub, kv);
      return bptree_set_rec(tree, sub, subsubidx, kv);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, -0x40(%rbp)
movq %r15, -0x30(%rbp)
cmpb $0x0, (%r15)
jne 0x10e42
movq %r12, %rax
shlq $0x4, %rax
leaq (%r15,%rax), %rbx
addq $0x28, %rbx
movq (%rbx), %r14
movq 0x8(%r14), %rax
cmpb $0x1, (%r14)
jne 0x10d85
cmpq $0x1f4, %rax            # imm = 0x1F4
jne 0x10e77
cmpq $0xfa, 0x8(%r15)
jae 0x10e4c
movq (%rbx), %rbx
movl $0x1000, %esi           # imm = 0x1000
xorl %edi, %edi
movl $0x3, %edx
movl $0x2022, %ecx           # imm = 0x2022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
callq 0x6190
movq %rax, %r13
cmpq $-0x1, %rax
movl $0x0, %eax
cmoveq %rax, %r13
movb $0x1, (%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1067b
jmp 0x10de1
cmpq $0xfa, %rax
jne 0x10e60
cmpq $0xfa, 0x8(%r15)
jae 0x10e56
movq (%rbx), %rbx
movl $0x1000, %esi           # imm = 0x1000
xorl %edi, %edi
movl $0x3, %edx
movl $0x2022, %ecx           # imm = 0x2022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
callq 0x6190
movq %rax, %r13
cmpq $-0x1, %rax
movl $0x0, %eax
cmoveq %rax, %r13
movb $0x0, (%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x10745
movq 0x20(%r13), %rbx
movl $0x0, %r14d
testq %rbx, %rbx
je 0x10e1a
movl 0x8(%rbx), %r15d
addq $0x10, %r15
movq %r15, %rdi
callq 0x63a0
movq %rax, %r14
testq %rax, %rax
je 0x10e16
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x6340
movq -0x30(%rbp), %r15
incq %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x14067
movq %r15, %rdi
movq -0x38(%rbp), %rsi
callq 0x10c50
movq %rax, %r12
jmp 0x10d01
callq 0x66ef
jmp 0x10d0b
callq 0x66ef
jmp 0x10d41
callq 0x66ef
jmp 0x10d9f
movq %r14, %rdi
movq -0x38(%rbp), %rsi
callq 0x10c50
movq %rax, %r12
movq %r14, %r15
jmp 0x10cfd
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq -0x38(%rbp), %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b07
// File: /workspace/github_c_makefile_star2_O1/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 0x10f05
testq %rax, %rax
je 0x10f32
xorl %r15d, %r15d
movq 0x20(%rbx,%r15,8), %rdi
testq %rdi, %rdi
je 0x10efa
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x10efa
movq 0x18(%r14), %rsi
callq *%rax
incq %r15
cmpq 0x8(%rbx), %r15
jb 0x10ee1
jmp 0x10f32
testq %rax, %rax
je 0x10f32
leaq 0x28(%rbx), %r15
xorl %r12d, %r12d
movq -0x8(%r15), %rdi
callq 0x6060
movq (%r15), %rsi
movq %r14, %rdi
callq 0x10ebf
incq %r12
addq $0x10, %r15
cmpq 0x8(%rbx), %r12
jb 0x10f11
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_O1/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 0x10fe3
movl $0x1, %ecx
cmpq $0x1, 0x8(%rax)
ja 0x11008
xorl %ecx, %ecx
movq 0x10(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x10ffd
movq %rax, (%rbx)
movq %rcx, 0x8(%rbx)
cmpq $0x0, 0x20(%rax)
jne 0x1101e
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x66ef
jmp 0x11016
// File: /workspace/github_c_makefile_star2_O1/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 0x1108e
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, 0x8(%r13)
je 0x110bd
movq 0x8(%r14), %r12
movq 0x20(%r13,%r12,8), %r15
testq %r15, %r15
je 0x11092
movl 0x8(%r15), %eax
movl 0xc(%r15), %ecx
leaq (%rax,%rcx), %rdx
addq $0x10, %rdx
testq %rbx, %rbx
jne 0x11081
movq %rdx, %rdi
movq %rdx, %rbx
callq 0x63a0
movq %rbx, %rdx
movq %rax, %rbx
testq %rax, %rax
je 0x11094
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6340
jmp 0x11094
xorl %ebx, %ebx
jmp 0x110ab
xorl %ebx, %ebx
incq %r12
cmpq 0x8(%r13), %r12
jb 0x110a7
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 0x11048
// File: /workspace/github_c_makefile_star2_O1/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 0xb559
testq %rax, %rax
je 0x1118b
movq %rax, %rbx
movl $0x10, %edi
callq 0x63a0
movq %rbx, (%rax)
movb $0x1, 0x8(%rax)
jmp 0x1118d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x11275
xorl %r15d, %r15d
testb %al, %al
je 0x11267
cmpb $0x0, -0x19(%rbp)
je 0x11267
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 0x1125f
movq %rbx, %r15
testq %rbx, %rbx
jne 0x11219
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
leaq (%rax,%rcx), %rdi
addq $0x10, %rdi
callq 0x63a0
movq %rax, %r15
testq %r15, %r15
je 0x11264
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 0x11267
movb $0x0, 0x8(%r14)
testq %rbx, %rbx
jne 0x11264
movq %r15, %rdi
callq 0x6060
jmp 0x11264
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_O1/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 0x11316
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 0x11312
movl 0x8(%r15), %esi
addq $0x10, %rsi
cmpb $0x53, -0x19(%rbp)
jne 0x112ca
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 0x11312
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 0x11318
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_O1/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 0x11407
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 0x113fd
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 0x11401
movb $0x0, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_probe
bool
icache_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);
  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);
        // cache hit
        icache_unlock_hash(cache, hash);
        return true;
      }
    }
  }
  const bool r = cache->map_api->probe(cache->map_api->map, key);
  // index hit/miss
  icache_unlock_hash(cache, hash);
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq (%rsi), %rbx
movq %rbx, %rcx
shrq $0x6, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdx, %r12
movq 0x10130(%rdi), %r13
shlq $0x6, %r12
prefetcht0 (%r13,%r12)
andl $0x3ff, %ecx            # imm = 0x3FF
shll $0x6, %ecx
movq %rdi, -0x38(%rbp)
addq %rcx, %rdi
addq $0xe0, %rdi
movq %rdi, -0x30(%rbp)
callq 0x6050
cmpl $0x23, %eax
je 0x117fe
addq %r12, %r13
movq %rbx, %rax
shrq $0x20, %rax
xorq %rbx, %rax
movq %rax, %r12
shrq $0x10, %r12
xorq %rax, %r12
leaq 0x10(%r14), %rax
movq %rax, -0x40(%rbp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x8(%r13,%r15,8), %rdi
movl %r12d, %eax
xorw %di, %ax
jne 0x11775
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0x11775
shrq $0x10, %rdi
movq (%rdi), %rax
cmpq (%r14), %rax
jne 0x11775
movl 0x8(%rdi), %edx
cmpl 0x8(%r14), %edx
jne 0x11775
addq $0x10, %rdi
movq -0x40(%rbp), %rsi
callq 0x63d0
testl %eax, %eax
je 0x117b4
incq %r15
addq $0x4, %rbx
cmpq $0x1c, %rbx
jne 0x11739
movq -0x38(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq *0x10(%rax)
movl %eax, %r14d
movq -0x30(%rbp), %rdi
callq 0x6320
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r13), %rax
movb $0x3c, %cl
bzhiq %rcx, %rax, %rcx
shrxq %rbx, %rcx, %rcx
notl %ecx
movb $0x1, %r14b
testb $0xf, %cl
je 0x11799
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
movl $0x1, %edx
shlxq %rbx, %rdx, %rdx
addq %rax, %rdx
andq %rcx, %rdx
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
andq %rax, %rcx
orq %rdx, %rcx
movq %rcx, (%r13)
jmp 0x11799
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_set
bool
icache_set(struct icache * const cache, const struct kv * const kv)
{
  const u64 hash = kv->hash;
  icache_lock_hash(cache, hash);
  const bool ret = cache->map_api->set(cache->map_api->map, kv);
  icache_unlock_hash(cache, hash);
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r15
movl $0xffc0, %eax           # imm = 0xFFC0
andl (%rsi), %eax
leaq (%rdi,%rax), %r14
addq $0xe0, %r14
movq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x1185b
movq 0x10150(%r15), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq *0x18(%rax)
movl %eax, %ebx
movq %r14, %rdi
callq 0x6320
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_del
bool
icache_del(struct icache * const cache, const struct kv * const key)
{
  const u64 hash = key->hash;
  icache_lock_hash(cache, hash);
  const bool ret = cache->map_api->del(cache->map_api->map, key);
  icache_unlock_hash(cache, hash);
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r15
movl $0xffc0, %eax           # imm = 0xFFC0
andl (%rsi), %eax
leaq (%rdi,%rax), %r14
addq $0xe0, %r14
movq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x118b8
movq 0x10150(%r15), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq *0x20(%rax)
movl %eax, %ebx
movq %r14, %rdi
callq 0x6320
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/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 0x1195d
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0x118d6
movq 0x10150(%rbx), %rax
testq %rax, %rax
je 0x11903
movq (%rax), %rdi
callq *0x28(%rax)
cmpq $0x0, 0x10120(%rbx)
je 0x11937
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 0x11915
xorl %ebx, %ebx
leaq (%r14,%rbx), %rdi
vzeroupper
callq 0x6320
addq $0x40, %rbx
cmpq $0x10000, %rbx          # imm = 0x10000
jne 0x11939
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/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 0x119bc
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 0x11999
incq %rdi
addq $0x40, %rsi
cmpq %rax, %rdi
jne 0x11993
jmp 0x119be
xorl %edx, %edx
leaq 0x3bdf(%rip), %rsi      # 0x155a4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6300
movq 0x10150(%r14), %rax
testq %rax, %rax
je 0x119f0
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0x119f0
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_O1/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 0x11a31
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_O1/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 0x1254a
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0x1254a
shrq $0x10, %rdi
cmpq %r15, (%rdi)
jne 0x1254a
movl 0x8(%rdi), %edx
cmpl 0x8(%rsi), %edx
jne 0x1254a
addq $0x10, %rdi
movq -0x38(%rbp), %rsi
callq 0x63d0
movq -0x40(%rbp), %rsi
testl %eax, %eax
je 0x12579
incq %rbx
addq $0x4, %r12
cmpq $0x1c, %r12
jne 0x1250e
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 0x125be
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_O1/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 0x1270b
movq %rdi, %r14
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movl $0x10080, %edi          # imm = 0x10080
callq 0x63a0
movq %rax, %rbx
xorl %r15d, %r15d
movl $0x10080, %edx          # imm = 0x10080
movq %rax, %rdi
xorl %esi, %esi
callq 0x6210
leaq (%rbx,%r15), %rdi
movl $0x1, %esi
callq 0x62e0
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0x12656
movq %r14, %r13
shlq $0x14, %r13
leaq 0x10040(%rbx), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x831a
testq %rax, %rax
je 0x12703
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 0x831a
testq %rax, %rax
je 0x126f4
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 0x1270d
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_O1/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 $0x38, %rsp
movq %rdx, %rbx
movq %rsi, -0x58(%rbp)
movq %rdx, %rcx
shrq $0x6, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x10038(%rdi)
movq %rdx, %r13
movq 0x10048(%rdi), %r12
shlq $0x6, %r13
prefetcht0 (%r12,%r13)
andl $0x3ff, %ecx            # imm = 0x3FF
shll $0x6, %ecx
movq %rdi, -0x50(%rbp)
addq %rdi, %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x12888
addq %r13, %r12
movq %rbx, %rax
shrq $0x20, %rax
xorq %rbx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
xorq %rax, %rcx
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %r12, %rdx
movq %r12, -0x40(%rbp)
movq %rcx, -0x38(%rbp)
movq 0x8(%rdx,%r14,8), %r13
movl %ecx, %eax
xorw %r13w, %ax
jne 0x12849
movb $0x1, %r12b
cmpq $0x10000, %r13          # imm = 0x10000
jb 0x12844
shrq $0x10, %r13
movq %r13, %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
callq *0x10068(%rax)
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rdx
testb %al, %al
je 0x12844
movq (%rdx), %rax
movq %rax, %rcx
movabsq $0xfffffffffffffff, %rsi # imm = 0xFFFFFFFFFFFFFFF
andq %rsi, %rcx
shrxq %r15, %rcx, %rcx
notl %ecx
testb $0xf, %cl
je 0x1282c
movl $0x1, %ecx
shlxq %r15, %rcx, %rcx
addq %rax, %rcx
andq %rsi, %rcx
movabsq $-0x1000000000000000, %rsi # imm = 0xF000000000000000
andq %rsi, %rax
orq %rcx, %rax
movq %rax, (%rdx)
movq -0x30(%rbp), %rdi
callq 0x6320
movq -0x40(%rbp), %rdx
xorl %r12d, %r12d
movq %r13, -0x48(%rbp)
movq -0x38(%rbp), %rcx
testb %r12b, %r12b
je 0x12865
cmpq $0x6, %r14
leaq 0x1(%r14), %rax
setae %bl
addq $0x4, %r15
movq %rax, %r14
cmpq $0x7, %rax
jne 0x127ac
testb $0x1, %bl
movq -0x48(%rbp), %rax
je 0x12879
movq -0x30(%rbp), %rdi
callq 0x6320
xorl %eax, %eax
addq $0x38, %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_O1/wuxb45[P]SLB/lib1.c
// Function: rcache_invalidate_hash
void
rcache_invalidate_hash(struct rcache * const cache, const u64 hash)
{
  const u64 idx = (hash >> KVMAP_BASE_LEVEL) % cache->nr_slots;
  struct __icache_slot * const slot = &(cache->table[idx]);
  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) && slot->e[i].ptr) {
      icache_put_entry(&(slot->e[i]), NULL);
      slot->used--;
      icache_amap_clear(slot, i);
    }
  }
  rcache_unlock_hash(cache, hash);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rsi, %rbx
shrq $0x6, %rbx
movq %rbx, %rax
xorl %edx, %edx
divq 0x10038(%rdi)
movq %rdx, %r14
shlq $0x6, %r14
addq 0x10048(%rdi), %r14
andl $0x3ff, %ebx            # imm = 0x3FF
shll $0x6, %ebx
addq %rdi, %rbx
movq %rbx, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x12daf
movq %r15, %rcx
shrq $0x20, %rcx
xorq %r15, %rcx
movq %rcx, %rax
shrq $0x10, %rax
xorq %rcx, %rax
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
xorl %edx, %edx
movb $0x3c, %sil
movl $0xf, %edi
xorl %r8d, %r8d
movq 0x8(%r14,%r8,8), %r9
cmpq $0x10000, %r9           # imm = 0x10000
jb 0x12d90
xorl %eax, %r9d
movzwl %r9w, %r9d
testq %r9, %r9
jne 0x12d90
movq $0x0, 0x8(%r14,%r8,8)
movq (%r14), %r9
bzhiq %rsi, %r9, %r10
andq %rcx, %r9
addq %rcx, %r9
orq %r9, %r10
shlxq %rdx, %rdi, %r9
andnq %r10, %r9, %r9
movq %r9, (%r14)
incq %r8
addq $0x4, %rdx
cmpq $0x1c, %rdx
jne 0x12d4f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6320
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: rcache_clean
void
rcache_clean(struct rcache * const cache)
{
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_lock(&(cache->hlocks[i]));
  }
  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 %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
leaq (%rbx,%r14), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x12e79
addq $0x40, %r14
cmpq $0x10000, %r14          # imm = 0x10000
jne 0x12e09
cmpq $0x0, 0x10038(%rbx)
je 0x12e58
xorl %eax, %eax
vxorps %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
movq 0x10048(%rbx), %rdx
vmovups %ymm0, 0x20(%rdx,%rax)
vmovups %ymm0, (%rdx,%rax)
incq %rcx
addq $0x40, %rax
cmpq 0x10038(%rbx), %rcx
jb 0x12e36
xorl %r14d, %r14d
leaq (%rbx,%r14), %rdi
vzeroupper
callq 0x6320
addq $0x40, %r14
cmpq $0x10000, %r14          # imm = 0x10000
jne 0x12e5b
popq %rbx
popq %r14
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: rcache_destroy
void
rcache_destroy(struct rcache * const cache)
{
  rcache_clean(cache);
  pages_unmap(cache->table, cache->slots_alloc_size);
  pages_unmap(cache->hists, cache->hists_alloc_size);
  free(cache);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x12dfc
movq 0x10040(%rbx), %rsi
movq 0x10048(%rbx), %rdi
callq 0x6410
movq 0x10058(%rbx), %rsi
movq 0x10060(%rbx), %rdi
callq 0x6410
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x6060
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: maptest_passes
int
maptest_passes(int argc, char ** argv, char ** const pref0, struct pass_info * const pi)
{
  char * pref[64];
  int np = 0;
  while (pref0[np]) {
    pref[np] = pref0[np];
    np++;
  }
  const int n1 = np;

  const int argc0 = argc;
  do {
    int pi1 = n1;
    struct rgen * gen = NULL;
    if ((argc < 1) || (strcmp(argv[0], "rgen") != 0)) {
      break;
    }
    const int n2 = rgen_helper(argc, argv, &gen);
    if (n2 < 0) {
      return n2;
    }
    for (int i = 0; i < n2; i++) {
      pref[pi1++] = argv[i];
    }
    pref[pi1] = NULL;
    argc -= n2;
    argv += n2;

    while ((argc > 0) && (strcmp(argv[0], "pass") == 0)) {
      debug_perf_switch();
      pi->gen0 = gen;
      const int n3 = maptest_pass(argc, argv, pref, pi);
      if (n3 < 0) {
        return n3;
      }
      argc -= n3;
      argv += n3;
    }

    rgen_destroy(gen);
  } while (argc > 0);
  return argc0 - argc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rcx, -0x48(%rbp)
movq %rsi, %r15
movl %edi, %r13d
movq (%rdx), %rax
xorl %r12d, %r12d
testq %rax, %rax
je 0x135b8
movq %rax, -0x250(%rbp,%r12,8)
movq 0x8(%rdx,%r12,8), %rax
incq %r12
jmp 0x135a1
movl %r12d, %eax
movq %rax, -0x40(%rbp)
leaq -0x250(,%rax,8), %rbx
addq %rbp, %rbx
leaq 0x1def(%rip), %r14      # 0x153c0
movl %r13d, -0x34(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x4, %ecx
testl %r13d, %r13d
jle 0x136cf
movq (%r15), %rdi
movq %r14, %rsi
callq 0x62f0
testl %eax, %eax
je 0x13604
movl $0x4, %ecx
jmp 0x136cf
movl %r13d, %edi
movq %r15, %rsi
leaq -0x30(%rbp), %rdx
callq 0xa8ee
movl $0x1, %ecx
testl %eax, %eax
js 0x136cf
movl %eax, %ecx
movl %r12d, %edx
je 0x1363c
xorl %edx, %edx
movq (%r15,%rdx,8), %rsi
movq %rsi, (%rbx,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x13629
addl -0x40(%rbp), %edx
movl %edx, %edx
movq $0x0, -0x250(%rbp,%rdx,8)
subl %eax, %r13d
leaq (%r15,%rcx,8), %r15
movq -0x30(%rbp), %r14
testl %r13d, %r13d
jle 0x136bd
movq (%r15), %rdi
leaq 0x1f54(%rip), %rsi      # 0x155b8
callq 0x62f0
testl %eax, %eax
jne 0x136bd
movl 0x8cd5(%rip), %edi      # 0x1c348
testl %edi, %edi
jle 0x13681
movl $0xc, %esi
callq 0x6350
movq -0x48(%rbp), %rcx
movq %r14, (%rcx)
movl %r13d, %edi
movq %r15, %rsi
leaq -0x250(%rbp), %rdx
callq 0x12ec2
movl %eax, %ecx
sarl $0x1f, %ecx
andnl %eax, %ecx, %ecx
subl %ecx, %r13d
leaq (%r15,%rcx,8), %r15
testl %eax, %eax
jns 0x13655
leaq 0x1d0a(%rip), %r14      # 0x153c0
movl $0x1, %ecx
jmp 0x136cf
movq -0x30(%rbp), %rdi
callq 0xa871
xorl %ecx, %ecx
leaq 0x1cf1(%rip), %r14      # 0x153c0
testl %ecx, %ecx
jne 0x136de
testl %r13d, %r13d
jg 0x135d5
jmp 0x136e3
cmpl $0x4, %ecx
jne 0x136eb
movl -0x34(%rbp), %eax
subl %r13d, %eax
jmp 0x136f0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: zeta_range_worker
static void *
zeta_range_worker(void * const ptr)
{
  struct zeta_range_info * const zi = (typeof(zi))ptr;
  const u64 seq = atomic_fetch_add(&(zi->seq), 1);
  const u64 start = zi->start;
  const double theta = zi->theta;
  const u64 count = zi->count;
  const u64 nth = zi->nth;
  double local_sum = 0.0;
  for (u64 i = seq; i < count; i += nth) {
    local_sum += (1.0 / pow((double)(start + i + 1lu), theta));
  }
  spinlock_lock(&(zi->lock));
  zi->sum += local_sum;
  spinlock_unlock(&(zi->lock));
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x1, %r14d
lock
xaddq %r14, (%rdi)
movq 0x18(%rdi), %r15
vxorpd %xmm0, %xmm0, %xmm0
cmpq %r15, %r14
jae 0x137ad
vmovsd 0x20(%rbx), %xmm0
vmovsd %xmm0, -0x38(%rbp)
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %r13
incq %r13
vxorpd %xmm0, %xmm0, %xmm0
vmovsd %xmm0, -0x30(%rbp)
leaq (%r14,%r13), %rax
vcvtusi2sd %rax, %xmm2, %xmm0
vmovsd -0x38(%rbp), %xmm1
callq 0x6130
vmovsd 0x18ea(%rip), %xmm1     # 0x15078
vdivsd %xmm0, %xmm1, %xmm0
vmovsd -0x30(%rbp), %xmm1
vaddsd %xmm0, %xmm1, %xmm1
vmovsd %xmm1, -0x30(%rbp)
vmovsd -0x30(%rbp), %xmm0
addq %r12, %r14
cmpq %r15, %r14
jb 0x1376d
vmovsd %xmm0, -0x30(%rbp)
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x137eb
vmovsd -0x30(%rbp), %xmm0
vaddsd 0x28(%rbx), %xmm0, %xmm0
vmovsd %xmm0, 0x28(%rbx)
movq %r14, %rdi
callq 0x6320
xorl %eax, %eax
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_O1/wuxb45[P]SLB/lib1.c
// Function: cuckoo_expand_thread
static void *
cuckoo_expand_thread(void * const ptr)
{
  struct cuckoo * const map = (typeof(map))ptr;
  debug_assert(map->bm);
  struct __cuckoo_level * const level0 = map->levels[0].table ? &(map->levels[0]) : &(map->levels[1]);
  struct __cuckoo_level * const level1 = map->levels[0].table ? &(map->levels[1]) : &(map->levels[0]);
  debug_assert(level0->table);
  debug_assert(level1->table == NULL);
  const u64 power1 = level0->power + 1;
  level1->power = power1;
  level1->table = pages_alloc_best(KVMAP_SIZE_OF_LEVEL(power1), true, &(level1->alloc_size));

  struct cuckoo_expand_worker_info info = {
    .map = map,
    .uniq = 0,
    .level0 = level0,
    .level1 = level1,
    .bm_updater = bitmap_count(map->bm) ? bitmap_set0 : bitmap_set1,
  };
  const double dt = thread_fork_join(0, cuckoo_expand_worker, &info);
  (void)dt;
  //fprintf(stderr, "%s workers time %.2lf\n", __func__, dt);
  debug_assert(atomic_load(&info.uniq) > KVMAP_HLOCK_NR);
  pages_unmap(level0->table, level0->alloc_size);
  level0->table = NULL;
  mutexlock_unlock(&(map->expand_lock));
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x100d8(%rdi)
je 0x13c04
movl $0x10118, %eax          # imm = 0x10118
leaq (%rbx,%rax), %rcx
movl $0x10130, %r14d         # imm = 0x10130
leaq (%rbx,%r14), %r13
cmpq $0x0, 0x10118(%rbx)
movl $0x10118, %r15d         # imm = 0x10118
cmoveq %r14, %r15
movq %rcx, %r12
cmoveq %r13, %r12
cmoveq %rax, %r14
cmoveq %rcx, %r13
cmpq $0x0, (%rbx,%r15)
je 0x13c0e
cmpq $0x0, (%r13)
jne 0x13c18
movq 0x10(%r12), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%r13)
addb $-0x5, %al
movl $0x1000, %ecx           # imm = 0x1000
shlxq %rax, %rcx, %rdi
leaq 0x8(%r13), %rdx
movl $0x1, %esi
callq 0x831a
movq %rax, (%rbx,%r14)
leaq -0x50(%rbp), %r14
movq %rbx, (%r14)
movq $0x0, 0x8(%r14)
movq %r12, 0x10(%r14)
movq %r13, 0x18(%r14)
movq 0x100d8(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
leaq -0xc275(%rip), %rax     # 0x7924
leaq -0xc24b(%rip), %rcx     # 0x7955
cmoveq %rax, %rcx
movq %rcx, 0x20(%r14)
leaq 0x81(%rip), %rsi        # 0x13c30
xorl %edi, %edi
movq %r14, %rdx
callq 0x80fb
movq 0x8(%r14), %rax
cmpq $0x400, %rax            # imm = 0x400
jbe 0x13c22
movq (%rbx,%r15), %rdi
movq 0x8(%r12), %rsi
callq 0x6410
movq $0x0, (%rbx,%r15)
addq $0x10050, %rbx          # imm = 0x10050
movq %rbx, %rdi
callq 0x6390
cmpl $0xb, %eax
je 0x13be2
testl %eax, %eax
jne 0x13c29
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
jmp 0x13af8
callq 0x66ef
jmp 0x13b37
callq 0x66ef
jmp 0x13b42
callq 0x66ef
jmp 0x13bc5
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: chainmap_expand_thread
static void *
chainmap_expand_thread(void * const ptr)
{
  struct chainmap * const map = (typeof(map))ptr;
  struct chainmap_expand_worker_info info;
  info.map = map;
  info.new_power = map->power + 1;
  const u64 table_size = sizeof(map->table[0]) * (UINT64_C(1) << info.new_power);
  info.new_table = (typeof(info.new_table))pages_alloc_best(table_size, true, &(info.new_alloc_size));
  debug_assert(info.new_table);
  atomic_store(&(info.uniq), 0);
  const double dt = thread_fork_join(0, chainmap_expand_worker, &info);
  pages_unmap(map->table, map->alloc_size);
  map->table = info.new_table;
  map->alloc_size = info.new_alloc_size;
  map->power = info.new_power;
  map->trigger = UINT64_C(2) << map->power;
  atomic_thread_fence(memory_order_seq_cst);

  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_unlock(&(map->hlocks[i]));
  }
  mutexlock_unlock(&(map->expand_lock));
  fprintf(stderr, "%s workers time %.2lf\n", __func__, dt);
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq -0x30(%rbp), %r14
movq %rdi, -0x18(%r14)
movq 0xd0(%rdi), %rax
incq %rax
movq %rax, -0x10(%r14)
movl $0x8, %ecx
shlxq %rax, %rcx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x831a
movq %rax, -0x8(%r14)
testq %rax, %rax
jne 0x13e8f
callq 0x66ef
xorl %r15d, %r15d
leaq -0x48(%rbp), %r14
xorl %eax, %eax
xchgq %rax, 0x20(%r14)
leaq 0xc4(%rip), %rsi        # 0x13f67
xorl %edi, %edi
movq %r14, %rdx
callq 0x80fb
vmovsd %xmm0, -0x20(%rbp)
movq 0xe8(%rbx), %rdi
movq 0xf0(%rbx), %rsi
callq 0x6410
movq 0x10(%r14), %rax
movq %rax, 0xe8(%rbx)
movq 0x18(%r14), %rax
movq %rax, 0xf0(%rbx)
movq 0x8(%r14), %rax
movq %rax, 0xd0(%rbx)
movl $0x2, %ecx
shlxq %rax, %rcx, %rax
movq %rax, 0xd8(%rbx)
mfence
leaq 0x138(%rbx), %r14
leaq (%r14,%r15), %rdi
callq 0x6320
addq $0x40, %r15
cmpq $0x10000, %r15          # imm = 0x10000
jne 0x13f01
addq $0xf8, %rbx
movq %rbx, %rdi
callq 0x6390
cmpl $0xb, %eax
je 0x13f1e
testl %eax, %eax
jne 0x13f60
movq 0x80c2(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x189b(%rip), %rsi      # 0x157db
leaq 0x18ab(%rip), %rdx      # 0x157f2
vmovsd -0x20(%rbp), %xmm0
movb $0x1, %al
callq 0x6300
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: chainmap_expand_worker
static void *
chainmap_expand_worker(void * const ptr)
{
  struct chainmap_expand_worker_info * const info = (typeof(info))ptr;
  struct chainmap * const map = info->map;
  debug_assert(map->power >= KVMAP_HLOCK_POWER);
  const u64 hi_max = UINT64_C(1) << (map->power - KVMAP_HLOCK_POWER);
  do {
    const u64 lidx = atomic_fetch_add(&(info->uniq), 1);
    if (lidx >= KVMAP_HLOCK_NR) break;
    spinlock_lock(&(map->hlocks[lidx]));
    for (u64 h = 0; h < hi_max; h++) {
      const u64 hidx = (h << KVMAP_HLOCK_POWER) | lidx;
      struct chainnode * iter = info->map->table[hidx];
      while (iter) {
        struct chainnode * const next = iter->next;
        struct kv * const curr = __u64_to_ptr(iter->e.ptr);
        const u64 h2 = (curr->hash >> KVMAP_BASE_LEVEL) & ((UINT64_C(1) << info->new_power) - UINT64_C(1));
        iter->next = info->new_table[h2];
        info->new_table[h2] = iter;
        iter = next;
      }
    }
  } while (true);
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
cmpq $0x9, 0xd0(%r14)
jbe 0x14056
movq 0xd0(%r14), %r15
addq $-0xa, %r15
addq $0x138, %r14            # imm = 0x138
movq $-0x1, %r12
movl $0x1, %r13d
lock
xaddq %r13, 0x20(%rbx)
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x14045
movq %r13, %rdi
shlq $0x6, %rdi
addq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x14060
xorl %eax, %eax
movq (%rbx), %rcx
movq 0xe8(%rcx), %rcx
movq %rax, %rdx
shlq $0xd, %rdx
leaq (%rdx,%r13,8), %rdx
movq (%rcx,%rdx), %rcx
testq %rcx, %rcx
je 0x1402b
movb 0x8(%rbx), %dl
shlxq %rdx, %r12, %rdx
notq %rdx
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
shrq $0x10, %rsi
movq (%rsi), %rsi
shrq $0x6, %rsi
andq %rdx, %rsi
movq 0x10(%rbx), %r8
movq (%r8,%rsi,8), %r9
movq %r9, 0x8(%rcx)
movq %rcx, (%r8,%rsi,8)
movq %rdi, %rcx
testq %rdi, %rdi
jne 0x13ffe
incq %rax
shrxq %r15, %rax, %rcx
testq %rcx, %rcx
je 0x13fd5
cmpq $0x400, %r13            # imm = 0x400
jb 0x13fa2
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
jmp 0x13f89
xorl %edi, %edi
callq 0x6530
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: bptree_raw_insert_intm
static void
bptree_raw_insert_intm(struct bpnode * const node, const u64 idx, const struct kv * const key, struct bpnode * const sub)
{
  debug_assert(idx <= node->nr);
  memmove(&(node->iarray[idx + 1]), &(node->iarray[idx]), sizeof(node->iarray[0]) * (node->nr - idx));
  node->iarray[idx].key = key;
  node->iarray[idx].sub = sub;
  node->nr++;
  // link
  if (node->nr > 1) {
    if (idx > 0) {
      struct bpnode * const left = node->iarray[idx - 1].sub;
      if (left->next) {
        sub->next = left->next;
        left->next->prev = sub;
      }
      sub->prev = left;
      left->next = sub;
    } else {
      struct bpnode * const right = node->iarray[idx + 1].sub;
      if (right->prev) {
        sub->prev = right->prev;
        right->prev->next = sub;
      }
      sub->next = right;
      right->prev = sub;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, -0x38(%rbp)
movq %rsi, %r13
movq %rdi, %r14
cmpq %rsi, 0x8(%rdi)
jb 0x1413b
movq %r13, %r15
shlq $0x4, %r15
leaq (%r14,%r15), %rdi
addq $0x30, %rdi
leaq (%r14,%r15), %rbx
addq $0x20, %rbx
movq 0x8(%r14), %rdx
subq %r13, %rdx
shlq $0x4, %rdx
movq %rdi, -0x30(%rbp)
movq %rbx, %rsi
callq 0x6450
movq -0x38(%rbp), %rax
movq %rax, (%rbx)
movq %r12, 0x8(%rbx)
movq 0x8(%r14), %rax
incq %rax
movq %rax, 0x8(%r14)
cmpq $0x2, %rax
jb 0x1412c
testq %r13, %r13
je 0x140fb
addq $0x20, %r14
movq -0x8(%r15,%r14), %rax
leaq 0x10(%rax), %rcx
movq 0x10(%rax), %rsi
movl $0x10, %edi
movl $0x18, %edx
jmp 0x14115
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
leaq 0x18(%rax), %rcx
movq 0x18(%rax), %rsi
movl $0x18, %edi
movl $0x10, %edx
testq %rsi, %rsi
je 0x14125
movq %rsi, (%r12,%rdi)
movq (%rcx), %rsi
movq %r12, (%rsi,%rdx)
movq %rax, (%r12,%rdx)
movq %r12, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
jmp 0x1408f