// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/DigestCache.cpp
// Function: t2::DigestCacheOpen(t2::DigestCache*, char const*)
void DigestCacheOpen(DigestCache* self, const char* filename)
{
  MmapFileMap(&self->m_StateFile, filename);
  if (MmapFileValid(&self->m_StateFile))
  {
    const DigestCacheState* state = (const DigestCacheState*) self->m_StateFile.m_Address;
    if (DigestCacheState::MagicNumber == state->m_MagicNumber)
    {
      const uint64_t time_now = time(nullptr);

      // Throw out records that haven't been accessed in a week.
      const uint64_t cutoff_time = time_now - 7 * 24 * 60 * 60;

      self->m_State = state;

      //HashTablePrepareBulkInsert(&self->m_Table, state->m_Records.GetCount());

      for (const FrozenDigestRecord& record : state->m_Records)
      {
        if (record.m_AccessTime < cutoff_time)
          continue;

        DigestCacheRecord r;
        r.m_ContentDigest = record.m_ContentDigest;
        r.m_Timestamp     = record.m_Timestamp;
        r.m_AccessTime    = record.m_AccessTime;
        HashTableInsert(&self->m_Table, record.m_FilenameHash, record.m_Filename.Get(), r);
      }
      Log(kDebug, "digest cache initialized -- %d entries", state->m_Records.GetCount());
    }
    else
    {
      MmapFileUnmap(&self->m_StateFile);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x80, %rdi
movq -0x10(%rbp), %rsi
callq 0x18d30
movq -0x8(%rbp), %rdi
addq $0x80, %rdi
callq 0x14a90
testb $0x1, %al
jne 0x1f420
jmp 0x1f55d
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movl $0x6a683db8, %eax       # imm = 0x6A683DB8
cmpl (%rcx), %eax
jne 0x1f54b
xorl %eax, %eax
movl %eax, %edi
callq 0x3310
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
subq $0x93a80, %rax          # imm = 0x93A80
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1fb60
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1fb80
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x1f527
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x28(%rbp), %rax
jae 0x1f4b3
jmp 0x1f516
movq -0x48(%rbp), %rax
movq 0x14(%rax), %rcx
movq %rcx, -0x68(%rbp)
movq 0x1c(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x48(%rbp), %rdi
addq $0x24, %rdi
callq 0x6c00
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %esi
movq %rax, %rdx
leaq -0x68(%rbp), %rcx
callq 0x1fbc0
movq -0x38(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x38(%rbp)
jmp 0x1f48d
movq -0x18(%rbp), %rdi
addq $0x4, %rdi
callq 0x1fc30
movl %eax, %edx
movl $0x8, %edi
leaq 0x615d(%rip), %rsi      # 0x2569f
movb $0x0, %al
callq 0x7a60
jmp 0x1f55b
movq -0x8(%rbp), %rdi
addq $0x80, %rdi
callq 0x18c60
jmp 0x1f55d
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)