// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/HashTable.hpp
// Function: void t2::HashTableGrow<t2::CommonStringRecord, 0u>(t2::HashTable<t2::CommonStringRecord, 0u>*)
void HashTableGrow(HashTable<T, kFlags>* self)
  {
    MemAllocHeap*  heap      = self->m_Heap;

    const uint32_t old_size  = self->m_TableSize;
    // start at 1<<7 (128), increase by 4x each time
    const uint32_t new_shift = std::max(self->m_TableSizeShift + 2, 7u);
    const uint32_t new_size  = 1 << new_shift;

    uint32_t* old_hashes = self->m_Hashes;
    const char** old_strings = self->m_Strings;
    const T* old_payloads = self->m_Payloads;

    uint32_t* new_hashes = HeapAllocateArrayZeroed<uint32_t>(heap, new_size);
    const char** new_strings = HeapAllocateArrayZeroed<const char*>(heap, new_size);
    T* new_payloads = HeapAllocateArrayZeroed<T>(heap, new_size);

    const uint32_t new_mask = new_size - 1;

    for (uint32_t i = 0; i < old_size; ++i)
    {
      if (uint32_t h = old_hashes[i])
      {
        uint32_t index = h & new_mask;

        while (new_hashes[index] != 0)
        {
          index = (index + 1) & new_mask;
        }

        new_hashes[index] = h;
        new_strings[index] = old_strings[i];
        new_payloads[index] = old_payloads[i];
      }
    }

    HeapFree(heap, old_payloads);
    HeapFree(heap, old_strings);
    HeapFree(heap, old_hashes);

    // Commit
    self->m_Hashes         = new_hashes;
    self->m_Strings        = new_strings;
    self->m_Payloads       = new_payloads;
    self->m_TableSize      = new_size;
    self->m_TableSizeShift = new_shift;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl $0x7, -0x20(%rbp)
leaq -0x1c(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xc430
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xc470
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xc4c0
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %esi
callq 0xc510
movq %rax, -0x58(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0xc3be
movq -0x30(%rbp), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0xc3ae
movl -0x64(%rbp), %eax
andl -0x5c(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movl -0x68(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0xc361
movl -0x68(%rbp), %eax
addl $0x1, %eax
andl -0x5c(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0xc346
movl -0x64(%rbp), %edx
movq -0x48(%rbp), %rax
movl -0x68(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x50(%rbp), %rax
movl -0x68(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x40(%rbp), %rcx
movl -0x60(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x58(%rbp), %rax
movl -0x68(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0xc3b0
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xc31e
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x18960
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x18960
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x18960
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x14(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)