// File: /workspace/github_cpp_makefile_star2_O1/prakhar2808[P]DBEngine/dbengine/MurmurHash3.cc
// Function: MurmurHash3_x86_128(void const*, int, unsigned int, void*)
void MurmurHash3_x86_128 ( const void * key, const int len,
                           uint32_t seed, void * out )
{
  const uint8_t * data = (const uint8_t*)key;
  const int nblocks = len / 16;

  uint32_t h1 = seed;
  uint32_t h2 = seed;
  uint32_t h3 = seed;
  uint32_t h4 = seed;

  const uint32_t c1 = 0x239b961b; 
  const uint32_t c2 = 0xab0e9789;
  const uint32_t c3 = 0x38b34ae5; 
  const uint32_t c4 = 0xa1e38b93;

  //----------
  // body

  const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);

  for(int i = -nblocks; i; i++)
  {
    uint32_t k1 = getblock32(blocks,i*4+0);
    uint32_t k2 = getblock32(blocks,i*4+1);
    uint32_t k3 = getblock32(blocks,i*4+2);
    uint32_t k4 = getblock32(blocks,i*4+3);

    k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;

    h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;

    k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;

    h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;

    k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;

    h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;

    k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;

    h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
  }

  //----------
  // tail

  const uint8_t * tail = (const uint8_t*)(data + nblocks*16);

  uint32_t k1 = 0;
  uint32_t k2 = 0;
  uint32_t k3 = 0;
  uint32_t k4 = 0;

  switch(len & 15)
  {
  case 15: k4 ^= tail[14] << 16;
  case 14: k4 ^= tail[13] << 8;
  case 13: k4 ^= tail[12] << 0;
           k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;

  case 12: k3 ^= tail[11] << 24;
  case 11: k3 ^= tail[10] << 16;
  case 10: k3 ^= tail[ 9] << 8;
  case  9: k3 ^= tail[ 8] << 0;
           k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;

  case  8: k2 ^= tail[ 7] << 24;
  case  7: k2 ^= tail[ 6] << 16;
  case  6: k2 ^= tail[ 5] << 8;
  case  5: k2 ^= tail[ 4] << 0;
           k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;

  case  4: k1 ^= tail[ 3] << 24;
  case  3: k1 ^= tail[ 2] << 16;
  case  2: k1 ^= tail[ 1] << 8;
  case  1: k1 ^= tail[ 0] << 0;
           k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
  };

  //----------
  // finalization

  h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;

  h1 += h2; h1 += h3; h1 += h4;
  h2 += h1; h3 += h1; h4 += h1;

  h1 = fmix32(h1);
  h2 = fmix32(h2);
  h3 = fmix32(h3);
  h4 = fmix32(h4);

  h1 += h2; h1 += h3; h1 += h4;
  h2 += h1; h3 += h1; h4 += h1;

  ((uint32_t*)out)[0] = h1;
  ((uint32_t*)out)[1] = h2;
  ((uint32_t*)out)[2] = h3;
  ((uint32_t*)out)[3] = h4;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leal 0xf(%rsi), %r8d
testl %esi, %esi
movl %esi, %eax
cmovsl %r8d, %eax
movl %eax, %r9d
andl $-0x10, %r9d
movslq %r9d, %r10
cmpl $0x1f, %r8d
jae 0x5dce
movl %edx, %eax
movl %edx, %r8d
movl %edx, %r9d
jmp 0x5ed2
sarl $0x4, %eax
movslq %eax, %r11
movq %r11, %rax
shlq $0x4, %rax
movq %r10, %r8
subq %rax, %r8
leaq (%r8,%rdi), %rbx
addq $0xc, %rbx
movl %edx, %r9d
movl %edx, %r8d
movl %edx, %eax
movl -0xc(%rbx), %ebp
movl -0x8(%rbx), %r12d
movl -0x4(%rbx), %r15d
imull $0x239b961b, %ebp, %r14d # imm = 0x239B961B
imull $0xcb0d8000, %ebp, %ebp # imm = 0xCB0D8000
shrl $0x11, %r14d
orl %ebp, %r14d
imull $0xab0e9789, %r14d, %r13d # imm = 0xAB0E9789
xorl %edx, %r13d
roll $0x13, %r13d
movl (%rbx), %ebp
addl %r9d, %r13d
leal (%r13,%r13,4), %r14d
leal 0x561ccd1b(%r13,%r13,4), %edx
imull $0xab0e9789, %r12d, %r13d # imm = 0xAB0E9789
imull $0x97890000, %r12d, %r12d # imm = 0x97890000
shrl $0x10, %r13d
orl %r12d, %r13d
imull $0x38b34ae5, %r13d, %r12d # imm = 0x38B34AE5
xorl %r9d, %r12d
roll $0x11, %r12d
addl %r8d, %r12d
leal (%r12,%r12,4), %r9d
addl $0xbcaa747, %r9d        # imm = 0xBCAA747
imull $0x38b34ae5, %r15d, %r12d # imm = 0x38B34AE5
imull $0x95ca0000, %r15d, %r15d # imm = 0x95CA0000
shrl $0xf, %r12d
orl %r15d, %r12d
imull $0xa1e38b93, %r12d, %r15d # imm = 0xA1E38B93
xorl %r8d, %r15d
roll $0xf, %r15d
addl %eax, %r15d
leal (%r15,%r15,4), %r8d
addl $0x96cd1c35, %r8d       # imm = 0x96CD1C35
imull $0xa1e38b93, %ebp, %r15d # imm = 0xA1E38B93
imull $0x2e4c0000, %ebp, %ebp # imm = 0x2E4C0000
shrl $0xe, %r15d
orl %ebp, %r15d
imull $0x239b961b, %r15d, %r15d # imm = 0x239B961B
xorl %eax, %r15d
roll $0xd, %r15d
leal (%r15,%r14), %eax
addl $0x561ccd1b, %eax       # imm = 0x561CCD1B
leal (%rax,%rax,4), %eax
addl $0x32ac3b17, %eax       # imm = 0x32AC3B17
addq $0x10, %rbx
decq %r11
jne 0x5df1
movl %esi, %ebx
andl $0xf, %ebx
xorl %r11d, %r11d
leaq 0x15133(%rip), %r14     # 0x1b014
movslq (%r14,%rbx,4), %rbx
addq %r14, %rbx
jmpq *%rbx
movzbl 0xe(%rdi,%r10), %r11d
shll $0x10, %r11d
movzbl 0xd(%rdi,%r10), %ebx
shll $0x8, %ebx
orl %ebx, %r11d
movzbl 0xc(%rdi,%r10), %ebx
xorl %r11d, %ebx
imull $0xa1e38b93, %ebx, %r11d # imm = 0xA1E38B93
imull $0x2e4c0000, %ebx, %ebx # imm = 0x2E4C0000
shrl $0xe, %r11d
orl %ebx, %r11d
imull $0x239b961b, %r11d, %r11d # imm = 0x239B961B
xorl %r11d, %eax
movzbl 0xb(%rdi,%r10), %r11d
shll $0x18, %r11d
movzbl 0xa(%rdi,%r10), %ebx
shll $0x10, %ebx
orl %ebx, %r11d
movzbl 0x9(%rdi,%r10), %ebx
shll $0x8, %ebx
xorl %ebx, %r11d
movzbl 0x8(%rdi,%r10), %ebx
xorl %r11d, %ebx
imull $0x38b34ae5, %ebx, %r11d # imm = 0x38B34AE5
imull $0x95ca0000, %ebx, %ebx # imm = 0x95CA0000
shrl $0xf, %r11d
orl %ebx, %r11d
imull $0xa1e38b93, %r11d, %r11d # imm = 0xA1E38B93
xorl %r11d, %r8d
movzbl 0x7(%rdi,%r10), %r11d
shll $0x18, %r11d
movzbl 0x6(%rdi,%r10), %ebx
shll $0x10, %ebx
orl %ebx, %r11d
movzbl 0x5(%rdi,%r10), %ebx
shll $0x8, %ebx
xorl %ebx, %r11d
movzbl 0x4(%rdi,%r10), %ebx
xorl %r11d, %ebx
imull $0xab0e9789, %ebx, %r11d # imm = 0xAB0E9789
imull $0x97890000, %ebx, %ebx # imm = 0x97890000
shrl $0x10, %r11d
orl %ebx, %r11d
imull $0x38b34ae5, %r11d, %r11d # imm = 0x38B34AE5
xorl %r11d, %r9d
movzbl 0x3(%rdi,%r10), %r11d
shll $0x18, %r11d
movzbl 0x2(%rdi,%r10), %ebx
shll $0x10, %ebx
orl %ebx, %r11d
movzbl 0x1(%rdi,%r10), %ebx
shll $0x8, %ebx
xorl %ebx, %r11d
movzbl (%rdi,%r10), %edi
xorl %r11d, %edi
imull $0x239b961b, %edi, %r10d # imm = 0x239B961B
imull $0xcb0d8000, %edi, %edi # imm = 0xCB0D8000
shrl $0x11, %r10d
orl %edi, %r10d
imull $0xab0e9789, %r10d, %edi # imm = 0xAB0E9789
xorl %edi, %edx
xorl %esi, %edx
xorl %esi, %r9d
xorl %esi, %r8d
xorl %esi, %eax
addl %r9d, %edx
addl %r8d, %edx
addl %eax, %edx
addl %edx, %r9d
addl %edx, %r8d
addl %edx, %eax
movl %edx, %esi
shrl $0x10, %esi
xorl %edx, %esi
imull $0x85ebca6b, %esi, %edx # imm = 0x85EBCA6B
movl %edx, %esi
shrl $0xd, %esi
xorl %edx, %esi
imull $0xc2b2ae35, %esi, %esi # imm = 0xC2B2AE35
movl %esi, %edx
shrl $0x10, %edx
xorl %esi, %edx
movl %r9d, %esi
shrl $0x10, %esi
xorl %r9d, %esi
imull $0x85ebca6b, %esi, %esi # imm = 0x85EBCA6B
movl %esi, %edi
shrl $0xd, %edi
xorl %esi, %edi
imull $0xc2b2ae35, %edi, %edi # imm = 0xC2B2AE35
movl %edi, %esi
shrl $0x10, %esi
xorl %edi, %esi
movl %r8d, %edi
shrl $0x10, %edi
xorl %r8d, %edi
imull $0x85ebca6b, %edi, %edi # imm = 0x85EBCA6B
movl %edi, %r8d
shrl $0xd, %r8d
xorl %edi, %r8d
imull $0xc2b2ae35, %r8d, %r8d # imm = 0xC2B2AE35
movl %r8d, %edi
shrl $0x10, %edi
xorl %r8d, %edi
movl %eax, %r8d
shrl $0x10, %r8d
xorl %eax, %r8d
imull $0x85ebca6b, %r8d, %eax # imm = 0x85EBCA6B
movl %eax, %r8d
shrl $0xd, %r8d
xorl %eax, %r8d
imull $0xc2b2ae35, %r8d, %eax # imm = 0xC2B2AE35
movl %eax, %r8d
shrl $0x10, %r8d
xorl %eax, %r8d
addl %esi, %edx
addl %edi, %edx
addl %r8d, %edx
addl %edx, %esi
addl %edx, %edi
addl %edx, %r8d
movl %edx, (%rcx)
movl %esi, 0x4(%rcx)
movl %edi, 0x8(%rcx)
movl %r8d, 0xc(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq