// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]tundra/src/FileSign.cpp
// Function: t2::ComputeFileSignature(t2::HashState*, t2::StatCache*, t2::DigestCache*, char const*, unsigned int, unsigned int const*, int)
void ComputeFileSignature(
  HashState*          out,
  StatCache*          stat_cache,
  DigestCache*        digest_cache,
  const char*         filename,
  uint32_t            fn_hash,
  const uint32_t      sha_extension_hashes[],
  int                 sha_extension_hash_count)
{
  if (const char* ext = strrchr(filename, '.'))
  {
    uint32_t ext_hash = Djb2Hash(ext);
    for (int i  = 0; i < sha_extension_hash_count; ++i)
    {
      if (sha_extension_hashes[i] == ext_hash)
      {
        ComputeFileSignatureSha1(out, stat_cache, digest_cache, filename, fn_hash);
        return;
      }
    }
  }

  ComputeFileSignatureTimestamp(out, stat_cache, filename, fn_hash);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20f8, %rsp           # imm = 0x20F8
movq %r9, %r13
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, (%rsp)
pushq $0x2e
popq %rsi
movq %rcx, %rdi
callq 0x3380
testq %rax, %rax
je 0x11572
movl 0x2130(%rsp), %ebx
movq %rax, %rdi
callq 0x58de
xorl %ecx, %ecx
testl %ebx, %ebx
cmovlel %ecx, %ebx
cmpq %rcx, %rbx
je 0x11572
leaq 0x1(%rcx), %rdx
cmpl %eax, (%r13,%rcx,4)
movq %rdx, %rcx
jne 0x11540
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x101cf
testb $0x1, (%rbx)
jne 0x115b6
pushq $-0x1
popq %rsi
jmp 0x1159b
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x101cf
movl (%rbx), %eax
andl $0x1, %eax
xorl %esi, %esi
cmpl $0x1, %eax
sbbq %rsi, %rsi
orq 0x10(%rbx), %rsi
movq (%rsp), %rdi
callq 0xcdf4
addq $0x20f8, %rsp           # imm = 0x20F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x111bc
testb %al, %al
je 0x115e6
leaq 0xbfc6(%rip), %rax      # 0x1d5a0
lock
incl 0xb0(%rax)
jmp 0x116bd
leaq 0xbfb3(%rip), %rax      # 0x1d5a0
leaq 0xb4(%rax), %rcx
movq %rcx, 0x20(%rsp)
addq $0xb8, %rax
movq %rax, 0x28(%rsp)
callq 0x5b35
movq %rax, 0x30(%rsp)
leaq 0x294c(%rip), %rsi      # 0x13f61
movq %r14, %rdi
callq 0x33c0
movq %rax, %r12
testq %rax, %rax
je 0x1169a
leaq 0x50(%rsp), %rdi
callq 0xcd00
leaq 0xf0(%rsp), %r13
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbx
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x34e0
testq %rax, %rax
je 0x11668
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xcc00
jmp 0x11640
movq %r12, %rdi
callq 0x3340
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xcd14
movq 0x48(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x1121f
jmp 0x116aa
leaq 0x3c75(%rip), %rsi      # 0x15316
movq (%rsp), %rdi
callq 0x557d
leaq 0x20(%rsp), %rdi
callq 0x55d6
testq %r12, %r12
je 0x115a4
leaq 0x10(%rsp), %rsi
pushq $0x10
popq %rdx
movq (%rsp), %rdi
callq 0xcc00
jmp 0x115a4
jmp 0x116d9
jmp 0x116d9
jmp 0x116d9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x55d6
movq %rbx, %rdi
callq 0x35e0