// File: /workspace/github_c_makefile_star2_O0/wuxb45[P]SLB/lib1.c
// Function: kvmap1_iter_next
static struct kv *
kvmap1_iter_next(struct kvmap1_iter * const iter, struct kv * const out)
{
  u64 i = iter->i;
  u64 j = iter->j;
  u64 k = iter->k;
  struct kv * ret = NULL;
  while (i >= KVMAP_MIN_LEVEL) {
    if (iter->map->levels[i].table == NULL) {
      i--;
      continue;
    }
    struct __kvmap1_level * const level = &(iter->map->levels[i]);
    if (k == 0) { // try skip empty slots at every new j
      while ((j < (1lu << i)) && (bitmap_test(level->bm, j) == false)) j++;
      if (j >= (1lu << i)) {
        j = 0;
        i--;
        continue;
      }
    }
    if (level->table[j].e[k].ptr) {
      struct kv * const kv = __u64_to_ptr(level->table[j].e[k].ptr);
      ret = kv_dup2(kv, out);
    }
    // shift next
    k++;
    if (k >= 8) {
      k = 0;
      j++;
      if (j >= (1lu << i)) {
        j = 0;
        i--;
      }
    }
    if (ret) break;
  }
  iter->i = i;
  iter->j = j;
  iter->k = k;
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x10, -0x18(%rbp)
jb 0x10696
movq -0x8(%rbp), %rax
movq (%rax), %rax
addq $0x10128, %rax          # imm = 0x10128
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x10523
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x104ec
movq -0x8(%rbp), %rax
movq (%rax), %rax
addq $0x10128, %rax          # imm = 0x10128
movq -0x18(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x105d7
jmp 0x1054c
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq -0x50(%rbp), %rcx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x41(%rbp)
jae 0x1058d
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7cd0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x10596
jmp 0x105a4
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1054c
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jb 0x105d5
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x104ec
jmp 0x105d7
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x10, %rax
cmpq $0x0, %rax
je 0x10633
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
shrq $0x10, %rdi
callq 0xf220
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xdfb0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x8, -0x28(%rbp)
jb 0x10688
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jb 0x10686
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x10688
cmpq $0x0, -0x30(%rbp)
je 0x10691
jmp 0x10696
jmp 0x104ec
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)