// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]tundra/src/HashTable.hpp
// Function: void t2::HashTableGrow<t2::FileInfo, 0u>(t2::HashTable<t2::FileInfo, 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0x14(%rdi), %eax
addl $0x2, %eax
cmpl $0x8, %eax
movl $0x7, %ebx
cmovael %eax, %ebx
movl $0x1, %r14d
movl %ebx, %ecx
shll %cl, %r14d
movq 0x20(%rdi), %rcx
movq %rcx, 0x18(%rsp)
movl 0x10(%rdi), %r12d
movq (%rdi), %r15
movq 0x8(%rdi), %rax
movq %rax, 0x20(%rsp)
movq %rdi, 0x30(%rsp)
movq 0x28(%rdi), %rbp
leaq (,%r14,4), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rsi
shlq $0x4, %rsi
movq %rcx, %rdi
callq 0xef62
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rdx
callq 0x31b0
leaq (,%r14,8), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x8(%rsp)
shlq $0x6, %r14
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0xef62
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x31b0
movl $0x18, %eax
movl %ebx, %ecx
shlq %cl, %rax
movq %rax, 0x28(%rsp)
movl $0x240, %esi            # imm = 0x240
movl %ebx, 0x10(%rsp)
shlq %cl, %rsi
movq 0x18(%rsp), %rdi
callq 0xef62
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq 0x28(%rsp), %rdx
callq 0x31b0
testq %r12, %r12
je 0x120ed
movq 0x8(%rsp), %rax
decl %eax
xorl %ecx, %ecx
movl (%r15,%rcx,4), %edx
testl %edx, %edx
je 0x120e5
movl %edx, %edi
movl %edi, %esi
andl %eax, %esi
movl %esi, %edi
incl %edi
cmpl $0x0, (%r13,%rsi,4)
jne 0x120a8
movl %edx, (%r13,%rsi,4)
movq 0x20(%rsp), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, (%r14,%rsi,8)
leaq (%rcx,%rcx,2), %rdx
leaq (%rsi,%rsi,2), %rsi
movq 0x10(%rbp,%rdx,8), %rdi
movq %rdi, 0x10(%rbx,%rsi,8)
movups (%rbp,%rdx,8), %xmm0
movups %xmm0, (%rbx,%rsi,8)
incq %rcx
cmpq %r12, %rcx
jne 0x1209e
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0xef6a
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0xef6a
movq %r12, %rdi
movq %r15, %rsi
callq 0xef6a
movq 0x30(%rsp), %rax
movq %r13, (%rax)
movq %r14, 0x8(%rax)
movq %rbx, 0x28(%rax)
movq 0x8(%rsp), %rcx
movl %ecx, 0x10(%rax)
movl 0x10(%rsp), %ecx
movl %ecx, 0x14(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop