// File: /workspace/github_cpp_makefile_star2_O2/BU-DiSC[P]BF-Shared-Hashing/hash/city.cc
// Function: CityHash128WithSeed(char const*, unsigned long, std::pair<unsigned long, unsigned long>)
uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) {
  if (len < 128) {
    return CityMurmur(s, len, seed);
  }

  // We expect len >= 128 to be the common case.  Keep 56 bytes of state:
  // v, w, x, y, and z.
  pair<uint64, uint64> v, w;
  uint64 x = Uint128Low64(seed);
  uint64 y = Uint128High64(seed);
  uint64 z = len * k1;
  v.first = Rotate(y ^ k1, 49) * k1 + Fetch64(s);
  v.second = Rotate(v.first, 42) * k1 + Fetch64(s + 8);
  w.first = Rotate(y + z, 35) * k1 + x;
  w.second = Rotate(x + Fetch64(s + 88), 53) * k1;

  // This is the same inner loop as CityHash64(), manually unrolled.
  do {
    x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
    y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
    x ^= w.second;
    y += v.first + Fetch64(s + 40);
    z = Rotate(z + w.first, 33) * k1;
    v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
    w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
    std::swap(z, x);
    s += 64;
    x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
    y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
    x ^= w.second;
    y += v.first + Fetch64(s + 40);
    z = Rotate(z + w.first, 33) * k1;
    v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
    w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
    std::swap(z, x);
    s += 64;
    len -= 128;
  } while (LIKELY(len >= 128));
  x += Rotate(v.first + z, 49) * k0;
  y = y * k0 + Rotate(w.second, 37);
  z = z * k0 + Rotate(w.first, 27);
  w.first *= 9;
  v.first *= k0;
  // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
  for (size_t tail_done = 0; tail_done < len; ) {
    tail_done += 32;
    y = Rotate(x + y, 42) * k0 + v.second;
    w.first += Fetch64(s + len - tail_done + 16);
    x = x * k0 + w.first;
    z += w.second + Fetch64(s + len - tail_done);
    w.second += v.first;
    v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
    v.first *= k0;
  }
  // At this point our 56 bytes of state should contain more than
  // enough information for a strong 128-bit hash.  We use two
  // different 56-byte-to-8-byte hashes to get a 16-byte final result.
  x = HashLen16(x, v.first);
  y = HashLen16(y + z, w.first);
  return uint128(HashLen16(x + v.second, w.second) + y,
                 HashLen16(x + w.second, y + v.second));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %rcx
movq %rdi, %rbp
movabsq $-0x4b6d499041670d8d, %rax # imm = 0xB492B66FBE98F273
cmpq $0x7f, %rsi
ja 0x21b8c
cmpq $0x10, %rcx
ja 0x21e17
imulq %rax, %r13
movq %r13, %r14
shrq $0x2f, %r14
xorq %r13, %r14
imulq %rax, %r14
imulq %rbx, %rax
movq %rax, %r12
movq %rbp, %rdi
movq %rcx, %rsi
movq %rcx, %r15
callq 0x219ba
movq %rax, %rsi
addq %r12, %rsi
movq %rsi, %rax
cmpq $0x8, %r15
jb 0x21b7a
movq (%rbp), %rax
addq %r14, %rax
movq %rax, %r15
shrq $0x2f, %r15
xorq %rax, %r15
jmp 0x21ea5
movq %rbx, %r12
xorq %rax, %r12
rolq $0xf, %r12
imulq %rax, %r12
addq (%rbp), %r12
movq %rcx, %r15
movq %r12, %r8
rolq $0x16, %r8
imulq %rax, %r15
imulq %rax, %r8
addq 0x8(%rbp), %r8
leaq (%r15,%rbx), %r14
rolq $0x1d, %r14
imulq %rax, %r14
movq 0x58(%rbp), %r9
addq %r13, %r9
rolq $0xb, %r9
addq %r13, %r14
imulq %rax, %r9
movq %rbp, 0x30(%rsp)
addq $0x40, %rbp
movq %rcx, 0x28(%rsp)
movq %rcx, %rsi
movq %rsi, 0x10(%rsp)
addq %r12, %r13
addq %rbx, %r13
addq -0x38(%rbp), %r13
leaq -0x40(%rbp), %rdi
rolq $0x1b, %r13
addq %r8, %rbx
addq -0x10(%rbp), %rbx
rolq $0x16, %rbx
movabsq $-0x4b6d499041670d8d, %rax # imm = 0xB492B66FBE98F273
imulq %rax, %r13
imulq %rax, %rbx
addq -0x18(%rbp), %r12
xorq %r9, %r13
addq %r14, %r15
rolq $0x1f, %r15
addq %rbx, %r12
imulq %rax, %r15
imulq %rax, %r8
addq %r13, %r14
movq %r8, %rsi
movq %r14, %rdx
movq %r9, %r14
callq 0x21aac
movq %rax, %rbx
movq %rdx, 0x8(%rsp)
leaq -0x20(%rbp), %rdi
addq %r15, %r14
movq -0x30(%rbp), %rdx
addq %r12, %rdx
movq %r14, %rsi
callq 0x21aac
addq %r12, %r15
addq %rbx, %r15
addq 0x8(%rbp), %r15
movq %rdx, %r14
rolq $0x1b, %r15
movq 0x8(%rsp), %rsi
addq %rsi, %r12
addq 0x30(%rbp), %r12
rolq $0x16, %r12
movabsq $-0x4b6d499041670d8d, %rcx # imm = 0xB492B66FBE98F273
imulq %rcx, %r15
imulq %rcx, %r12
addq 0x28(%rbp), %rbx
xorq %rdx, %r15
addq %rax, %r13
rolq $0x1f, %r13
addq %r12, %rbx
imulq %rcx, %r13
imulq %rcx, %rsi
leaq (%rax,%r15), %rdx
movq %rbp, %rdi
callq 0x21aac
movq %rax, %r12
movq %rdx, 0x18(%rsp)
leaq 0x20(%rbp), %rdi
addq %r13, %r14
movq 0x10(%rbp), %rdx
addq %rbx, %rdx
movq %r14, %rsi
callq 0x21aac
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rsi
movq %rax, %r14
movq %rdx, %r9
addq $-0x80, %rsi
subq $-0x80, %rbp
cmpq $0x7f, %rsi
ja 0x21be3
movabsq $-0x3c5a37a36834ced9, %rbp # imm = 0xC3A5C85C97CB3127
movq %r12, %rax
addq %r15, %rax
rolq $0xf, %rax
imulq %rbp, %rax
addq %r13, %rax
movq %rax, 0x8(%rsp)
imulq %rbp, %rbx
movq %r9, 0x10(%rsp)
movq %r9, %r13
rolq $0x1b, %r13
addq %rbx, %r13
leaq (%r14,%r14,8), %rax
movq %rax, 0x20(%rsp)
rolq $0x25, %r14
imulq %rbp, %r15
addq %r15, %r14
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax), %rbx
addq $-0x20, %rbx
xorl %ecx, %ecx
imulq %rbp, %r12
cmpq %rsi, %rcx
jae 0x21dcc
movq 0x8(%rsp), %rax
addq %rax, %r13
rolq $0x16, %r13
addq $0x20, %rcx
movq %rcx, 0x18(%rsp)
imulq %rbp, %r13
movq 0x20(%rsp), %rcx
addq 0x10(%rbx), %rcx
addq %r8, %r13
imulq %rbp, %rax
movq %rcx, 0x20(%rsp)
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
addq %rax, %r14
addq (%rbx), %r14
addq %r12, %rax
movq %rax, 0x10(%rsp)
addq %r14, %r12
movq %rbx, %rdi
movq %rsi, %r15
movq %r12, %rsi
movq %r8, %rdx
callq 0x21aac
movq 0x18(%rsp), %rcx
movq %r15, %rsi
movq %rax, %r12
movq %rdx, %r8
addq $-0x20, %rbx
jmp 0x21d52
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r8, %r15
callq 0x21a8f
movq %rax, %r12
addq %r14, %r13
movq %r13, %rdi
movq 0x20(%rsp), %rsi
callq 0x21a8f
movq %rax, %r14
leaq (%r12,%r15), %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x21a8f
movq %rax, %rbx
addq %r14, %rbx
addq %r13, %r12
addq %r15, %r14
movq %r12, %rdi
jmp 0x21ec4
movq %rax, %r15
movq -0x8(%rbp,%rcx), %rdi
addq %rax, %rdi
movq %r13, %rsi
movq %rcx, %r14
callq 0x21a8f
movq %rax, %r12
leaq (%rbx,%r14), %rdi
movq %rax, %rsi
addq -0x10(%rbp,%r14), %rsi
callq 0x21a8f
movq %r15, %rdi
movq %r14, %rdx
movq %rax, %r15
addq %r13, %rax
addq $0x10, %rdx
movq (%rbp), %rcx
imulq %rdi, %rcx
movq %rcx, %r14
shrq $0x2f, %r14
xorq %rcx, %r14
imulq %rdi, %r14
xorq %rax, %r14
imulq %rdi, %r14
xorq %r14, %rbx
movq 0x8(%rbp), %rax
imulq %rdi, %rax
movq %rax, %rsi
shrq $0x2f, %rsi
xorq %rax, %rsi
imulq %rdi, %rsi
xorq %r12, %rsi
imulq %rdi, %rsi
xorq %rsi, %r15
addq $0x10, %rbp
addq $-0x10, %rdx
movq %r14, %rax
movq %rsi, %r12
cmpq $0x20, %rdx
ja 0x21e51
movq %r14, %rdi
callq 0x21a8f
movq %rax, %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21a8f
movq %rax, %rbx
xorq %r14, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x21a8f
movq %rax, %rdx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq