public static long spooky4(final BitVector bv,final long seed){
  long h0, h1, h2, h3;
  h0=seed;
  h1=seed;
  h2=ARBITRARY_BITS;
  h3=ARBITRARY_BITS;
  final int length=(int)bv.length();
  int remaining=length;
  int pos=0;
  while (remaining >= Long.SIZE * 4) {
    h2+=bv.getLong(pos + 0 * Long.SIZE,pos + 1 * Long.SIZE);
    h3+=bv.getLong(pos + 1 * Long.SIZE,pos + 2 * Long.SIZE);
    h2=Long.rotateLeft(h2,50);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,52);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,30);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,41);
    h1+=h2;
    h3^=h1;
    h2=Long.rotateLeft(h2,54);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,48);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,38);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,37);
    h1+=h2;
    h3^=h1;
    h2=Long.rotateLeft(h2,62);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,34);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,5);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,36);
    h1+=h2;
    h3^=h1;
    h0+=bv.getLong(pos + 2 * Long.SIZE,pos + 3 * Long.SIZE);
    h1+=bv.getLong(pos + 3 * Long.SIZE,pos + 4 * Long.SIZE);
    remaining-=4 * Long.SIZE;
    pos+=4 * Long.SIZE;
  }
  if (remaining >= Long.SIZE * 2) {
    h2+=bv.getLong(pos + 0 * Long.SIZE,pos + 1 * Long.SIZE);
    h3+=bv.getLong(pos + 1 * Long.SIZE,pos + 2 * Long.SIZE);
    remaining-=2 * Long.SIZE;
    pos+=2 * Long.SIZE;
    h2=Long.rotateLeft(h2,50);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,52);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,30);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,41);
    h1+=h2;
    h3^=h1;
    h2=Long.rotateLeft(h2,54);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,48);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,38);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,37);
    h1+=h2;
    h3^=h1;
    h2=Long.rotateLeft(h2,62);
    h2+=h3;
    h0^=h2;
    h3=Long.rotateLeft(h3,34);
    h3+=h0;
    h1^=h3;
    h0=Long.rotateLeft(h0,5);
    h0+=h1;
    h2^=h0;
    h1=Long.rotateLeft(h1,36);
    h1+=h2;
    h3^=h1;
  }
  if (remaining > Long.SIZE) {
    h2+=bv.getLong(pos + 0 * Long.SIZE,pos + 1 * Long.SIZE);
    h3+=bv.getLong(pos + 1 * Long.SIZE,length);
  }
 else   if (remaining > 0) {
    h2+=bv.getLong(pos,length);
  }
 else {
    h2+=ARBITRARY_BITS;
    h3+=ARBITRARY_BITS;
  }
  h0+=length;
  h3^=h2;
  h2=Long.rotateLeft(h2,15);
  h3+=h2;
  h0^=h3;
  h3=Long.rotateLeft(h3,52);
  h0+=h3;
  h1^=h0;
  h0=Long.rotateLeft(h0,26);
  h1+=h0;
  h2^=h1;
  h1=Long.rotateLeft(h1,51);
  h2+=h1;
  h3^=h2;
  h2=Long.rotateLeft(h2,28);
  h3+=h2;
  h0^=h3;
  h3=Long.rotateLeft(h3,9);
  h0+=h3;
  h1^=h0;
  h0=Long.rotateLeft(h0,47);
  h1+=h0;
  h2^=h1;
  h1=Long.rotateLeft(h1,54);
  h2+=h1;
  h3^=h2;
  h2=Long.rotateLeft(h2,32);
  h3+=h2;
  h0^=h3;
  h3=Long.rotateLeft(h3,25);
  h0+=h3;
  h1^=h0;
  h0=Long.rotateLeft(h0,63);
  h1+=h0;
  return h0;
}

public static long spooky4 ( final BitVector bv , final long seed ) { long h0 , h1 , h2 , h3 ; h0 = seed ; h1 = seed ; h2 = ARBITRARY_BITS ; h3 = ARBITRARY_BITS ; final int length = ( int ) bv . length ( ) ; int remaining = length ; int pos = 0 ; while ( remaining >= Long . SIZE * 4 ) { h2 += bv . getLong ( pos + 0 * Long . SIZE , pos + 1 * Long . SIZE ) ; h3 += bv . getLong ( pos + 1 * Long . SIZE , pos + 2 * Long . SIZE ) ; h2 = Long . rotateLeft ( h2 , 50 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 52 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 30 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 41 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 54 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 48 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 38 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 37 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 62 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 34 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 5 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 36 ) ; h1 += h2 ; h3 ^= h1 ; h0 += bv . getLong ( pos + 2 * Long . SIZE , pos + 3 * Long . SIZE ) ; h1 += bv . getLong ( pos + 3 * Long . SIZE , pos + 4 * Long . SIZE ) ; remaining -= 4 * Long . SIZE ; pos += 4 * Long . SIZE ; } if ( remaining >= Long . SIZE * 2 ) { h2 += bv . getLong ( pos + 0 * Long . SIZE , pos + 1 * Long . SIZE ) ; h3 += bv . getLong ( pos + 1 * Long . SIZE , pos + 2 * Long . SIZE ) ; remaining -= 2 * Long . SIZE ; pos += 2 * Long . SIZE ; h2 = Long . rotateLeft ( h2 , 50 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 52 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 30 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 41 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 54 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 48 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 38 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 37 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 62 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 34 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 5 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 36 ) ; h1 += h2 ; h3 ^= h1 ; } if ( remaining > Long . SIZE ) { h2 += bv . getLong ( pos + 0 * Long . SIZE , pos + 1 * Long . SIZE ) ; h3 += bv . getLong ( pos + 1 * Long . SIZE , length ) ; } else if ( remaining > 0 ) { h2 += bv . getLong ( pos , length ) ; } else { h2 += ARBITRARY_BITS ; h3 += ARBITRARY_BITS ; } h0 += length ; h3 ^= h2 ; h2 = Long . rotateLeft ( h2 , 15 ) ; h3 += h2 ; h0 ^= h3 ; h3 = Long . rotateLeft ( h3 , 52 ) ; h0 += h3 ; h1 ^= h0 ; h0 = Long . rotateLeft ( h0 , 26 ) ; h1 += h0 ; h2 ^= h1 ; h1 = Long . rotateLeft ( h1 , 51 ) ; h2 += h1 ; h3 ^= h2 ; h2 = Long . rotateLeft ( h2 , 28 ) ; h3 += h2 ; h0 ^= h3 ; h3 = Long . rotateLeft ( h3 , 9 ) ; h0 += h3 ; h1 ^= h0 ; h0 = Long . rotateLeft ( h0 , 47 ) ; h1 += h0 ; h2 ^= h1 ; h1 = Long . rotateLeft ( h1 , 54 ) ; h2 += h1 ; h3 ^= h2 ; h2 = Long . rotateLeft ( h2 , 32 ) ; h3 += h2 ; h0 ^= h3 ; h3 = Long . rotateLeft ( h3 , 25 ) ; h0 += h3 ; h1 ^= h0 ; h0 = Long . rotateLeft ( h0 , 63 ) ; h1 += h0 ; return h0 ; }
spookyhash 4 - word - state ( up to four values produced ) .
