// File: /workspace/github_c_makefile_star2_O1/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 0x13e2c
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 0x13e3d
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), %rdx
movq %rbx, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
shlq $0x10, %rcx
orq -0x70(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsi
shlq $0x6, %rsi
xorl %edi, %edi
cmpq $0x400, %rbx            # imm = 0x400
jae 0x13db2
movq -0x88(%rbp), %r13
orq %rdi, %r13
movq -0x48(%rbp), %rax
movq (%rax), %rbx
addq %rsi, %rbx
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rax
cmpq $0x10000, %rax          # imm = 0x10000
jb 0x13d69
shrq $0x10, %rax
movq (%rax), %rax
rorxq $0x2d, %rax, %r12
movq %rax, %rcx
andq %r15, %rcx
cmpq %r13, %rcx
cmoveq %rax, %r12
movq %r12, %rax
andq %r15, %rax
cmpq %r13, %rax
jne 0x13d74
movb 0x10(%rdx), %al
bzhiq %rax, %r12, %rax
shlq $0x6, %rax
addq (%rdx), %rax
movq (%rbx,%r14,8), %rcx
movq %rcx, (%rax,%r14,8)
movq $0x0, (%rbx,%r14,8)
incq %r14
cmpq $0x8, %r14
jne 0x13d19
jmp 0x13d9b
movq %rsi, -0x98(%rbp)
movq %rdi, -0x90(%rbp)
callq 0x66ef
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x30(%rbp), %rdx
jmp 0x13d4a
incq %rdi
addq $0x40, %rsi
cmpq $0x40, %rdi
movq -0x80(%rbp), %rbx
jne 0x13cf5
jmp 0x13dcc
movq %rsi, %rbx
movq %rdi, %r14
callq 0x66ef
movq %r14, %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %rdx
jmp 0x13d02
movq -0x78(%rbp), %rcx
incq %rcx
movq -0x68(%rbp), %rax
shrxq %rax, %rcx, %rax
testq %rax, %rax
je 0x13cd9
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 0x13c88
movl $0x40, %ebx
movq -0x40(%rbp), %rax
lock
xaddq %rbx, 0x8(%rax)
cmpq $0x3ff, %rbx            # imm = 0x3FF
jbe 0x13c80
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x6530