public static long cityHash64()

in java/src/main/java/com/epam/deltix/containers/binaryarrayoptimizations/BinaryArrayOptimizationTotal.java [158:257]


    public static long cityHash64(long[] in, long off, long len) {
        if (len <= 32L) {
            if (len <= 16L) {
                return hashLen0To16(in, off, len);
            } else {
                return hashLen17To32(in, off, len);
            }
        } else if (len <= 64L) {
            return cityHashLen33To64(in, off, len);
        }

        long x = fetch64(in, off + len - 40L);
        long y = fetch64(in, off + len - 16L) + fetch64(in, off + len - 56L);
        long z = hashLen16(fetch64(in, off + len - 48L) + len,
                fetch64(in, off + len - 24L));

        long vFirst, vSecond, wFirst, wSecond;

        // This and following 3 blocks are produced by a single-click inline-function refactoring.
        // IntelliJ IDEA ftw
        // WeakHashLen32WithSeeds
        long a3 = len;
        long b3 = z;
        long w4 = fetch64(in, off + len - 64L);
        long x4 = fetch64(in, off + len - 64L + 8L);
        long y4 = fetch64(in, off + len - 64L + 16L);
        long z4 = fetch64(in, off + len - 64L + 24L);
        a3 += w4;
        b3 = rotateRight(b3 + a3 + z4, 21);
        long c3 = a3;
        a3 += x4 + y4;
        b3 += rotateRight(a3, 44);
        vFirst = a3 + z4;
        vSecond = b3 + c3;

        // WeakHashLen32WithSeeds
        long a2 = y + K1;
        long b2 = x;
        long w3 = fetch64(in, off + len - 32L);
        long x3 = fetch64(in, off + len - 32L + 8L);
        long y3 = fetch64(in, off + len - 32L + 16L);
        long z3 = fetch64(in, off + len - 32L + 24L);
        a2 += w3;
        b2 = rotateRight(b2 + a2 + z3, 21);
        long c2 = a2;
        a2 += x3 + y3;
        b2 += rotateRight(a2, 44);
        wFirst = a2 + z3;
        wSecond = b2 + c2;

        x = x * K1 + fetch64(in, off);

        len = (len - 1L) & (~63L);
        do {
            x = rotateRight(x + y + vFirst + fetch64(in, off + 8L), 37) * K1;
            y = rotateRight(y + vSecond + fetch64(in, off + 48L), 42) * K1;
            x ^= wSecond;
            y += vFirst + fetch64(in, off + 40L);
            z = rotateRight(z + wFirst, 33) * K1;

            // WeakHashLen32WithSeeds
            long a1 = vSecond * K1;
            long b1 = x + wFirst;
            long w2 = fetch64(in, off);
            long x2 = fetch64(in, off + 8L);
            long y2 = fetch64(in, off + 16L);
            long z2 = fetch64(in, off + 24L);
            a1 += w2;
            b1 = rotateRight(b1 + a1 + z2, 21);
            long c1 = a1;
            a1 += x2 + y2;
            b1 += rotateRight(a1, 44);
            vFirst = a1 + z2;
            vSecond = b1 + c1;

            // WeakHashLen32WithSeeds
            long a = z + wSecond;
            long b = y + fetch64(in, off + 16L);
            long w1 = fetch64(in, off + 32L);
            long x1 = fetch64(in, off + 32L + 8L);
            long y1 = fetch64(in, off + 32L + 16L);
            long z1 = fetch64(in, off + 32L + 24L);
            a += w1;
            b = rotateRight(b + a + z1, 21);
            long c = a;
            a += x1 + y1;
            b += rotateRight(a, 44);
            wFirst = a + z1;
            wSecond = b + c;

            long tmp = x;
            x = z;
            z = tmp;

            len -= 64L;
            off += 64L;
        } while (len != 0);
        return hashLen16(hashLen16(vFirst, wFirst) + shiftMix(y) * K1 + z,
                hashLen16(vSecond, wSecond) + x);
    }