// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/ScanCache.cpp
// Function: void t2::SaveRecord<t2::FileAndHash>(t2::ScanCacheWriter*, t2::HashTable<t2::BinaryLocator, 0u>*, t2::HashDigest const*, t2::FileAndHash*, int, unsigned long, unsigned long)
static void SaveRecord(
    ScanCacheWriter*    self,
    HashTable<BinaryLocator, kFlagPathStrings>* atoms,
    const HashDigest*   digest,
    T*                  includes,
    int                 include_count,
    uint64_t            file_timestamp,
    uint64_t            access_time)
{
  // TODO: Check access time to see if we should discard.
  BinarySegment *digest_seg    = self->m_DigestSeg;
  BinarySegment *data_seg      = self->m_DataSeg;
  BinarySegment *timestamp_seg = self->m_TimestampSeg;
  BinarySegment *string_seg    = self->m_StringSeg;
  BinarySegment *array_seg     = self->m_ArraySeg;

  BinaryLocator string_ptrs = BinarySegmentPosition(array_seg);

  for (int i = 0; i < include_count; ++i)
  {
    WriteUniqueStringPointer(atoms, array_seg, string_seg, includes[i].m_FilenameHash, includes[i].m_Filename);
    BinarySegmentWriteUint32(array_seg, includes[i].m_FilenameHash);
  }

  BinarySegmentWrite(digest_seg, (const char*) digest->m_Data, sizeof(HashDigest));

  BinarySegmentWriteUint64(data_seg, file_timestamp);
  BinarySegmentWriteUint32(data_seg, uint32_t(include_count));
  BinarySegmentWritePointer(data_seg, string_ptrs);

  BinarySegmentWriteUint64(timestamp_seg, access_time);

  self->m_RecordsOut++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x20e20
movl %eax, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1b3bd
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x6c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movslq -0x6c(%rbp), %r8
shlq $0x4, %r8
addq %r8, %rax
movq (%rax), %r8
callq 0x1b440
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x6c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0xbaa0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1b35a
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x10, %edx
callq 0x20d70
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xbbc0
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xbaa0
movq -0x40(%rbp), %rdi
movq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x80(%rbp), %esi
movq -0x78(%rbp), %rdx
callq 0x20db0
movq -0x48(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0xbbc0
movq -0x8(%rbp), %rax
movl 0x80(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x80(%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)