// File: /workspace/github_c_makefile_star2_O1/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 $0x2108, %rsp           # imm = 0x2108
movq %r9, %r13
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
movq %rcx, %rdi
movl $0x2e, %esi
callq 0x3380
testq %rax, %rax
je 0x13685
movq %rbx, 0x10(%rsp)
movl 0x2140(%rsp), %ebx
movq %rax, %rdi
callq 0x5df8
xorl %ecx, %ecx
testl %ebx, %ebx
setg %r12b
jle 0x13680
cmpl %eax, (%r13)
je 0x13525
movl %ebx, %edx
movl $0x1, %esi
cmpq %rsi, %rdx
je 0x13587
leaq 0x1(%rsi), %rdi
cmpl %eax, (%r13,%rsi,4)
movq %rdi, %rsi
jne 0x13508
decq %rdi
cmpq %rdx, %rdi
setb %r12b
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x11dc4
testb $0x1, (%rbx)
jne 0x13557
movq 0x8(%rsp), %rdi
movq $-0x1, %rsi
callq 0xe28e
jmp 0x1367b
movq 0x58(%rsp), %rcx
leaq 0x20(%rsp), %r8
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x130a2
testb %al, %al
je 0x13590
leaq 0xa025(%rip), %rax      # 0x1d5a0
lock
incl 0xb0(%rax)
jmp 0x13667
seta %r12b
jmp 0x13680
leaq 0xa009(%rip), %rax      # 0x1d5a0
leaq 0xb4(%rax), %rcx
movq %rcx, 0x30(%rsp)
addq $0xb8, %rax
movq %rax, 0x38(%rsp)
callq 0x60a6
movq %rax, 0x40(%rsp)
leaq 0x29b4(%rip), %rsi      # 0x15f73
movq %r14, %rdi
callq 0x33c0
movq %rax, %r13
testq %rax, %rax
je 0x13642
leaq 0x60(%rsp), %rdi
callq 0xe17e
leaq 0x100(%rsp), %rbx
leaq 0x60(%rsp), %r15
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %rbx, %rdi
movq %r13, %rcx
callq 0x34e0
testq %rax, %rax
je 0x13610
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xe068
jmp 0x135e6
movq %r13, %rdi
callq 0x3340
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xe195
movq 0x58(%rsp), %rcx
leaq 0x20(%rsp), %r8
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x1313a
jmp 0x13658
leaq 0x3cd5(%rip), %rsi      # 0x1731e
movl $0x9, %edx
movq 0x8(%rsp), %rdi
callq 0xe068
leaq 0x30(%rsp), %rdi
callq 0x5bac
testq %r13, %r13
je 0x1367b
leaq 0x20(%rsp), %rsi
movl $0x10, %edx
movq 0x8(%rsp), %rdi
callq 0xe068
movl $0x1, %ecx
testb %r12b, %r12b
jne 0x13687
xorl %ecx, %ecx
testl %ecx, %ecx
jne 0x136c0
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x11dc4
movl (%rbx), %eax
andl $0x1, %eax
xorl %esi, %esi
cmpl $0x1, %eax
sbbq %rsi, %rsi
orq 0x10(%rbx), %rsi
movq 0x8(%rsp), %rdi
callq 0xe28e
addq $0x2108, %rsp           # imm = 0x2108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x136d8
jmp 0x136d8
jmp 0x136d8
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5bac
movq %rbx, %rdi
callq 0x35e0