// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rcx, %rdi
movl $0x2e, %esi
callq 0x3380
testq %rax, %rax
je 0x12de8
movl 0x2130(%rsp), %r15d
movq %rax, %rdi
callq 0x5c7c
testl %r15d, %r15d
jle 0x12de8
movl %r15d, %ecx
xorl %edx, %edx
cmpl %eax, (%r13,%rdx,4)
je 0x12e2c
incq %rdx
cmpq %rdx, %rcx
jne 0x12dd9
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x116f1
movl (%r15), %eax
andl $0x1, %eax
xorl %esi, %esi
cmpl $0x1, %eax
sbbq %rsi, %rsi
orq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xddb2
addq $0x20f8, %rsp           # imm = 0x20F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x116f1
testb $0x1, (%r15)
jne 0x12e53
movq %rbx, %rdi
movq $-0x1, %rsi
jmp 0x12e15
movq 0x48(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x12995
testb %al, %al
je 0x12e83
leaq 0xa729(%rip), %rax      # 0x1d5a0
lock
incl 0xb0(%rax)
jmp 0x12f41
leaq 0xa716(%rip), %rax      # 0x1d5a0
leaq 0xb4(%rax), %rcx
movq %rcx, 0x20(%rsp)
addq $0xb8, %rax
movq %rax, 0x28(%rsp)
callq 0x5f2a
movq %rax, 0x30(%rsp)
leaq 0x30b1(%rip), %rsi      # 0x15f63
movq %r14, %rdi
callq 0x33c0
testq %rax, %rax
je 0x12f58
movq %rax, %r12
leaq 0x50(%rsp), %rdi
callq 0xdc4a
leaq 0xf0(%rsp), %r13
leaq 0x50(%rsp), %r15
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %r13, %rdi
movq %r12, %rcx
callq 0x34e0
testq %rax, %rax
je 0x12f07
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xdb34
jmp 0x12edd
movq %r12, %rdi
callq 0x3340
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xdc61
movq 0x48(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x12a2c
leaq 0x20(%rsp), %rdi
callq 0x5a30
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
movq %rbx, %rdi
callq 0xdb34
jmp 0x12e1a
leaq 0x43bf(%rip), %rsi      # 0x1731e
movl $0x9, %edx
movq %rbx, %rdi
callq 0xdb34
leaq 0x20(%rsp), %rdi
callq 0x5a30
jmp 0x12e1a
jmp 0x12f81
jmp 0x12f81
jmp 0x12f81
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5a30
movq %rbx, %rdi
callq 0x35e0