// File: /workspace/github_c_makefile_star2_O2/wuxb45[P]SLB/lib1.c
// Function: cuckoo_expand_worker
static void *
cuckoo_expand_worker(void * const ptr)
{
  struct cuckoo_expand_worker_info * const info = (typeof(info))ptr;
  struct cuckoo * const map = info->map;
  struct __cuckoo_level * const level0 = info->level0;
  struct __cuckoo_level * const level1 = info->level1;
  u64 uniq;
  while ((uniq = atomic_fetch_add(&(info->uniq), 64)) < KVMAP_HLOCK_NR) {
    for (u64 lidx = uniq; lidx < (uniq + 64); lidx++) {
      spinlock_lock(&(map->hlocks[lidx]));
      const u64 power0 = level0->power;
      const u64 hi_nr = UINT64_C(1) << (power0 - KVMAP_MIN_LEVEL);
      const u64 lo_nr = UINT64_C(1) << KVMAP_BASE_LEVEL;
      const u64 mid = lidx << KVMAP_BASE_LEVEL;
      for (u64 hi = 0; hi < hi_nr; hi++) {
        for (u64 lo = 0; lo < lo_nr; lo++) {
          const u64 hidx0 = (hi << KVMAP_MIN_LEVEL) | mid | lo;
          debug_assert(kvmap_hlocks_index(hidx0) == lidx);
          struct __kvmap_slot * const slot = &(level0->table[hidx0]);
          for (u64 k = 0; k < 8; k++) {
            if (slot->e[k].ptr) {
              struct kv * const curr = __u64_to_ptr(slot->e[k].ptr);
              const u64 hash2[2] = {cuckoo_hash(curr, 0), cuckoo_hash(curr, 1), };
              const u64 hash = __cuckoo_hidx(hash2[0], power0) == hidx0 ? hash2[0] : hash2[1];
              debug_assert(__cuckoo_hidx(hash, power0) == hidx0);
              level1->table[__cuckoo_hidx(hash, level1->power)].e[k] = slot->e[k];
              slot->e[k].ptr = 0;
              slot->e[k].pkey = 0;
            }
          }
        }
      }
      info->bm_updater(map->bm, lidx);
      spinlock_unlock(&(map->hlocks[lidx]));
    }
  }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
movq %rcx, -0x38(%rbp)
movq %rdi, -0x30(%rbp)
movq 0x18(%rdi), %rcx
movq %rcx, -0x98(%rbp)
movq %rax, -0x48(%rbp)
addq $0x50, %rax
movq %rax, -0x40(%rbp)
pushq $0x40
popq %rbx
movq -0x30(%rbp), %rax
lock
xaddq %rbx, 0x8(%rax)
cmpq $0x3ff, %rbx            # imm = 0x3FF
ja 0x10c7b
leaq 0x40(%rbx), %rax
movq %rax, -0x50(%rbp)
cmpq -0x50(%rbp), %rbx
je 0x10af1
movq %rbx, %rcx
shlq $0x6, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x60(%rbp)
leaq (%rax,%rcx), %rdi
movq %rdi, -0x58(%rbp)
callq 0x6afb
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
leaq -0x10(%rax), %rcx
movq %rcx, -0x68(%rbp)
pushq $-0x1
popq %rcx
shlxq %rax, %rcx, %r15
notq %r15
xorl %ecx, %ecx
movq %rbx, -0x70(%rbp)
movq -0x68(%rbp), %rax
shrxq %rax, %rcx, %rax
testq %rax, %rax
jne 0x10c55
movq %rcx, %rax
shlq $0x10, %rax
orq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movq %rax, %r14
shlq $0x6, %r14
xorl %eax, %eax
movq %rcx, -0x80(%rbp)
cmpq $0x40, %rax
je 0x10c4d
cmpq $0x400, %rbx            # imm = 0x400
jb 0x10ba2
movq %rax, %rbx
callq 0x6e43
movq %rbx, %rax
movq -0x78(%rbp), %r13
movq %rax, -0x88(%rbp)
orq %rax, %r13
movq -0x38(%rbp), %rax
movq (%rax), %rbx
movq %r14, -0x90(%rbp)
addq %r14, %rbx
xorl %r14d, %r14d
cmpq $0x8, %r14
je 0x10c2b
movq (%rbx,%r14,8), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jb 0x10c26
movq %rax, %rcx
shrq $0x10, %rcx
movq (%rcx), %rcx
rorxq $0x2d, %rcx, %r12
movq %rcx, %rdx
andq %r15, %rdx
cmpq %r13, %rdx
cmoveq %rcx, %r12
movq %r12, %rcx
andq %r15, %rcx
cmpq %r13, %rcx
je 0x10c07
callq 0x6e43
movq (%rbx,%r14,8), %rax
movq -0x98(%rbp), %rdx
movb 0x10(%rdx), %cl
bzhiq %rcx, %r12, %rcx
shlq $0x6, %rcx
addq (%rdx), %rcx
movq %rax, (%rcx,%r14,8)
andq $0x0, (%rbx,%r14,8)
incq %r14
jmp 0x10bc4
movq -0x88(%rbp), %rax
incq %rax
movq -0x90(%rbp), %r14
addq $0x40, %r14
movq -0x70(%rbp), %rbx
movq -0x80(%rbp), %rcx
jmp 0x10b84
incq %rcx
jmp 0x10b56
movq -0x48(%rbp), %rax
movq 0x100d8(%rax), %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %rax
callq *0x20(%rax)
movq -0x58(%rbp), %rdi
callq 0x6320
incq %rbx
jmp 0x10b13
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq