// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/InspectMain.cpp
// Function: main
int main(int argc, char* argv[])
{
  MemoryMappedFile f;

  const char* fn = argc >=2 ? argv[1] : ".tundra2.dag";

  MmapFileInit(&f);
  MmapFileMap(&f, fn);

  if (MmapFileValid(&f))
  {
    const char* suffix = strrchr(fn, '.');

    if (0 == strcmp(suffix, ".dag"))
    {
      const DagData* data = (const DagData*) f.m_Address;
      if (data->m_MagicNumber == DagData::MagicNumber)
      {
        DumpDag(data);
      }
      else
      {
        fprintf(stderr, "%s: bad magic number\n", fn);
      }
    }
    else if (0 == strcmp(suffix, ".state"))
    {
      const StateData* data = (const StateData*) f.m_Address;
      if (data->m_MagicNumber == StateData::MagicNumber)
      {
        DumpState(data);
      }
      else
      {
        fprintf(stderr, "%s: bad magic number\n", fn);
      }
    }
    else if (0 == strcmp(suffix, ".scancache"))
    {
      const ScanData* data = (const ScanData*) f.m_Address;
      if (data->m_MagicNumber == ScanData::MagicNumber)
      {
        DumpScanCache(data);
      }
      else
      {
        fprintf(stderr, "%s: bad magic number\n", fn);
      }
    }
    else if (0 == strcmp(suffix, ".digestcache"))
    {
      const DigestCacheState* data = (const DigestCacheState*) f.m_Address;
      if (data->m_MagicNumber == DigestCacheState::MagicNumber)
      {
        DumpDigestCache(data);
      }
      else
      {
        fprintf(stderr, "%s: bad magic number\n", fn);
      }
    }
    else
    {
      fprintf(stderr, "%s: unknown file type\n", fn);
    }
  }
  else
  {
    fprintf(stderr, "%s: couldn't mmap file\n", fn);
  }

  MmapFileUnmap(&f);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jl 0x278a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x2797
leaq 0x20873(%rip), %rax     # 0x23004
movq %rax, -0x68(%rbp)
jmp 0x2797
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4f50
movq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x50a0
leaq -0x30(%rbp), %rdi
callq 0x3df0
testb $0x1, %al
jne 0x27c7
jmp 0x2957
movq -0x38(%rbp), %rdi
movl $0x2e, %esi
callq 0x23a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x20828(%rip), %rsi     # 0x2300c
callq 0x2668
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x2831
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x6d992313, (%rax)     # imm = 0x6D992313
jne 0x2810
movq -0x48(%rbp), %rdi
callq 0x2990
jmp 0x282c
movq 0x2c7c1(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x207ec(%rip), %rsi     # 0x23011
movb $0x0, %al
callq 0x2490
jmp 0x2955
movq -0x40(%rbp), %rdi
leaq 0x222d2(%rip), %rsi     # 0x24b0e
callq 0x2668
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x2889
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x6d99231c, (%rax)     # imm = 0x6D99231C
jne 0x2868
movq -0x50(%rbp), %rdi
callq 0x3910
jmp 0x2884
movq 0x2c769(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x20794(%rip), %rsi     # 0x23011
movb $0x0, %al
callq 0x2490
jmp 0x2953
movq -0x40(%rbp), %rdi
leaq 0x222bf(%rip), %rsi     # 0x24b53
callq 0x2668
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x28de
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x6d072210, (%rax)     # imm = 0x6D072210
jne 0x28c0
movq -0x58(%rbp), %rdi
callq 0x3b00
jmp 0x28dc
movq 0x2c711(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x2073c(%rip), %rsi     # 0x23011
movb $0x0, %al
callq 0x2490
jmp 0x2951
movq -0x40(%rbp), %rdi
leaq 0x222bd(%rip), %rsi     # 0x24ba6
callq 0x2668
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x2933
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x6a683db8, (%rax)     # imm = 0x6A683DB8
jne 0x2915
movq -0x60(%rbp), %rdi
callq 0x3c80
jmp 0x2931
movq 0x2c6bc(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x206e7(%rip), %rsi     # 0x23011
movb $0x0, %al
callq 0x2490
jmp 0x294f
movq 0x2c69e(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x206df(%rip), %rsi     # 0x23027
movb $0x0, %al
callq 0x2490
jmp 0x2951
jmp 0x2953
jmp 0x2955
jmp 0x2973
movq 0x2c67a(%rip), %rax     # 0x2efd8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x206d2(%rip), %rsi     # 0x2303e
movb $0x0, %al
callq 0x2490
leaq -0x30(%rbp), %rdi
callq 0x4fd0
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)