// File: /workspace/github_c_makefile_star2_O0/wuxb45[P]SLB/lib1.c
// Function: kvmap1_clean
static void
kvmap1_clean(struct kvmap1 * const map)
{
  for (u64 i = map->max_level; i >= KVMAP_MIN_LEVEL; i--) {
    struct __kvmap1_level * const level = &(map->levels[i]);
    if (level->bm == NULL) continue;
    const u64 nr_slots = KVMAP_SLOTS_OF(i);
    for (u64 j = 0; j < nr_slots; j++) {
      if (bitmap_test(level->bm, j)) {
        struct __kvmap_slot * const slot = &(level->table[j]);
        for (u64 k = 0; k < 8; k++) {
          struct __kvmap_entry * const e = &(slot->e[k]);
          if (e->ptr) {
            kvmap1_put_entry(map, e, NULL);
            //(void)atomic_fetch_sub(&(map->nr_kv), 1);
            (void)atomic_fetch_sub(&(level->nr_kv), 1);
          }
        }
      }
    }
    debug_assert(atomic_load(&(level->nr_kv)) == 0);
    if (level->table) {
      pages_unmap(level->table, level->alloc_size);
      level->table = NULL;
    }
    free(level->bm);
    level->bm = NULL;
  }
  debug_assert(atomic_load(&(map->nr_kv)) == 0);
  kvmap1_init(map);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x10, -0x10(%rbp)
jb 0xff0a
movq -0x8(%rbp), %rax
addq $0x10128, %rax          # imm = 0x10128
movq -0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xfdbc
jmp 0xfef9
movq -0x10(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xfe98
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x7cd0
testb $0x1, %al
jne 0xfdfc
jmp 0xfe85
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x8, -0x38(%rbp)
jae 0xfe83
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
shrq $0x10, %rax
cmpq $0x0, %rax
je 0xfe73
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xf8d0
movq -0x18(%rbp), %rcx
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rax
negq %rax
lock
xaddq %rax, 0x18(%rcx)
movq %rax, -0x50(%rbp)
jmp 0xfe75
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xfe1a
jmp 0xfe85
jmp 0xfe87
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xfdd4
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0xfee0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x8c10
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x6060
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xfd88
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x8(%rbp), %rdi
callq 0x18440
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)