// File: /workspace/github_c_makefile_star2_O0/redis-force[P]rpm/module/rpm_hashmap.c
// Function: hash_map_rehash_step
static void hash_map_rehash_step(hash_map *map, size_t steps)
{
  hash_map_entry *entry, *next_entry;
  hash_table *curr, *next;
  int64_t rehash_index;
  size_t size_mask, hash, curr_used, next_used;

  /* we can't rehash at this time as there is an open iterator */
  if (map->iterators != 0) {
    return;
  }
  if (!HASH_MAP_IS_REHASHING(map)) {
    return;
  }

  curr = &map->tables[0];
  next = &map->tables[1];
  rehash_index = map->rehash_index;
  size_mask = next->size_mask;
  curr_used = curr->used;
  next_used = next->used;

  while (steps--) {
    if (curr_used == 0) {
      /* we are done */
      HASH_MAP_FREE(map, curr->buckets);
      curr->used = curr_used;
      next->used = next_used;
      *curr = *next;
      hash_table_reset(next);
      map->rehash_index = -1;
      return;
    }

    /* rehash index can't overflow */
    while (curr->buckets[rehash_index] == NULL) {
      ++rehash_index;
    }

    entry = curr->buckets[rehash_index];
    while (entry) {
      next_entry = entry->next;
      hash = HASH_MAP_HASH_CODE(map, entry->key, entry->ksize);
      hash = hash & size_mask;
      entry->next = next->buckets[hash];
      next->buckets[hash] = entry;
      curr_used--;
      next_used++;
      entry = next_entry;
    }
    curr->buckets[rehash_index] = NULL;
    rehash_index++;
  }
  curr->used = curr_used;
  next->used = next_used;
  map->rehash_index = rehash_index;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x50(%rsp), %rax
cmpq $0x0, 0x90(%rax)
je 0x9872
jmp 0x9ab4
movq 0x50(%rsp), %rax
cmpq $-0x1, 0x88(%rax)
jne 0x9886
jmp 0x9ab4
movq 0x50(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x30(%rsp)
movq 0x50(%rsp), %rax
addq $0x48, %rax
addq $0x20, %rax
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, 0x48(%rsp)
cmpq $0x0, %rax
je 0x9a88
cmpq $0x0, 0x8(%rsp)
jne 0x997b
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rsi
callq 0x5040
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq (%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rdi
callq 0x95d0
movq 0x50(%rsp), %rax
movq $-0x1, 0x88(%rax)
jmp 0x9ab4
jmp 0x997d
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x99a1
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x997d
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0x9a60
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rdi
movq 0x40(%rsp), %rcx
movq (%rcx), %rsi
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rdx
callq *%rax
movl %eax, %eax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
andq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x40(%rsp), %rdx
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x8(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x8(%rsp)
movq (%rsp), %rax
addq $0x1, %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x99b7
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x98e0
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq (%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x88(%rax)
addq $0x58, %rsp
retq
nopl (%rax)