// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]tundra/src/HashFast.cpp
// Function: t2::HashBlock(unsigned char const*, t2::HashStateImpl*, void*)
void HashBlock(const uint8_t* block, HashStateImpl* state, void* debug_file_)
{
  const uint32_t* p = (const uint32_t*) block;
  const size_t buffer_size = sizeof(HashState().m_Buffer);

  if (FILE* debug_file = (FILE*) debug_file_)
  {
    const size_t line_size = 16;

    for (size_t i = 0; i < buffer_size; i += line_size)
    {
      for (size_t x = 0; x < line_size; ++x)
      {
        int ch = block[x + i];
        static const char hex[] = "0123456789ABCDEF";
        fputc(hex[(ch & 0xf0) >> 4], debug_file);
        fputc(hex[(ch & 0x0f)     ], debug_file);
        fputc(' ', debug_file);
      }

      fputs(" | ", debug_file);

      for (size_t x = 0; x < line_size; ++x)
      {
        int ch = block[x + i];
        if (isalnum(ch) || ispunct(ch) || ' ' == ch)
          fputc(ch, debug_file);
        else
          fputc('.', debug_file);
      }
      fputc('\n', debug_file);
    }
  }

  static_assert((buffer_size & 63) == 0, "buffer must be multiple of 64 bytes");

  for (size_t i = 0; i < buffer_size/64; ++i)
  {
    for (int v = 0; v < 4; ++v)
    {
      uint32_t v0 = state->m_V[v][0];
      uint32_t v1 = state->m_V[v][1];
      uint32_t v2 = state->m_V[v][2];
      uint32_t v3 = state->m_V[v][3];

      v0 += *p++ * kPrime32_2; v0 = RotateLeft(v0, 13); v0 *= kPrime32_1;
      v1 += *p++ * kPrime32_2; v1 = RotateLeft(v1, 13); v1 *= kPrime32_1;
      v2 += *p++ * kPrime32_2; v2 = RotateLeft(v2, 13); v2 *= kPrime32_1;
      v3 += *p++ * kPrime32_2; v3 = RotateLeft(v3, 13); v3 *= kPrime32_1;

      state->m_V[v][0] = v0;
      state->m_V[v][1] = v1;
      state->m_V[v][2] = v2;
      state->m_V[v][3] = v3;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
testq %rdx, %rdx
je 0x13a03
movq %rdx, %r15
xorl %eax, %eax
leaq 0x39e9(%rip), %r13      # 0x17330
movq 0x8(%rsp), %r14
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movzbl (%r14,%r12), %ebp
movl %ebp, %eax
shrl $0x4, %eax
movsbl (%rax,%r13), %edi
movq %r15, %rsi
callq 0x3410
andl $0xf, %ebp
movsbl (%rbp,%r13), %edi
movq %r15, %rsi
callq 0x3410
movl $0x20, %edi
movq %r15, %rsi
callq 0x3410
incq %r12
cmpq $0x10, %r12
jne 0x13954
leaq 0x39a8(%rip), %rdi      # 0x17341
movq %r15, %rsi
callq 0x33a0
xorl %r12d, %r12d
movzbl (%r14,%r12), %ebp
movl %ebp, %edi
callq 0x3350
testl %eax, %eax
jne 0x139cc
movl %ebp, %edi
callq 0x3630
movl %ebp, %ecx
testl %eax, %eax
jne 0x139c6
movl $0x2e, %ecx
cmpl $0x20, %ebp
cmovnel %ecx, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x3410
incq %r12
cmpq $0x10, %r12
jne 0x139a4
movl $0xa, %edi
movq %r15, %rsi
callq 0x3410
movq 0x10(%rsp), %rcx
leaq 0x10(%rcx), %rax
addq $0x10, %r14
cmpq $0x30, %rcx
jb 0x1394c
xorl %eax, %eax
movq 0x8(%rsp), %r8
imull $0x85ebca77, (%r8,%rax), %ecx # imm = 0x85EBCA77
addl (%rbx,%rax), %ecx
roll $0xd, %ecx
imull $0x85ebca77, 0x4(%r8,%rax), %edx # imm = 0x85EBCA77
addl 0x4(%rbx,%rax), %edx
imull $0x9e3779b1, %ecx, %ecx # imm = 0x9E3779B1
roll $0xd, %edx
imull $0x9e3779b1, %edx, %edx # imm = 0x9E3779B1
imull $0x85ebca77, 0x8(%r8,%rax), %esi # imm = 0x85EBCA77
addl 0x8(%rbx,%rax), %esi
roll $0xd, %esi
imull $0x85ebca77, 0xc(%r8,%rax), %edi # imm = 0x85EBCA77
addl 0xc(%rbx,%rax), %edi
roll $0xd, %edi
imull $0x9e3779b1, %esi, %esi # imm = 0x9E3779B1
imull $0x9e3779b1, %edi, %edi # imm = 0x9E3779B1
movl %ecx, (%rbx,%rax)
movl %edx, 0x4(%rbx,%rax)
movl %esi, 0x8(%rbx,%rax)
movl %edi, 0xc(%rbx,%rax)
addq $0x10, %rax
cmpq $0x40, %rax
jne 0x13a0a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq