// File: /workspace/github_c_makefile_star2_O3/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 %rax, -0x38(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x48(%rbp)
movq 0x18(%rdi), %rax
movq %rax, -0x30(%rbp)
movl $0x40, %ebx
movq %rdi, -0x40(%rbp)
lock
xaddq %rbx, 0x8(%rdi)
cmpq $0x3ff, %rbx            # imm = 0x3FF
ja 0x138c2
movq -0x38(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x50(%rbp)
leaq 0x40(%rbx), %rax
movq %rax, -0x58(%rbp)
movq %rbx, %rcx
shlq $0x6, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x70(%rbp)
leaq (%rax,%rcx), %r14
movq %r14, %rdi
callq 0x6050
cmpl $0x23, %eax
je 0x138d3
movq %r14, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
leaq -0x10(%rax), %rcx
movq %rcx, -0x68(%rbp)
movq $-0x1, %rcx
shlxq %rax, %rcx, %r15
notq %r15
xorl %ecx, %ecx
movq -0x30(%rbp), %rsi
movq %rbx, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
shlq $0x10, %rcx
orq -0x70(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rdi
shlq $0x6, %rdi
xorl %r8d, %r8d
cmpq $0x400, %rbx            # imm = 0x400
jae 0x13848
movq -0x88(%rbp), %r13
orq %r8, %r13
movq -0x48(%rbp), %rax
movq (%rax), %rbx
addq %rdi, %rbx
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jb 0x137fb
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
jne 0x13806
movb 0x10(%rsi), %cl
bzhiq %rcx, %r12, %rcx
shlq $0x6, %rcx
addq (%rsi), %rcx
movq %rax, (%rcx,%r14,8)
movq $0x0, (%rbx,%r14,8)
incq %r14
cmpq $0x8, %r14
jne 0x137ac
jmp 0x13831
movq %rdi, -0x98(%rbp)
movq %r8, -0x90(%rbp)
callq 0x66ef
movq -0x90(%rbp), %r8
movq -0x98(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq (%rbx,%r14,8), %rax
jmp 0x137e0
incq %r8
addq $0x40, %rdi
cmpq $0x40, %r8
movq -0x80(%rbp), %rbx
jne 0x13788
jmp 0x13862
movq %rdi, %rbx
movq %r8, %r14
callq 0x66ef
movq %r14, %r8
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
jmp 0x13795
movq -0x78(%rbp), %rcx
incq %rcx
movq -0x68(%rbp), %rax
shrxq %rax, %rcx, %rax
testq %rax, %rax
je 0x1376b
movq -0x38(%rbp), %rax
movq 0x100d8(%rax), %rdi
movq %rbx, %rsi
movq -0x40(%rbp), %rax
callq *0x20(%rax)
movq -0x60(%rbp), %rdi
callq 0x6320
incq %rbx
cmpq -0x58(%rbp), %rbx
jb 0x1371a
movl $0x40, %ebx
movq -0x40(%rbp), %rax
lock
xaddq %rbx, 0x8(%rax)
cmpq $0x3ff, %rbx            # imm = 0x3FF
jbe 0x13712
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530