LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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 0xeb7f
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq (%rsi), %rax
movq (%rax), %rcx
leaq -0x19(%rbp), %rdi
pushq $0x1
popq %rdx
movq %rdx, %rsi
callq 0x6550
cmpq $0x1, %rax
jne 0xeb7b
movl 0x8(%r15), %esi
addq $0x10, %rsi
cmpb $0x53, -0x19(%rbp)
jne 0xeb39
movl 0xc(%r15), %eax
addq %rax, %rsi
movq (%rbx), %rax
movq (%rax), %rcx
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x6550
cmpq $0x1, %rax
jne 0xeb7b
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x63b0
movq (%rbx), %rax
movq 0x8(%rax), %rcx
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x60f0
movq %rax, %rcx
movb $0x1, %al
cmpq $0x1, %rcx
je 0xeb81
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_O2/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 0xec62
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
pushq $0x1
popq %rdx
movq %rdx, %rsi
callq 0x6550
cmpq $0x1, %rax
jne 0xec58
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x63b0
leaq -0x9(%rbp), %rdi
movb $0x0, (%rdi)
movq (%rbx), %rax
movq 0x8(%rax), %rcx
pushq $0x1
popq %rdx
movq %rdx, %rsi
callq 0x60f0
cmpq $0x1, %rax
je 0xec5c
movb $0x0, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %r12
movq (%rsi), %rsi
movq %rsi, %rax
shrq $0x6, %rax
xorl %r13d, %r13d
xorl %edx, %edx
divq 0x10120(%rdi)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r15
prefetcht0 (%rax,%rdx)
movq %rsi, %rax
shrq $0x20, %rax
xorq %rsi, %rax
movq %rax, %rbx
shrq $0x10, %rbx
xorq %rax, %rbx
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
callq 0xedd9
cmpq $0x7, %r13
je 0xed80
movq 0x8(%r15,%r13,8), %r14
movl %ebx, %eax
xorw %r14w, %ax
jne 0xed7b
shrq $0x10, %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xab0c
testb %al, %al
jne 0xed9d
incq %r13
jmp 0xed55
movq -0x38(%rbp), %rbx
movq 0x10150(%rbx), %rax
movq (%rax), %rdi
movq %r12, %rsi
movq -0x30(%rbp), %rdx
callq *0x8(%rax)
movq %rax, %r14
jmp 0xedbb
movq %r15, %rdi
movq %r13, %rsi
callq 0xedf3
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0xaa68
movq %rax, %r14
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0xee45
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %r15
movq (%rsi), %rbx
movq %rbx, %rax
shrq $0x6, %rax
xorl %r12d, %r12d
xorl %edx, %edx
divq 0x10120(%rdi)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r13
prefetcht0 (%rax,%rdx)
movq %rbx, %rax
shrq $0x20, %rax
xorq %rbx, %rax
movq %rax, %r14
shrq $0x10, %r14
xorq %rax, %r14
movq %rdi, -0x30(%rbp)
movq %rbx, %rsi
callq 0xedd9
cmpq $0x7, %r12
je 0xeee1
movq 0x8(%r13,%r12,8), %rdi
movl %r14d, %eax
xorw %di, %ax
jne 0xeedc
shrq $0x10, %rdi
movq %r15, %rsi
callq 0xab0c
testb %al, %al
jne 0xeefa
incq %r12
jmp 0xeeb9
movq -0x30(%rbp), %r14
movq 0x10150(%r14), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq *0x10(%rax)
movl %eax, %r15d
jmp 0xef0c
movq %r13, %rdi
movq %r12, %rsi
callq 0xedf3
movb $0x1, %r15b
movq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xee45
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq (%rsi), %r15
movq %r15, %rsi
callq 0xedd9
movq 0x10150(%r14), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq *0x18(%rax)
movl %eax, %ebx
movq %r14, %rdi
movq %r15, %rsi
callq 0xee45
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
cmpq $0x10000, %r15          # imm = 0x10000
je 0xefe2
leaq (%r14,%r15), %rdi
callq 0x6afb
addq $0x40, %r15
jmp 0xefca
movq 0x10150(%rbx), %rax
testq %rax, %rax
je 0xeff4
movq (%rax), %rdi
callq *0x28(%rax)
xorl %eax, %eax
vxorps %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
cmpq 0x10120(%rbx), %rcx
jae 0xf020
movq 0x10130(%rbx), %rdx
vmovups %ymm0, 0x20(%rdx,%rax)
vmovups %ymm0, (%rdx,%rax)
incq %rcx
addq $0x40, %rax
jmp 0xeffc
xorl %ebx, %ebx
cmpq $0x10000, %rbx          # imm = 0x10000
je 0xf03d
leaq (%r14,%rbx), %rdi
vzeroupper
callq 0x6320
addq $0x40, %rbx
jmp 0xf022
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
// File: /workspace/github_c_makefile_star2_O2/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
xorl %ecx, %ecx
pushq $0x1
popq %rsi
xorl %edi, %edi
xorl %edx, %edx
cmpq %rax, %rdi
je 0xf09a
movq 0x10130(%r14), %r8
addq %rcx, %r8
movq %rsi, %r9
cmpq $0x8, %r9
je 0xf091
cmpq $0x10000, (%r8,%r9,8)   # imm = 0x10000
sbbq $-0x1, %rdx
incq %r9
jmp 0xf07a
incq %rdi
addq $0x40, %rcx
jmp 0xf068
imulq $0x7, %rax, %rcx
leaq 0x350f(%rip), %rsi      # 0x125b4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6300
movq 0x10150(%r14), %rax
testq %rax, %rax
je 0xf0d0
movq 0x38(%rax), %rcx
testq %rcx, %rcx
je 0xf0d0
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_O2/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 0xf10f
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rax), %rdi
callq *0x40(%rax)
movq %rax, %r14
pushq $0x10
popq %rdi
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_O2/wuxb45[P]SLB/lib1.c
// Function: icache_invalidate
static inline void
icache_invalidate(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]);
  const u64 pkey = kvmap_pkey(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);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
movq (%rsi), %rax
movq %rax, %r8
shrq $0x20, %r8
xorq %rax, %r8
shrq $0x6, %rax
xorl %edx, %edx
divq 0x10120(%rdi)
shlq $0x6, %rdx
addq 0x10130(%rdi), %rdx
xorl %eax, %eax
movq %r8, %rsi
shrq $0x10, %rsi
xorq %r8, %rsi
movb $0x3c, %dil
movabsq $0xf, %r8
xorl %r9d, %r9d
cmpq $0x1c, %rax
je 0xf226
movq 0x8(%rdx,%r9,8), %r10
cmpq $0x10000, %r10          # imm = 0x10000
jb 0xf21d
xorl %esi, %r10d
movzwl %r10w, %r10d
testq %r10, %r10
jne 0xf21d
andq $0x0, 0x8(%rdx,%r9,8)
movq (%rdx), %r10
bzhiq %rdi, %r10, %r11
andq %rcx, %r10
addq %rcx, %r10
orq %r10, %r11
shlxq %rax, %r8, %r10
andnq %r11, %r10, %r10
movq %r10, (%rdx)
incq %r9
addq $0x4, %rax
jmp 0xf1d9
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: icache_hist_update
static inline u64
icache_hist_update(struct __icache_hist * const hist, const u64 pkey)
{
  u64 rep = 0;
  for (u64 i = 0; i < ICACHE_HIST_NR; i++) {
    if (pkey == hist->tags[i]) {
      rep++;
    }
  }
  hist->tags[hist->head] = pkey;
  hist->head = (hist->head + 1) % ICACHE_HIST_NR;
  return rep;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movabsq $0x1, %rax
xorl %ecx, %ecx
cmpq $0x8, %rax
je 0xf4a3
movzwl (%rdi,%rax,2), %edx
xorl %r8d, %r8d
cmpq %rsi, %rdx
sete %r8b
addq %r8, %rcx
incq %rax
jmp 0xf487
movzwl (%rdi), %eax
movw %si, 0x2(%rdi,%rax,2)
incl %eax
movl $0x7, %esi
xorl %edx, %edx
divl %esi
movw %dx, (%rdi)
movq %rcx, %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %r14
movq (%rsi), %rax
movq %rax, %rcx
shrq $0x20, %rcx
xorq %rax, %rcx
shrq $0x6, %rax
xorl %r12d, %r12d
xorl %edx, %edx
divq 0x10120(%rdi)
movq %rdi, -0x38(%rbp)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r13
prefetcht0 (%rax,%rdx)
movq %rcx, %r15
shrq $0x10, %r15
xorq %rcx, %r15
cmpq $0x7, %r12
je 0xf5db
movq 0x8(%r13,%r12,8), %rbx
movl %r15d, %eax
xorw %bx, %ax
jne 0xf5d6
shrq $0x10, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xab0c
testb %al, %al
jne 0xf604
incq %r12
jmp 0xf5b0
movq -0x38(%rbp), %rax
movq 0x10150(%rax), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq %r14, %rsi
movq -0x30(%rbp), %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r13, %rdi
movq %r12, %rsi
callq 0xedf3
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaa68
// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
movq %rax, %rcx
shrq $0x20, %rcx
xorq %rax, %rcx
shrq $0x6, %rax
xorl %r15d, %r15d
xorl %edx, %edx
divq 0x10120(%rdi)
movq 0x10130(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r12
prefetcht0 (%rax,%rdx)
movq %rcx, %r13
shrq $0x10, %r13
xorq %rcx, %r13
cmpq $0x7, %r15
je 0xf69f
movq 0x8(%r12,%r15,8), %rdi
movl %r13d, %eax
xorw %di, %ax
jne 0xf69a
shrq $0x10, %rdi
movq %rbx, %rsi
callq 0xab0c
testb %al, %al
jne 0xf6c0
incq %r15
jmp 0xf677
movq 0x10150(%r14), %rax
movq (%rax), %rdi
movq 0x10(%rax), %rax
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r12, %rdi
movq %r15, %rsi
callq 0xedf3
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xf809
movq %rdi, %r14
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
pushq $0x1
popq %rdi
movl $0x10080, %esi          # imm = 0x10080
callq 0x62d0
movq %rax, %rbx
xorl %r15d, %r15d
cmpq $0x10000, %r15          # imm = 0x10000
je 0xf76f
leaq (%rbx,%r15), %rdi
callq 0x6aec
addq $0x40, %r15
jmp 0xf757
movq %r14, %r13
shlq $0x14, %r13
leaq 0x10040(%rbx), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x7c29
testq %rax, %rax
je 0xf801
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 0x7c29
testq %rax, %rax
je 0xf7f2
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 0xf80b
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_O2/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, %rcx
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
movq %rdx, %rax
shrq $0x6, %rax
xorl %r15d, %r15d
xorl %edx, %edx
divq 0x10038(%rdi)
movq 0x10048(%rdi), %rax
shlq $0x6, %rdx
leaq (%rax,%rdx), %r13
prefetcht0 (%rax,%rdx)
movq %rcx, %rax
shrq $0x20, %rax
xorq %rcx, %rax
movq %rax, %r12
shrq $0x10, %r12
xorq %rax, %r12
movq %rcx, -0x30(%rbp)
movq %rcx, %rsi
callq 0xf8ee
cmpq $0x7, %r15
je 0xf8b5
movq 0x8(%r13,%r15,8), %rbx
movl %r12d, %eax
xorw %bx, %ax
jne 0xf8b0
cmpq $0x10000, %rbx          # imm = 0x10000
jb 0xf8b0
shrq $0x10, %rbx
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq *0x10068(%r14)
testb %al, %al
jne 0xf8c5
incq %r15
jmp 0xf87e
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0xf901
xorl %ebx, %ebx
jmp 0xf8dc
movq %r13, %rdi
movq %r15, %rsi
callq 0xedf3
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0xf901
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_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movabsq $-0x1000000000000000, %r12 # imm = 0xF000000000000000
movq %rsi, %rax
shrq $0x6, %rax
xorl %r13d, %r13d
xorl %edx, %edx
divq 0x10038(%rdi)
movq %rdx, %r15
shlq $0x6, %r15
addq 0x10048(%rdi), %r15
movq %rsi, %rax
shrq $0x20, %rax
xorq %rsi, %rax
movq %rax, %r14
shrq $0x10, %r14
xorq %rax, %r14
movq %rdi, -0x30(%rbp)
callq 0xf8ee
movb $0x3c, %al
pushq $0xf
popq %rcx
xorl %edx, %edx
cmpq $0x1c, %r13
je 0xfc3b
movq 0x8(%r15,%rdx,8), %rsi
cmpq $0x10000, %rsi          # imm = 0x10000
jb 0xfc32
xorl %r14d, %esi
movzwl %si, %esi
testq %rsi, %rsi
jne 0xfc32
andq $0x0, 0x8(%r15,%rdx,8)
movq (%r15), %rsi
bzhiq %rax, %rsi, %rdi
andq %r12, %rsi
addq %r12, %rsi
orq %rsi, %rdi
shlxq %r13, %rcx, %rsi
andnq %rdi, %rsi, %rsi
movq %rsi, (%r15)
incq %rdx
addq $0x4, %r13
jmp 0xfbef
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf901
// File: /workspace/github_c_makefile_star2_O2/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
cmpq $0x10000, %r14          # imm = 0x10000
je 0xfcfb
leaq (%rbx,%r14), %rdi
callq 0x6afb
addq $0x40, %r14
jmp 0xfce3
xorl %eax, %eax
vxorps %xmm0, %xmm0, %xmm0
xorl %ecx, %ecx
cmpq 0x10038(%rbx), %rcx
jae 0xfd27
movq 0x10048(%rbx), %rdx
vmovups %ymm0, 0x20(%rdx,%rax)
vmovups %ymm0, (%rdx,%rax)
incq %rcx
addq $0x40, %rax
jmp 0xfd03
xorl %r14d, %r14d
cmpq $0x10000, %r14          # imm = 0x10000
je 0xfd45
leaq (%rbx,%r14), %rdi
vzeroupper
callq 0x6320
addq $0x40, %r14
jmp 0xfd2a
popq %rbx
popq %r14
popq %rbp
vzeroupper
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xfcd6
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_O2/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 $0x218, %rsp            # imm = 0x218
movq %rcx, %r14
movq %rsi, %r15
movl %edi, %r12d
xorl %r13d, %r13d
movq (%rdx,%r13,8), %rax
testq %rax, %rax
je 0x10341
movq %rax, -0x240(%rbp,%r13,8)
incq %r13
jmp 0x1032b
leaq 0x2088(%rip), %rsi      # 0x123d0
leaq -0x30(%rbp), %rbx
movl %r12d, -0x34(%rbp)
andq $0x0, -0x30(%rbp)
testl %r12d, %r12d
jle 0x10432
movq (%r15), %rdi
callq 0x62f0
testl %eax, %eax
jne 0x10432
movl %r12d, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x9bce
testl %eax, %eax
js 0x10425
movl %eax, %ecx
leaq (,%rcx,8), %rdx
xorl %edi, %edi
movq %r13, %rsi
cmpq %rdi, %rdx
je 0x103ad
movq (%r15,%rdi), %r8
movq %r8, -0x240(%rbp,%rsi,8)
incq %rsi
addq $0x8, %rdi
jmp 0x10393
movl %esi, %edx
andq $0x0, -0x240(%rbp,%rdx,8)
subl %eax, %r12d
leaq (%r15,%rcx,8), %r15
movq -0x30(%rbp), %rbx
testl %r12d, %r12d
jle 0x1042a
movq (%r15), %rdi
leaq 0x21f6(%rip), %rsi      # 0x125c8
callq 0x62f0
testl %eax, %eax
jne 0x10407
callq 0x7200
movq %rbx, (%r14)
movl %r12d, %edi
movq %r15, %rsi
leaq -0x240(%rbp), %rdx
movq %r14, %rcx
callq 0xfd8f
subl %eax, %r12d
movl %eax, %ecx
leaq (%r15,%rcx,8), %r15
testl %eax, %eax
jns 0x103c3
jmp 0x10425
movq %rbx, %rdi
callq 0x9a86
testl %r12d, %r12d
leaq 0x1fb7(%rip), %rsi      # 0x123d0
leaq -0x30(%rbp), %rbx
jg 0x10350
jmp 0x10432
pushq $-0x1
popq %rax
jmp 0x10438
movq %rbx, %rdi
callq 0x9a86
movl -0x34(%rbp), %eax
subl %r12d, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: maptest_passes_message
void
maptest_passes_message(void)
{
  fprintf(stderr, "%s Usage: {rgen ... {pass ...}}\n", __func__);
  rgen_helper_message();
  fprintf(stderr, "%s Usage: pass <nth> <magic-type> <magic> <repeat> <vlen> <S%%> <D%%> <G%%> <rgen-opt>\n", __func__);
  fprintf(stderr, "%s magic-type: 0:time, 1:count\n", __func__);
  fprintf(stderr, "%s repeat: 0:damp\n", __func__);
  fprintf(stderr, "%s rgen-opt: 0:sync, 1:wait, 2:nowait\n", __func__);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x8ba0(%rip), %r14      # 0x18ff8
movq (%r14), %rdi
leaq 0x2185(%rip), %rsi      # 0x125e7
leaq 0x219f(%rip), %rbx      # 0x12608
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6300
callq 0x9b15
movq (%r14), %rdi
leaq 0x219d(%rip), %rsi      # 0x1261f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6300
movq (%r14), %rdi
leaq 0x21e1(%rip), %rsi      # 0x12677
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6300
movq (%r14), %rdi
leaq 0x21ed(%rip), %rsi      # 0x12697
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6300
movq (%r14), %rdi
leaq 0x21ec(%rip), %rsi      # 0x126aa
movq %rbx, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x6300
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r14
lock
xaddq %r14, (%rdi)
movq 0x8(%rdi), %r15
vmovsd 0x20(%rdi), %xmm0
vmovsd %xmm0, -0x38(%rbp)
movq 0x10(%rdi), %r12
movq 0x18(%rdi), %r13
incq %r12
vxorpd %xmm0, %xmm0, %xmm0
vmovsd %xmm0, -0x30(%rbp)
cmpq %r13, %r14
jae 0x106cc
leaq (%r12,%r14), %rax
vcvtusi2sd %rax, %xmm2, %xmm0
vmovsd -0x38(%rbp), %xmm1
callq 0x6130
vmovsd 0x19c3(%rip), %xmm1     # 0x12078
vdivsd %xmm0, %xmm1, %xmm0
vmovsd -0x30(%rbp), %xmm1
vaddsd %xmm0, %xmm1, %xmm1
vmovsd %xmm1, -0x30(%rbp)
addq %r15, %r14
jmp 0x10694
leaq 0x30(%rbx), %r14
movq %r14, %rdi
callq 0x6afb
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
// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: kvmap1_init
static inline void
kvmap1_init(struct kvmap1 * const map)
{
  const u64 lid = KVMAP_MIN_LEVEL;
  map->max_level = lid;
  map->min_level = lid;
  map->first_check = lid;
  struct __kvmap1_level * const l = &(map->levels[lid]);
  l->table = pages_alloc_best(KVMAP_SIZE_OF_LEVEL(lid), true, &(l->alloc_size));
  l->bm = bitmap_create(KVMAP_SLOTS_OF(lid));
  debug_assert(l->table);
  debug_assert(l->bm);
  bitmap_set_all1(l->bm);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
pushq $0x10
popq %rax
movq %rax, 0x58(%rdi)
movq %rax, 0x60(%rdi)
movq %rax, 0x68(%rdi)
leaq 0x10338(%rdi), %rdx
pushq $0x1
popq %rsi
movl $0x400000, %edi         # imm = 0x400000
callq 0x7c29
movq %rax, 0x10328(%rbx)
movl $0x10000, %edi          # imm = 0x10000
callq 0x7306
movq %rax, %r14
movq %rax, 0x10330(%rbx)
cmpq $0x0, 0x10328(%rbx)
jne 0x1075e
callq 0x6e43
movq 0x10330(%rbx), %r14
testq %r14, %r14
jne 0x1076f
callq 0x6e43
movq 0x10330(%rbx), %r14
leaq 0x10(%r14), %rdi
movq (%r14), %rbx
leaq 0x3f(%rbx), %rdx
shrq $0x3, %rdx
andq $-0x8, %rdx
movl $0xff, %esi
callq 0x6210
xchgq %rbx, 0x8(%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: kvmap1_locate_level
static inline void
kvmap1_locate_level(const struct kvmap1 * const map, const u64 hash, u64 * const out_level, u64 * const out_index)
{
  u64 i = map->first_check;
  const u64 check0 = i;
  while (i >= map->min_level) {
    const struct __kvmap1_level * const level = &(map->levels[i]);
    const u64 j = hash & ((UINT64_C(1) << i) - UINT64_C(1));
    if (bitmap_test(level->bm, j)) {
      *out_level = i;
      *out_index = j;
      return;
    } else if (i >= check0) {
      if (i == map->max_level) i = check0 - 1;
      else i++;
    } else {
      i--;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq %rsi, -0x50(%rbp)
movq 0x60(%rdi), %rbx
movq 0x68(%rdi), %r15
movq %rdi, -0x48(%rbp)
leaq 0x10128(%rdi), %r12
leaq -0x1(%r15), %rax
movq %rax, -0x40(%rbp)
movq %r15, %r14
cmpq %rbx, %r14
jb 0x10824
bzhiq %r14, -0x50(%rbp), %r13
movq %r14, %rax
shlq $0x5, %rax
movq 0x8(%r12,%rax), %rdi
movq %r13, %rsi
callq 0x7337
testb %al, %al
jne 0x10816
cmpq %r15, %r14
jae 0x107fd
decq %r14
jmp 0x107d0
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x58(%rcx), %r14
je 0x10811
incq %r14
movq %r14, %rax
movq %rax, %r14
jmp 0x107d0
movq -0x30(%rbp), %rax
movq %r14, (%rax)
movq -0x38(%rbp), %rax
movq %r13, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: cuckoo_cuckoo_depth
static bool
cuckoo_cuckoo_depth(struct cuckoo * const map, const u64 hash, const struct kv * const kv, const u64 max_cuckoo)
{
  if (max_cuckoo == 0) {
    return cuckoo_cuckoo_local(map, hash, kv);
  }

  struct __kvmap_slot * const slot = cuckoo_hash_slot(map, hash);
  const u64 lidx0 = kvmap_hlocks_index(hash);
  for (u64 k = 0; k < 8; k++) {
    if (slot->e[k].ptr == 0) { // some slots may be released by other threads
      //cuckoo_put_entry(map, &(slot->e[k]), kv);
      kvmap_put_entry(&(map->mm), &(slot->e[k]), kv);
      return true;
    }
    const struct kv * const curr = __u64_to_ptr(slot->e[k].ptr);
    const u64 hash2[2] = {cuckoo_hash(curr, 0), cuckoo_hash(curr, 1), };
    for (u64 x = 0; x < 2; x++) {
      const u64 lidx1 = kvmap_hlocks_index(hash2[x]);
      if ((lidx1 != lidx0) && (cuckoo_trylock(map, lidx1))) {
        const bool r = cuckoo_cuckoo_depth(map, hash2[x], curr, max_cuckoo - 1lu);
        cuckoo_unlock(map, lidx1);
        if (r) {
          slot->e[k].ptr = 0;
          slot->e[k].pkey = 0;
          //cuckoo_put_entry(map, &(slot->e[k]), kv);
          kvmap_put_entry(&(map->mm), &(slot->e[k]), kv);
          return true;
        }
      }
    }
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
testq %rcx, %rcx
je 0x10941
movq %rcx, %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc84c
movq %rax, -0x38(%rbp)
shrl $0x6, %r15d
andl $0x3ff, %r15d           # imm = 0x3FF
movq %rbx, -0x40(%rbp)
leaq 0x50(%rbx), %rax
movq %rax, -0x58(%rbp)
decq %r14
xorl %ecx, %ecx
movq %r14, -0x50(%rbp)
cmpq $0x8, %rcx
je 0x10964
movq -0x38(%rbp), %rax
movq (%rax,%rcx,8), %rbx
cmpq $0xffff, %rbx           # imm = 0xFFFF
jbe 0x1098b
movq %rcx, -0x48(%rbp)
shrq $0x10, %rbx
movq (%rbx), %rax
movq %rax, -0x70(%rbp)
rorxq $0x2d, %rax, %rax
movq %rax, -0x68(%rbp)
xorl %r12d, %r12d
cmpq $0x2, %r12
je 0x1091e
movq -0x70(%rbp,%r12,8), %r14
movl %r14d, %r13d
shrl $0x6, %r13d
andl $0x3ff, %r13d           # imm = 0x3FF
cmpq %r15, %r13
je 0x10919
shll $0x6, %r13d
addq -0x58(%rbp), %r13
movq %r13, %rdi
callq 0x6b12
testb %al, %al
je 0x10919
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq -0x50(%rbp), %rcx
callq 0x10833
movl %eax, %r14d
movq %r13, %rdi
callq 0x6320
testb %r14b, %r14b
jne 0x1092a
incq %r12
jmp 0x108c4
movq -0x48(%rbp), %rcx
incq %rcx
jmp 0x10889
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq (%rax,%rcx,8), %rsi
andq $0x0, (%rax,%rcx,8)
movq -0x40(%rbp), %rdi
jmp 0x10971
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc84c
xorl %ecx, %ecx
cmpq $0x40, %rcx
je 0x10964
cmpq $0xffff, (%rax,%rcx)    # imm = 0xFFFF
jbe 0x10968
addq $0x8, %rcx
jmp 0x1094e
xorl %eax, %eax
jmp 0x1097c
addq %rcx, %rax
movq %rbx, %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0xccb2
movb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rax
leaq (%rax,%rcx,8), %rsi
jmp 0x1093b
// File: /workspace/github_c_makefile_star2_O2/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)
jne 0x109b8
callq 0x6e43
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)
jne 0x109f8
callq 0x6e43
cmpq $0x0, (%r13)
je 0x10a04
callq 0x6e43
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
pushq $0x1
popq %rsi
callq 0x7c29
movq %rax, (%rbx,%r14)
leaq -0x50(%rbp), %r14
movq %rbx, (%r14)
andq $0x0, 0x8(%r14)
movq %r12, 0x10(%r14)
movq %r13, 0x18(%r14)
movq 0x100d8(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
leaq -0x96dd(%rip), %rax     # 0x7379
leaq -0x96ae(%rip), %rcx     # 0x73af
cmoveq %rax, %rcx
movq %rcx, 0x20(%r14)
leaq 0x4e(%rip), %rsi        # 0x10aba
xorl %edi, %edi
movq %r14, %rdx
callq 0x7a73
movq 0x8(%r14), %rax
cmpq $0x400, %rax            # imm = 0x400
ja 0x10a87
callq 0x6e43
movq (%rbx,%r15), %rdi
movq 0x8(%r12), %rsi
callq 0x6410
andq $0x0, (%rbx,%r15)
addq $0x10050, %rbx          # imm = 0x10050
movq %rbx, %rdi
callq 0x6ba1
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x8
popq %rcx
shlxq %rax, %rcx, %rdi
pushq $0x1
popq %rsi
movq %r14, %rdx
callq 0x7c29
movq %rax, -0x8(%r14)
testq %rax, %rax
jne 0x10cd3
callq 0x6e43
xorl %r15d, %r15d
leaq -0x48(%rbp), %r14
xorl %eax, %eax
xchgq %rax, 0x20(%r14)
leaq 0xb4(%rip), %rsi        # 0x10d9b
xorl %edi, %edi
movq %r14, %rdx
callq 0x7a73
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)
pushq $0x2
popq %rcx
shlxq %rax, %rcx, %rax
movq %rax, 0xd8(%rbx)
mfence
leaq 0x138(%rbx), %r14
cmpq $0x10000, %r15          # imm = 0x10000
je 0x10d5b
leaq (%r14,%r15), %rdi
callq 0x6320
addq $0x40, %r15
jmp 0x10d43
addq $0xf8, %rbx
movq %rbx, %rdi
callq 0x6ba1
movq 0x8287(%rip), %rax      # 0x18ff8
movq (%rax), %rdi
leaq 0x1a6c(%rip), %rsi      # 0x127e7
leaq 0x1a7c(%rip), %rdx      # 0x127fe
vmovsd -0x20(%rbp), %xmm0
movb $0x1, %al
callq 0x6300
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
movq 0xd0(%r14), %r15
cmpq $0x9, %r15
ja 0x10dc8
callq 0x6e43
movq 0xd0(%r14), %r15
addq $-0xa, %r15
addq $0x138, %r14            # imm = 0x138
pushq $0x1
popq %r12
movq %r12, %r13
lock
xaddq %r13, 0x20(%rbx)
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x10e57
movq %r13, %rdi
shlq $0x6, %rdi
addq %r14, %rdi
callq 0x6afb
xorl %eax, %eax
shrxq %r15, %rax, %rcx
testq %rcx, %rcx
jne 0x10dd7
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 0x10e52
movq (%rcx), %rdx
movq 0x8(%rcx), %rsi
shrq $0x10, %rdx
movq (%rdx), %rdx
shrq $0x6, %rdx
movb 0x8(%rbx), %dil
bzhiq %rdi, %rdx, %rdx
movq 0x10(%rbx), %rdi
movq (%rdi,%rdx,8), %r8
movq %r8, 0x8(%rcx)
movq %rcx, (%rdi,%rdx,8)
movq %rsi, %rcx
jmp 0x10e1d
incq %rax
jmp 0x10dfa
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movq %rsi, %r12
movq %rdi, %r14
movq 0x8(%rdi), %rdx
cmpq %rsi, %rdx
jae 0x10e99
callq 0x6e43
movq 0x8(%r14), %rdx
movq %r12, %r15
shlq $0x4, %r15
leaq (%r14,%r15), %r13
addq $0x30, %r13
leaq (%r14,%r15), %rbx
addq $0x20, %rbx
subq %r12, %rdx
shlq $0x4, %rdx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x6450
movq -0x30(%rbp), %rax
movq %rax, (%rbx)
movq -0x38(%rbp), %r8
movq %r8, 0x8(%rbx)
movq 0x8(%r14), %rax
incq %rax
movq %rax, 0x8(%r14)
cmpq $0x2, %rax
jb 0x10f2d
testq %r12, %r12
je 0x10f04
addq $0x20, %r14
movq -0x8(%r15,%r14), %rax
leaq 0x10(%rax), %rcx
movq 0x10(%rax), %rsi
pushq $0x18
popq %rdx
testq %rsi, %rsi
je 0x10f26
pushq $0x10
jmp 0x10f1a
movq 0x8(%r13), %rax
leaq 0x18(%rax), %rcx
movq 0x18(%rax), %rsi
pushq $0x10
popq %rdx
testq %rsi, %rsi
je 0x10f26
pushq $0x18
popq %rdi
movq %rsi, (%r8,%rdi)
movq (%rcx), %rsi
movq %r8, (%rsi,%rdx)
movq %rax, (%r8,%rdx)
movq %r8, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: mkblobi
Blob *
mkblobi(Blobtype type, uint64_t ival)
{
	Blob *b;

	b = zalloc(sizeof(Blob));
	b->type = type;
	b->ival = ival;
	return b;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
pushq $0x38
popq %rdi
callq 0x29a78
movl %ebp, (%rax)
movq %rbx, 0x20(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: mkblobpad
Blob *
mkblobpad(size_t sz)
{
	Blob *b;

	b = zalloc(sizeof(Blob));
	b->type = Btpad;
	b->npad = sz;
	return b;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
pushq $0x38
popq %rdi
callq 0x29a78
movl $0x8, (%rax)
movq %rbx, 0x20(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: mkblobbytes
Blob *
mkblobbytes(char *buf, size_t len)
{
	Blob *b;

	b = zalloc(sizeof(Blob));
	b->type = Btbytes;
	b->bytes.buf = buf;
	b->bytes.len = len;
	return b;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x38
popq %rdi
callq 0x29a78
movl $0x6, (%rax)
movq %r14, 0x28(%rax)
movq %rbx, 0x20(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: mkblobseq
Blob *
mkblobseq(Blob **sub, size_t nsub)
{
	Blob *b;

	b = zalloc(sizeof(Blob));
	b->type = Btseq;
	b->seq.sub = sub;
	b->seq.nsub = nsub;
	return b;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x38
popq %rdi
callq 0x29a78
movl $0x7, (%rax)
movq %r14, 0x28(%rax)
movq %rbx, 0x20(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: mkblobref
Blob *
mkblobref(char *lbl, size_t off, int isextern)
{
	Blob *b;

	b = zalloc(sizeof(Blob));
	b->type = Btref;
	b->ref.str = strdup(lbl);
	b->ref.isextern = isextern;
	b->ref.off = off;
	return b;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x38
popq %rdi
callq 0x29a78
movq %rax, %r12
movl $0x5, (%rax)
movq %r15, %rdi
callq 0x4340
movq %rax, 0x20(%r12)
movb %bl, 0x28(%r12)
movq %r14, 0x30(%r12)
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/blob.c
// Function: blobfree
void
blobfree(Blob *b)
{
	size_t i;

	if (!b)
		return;
	switch (b->type) {
	case Btref:
		free(b->lbl);
		break;
	case Btseq:
		for (i = 0; i < b->seq.nsub; i++)

			blobfree(b->seq.sub[i]);
		break;
	default:
		break;
	}
	free(b);
}

// Assembly:
testq %rdi, %rdi
je 0x459b
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x5, %eax
je 0x459c
cmpl $0x7, %eax
jne 0x45a5
xorl %r14d, %r14d
cmpq 0x20(%rbx), %r14
jae 0x45a5
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x4568
incq %r14
jmp 0x4583
retq
movq 0x10(%rbx), %rdi
callq 0x4040
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4040