// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/LuaProfiler.cpp
// Function: t2::PushInvocation(t2::FunctionMeta*, unsigned int)
static Invocation* PushInvocation(FunctionMeta* f, uint32_t hash)
{
  Invocation* parent = s_Profiler.m_CurrentInvocation;
  if (parent)
    hash ^= parent->m_Hash;

  uint32_t index = hash & (s_Profiler.m_InvocationTableSize - 1);

  Invocation* chain = s_Profiler.m_InvocationTable[index];
  while (chain)
  {
    if (chain->m_Hash == hash && chain->m_Function == f && MatchInvocation(chain->m_Parent, s_Profiler.m_CurrentInvocation))
    {
      return chain;
    }

    chain = chain->m_Next;
  }

  // Create a new invocation.

  // See if we need to rehash.
  if (double(s_Profiler.m_InvocationCount + 1) / double(s_Profiler.m_InvocationTableSize) > 0.75)
  {
    RehashInvocationTable(s_Profiler.m_InvocationTableSize * 2);
  }

  // Recompute insertion index.
  index = hash & (s_Profiler.m_InvocationTableSize - 1);

  // Allocate and populate invocation record.
  Invocation* i = LinearAllocate<Invocation>(s_Profiler.m_Allocator);
  i->m_Hash      = hash;
  i->m_Function  = f;
  i->m_Parent    = parent;
  i->m_CallCount = 0;
  i->m_Ticks     = 0;
  i->m_StartTick = 0;
  i->m_Next      = s_Profiler.m_InvocationTable[index];

  // Insert
  s_Profiler.m_InvocationTable[index] = i;

  return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq 0x58f62(%rip), %rax     # 0x639d8
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xaa8d
movq -0x20(%rbp), %rax
movl (%rax), %eax
xorl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl 0x58f36(%rip), %ecx     # 0x639cc
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x24(%rbp)
movq 0x58f2b(%rip), %rax     # 0x639d0
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xab05
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0xaaf7
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0xaaf7
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x58ef9(%rip), %rsi     # 0x639d8
callq 0xaec0
testb $0x1, %al
jne 0xaaea
jmp 0xaaf7
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xabd1
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xaab0
movl 0x58ebd(%rip), %eax     # 0x639c8
incl %eax
cvtsi2sd %rax, %xmm0
movl 0x58eb4(%rip), %eax     # 0x639cc
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd 0x42ba7(%rip), %xmm1    # 0x4d6d0
ucomisd %xmm1, %xmm0
jbe 0xab3c
movl 0x58e97(%rip), %edi     # 0x639cc
shll %edi
callq 0xa980
movl -0x14(%rbp), %eax
movl 0x58e87(%rip), %ecx     # 0x639cc
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x24(%rbp)
movq 0x58e3c(%rip), %rdi     # 0x63990
callq 0xb2d0
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x28(%rax)
movq 0x58e28(%rip), %rax     # 0x639d0
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x38(%rbp), %rdx
movq 0x58e0e(%rip), %rax     # 0x639d0
movl -0x24(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)