LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: stream2_create
struct stream2 *
stream2_create(const char * const host, const int port)
{
  char portstr[6];
  snprintf(portstr, 6, "%d", port);
  struct addrinfo info0 = {.ai_family = AF_INET, .ai_socktype = SOCK_STREAM};
  struct addrinfo *info = NULL;
  if (getaddrinfo(host, portstr, &info0, &info) != 0) return NULL;

  for (struct addrinfo * p = info; p != NULL; p = p->ai_next) {
    const int fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if (fd < 0) continue;
    int one = 1;
    (void)setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
    if (connect(fd, p->ai_addr, p->ai_addrlen) != 0) {
      close(fd);
      continue;
    }
    freeaddrinfo(info);
    struct stream2 * const stream2 = (typeof(stream2))malloc(sizeof(*stream2));
    stream2->w = fdopen(dup(fd), "wb");
    stream2->r= fdopen(fd, "rb");
    return stream2;
  }
  if (info) freeaddrinfo(info);
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ecx
movq %rdi, %r14
leaq 0x9c68(%rip), %rdx      # 0x151de
xorl %ebx, %ebx
leaq -0x3a(%rbp), %r15
movl $0x6, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x61e0
vxorps %xmm0, %xmm0, %xmm0
leaq -0x70(%rbp), %rdx
vmovups %ymm0, (%rdx)
vmovups %ymm0, 0x10(%rdx)
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x4(%rdx)
leaq -0x30(%rbp), %rcx
movq $0x0, (%rcx)
movq %r14, %rdi
movq %r15, %rsi
vzeroupper
callq 0x6590
testl %eax, %eax
jne 0xb6b1
movq -0x30(%rbp), %r12
testq %r12, %r12
sete %r15b
je 0xb69b
movl 0x4(%r12), %edi
movl 0x8(%r12), %esi
movl 0xc(%r12), %edx
callq 0x6620
testl %eax, %eax
js 0xb63d
movl %eax, %r13d
movl $0x1, -0x34(%rbp)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x34(%rbp), %rcx
movl $0x4, %r8d
callq 0x6100
movq 0x18(%r12), %rsi
movl 0x10(%r12), %edx
movl %r13d, %edi
callq 0x6540
testl %eax, %eax
setne %r14b
je 0xb642
movl %r13d, %edi
callq 0x6220
jmp 0xb684
movb $0x1, %r14b
jmp 0xb684
movq -0x30(%rbp), %rdi
callq 0x6610
movl $0x10, %edi
callq 0x63a0
movq %rax, %rbx
movl %r13d, %edi
callq 0x61f0
movl %eax, %edi
leaq 0x9da3(%rip), %rsi      # 0x1540c
callq 0x6400
movq %rax, (%rbx)
movl %r13d, %edi
leaq 0x9bfa(%rip), %rsi      # 0x15275
callq 0x6400
movq %rax, 0x8(%rbx)
testb %r14b, %r14b
je 0xb69b
movq 0x28(%r12), %r12
testq %r12, %r12
sete %r15b
jne 0xb5dc
testb $0x1, %r15b
je 0xb6b1
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0xb6af
callq 0x6610
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %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: kv_refill
inline void
kv_refill(struct kv * const kv, const void * const key, const u32 klen, const void * const value, const u32 vlen)
{
  if (kv) {
    kv->klen = klen;
    kv->vlen = vlen;
    memcpy(&(kv->kv[0]), key, klen);
    memcpy(&(kv->kv[klen]), value, vlen);
    kv_update_hash(kv);
  }
}

// Assembly:
testq %rdi, %rdi
je 0xb803
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r15d
movq %rcx, %r14
movq %rdi, %rbx
movl %edx, 0x8(%rdi)
movl %r8d, 0xc(%rdi)
leaq 0x10(%rdi), %r12
movl %edx, %r13d
movq %r12, %rdi
movq %r13, %rdx
callq 0x6340
leaq (%rbx,%r13), %rdi
addq $0x10, %rdi
movl %r15d, %edx
movq %r14, %rsi
callq 0x6340
movl 0x8(%rbx), %esi
movq %r12, %rdi
callq 0x90e8
movq %rax, (%rbx)
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: kv_dup
inline struct kv *
kv_dup(const struct kv * const kv)
{
  if (kv == NULL) return NULL;

  const size_t sz = kv_size(kv);
  struct kv * const new = (typeof(new))malloc(sz);
  if (new) {
    memcpy(new, kv, sz);
  }
  return new;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xb9e0
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
leaq (%rax,%rcx), %r14
addq $0x10, %r14
movq %r14, %rdi
callq 0x63a0
testq %rax, %rax
je 0xb9e2
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0x6340
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kv_dup_key
inline struct kv *
kv_dup_key(const struct kv * const kv)
{
  if (kv == NULL) return NULL;

  const size_t sz = key_size(kv);
  struct kv * const new = (typeof(new))malloc(sz);
  if (new) {
    memcpy(new, kv, sz);
  }
  return new;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xba1d
movq %rdi, %rbx
movl 0x8(%rdi), %r14d
addq $0x10, %r14
movq %r14, %rdi
callq 0x63a0
testq %rax, %rax
je 0xba1f
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0x6340
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kv_dup2
inline struct kv *
kv_dup2(const struct kv * const from, struct kv * const to)
{
  if (from == NULL) return NULL;

  const size_t sz = kv_size(from);
  if (to) {
    memcpy(to, from, sz);
    return to;
  } else {
    struct kv * const new = (typeof(new))malloc(sz);
    if (new) {
      memcpy(new, from, sz);
    }
    return new;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xba68
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
leaq (%rax,%rcx), %r14
addq $0x10, %r14
testq %rsi, %rsi
jne 0xba56
movq %r14, %rdi
callq 0x63a0
movq %rax, %rsi
testq %rax, %rax
je 0xba6a
movq %rsi, %rdi
movq %rbx, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0x6340
xorl %esi, %esi
movq %rsi, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kv_dup2_key
inline struct kv *
kv_dup2_key(const struct kv * const from, struct kv * const to)
{
  if (from == NULL) return NULL;

  const size_t sz = key_size(from);
  if (to) {
    memcpy(to, from, sz);
    return to;
  } else {
    struct kv * const new = (typeof(new))malloc(sz);
    if (new) {
      memcpy(new, from, sz);
    }
    return new;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xbab0
movq %rdi, %rbx
movl 0x8(%rdi), %r14d
addq $0x10, %r14
testq %rsi, %rsi
jne 0xba9e
movq %r14, %rdi
callq 0x63a0
movq %rax, %rsi
testq %rax, %rax
je 0xbab2
movq %rsi, %rdi
movq %rbx, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0x6340
xorl %esi, %esi
movq %rsi, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kv_keycompare
int
kv_keycompare(const struct kv * const kv1, const struct kv * const kv2)
{
  if (kv1 == NULL) {
    return (kv2 == NULL) ? 0 : -1;
  } else if (kv2 == NULL) {
    return 1;
  }
  const u32 len = kv1->klen < kv2->klen ? kv1->klen : kv2->klen;
  const int cmp = memcmp(kv1->kv, kv2->kv, (size_t)len);
  if (cmp == 0) {
    if (kv1->klen < kv2->klen) {
      return -1;
    } else if (kv1->klen > kv2->klen) {
      return 1;
    } else {
      return 0;
    }
  } else {
    return cmp;
  }
}

// Assembly:
testq %rdi, %rdi
je 0xbb9c
testq %rsi, %rsi
je 0xbba4
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x8(%rdi), %ebx
movl 0x8(%rsi), %r14d
cmpl %r14d, %ebx
setb %r15b
movl %r14d, %edx
cmovbl %ebx, %edx
addq $0x10, %rdi
addq $0x10, %rsi
callq 0x62a0
movl %eax, %ecx
testl %eax, %eax
setne %dl
orb %r15b, %dl
xorl %eax, %eax
cmpl $0x1, %ecx
sbbl %eax, %eax
testb %dl, %dl
je 0xbbaa
orl %ecx, %eax
jmp 0xbbb2
xorl %eax, %eax
negq %rsi
sbbl %eax, %eax
retq
movl $0x1, %eax
retq
xorl %eax, %eax
cmpl %r14d, %ebx
seta %al
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: kvmap_api_helper_map
static int
kvmap_api_helper_map(int argc, char ** const argv, struct kvmap_api ** const out, struct kvmap_mm * const mm)
{
  if (argc < 1) {
    return -1;
  }
  struct kvmap_api * tmp = NULL;
  int used = 0;
  if (strcmp("kvmap2", argv[0]) == 0) {
    tmp = kvmap2_api_create(kvmap2_create(mm));
    used = 1;
  } else if (strcmp("cuckoo", argv[0]) == 0) {
    tmp = cuckoo_api_create(cuckoo_create(mm));
    used = 1;
  } else if (strcmp("skiplist", argv[0]) == 0) {
    tmp = skiplist_api_create(skiplist_create(mm));
    used = 1;
  } else if (strcmp("chainmap", argv[0]) == 0) {
    tmp = chainmap_api_create(chainmap_create(mm));
    used = 1;
  } else if (strcmp("bptree", argv[0]) == 0) {
    tmp = bptree_api_create(bptree_create(mm));
    used = 1;
  } else if (strcmp("tcpmap", argv[0]) == 0) {
    if (argc < 3) return -1;
    tmp = tcpmap_api_create(tcpmap_create(argv[1], atoi(argv[2])));
    used = 3;
  }
  if (used > 0 && tmp) {
    *out = tmp;
    return used;
  } else {
    return -1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r12d
movq (%rsi), %r13
leaq 0x98b8(%rip), %rdi      # 0x1572f
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbeee
leaq 0x98ac(%rip), %rdi      # 0x15736
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbf00
leaq 0x98a0(%rip), %rdi      # 0x1573d
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbf12
leaq 0x9896(%rip), %rdi      # 0x15746
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbf2b
leaq 0x988c(%rip), %rdi      # 0x1574f
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbf3d
leaq 0x9880(%rip), %rdi      # 0x15756
movq %r13, %rsi
callq 0x62f0
testl %eax, %eax
je 0xbf7a
xorl %eax, %eax
xorl %esi, %esi
xorl %edx, %edx
jmp 0xbf55
movq %r15, %rdi
callq 0xc2d2
movq %rax, %rdi
callq 0xdc2b
jmp 0xbf4d
movq %r15, %rdi
callq 0xdcc2
movq %rax, %rdi
callq 0xec46
jmp 0xbf4d
leaq -0x3cb(%rip), %rsi      # 0xbb4e
movq %r15, %rdi
callq 0xecdd
movq %rax, %rdi
callq 0xf84a
jmp 0xbf4d
movq %r15, %rdi
callq 0xf8e1
movq %rax, %rdi
callq 0x103b5
jmp 0xbf4d
movq %r15, %rdi
callq 0x1044c
movq %rax, %rdi
callq 0x110ce
movl $0x1, %edx
movb $0x1, %sil
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb %sil, %sil
je 0xbf69
testq %rax, %rax
je 0xbf69
movq %rax, (%rbx)
movl %edx, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x3, %r12d
jl 0xbf69
movq 0x8(%r14), %r15
movq 0x10(%r14), %rdi
callq 0x64e0
movq %r15, %rdi
movl %eax, %esi
callq 0x11165
movq %rax, %rdi
callq 0x11427
movl $0x3, %edx
jmp 0xbf52
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_create
struct icache *
icache_create(const struct kvmap_mm * const mm, const u64 nr_mb)
{
  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);

  struct icache * const cache = (typeof(cache))malloc(sizeof(*cache));
  memset(cache, 0, sizeof(*cache));
  cache->mm = mm ? (*mm) : __kvmap_mm_default;
  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;
  return cache;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0x10158, %edi          # imm = 0x10158
callq 0x63a0
movq %rax, %rbx
movl $0x10158, %edx          # imm = 0x10158
movq %rax, %rdi
xorl %esi, %esi
callq 0x6210
testq %r15, %r15
je 0xbffa
vmovups (%r15), %ymm0
vmovups 0x20(%r15), %ymm1
vmovups 0x30(%r15), %ymm2
vmovups %ymm2, 0x30(%rbx)
vmovups %ymm1, 0x20(%rbx)
jmp 0xc01c
vmovups 0xfdb6(%rip), %ymm0     # 0x1bdb8
vmovups %ymm0, 0x30(%rbx)
vmovups 0xfd99(%rip), %ymm0     # 0x1bda8
vmovups %ymm0, 0x20(%rbx)
vmovups 0xfd6c(%rip), %ymm0     # 0x1bd88
vmovups %ymm0, (%rbx)
movl $0xe0, %r15d
leaq (%rbx,%r15), %rdi
movl $0x1, %esi
vzeroupper
callq 0x62e0
addq $0x40, %r15
cmpq $0x100e0, %r15          # imm = 0x100E0
jne 0xc026
movq %r14, %r15
shlq $0x14, %r15
leaq 0x10128(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x831a
testq %rax, %rax
je 0xc0b9
movq %rax, %r12
movq %r15, %rax
shrq $0x6, %rax
movq %r12, 0x10130(%rbx)
movq %rax, 0x10120(%rbx)
shlq $0x16, %r14
movq %rbx, %rdx
addq $0x10140, %rdx          # imm = 0x10140
movq %r14, %rdi
xorl %esi, %esi
callq 0x831a
testq %rax, %rax
je 0xc0aa
shrq $0x2, %r15
movq %r15, 0x10138(%rbx)
movq %rax, 0x10148(%rbx)
jmp 0xc0c3
movq 0x10128(%rbx), %rsi
movq %r12, %rdi
callq 0x6410
movq %rbx, %rdi
callq 0x6060
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_wrap_mm
inline void
icache_wrap_mm(struct icache * const cache, struct kvmap_mm * const mm)
{
  cache->map_mm = *mm;
  if (mm->rf) {
    mm->rf = __icache_kv_retire_cb;
    mm->rp = cache;
    mm->uf = __icache_kv_uncache_cb;
    mm->up = cache;
  }
  mm->hf = __icache_kv_hit_cb;
  mm->hp = cache;
  mm->xf = __icache_kv_refresh_cb;
  mm->xp = cache;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
vmovups (%rsi), %ymm0
vmovups 0x20(%rsi), %ymm1
vmovups 0x30(%rsi), %ymm2
vmovups %ymm2, 0x80(%rdi)
vmovups %ymm1, 0x70(%rdi)
vmovups %ymm0, 0x50(%rdi)
cmpq $0x0, 0x10(%rsi)
je 0xc118
leaq 0x5f16(%rip), %rax      # 0x12017
movq %rax, 0x10(%rsi)
movq %rdi, 0x18(%rsi)
leaq 0x5fba(%rip), %rax      # 0x120ca
movq %rax, 0x30(%rsi)
movq %rdi, 0x38(%rsi)
leaq 0x6064(%rip), %rax      # 0x12183
movq %rax, 0x20(%rsi)
movq %rdi, 0x28(%rsi)
leaq 0x6068(%rip), %rax      # 0x12196
movq %rax, 0x40(%rsi)
movq %rdi, 0x48(%rsi)
popq %rbp
vzeroupper
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: icache_destroy
void
icache_destroy(struct icache * const cache)
{
  icache_clean(cache);
  pages_unmap(cache->table, cache->slots_alloc_size);
  pages_unmap(cache->hists, cache->hists_alloc_size);
  if (cache->map_api) {
    kvmap_api_destroy(cache->map_api);
  }
  free(cache);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x118bf
movq 0x10128(%rbx), %rsi
movq 0x10130(%rbx), %rdi
callq 0x6410
movq 0x10140(%rbx), %rsi
movq 0x10148(%rbx), %rdi
callq 0x6410
movq 0x10150(%rbx), %r14
testq %r14, %r14
je 0xc18b
movq (%r14), %rdi
callq *0x30(%r14)
movq %r14, %rdi
callq 0x6060
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x6060
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kvmap2_create
struct kvmap2 *
kvmap2_create(const struct kvmap_mm * const mm)
{
  struct kvmap2 * const map2 = calloc(1, sizeof(*map2));
  map2->mm = mm ? (*mm) : __kvmap_mm_default;
  map2->sz_shift = 5;
  map2->maps[0] = kvmap1_create(mm, 0);
  map2->maps[1] = kvmap1_create(mm, 19);
  return map2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x1, %edi
movl $0x68, %esi
callq 0x62d0
movq %rax, %r14
testq %rbx, %rbx
je 0xc30f
vmovups (%rbx), %ymm0
vmovups 0x20(%rbx), %ymm1
vmovups 0x30(%rbx), %ymm2
vmovups %ymm2, 0x30(%r14)
vmovups %ymm1, 0x20(%r14)
jmp 0xc333
vmovups 0xfaa1(%rip), %ymm0     # 0x1bdb8
vmovups %ymm0, 0x30(%r14)
vmovups 0xfa83(%rip), %ymm0     # 0x1bda8
vmovups %ymm0, 0x20(%r14)
vmovups 0xfa55(%rip), %ymm0     # 0x1bd88
vmovups %ymm0, (%r14)
movq $0x5, 0x50(%r14)
movq %rbx, %rdi
xorl %esi, %esi
vzeroupper
callq 0xc36a
movq %rax, 0x58(%r14)
movl $0x13, %esi
movq %rbx, %rdi
callq 0xc36a
movq %rax, 0x60(%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kvmap1_create
static struct kvmap1 *
kvmap1_create(const struct kvmap_mm * const mm, const u64 hash_rotate)
{
  struct kvmap1 * const map = xalloc(64, sizeof(*map));
  memset(map, 0, sizeof(*map));

  map->mm = mm ? (*mm) : __kvmap_mm_default;
  map->hash_rotate = hash_rotate;

  for (u64 j = 0; j < KVMAP_HLOCK_NR; j++) {
    spinlock_init(&(map->hlocks[j]));
  }
  spinlock_init(&(map->split_lock));

  kvmap1_init(map);
  return map;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
leaq -0x20(%rbp), %rdi
movl $0x40, %esi
movl $0x10928, %edx          # imm = 0x10928
callq 0x6570
xorl %ebx, %ebx
testl %eax, %eax
jne 0xc397
movq -0x20(%rbp), %rbx
movl $0x10928, %edx          # imm = 0x10928
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6210
testq %r15, %r15
je 0xc3c8
vmovups (%r15), %ymm0
vmovups 0x20(%r15), %ymm1
vmovups 0x30(%r15), %ymm2
vmovups %ymm2, 0x30(%rbx)
vmovups %ymm1, 0x20(%rbx)
jmp 0xc3ea
vmovups 0xf9e8(%rip), %ymm0     # 0x1bdb8
vmovups %ymm0, 0x30(%rbx)
vmovups 0xf9cb(%rip), %ymm0     # 0x1bda8
vmovups %ymm0, 0x20(%rbx)
vmovups 0xf99e(%rip), %ymm0     # 0x1bd88
vmovups %ymm0, (%rbx)
movq %r14, 0x50(%rbx)
movl $0xe8, %r14d
leaq (%rbx,%r14), %rdi
movl $0x1, %esi
vzeroupper
callq 0x62e0
addq $0x40, %r14
cmpq $0x100e8, %r14          # imm = 0x100E8
jne 0xc3f8
leaq 0x100e8(%rbx), %rdi
movl $0x1, %esi
callq 0x62e0
movl $0x10, %eax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
movq %rax, 0x68(%rbx)
leaq 0x10338(%rbx), %rdx
movl $0x400000, %edi         # imm = 0x400000
movl $0x1, %esi
callq 0x831a
movq %rax, 0x10328(%rbx)
movl $0x1, %edi
movl $0x2010, %esi           # imm = 0x2010
callq 0x62d0
movq $0x10000, (%rax)        # imm = 0x10000
xorl %ecx, %ecx
xchgq %rcx, 0x8(%rax)
movq %rax, 0x10330(%rbx)
cmpq $0x0, 0x10328(%rbx)
je 0xc4c2
cmpq $0x0, 0x10330(%rbx)
je 0xc4c9
movq 0x10330(%rbx), %r14
leaq 0x10(%r14), %rdi
movq (%r14), %r15
leaq 0x3f(%r15), %rdx
shrq $0x3, %rdx
andq $-0x8, %rdx
movl $0xff, %esi
callq 0x6210
xchgq %r15, 0x8(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
jmp 0xc482
callq 0x66ef
jmp 0xc48c
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kvmap2_get
struct kv *
kvmap2_get(struct kvmap2 * const map2, const struct kv * const key, struct kv * const out)
{
  u64 i = UINT64_MAX;
  u64 j = UINT64_MAX;
  u64 k = UINT64_MAX;
  kvmap1_lock_hash(map2->maps[0], key);
  for (u64 x = 0; x < 2; x++) {
    struct kvmap1 * const map = map2->maps[x];
    if (kvmap1_locate_key(map, key, &i, &j, &k)) {
      struct kv * const curr = __u64_to_ptr(map->levels[i].table[j].e[k].ptr);
      if (map2->mm.hf) map2->mm.hf(curr, map2->mm.hp);
      struct kv * const ret = kv_dup2(curr, out);
      kvmap1_unlock_hash(map2->maps[x], key);
      return ret;
    }
    if (x == 0) {
      kvmap1_lock_hash(map2->maps[1], key);
    }
    kvmap1_unlock_hash(map2->maps[x], key);
  }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, -0x50(%rbp)
movq %rsi, %r14
movq %rdi, %r15
movq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq 0x58(%rdi), %rax
movq (%rsi), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xc660
xorl %r13d, %r13d
movq %r14, -0x58(%rbp)
movq 0x58(%r15,%r13,8), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x48(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0xc667
movl %eax, %r12d
testb %al, %al
je 0xc5a0
movq -0x48(%rbp), %rax
shlq $0x5, %rax
movq -0x40(%rbp), %rcx
shlq $0x6, %rcx
addq 0x10128(%rbx,%rax), %rcx
movq -0x38(%rbp), %rax
movq (%rcx,%rax,8), %rbx
movq %rbx, %r14
shrq $0x10, %r14
movq 0x20(%r15), %rax
testq %rax, %rax
je 0xc58d
movq 0x28(%r15), %rsi
movq %r14, %rdi
callq *%rax
cmpq $0x10000, %rbx          # imm = 0x10000
jae 0xc5d2
movq $0x0, -0x30(%rbp)
jmp 0xc60f
testq %r13, %r13
jne 0xc60f
movq 0x60(%r15), %rax
movq (%r14), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
jne 0xc60f
jmp 0xc660
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
leaq (%rax,%rcx), %rbx
addq $0x10, %rbx
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0xc600
movq %rbx, %rdi
callq 0x63a0
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0xc60f
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6340
movq 0x58(%r15,%r13,8), %rax
movq -0x58(%rbp), %r14
movq (%r14), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6320
testb %r12b, %r12b
jne 0xc64d
incq %r13
cmpq $0x1, %r13
je 0xc531
xorl %eax, %eax
jmp 0xc651
movq -0x30(%rbp), %rax
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: kvmap1_locate_key
static bool
kvmap1_locate_key(const struct kvmap1 * const map, const struct kv * const key,
    u64 * const out_level, u64 * const out_index, u64 * const out_entry)
{
  const u64 hash = bits_rotl_u64(key->hash, map->hash_rotate);
  const u64 pkey = kvmap_pkey(hash);
  kvmap1_locate_level(map, hash, out_level, out_index);
  const struct __kvmap_slot * const slot = &(map->levels[*out_level].table[*out_index]);
  u64 used = 0;
  for (u64 k = 0; k < 8; k++) {
    if (slot->e[k].ptr) {
      used++;
      if (slot->e[k].pkey == pkey) {
        const struct kv * const curr = __u64_to_ptr(slot->e[k].ptr);
        if (kv_keymatch(key, curr)) {
          *out_entry = k;
          return true;
        }
      }
    }
  }
  *out_entry = used;
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, -0x30(%rbp)
movq %rcx, %rax
movq %rsi, -0x38(%rbp)
movq (%rsi), %rsi
movb 0x50(%rdi), %cl
rolq %cl, %rsi
movq %rsi, %rcx
shrq $0x20, %rcx
xorq %rsi, %rcx
movq %rcx, %r13
shrq $0x10, %r13
xorq %rcx, %r13
movq 0x68(%rdi), %r8
leaq 0x10128(%rdi), %rcx
leaq -0x1(%r8), %r9
movq %r8, %r10
cmpq 0x60(%rdi), %r10
jb 0xc715
bzhiq %r10, %rsi, %rbx
movq %r10, %r11
shlq $0x5, %r11
movq 0x8(%rcx,%r11), %r11
cmpq %rbx, (%r11)
jbe 0xc6e4
movq %rbx, %r14
shrq $0x6, %r14
movq 0x10(%r11,%r14,8), %r11
btq %rbx, %r11
setb %r11b
jmp 0xc6e7
xorl %r11d, %r11d
testb %r11b, %r11b
je 0xc6f4
movq %r10, (%rdx)
movq %rbx, (%rax)
jmp 0xc710
cmpq %r8, %r10
jae 0xc6fe
decq %r10
jmp 0xc710
movq %r9, %rbx
cmpq 0x58(%rdi), %r10
je 0xc70d
incq %r10
movq %r10, %rbx
movq %rbx, %r10
testb %r11b, %r11b
je 0xc6b2
movq (%rdx), %rdx
shlq $0x5, %rdx
movq (%rax), %r15
shlq $0x6, %r15
addq (%rcx,%rdx), %r15
movq -0x38(%rbp), %rcx
leaq 0x10(%rcx), %rax
movq %rax, -0x40(%rbp)
movb $0x1, %r12b
xorl %r14d, %r14d
xorl %ebx, %ebx
movq (%r15,%r14,8), %rsi
cmpq $0x10000, %rsi          # imm = 0x10000
jb 0xc77c
incq %rbx
movl %r13d, %eax
xorw %si, %ax
jne 0xc77c
shrq $0x10, %rsi
movq (%rcx), %rax
cmpq (%rsi), %rax
jne 0xc77c
movl 0x8(%rcx), %edx
cmpl 0x8(%rsi), %edx
jne 0xc77c
addq $0x10, %rsi
movq -0x40(%rbp), %rdi
callq 0x63d0
testl %eax, %eax
je 0xc7b4
movq -0x38(%rbp), %rcx
cmpq $0x7, %r14
leaq 0x1(%r14), %rax
setb %r12b
movq %rax, %r14
cmpq $0x8, %rax
jne 0xc73b
testb $0x1, %r12b
jne 0xc79e
movq -0x30(%rbp), %rax
movq %rbx, (%rax)
andb $0x1, %r12b
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
movq %r14, (%rax)
jmp 0xc791
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kvmap2_probe
bool
kvmap2_probe(struct kvmap2 * const map2, const struct kv * const key)
{
  u64 i = UINT64_MAX;
  u64 j = UINT64_MAX;
  u64 k = UINT64_MAX;
  kvmap1_lock_hash(map2->maps[0], key);
  for (u64 x = 0; x < 2; x++) {
    struct kvmap1 * const map = map2->maps[x];
    if (kvmap1_locate_key(map, key, &i, &j, &k)) {
      struct kv * const curr = __u64_to_ptr(map->levels[i].table[j].e[k].ptr);
      if (map2->mm.hf) map2->mm.hf(curr, map2->mm.hp);
      kvmap1_unlock_hash(map2->maps[x], key);
      return true;
    }
    if (x == 0) {
      kvmap1_lock_hash(map2->maps[1], key);
    }
    kvmap1_unlock_hash(map2->maps[x], key);
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq 0x58(%rdi), %rax
movq %rsi, -0x30(%rbp)
movq (%rsi), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xc8f7
movb $0x1, %r15b
xorl %ebx, %ebx
movq 0x58(%r14,%rbx,8), %r12
movq %r12, %rdi
movq -0x30(%rbp), %rsi
leaq -0x48(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0xc667
movl %eax, %r13d
testb %al, %al
je 0xc872
movq 0x20(%r14), %rax
testq %rax, %rax
je 0xc8a3
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq -0x40(%rbp), %rdx
shlq $0x6, %rdx
addq 0x10128(%r12,%rcx), %rdx
movq -0x38(%rbp), %rcx
movq (%rdx,%rcx,8), %rdi
shrq $0x10, %rdi
movq 0x28(%r14), %rsi
callq *%rax
jmp 0xc8a3
testq %rbx, %rbx
jne 0xc8a3
movq 0x60(%r14), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xc8f7
movq 0x58(%r14,%rbx,8), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6320
testb %r13b, %r13b
jne 0xc8e1
incq %rbx
cmpq $0x1, %rbx
sete %r15b
je 0xc819
andb $0x1, %r15b
movl %r15d, %eax
addq $0x28, %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: kvmap2_del
bool
kvmap2_del(struct kvmap2 * const map2, const struct kv * const key)
{
  u64 i = UINT64_MAX;
  u64 j = UINT64_MAX;
  u64 k = UINT64_MAX;
  kvmap1_lock_hash(map2->maps[0], key);
  for (u64 x = 0; x < 2; x++) {
    struct kvmap1 * const map = map2->maps[x];
    if (kvmap1_locate_key(map, key, &i, &j, &k)) {
      struct __kvmap_entry * const e = &(map->levels[i].table[j].e[k]);
      //(void)atomic_fetch_sub(&(map->nr_kv), 1);
      (void)atomic_fetch_sub(&(map->levels[i].nr_kv), 1);
      kvmap1_put_entry(map, e, NULL);
      kvmap1_unlock_hash(map2->maps[x], key);
      return true;
    }
    if (x == 0) {
      kvmap1_lock_hash(map2->maps[1], key);
    }
    kvmap1_unlock_hash(map2->maps[x], key);
  }
  return false;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq 0x58(%rdi), %rax
movq (%rsi), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xd503
movb $0x1, -0x29(%rbp)
xorl %ebx, %ebx
movq %r14, -0x58(%rbp)
movq %r15, -0x50(%rbp)
movq 0x58(%r15,%rbx,8), %r12
movq %r12, %rdi
movq %r14, %rsi
leaq -0x48(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x38(%rbp), %r8
callq 0xc667
movl %eax, %r13d
testb %al, %al
je 0xd488
movq -0x48(%rbp), %rax
shlq $0x5, %rax
movq -0x40(%rbp), %r14
shlq $0x6, %r14
addq 0x10128(%r12,%rax), %r14
movq -0x38(%rbp), %r15
lock
decq 0x10140(%r12,%rax)
movq (%r14,%r15,8), %rdi
cmpq $0x10000, %rdi          # imm = 0x10000
jb 0xd476
movq 0x10(%r12), %rax
testq %rax, %rax
je 0xd476
shrq $0x10, %rdi
movq 0x18(%r12), %rsi
callq *%rax
movq $0x0, (%r14,%r15,8)
movq -0x58(%rbp), %r14
movq -0x50(%rbp), %r15
jmp 0xd4b5
testq %rbx, %rbx
jne 0xd4b5
movq 0x60(%r15), %rax
movq (%r14), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xd503
movq 0x58(%r15,%rbx,8), %rax
movq (%r14), %rdx
movb 0x50(%rax), %cl
rolq %cl, %rdx
andl $0xffc0, %edx           # imm = 0xFFC0
leaq (%rax,%rdx), %rdi
addq $0xe8, %rdi
callq 0x6320
testb %r13b, %r13b
jne 0xd4ef
incq %rbx
cmpq $0x1, %rbx
sete -0x29(%rbp)
je 0xd40c
movb -0x29(%rbp), %al
andb $0x1, %al
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: kvmap2_fprint
void
kvmap2_fprint(struct kvmap2 * const map2, FILE * const out)
{
  //u64 sum_kv = 0;
  //for (u64 x = 0; x < 2; x++) {
  //  sum_kv += atomic_load(&(map2->maps[x]->nr_kv));
  //}
  //const double sum100 = ((double)sum_kv) * 0.01;

  //fprintf(out, "KVMAP2 sz_shift %"PRIu64" nr_kv %"PRIu64"\n", map2->sz_shift, sum_kv);
  for (u64 x = 0; x < 2; x++) {
    //const u64 nr_kv = atomic_load(&(map2->maps[x]->nr_kv));
    //fprintf(out, "  KVMAP2 %"PRIu64" %.2lf%% ||| ", x, ((double)nr_kv) / sum100);
    kvmap1_fprint(map2->maps[x], out);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x30(%rbp)
movq %rdi, -0x40(%rbp)
xorl %edx, %edx
movq -0x40(%rbp), %rax
movq 0x58(%rax,%rdx,8), %rsi
leaq 0x10128(%rsi), %r12
xorl %eax, %eax
xorl %r15d, %r15d
cmpq $0x0, (%r12,%rax)
je 0xd7cf
cmpq $0x0, 0x8(%r12,%rax)
je 0xd7cf
movq 0x18(%r12,%rax), %rcx
addq %rcx, %r15
addq $0x20, %rax
cmpq $0x800, %rax            # imm = 0x800
jne 0xd7b8
movq %rdx, -0x48(%rbp)
movq 0x50(%rsi), %rdx
movq -0x30(%rbp), %rdi
movq %rsi, -0x38(%rbp)
leaq 0x7f6b(%rip), %rsi      # 0x1575d
movq %r15, %rcx
xorl %eax, %eax
callq 0x6300
movq -0x38(%rbp), %rcx
vcvtusi2sd %r15, %xmm2, %xmm0
vmulsd 0x78a2(%rip), %xmm0, %xmm0 # 0x150b0
vmovsd %xmm0, -0x50(%rbp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %eax, %eax
xorl %r15d, %r15d
cmpq $0x0, (%r12)
je 0xd8d3
cmpq $0x0, 0x8(%r12)
je 0xd8d3
movq %rax, -0x58(%rbp)
movq 0x18(%r12), %r13
movq 0x8(%r12), %rax
movq 0x8(%rax), %r8
vcvtusi2sd %r8, %xmm2, %xmm0
movl $0x1, %eax
shlxq %r15, %rax, %r9
vcvtusi2sd %r9, %xmm2, %xmm1
vdivsd %xmm1, %xmm0, %xmm0
vmulsd 0x7800(%rip), %xmm0, %xmm0 # 0x15068
cmpq 0x68(%rcx), %r15
movl $0x20, %edx
movl $0x2a, %eax
cmovel %eax, %edx
movl $0x8, %eax
shlxq %r15, %rax, %r10
vcvtusi2sd %r13, %xmm2, %xmm1
vdivsd -0x50(%rbp), %xmm1, %xmm1
movq -0x30(%rbp), %rdi
leaq 0x7edd(%rip), %rsi      # 0x15776
movq %r15, %rcx
movb $0x2, %al
pushq %r10
pushq %r13
callq 0x6300
movq -0x38(%rbp), %rcx
addq $0x10, %rsp
movq %r15, %rax
subq 0x68(%rcx), %rax
jae 0xd8bf
movq 0x58(%rcx), %rax
addq %rbx, %rax
addq %r13, %r14
incq %rax
imulq %r13, %rax
movq -0x58(%rbp), %rsi
addq %rax, %rsi
movq %rsi, %rax
incq %r15
decq %rbx
addq $0x20, %r12
cmpq $-0x40, %rbx
jne 0xd81d
vcvtusi2sd %rax, %xmm2, %xmm0
vcvtusi2sd %r14, %xmm2, %xmm1
vdivsd %xmm1, %xmm0, %xmm0
movq -0x30(%rbp), %rdi
leaq 0x7ea5(%rip), %rsi      # 0x157a7
movb $0x1, %al
callq 0x6300
movq -0x48(%rbp), %rcx
leaq 0x1(%rcx), %rdx
testq %rcx, %rcx
je 0xd7a3
addq $0x38, %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: kvmap2_iter_create
inline struct kvmap2_iter *
kvmap2_iter_create(struct kvmap2 * const map2)
{
  struct kvmap2_iter * const iter2 = (typeof(iter2))malloc(sizeof(*iter2));
  iter2->map2 = map2;
  iter2->map_id = 0;
  for (u64 x = 0; x < 2; x++) {
    iter2->iters[x] = kvmap1_iter_create(map2->maps[x]);
  }
  iter2->iter = iter2->iters[0];
  return iter2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x28, %edi
callq 0x63a0
movq %rax, %r14
movq %rbx, -0x30(%rbp)
movq %rbx, (%rax)
movq $0x0, 0x8(%rax)
xorl %r12d, %r12d
movq -0x30(%rbp), %rax
movq 0x58(%rax,%r12,8), %r13
movl $0x20, %edi
callq 0x63a0
testq %rax, %rax
je 0xd9bc
movq %rax, %r15
movl $0xe8, %ebx
leaq (%rbx,%r13), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xd9eb
addq $0x40, %rbx
cmpq $0x100e8, %rbx          # imm = 0x100E8
jne 0xd979
leaq 0x100e8(%r13), %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xd9eb
movq %r13, (%r15)
movq 0x58(%r13), %rax
movq %rax, 0x8(%r15)
vxorps %xmm0, %xmm0, %xmm0
vmovups %xmm0, 0x10(%r15)
jmp 0xd9bf
xorl %r15d, %r15d
movq %r15, 0x18(%r14,%r12,8)
leaq 0x1(%r12), %rax
testq %r12, %r12
movq %rax, %r12
je 0xd959
movq 0x18(%r14), %rax
movq %rax, 0x10(%r14)
movq %r14, %rax
addq $0x8, %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: kvmap2_iter_next
struct kv *
kvmap2_iter_next(struct kvmap2_iter * const iter2, struct kv * const out)
{
  struct kv * const ret = kvmap1_iter_next(iter2->iter, out);
  if (ret == NULL) {
    iter2->iter = NULL;
    iter2->map_id++;
    if (iter2->map_id < 2) {
      iter2->iter = iter2->iters[iter2->map_id];
      return kvmap1_iter_next(iter2->iter, out);
    }
  }
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0xda3e
testq %rax, %rax
jne 0xda39
movq $0x0, 0x10(%r14)
movq 0x8(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r14)
cmpq $0x1, %rdx
ja 0xda39
movq 0x20(%r14,%rcx,8), %rdi
movq %rdi, 0x10(%r14)
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0xda3e
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: kvmap1_iter_next
static struct kv *
kvmap1_iter_next(struct kvmap1_iter * const iter, struct kv * const out)
{
  u64 i = iter->i;
  u64 j = iter->j;
  u64 k = iter->k;
  struct kv * ret = NULL;
  while (i >= KVMAP_MIN_LEVEL) {
    if (iter->map->levels[i].table == NULL) {
      i--;
      continue;
    }
    struct __kvmap1_level * const level = &(iter->map->levels[i]);
    if (k == 0) { // try skip empty slots at every new j
      while ((j < (1lu << i)) && (bitmap_test(level->bm, j) == false)) j++;
      if (j >= (1lu << i)) {
        j = 0;
        i--;
        continue;
      }
    }
    if (level->table[j].e[k].ptr) {
      struct kv * const kv = __u64_to_ptr(level->table[j].e[k].ptr);
      ret = kv_dup2(kv, out);
    }
    // shift next
    k++;
    if (k >= 8) {
      k = 0;
      j++;
      if (j >= (1lu << i)) {
        j = 0;
        i--;
      }
    }
    if (ret) break;
  }
  iter->i = i;
  iter->j = j;
  iter->k = k;
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %r13
movq 0x18(%rdi), %r15
xorl %r10d, %r10d
xorl %eax, %eax
cmpq $0x10, %r14
jb 0xdb9d
movq (%rbx), %rdx
movq %r14, %rcx
shlq $0x5, %rcx
addq %rdx, %rcx
addq $0x10130, %rcx          # imm = 0x10130
movq -0x8(%rcx), %r9
testq %r9, %r9
jne 0xda9c
decq %r14
addq $-0x20, %rcx
cmpq $0xf, %r14
ja 0xda81
jmp 0xdb97
testq %r15, %r15
je 0xdb3d
movq %r13, %rcx
shlq $0x6, %rcx
addq %rcx, %r9
movq (%r9,%r15,8), %r12
cmpq $0x10000, %r12          # imm = 0x10000
jb 0xdb12
shrq $0x10, %r12
movl 0x8(%r12), %eax
movl 0xc(%r12), %ecx
leaq (%rax,%rcx), %rdx
addq $0x10, %rdx
movq %rsi, %rax
testq %rsi, %rsi
movq %rsi, -0x30(%rbp)
jne 0xdafa
movq %rdx, %rdi
movq %rdx, -0x38(%rbp)
callq 0x63a0
movq -0x38(%rbp), %rdx
xorl %r10d, %r10d
movq -0x30(%rbp), %rsi
testq %rax, %rax
je 0xdb12
movq %rax, %rdi
movq %r12, %rsi
movq %rax, %r12
callq 0x6340
xorl %r10d, %r10d
movq %r12, %rax
movq -0x30(%rbp), %rsi
incq %r15
cmpq $0x8, %r15
jb 0xdb35
incq %r13
shrxq %r14, %r13, %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
setne %cl
cmovneq %r10, %r13
subq %rcx, %r14
xorl %r15d, %r15d
testq %rax, %rax
setne %cl
jmp 0xdb8d
shrxq %r14, %r13, %rdx
testq %rdx, %rdx
sete %r8b
jne 0xdb85
movq (%rcx), %rcx
movq (%rcx), %rdx
cmpq %r13, %rdx
jbe 0xdb68
movq %r13, %rdi
shrq $0x6, %rdi
movq 0x10(%rcx,%rdi,8), %rdi
btq %r13, %rdi
jb 0xdb7b
incq %r13
shrxq %r14, %r13, %rdi
testq %rdi, %rdi
sete %r8b
je 0xdb51
jmp 0xdb85
testb $0x1, %r8b
jne 0xdaa5
decq %r14
xorl %r13d, %r13d
xorl %ecx, %ecx
testb %cl, %cl
je 0xda63
jmp 0xdb9d
movl $0xf, %r14d
movq %r14, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movq %r15, 0x18(%rbx)
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: cuckoo_create
struct cuckoo *
cuckoo_create(const struct kvmap_mm * const mm)
{
  struct cuckoo * const map = xalloc(64, sizeof(*map));
  memset(map, 0, sizeof(*map));

  map->mm = mm ? (*mm) : __kvmap_mm_default;
  for (u64 j = 0; j < KVMAP_HLOCK_NR; j++) {
    spinlock_init(&(map->hlocks[j]));
  }
  mutexlock_init(&(map->expand_lock));

  map->fixed_power = 0;
  if (map->fixed_power == 0) {
    map->bm = bitmap_create(KVMAP_HLOCK_NR);
  }

  cuckoo_init(map);
  return map;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
leaq -0x18(%rbp), %rdi
movl $0x40, %esi
movl $0x10148, %edx          # imm = 0x10148
callq 0x6570
xorl %ebx, %ebx
testl %eax, %eax
jne 0xdced
movq -0x18(%rbp), %rbx
movl $0x10148, %edx          # imm = 0x10148
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6210
testq %r14, %r14
je 0xdd1e
vmovups (%r14), %ymm0
vmovups 0x20(%r14), %ymm1
vmovups 0x30(%r14), %ymm2
vmovups %ymm2, 0x30(%rbx)
vmovups %ymm1, 0x20(%rbx)
jmp 0xdd40
vmovups 0xe092(%rip), %ymm0     # 0x1bdb8
vmovups %ymm0, 0x30(%rbx)
vmovups 0xe075(%rip), %ymm0     # 0x1bda8
vmovups %ymm0, 0x20(%rbx)
vmovups 0xe048(%rip), %ymm0     # 0x1bd88
vmovups %ymm0, (%rbx)
movl $0x50, %r14d
leaq (%rbx,%r14), %rdi
movl $0x1, %esi
vzeroupper
callq 0x62e0
addq $0x40, %r14
cmpq $0x10050, %r14          # imm = 0x10050
jne 0xdd4a
leaq 0x10050(%rbx), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x65d0
movq %r14, 0x100d0(%rbx)
movl $0x1, %edi
movl $0x90, %esi
callq 0x62d0
movq $0x400, (%rax)          # imm = 0x400
xchgq %r14, 0x8(%rax)
movq %rax, 0x100d8(%rbx)
movq %rbx, %rdi
callq 0xddb5
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: cuckoo_init
static void
cuckoo_init(struct cuckoo * const map)
{
  const u64 power = map->fixed_power > KVMAP_MIN_LEVEL ? map->fixed_power : KVMAP_MIN_LEVEL;
  map->levels[0].power = power;
  map->levels[0].table = pages_alloc_best(KVMAP_SIZE_OF_LEVEL(power), true, &(map->levels[0].alloc_size));
  if (map->fixed_power == 0) {
    bitmap_set_all0(map->bm);
  }
  debug_assert(map->levels[0].table);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x100d0(%rdi), %rax
cmpq $0x11, %rax
movl $0x10, %ecx
cmovaeq %rax, %rcx
movq %rcx, 0x10128(%rdi)
addb $-0x6, %cl
movl $0x1000, %eax           # imm = 0x1000
shlxq %rcx, %rax, %rdi
leaq 0x10120(%rbx), %rdx
movl $0x1, %esi
callq 0x831a
movq %rax, 0x10118(%rbx)
cmpq $0x0, 0x100d0(%rbx)
jne 0xde34
movq 0x100d8(%rbx), %r14
leaq 0x10(%r14), %rdi
movq (%r14), %rdx
addq $0x3f, %rdx
shrq $0x3, %rdx
andq $-0x8, %rdx
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x6210
xchgq %r15, 0x8(%r14)
cmpq $0x0, 0x10118(%rbx)
je 0xde49
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x66ef
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: cuckoo_lock_two
static void
cuckoo_lock_two(struct cuckoo * const map, const struct kv * const key)
{
  const u64 hash2[2] = {cuckoo_hash(key, 0), cuckoo_hash(key, 1), };
  const u64 i1 = kvmap_hlocks_index(hash2[0]);
  const u64 i2 = kvmap_hlocks_index(hash2[1]);
  if (i1 < i2) {
    cuckoo_lock(map, i1);
    cuckoo_lock(map, i2);
  } else if (i1 > i2) {
    cuckoo_lock(map, i2);
    cuckoo_lock(map, i1);
  } else { // equal
    cuckoo_lock(map, i1);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rsi), %r15
movq %r15, %r14
shrq $0x33, %r14
shrl $0x6, %r15d
andl $0x3ff, %r15d           # imm = 0x3FF
andl $0x3ff, %r14d           # imm = 0x3FF
cmpq %r14, %r15
jae 0xe0fd
shll $0x6, %r15d
leaq (%rbx,%r15), %rdi
addq $0x50, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xe139
addq $0x50, %rbx
shll $0x6, %r14d
addq %rbx, %r14
movq %r14, %rdi
jmp 0xe124
addq $0x50, %rbx
cmpl %r14d, %r15d
jbe 0xe11a
shll $0x6, %r14d
addq %rbx, %r14
movq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xe139
shll $0x6, %r15d
addq %r15, %rbx
movq %rbx, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0xe139
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: cuckoo_unlock_two
static void
cuckoo_unlock_two(struct cuckoo * const map, const struct kv * const key)
{
  const u64 hash2[2] = {cuckoo_hash(key, 0), cuckoo_hash(key, 1), };
  const u64 i1 = kvmap_hlocks_index(hash2[0]);
  const u64 i2 = kvmap_hlocks_index(hash2[1]);
  if (i1 < i2) {
    cuckoo_unlock(map, i1);
    cuckoo_unlock(map, i2);
  } else if (i1 > i2) {
    cuckoo_unlock(map, i2);
    cuckoo_unlock(map, i1);
  } else { // equal
    cuckoo_unlock(map, i1);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rsi), %r14
movq %r14, %r15
shrq $0x33, %r15
shrl $0x6, %r14d
andl $0x3ff, %r14d           # imm = 0x3FF
andl $0x3ff, %r15d           # imm = 0x3FF
cmpq %r15, %r14
jae 0xe18d
shll $0x6, %r14d
leaq (%rbx,%r14), %rdi
addq $0x50, %rdi
callq 0x6320
shll $0x6, %r15d
leaq (%rbx,%r15), %r14
addq $0x50, %r14
jmp 0xe1ac
addq $0x50, %rbx
cmpl %r15d, %r14d
jbe 0xe1a5
shll $0x6, %r15d
addq %rbx, %r15
movq %r15, %rdi
callq 0x6320
shll $0x6, %r14d
addq %rbx, %r14
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6320
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: cuckoo_probe
bool
cuckoo_probe(struct cuckoo * const map, const struct kv * const key)
{
  const u64 hash2[2] = {cuckoo_hash(key, 0), cuckoo_hash(key, 1), };
  const u64 pkey = kvmap_pkey(key->hash);

  cuckoo_lock_two(map, key);
  for (u64 x = 0; x < 2; x++) {
    struct __kvmap_slot * const slot = cuckoo_hash_slot(map, hash2[x]);
    for (u64 k = 0; k < 8; k++) {
      if (slot->e[k].pkey == pkey) {
        const struct kv * const curr = __u64_to_ptr(slot->e[k].ptr);
        if (kv_keymatch(key, curr)) {
          if (map->mm.hf) map->mm.hf(curr, map->mm.hp);
          cuckoo_unlock_two(map, key);
          return true;
        }
      }
    }
  }
  cuckoo_unlock_two(map, key);
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
movq %rax, -0x70(%rbp)
rorxq $0x2d, %rax, %rcx
movq %rcx, -0x68(%rbp)
movq %rax, %rcx
shrq $0x20, %rcx
xorq %rax, %rcx
movq %rcx, %r12
shrq $0x10, %r12
xorq %rcx, %r12
callq 0xe0a9
movq %rbx, %rsi
leaq 0x10118(%r14), %r13
leaq 0x10(%rbx), %rax
movq %rax, -0x50(%rbp)
movb $0x1, %bl
xorl %eax, %eax
movq %rsi, -0x38(%rbp)
movq %r14, -0x40(%rbp)
movq %r13, -0x48(%rbp)
movb %bl, -0x29(%rbp)
movq %rax, -0x58(%rbp)
movq -0x70(%rbp,%rax,8), %rbx
movq 0x100d8(%r14), %rax
testq %rax, %rax
je 0xe25c
movq %rbx, %rcx
shrq $0x6, %rcx
movl %ecx, %edx
andl $0x3ff, %edx            # imm = 0x3FF
cmpq %rdx, (%rax)
jbe 0xe25c
shrl $0x6, %edx
shrxq %rcx, 0x10(%rax,%rdx,8), %rax
andl $0x1, %eax
jmp 0xe25e
xorl %eax, %eax
leaq (%rax,%rax,2), %r15
movq 0x10(%r13,%r15,8), %r14
cmpq $0x0, (%r13,%r15,8)
je 0xe331
leaq (,%r15,8), %rax
addq %r13, %rax
bzhiq %r14, %rbx, %r15
shlq $0x6, %r15
addq (%rax), %r15
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rax
movl %r12d, %ecx
xorw %ax, %cx
jne 0xe306
movq %rax, %r13
shrq $0x10, %r13
cmpq $0x10000, %rax          # imm = 0x10000
jb 0xe2d2
movq (%rsi), %rax
cmpq (%r13), %rax
jne 0xe2d2
movl 0x8(%rsi), %edx
cmpl 0x8(%r13), %edx
jne 0xe2d2
leaq 0x10(%r13), %rsi
movq -0x50(%rbp), %rdi
callq 0x63d0
movq -0x38(%rbp), %rsi
testl %eax, %eax
sete %r14b
jmp 0xe2d5
xorl %r14d, %r14d
testb %r14b, %r14b
je 0xe306
movq -0x40(%rbp), %rdi
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0xe2f4
movq 0x28(%rdi), %rsi
movq %r13, %rdi
callq *%rax
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xe140
movq -0x38(%rbp), %rsi
testb %r14b, %r14b
jne 0xe33f
incq %rbx
cmpq $0x8, %rbx
jne 0xe28c
movq -0x58(%rbp), %rcx
leaq 0x1(%rcx), %rax
testq %rcx, %rcx
sete %bl
movq -0x40(%rbp), %r14
movq -0x48(%rbp), %r13
je 0xe221
jmp 0xe356
callq 0x66ef
movq -0x38(%rbp), %rsi
jmp 0xe273
movb -0x29(%rbp), %bl
andb $0x1, %bl
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0xe140
jmp 0xe342
// File: /workspace/github_c_makefile_star2_O1/wuxb45[P]SLB/lib1.c
// Function: cuckoo_set
bool
cuckoo_set(struct cuckoo * const map, const struct kv * const kv)
{
  const struct kv * const new = kv_alloc_dup(kv, &(map->mm));
  if (new == NULL) return false;
  if (map->fixed_power) {
    for (u64 i = 0; i < 8; i++) {
      if (cuckoo_try_set(map, new)) return true;
    }
    return false;
  } else {
    while (cuckoo_try_set(map, new) == false);
    return true;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %ecx
leaq (%rax,%rcx), %r12
addq $0x10, %r12
movq 0x8(%rdi), %rsi
movq %r12, %rdi
callq *(%rbx)
movq %rax, %r14
testq %rax, %rax
je 0xe3fc
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6340
cmpq $0x0, 0x100d0(%rbx)
je 0xe3e2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe413
movl %eax, %ecx
movb $0x1, %al
testb %cl, %cl
jne 0xe3f3
xorl %ecx, %ecx
movq %rcx, %r15
cmpq $0x7, %rcx
je 0xe3d9
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe413
leaq 0x1(%r15), %rcx
testb %al, %al
je 0xe3bd
cmpq $0x7, %r15
setb %al
jmp 0xe3f3
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe413
testb %al, %al
je 0xe3e2
movb $0x1, %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6340
xorl %eax, %eax
jmp 0xe3f3