// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x100d8(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10118(%rax)
je 0x1908c
movq -0x10(%rbp), %rax
addq $0x10118, %rax          # imm = 0x10118
movq %rax, -0x68(%rbp)
jmp 0x1909e
movq -0x10(%rbp), %rax
addq $0x10118, %rax          # imm = 0x10118
addq $0x18, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10118(%rax)
je 0x190c8
movq -0x10(%rbp), %rax
addq $0x10118, %rax          # imm = 0x10118
addq $0x18, %rax
movq %rax, -0x70(%rbp)
jmp 0x190d6
movq -0x10(%rbp), %rax
addq $0x10118, %rax          # imm = 0x10118
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
setne %al
movzbl %al, %edi
callq 0x7640
movq -0x20(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
sete %al
movzbl %al, %edi
callq 0x7640
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
incq %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movb -0x28(%rbp), %al
addb $-0x6, %al
movb %al, %cl
movl $0x1, %eax
shlxq %rcx, %rax, %rdi
shlq $0xc, %rdi
movq -0x20(%rbp), %rdx
addq $0x8, %rdx
movl $0x1, %esi
callq 0x8d40
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x100d8(%rax), %rdi
callq 0x7eb0
testq %rax, %rax
leaq -0x1135e(%rip), %rcx    # 0x7e30
leaq -0x113e5(%rip), %rax    # 0x7db0
cmovneq %rcx, %rax
movq %rax, -0x30(%rbp)
leaq 0x6c(%rip), %rsi        # 0x19210
xorl %eax, %eax
movl %eax, %edi
leaq -0x50(%rbp), %rdx
callq 0x89f0
vmovsd %xmm0, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x400, -0x60(%rbp)     # imm = 0x400
seta %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x8c10
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
addq $0x10050, %rdi          # imm = 0x10050
callq 0x6fb0
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)