1// Copyright (c) 2014 Google, Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20//
21// FarmHash, by Geoff Pike
22
23#include "farmhash.h"
24// FARMHASH ASSUMPTIONS: Modify as needed, or use -DFARMHASH_ASSUME_SSE42 etc.
25// Note that if you use -DFARMHASH_ASSUME_SSE42 you likely need -msse42
26// (or its equivalent for your compiler); if you use -DFARMHASH_ASSUME_AESNI
27// you likely need -maes (or its equivalent for your compiler).
28
29#ifdef FARMHASH_ASSUME_SSSE3
30#undef FARMHASH_ASSUME_SSSE3
31#define FARMHASH_ASSUME_SSSE3 1
32#endif
33
34#ifdef FARMHASH_ASSUME_SSE41
35#undef FARMHASH_ASSUME_SSE41
36#define FARMHASH_ASSUME_SSE41 1
37#endif
38
39#ifdef FARMHASH_ASSUME_SSE42
40#undef FARMHASH_ASSUME_SSE42
41#define FARMHASH_ASSUME_SSE42 1
42#endif
43
44#ifdef FARMHASH_ASSUME_AESNI
45#undef FARMHASH_ASSUME_AESNI
46#define FARMHASH_ASSUME_AESNI 1
47#endif
48
49#ifdef FARMHASH_ASSUME_AVX
50#undef FARMHASH_ASSUME_AVX
51#define FARMHASH_ASSUME_AVX 1
52#endif
53
54#if !defined(FARMHASH_CAN_USE_CXX11) && defined(LANG_CXX11)
55#define FARMHASH_CAN_USE_CXX11 1
56#else
57#undef FARMHASH_CAN_USE_CXX11
58#define FARMHASH_CAN_USE_CXX11 0
59#endif
60
61// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured
62
63#ifndef FARMHASH_DIE_IF_MISCONFIGURED
64#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
65#endif
66
67// FARMHASH PORTABILITY LAYER: "static inline" or similar
68
69#ifndef STATIC_INLINE
70#define STATIC_INLINE static inline
71#endif
72
73// FARMHASH PORTABILITY LAYER: LIKELY and UNLIKELY
74
75#if !defined(LIKELY)
76#if defined(FARMHASH_NO_BUILTIN_EXPECT) || (defined(FARMHASH_OPTIONAL_BUILTIN_EXPECT) && !defined(HAVE_BUILTIN_EXPECT))
77#define LIKELY(x) (x)
78#else
79#define LIKELY(x) (__builtin_expect(!!(x), 1))
80#endif
81#endif
82
83#undef UNLIKELY
84#define UNLIKELY(x) !LIKELY(!(x))
85
86// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
87
88#ifdef WORDS_BIGENDIAN
89#undef FARMHASH_BIG_ENDIAN
90#define FARMHASH_BIG_ENDIAN 1
91#endif
92
93#if defined(FARMHASH_LITTLE_ENDIAN) && defined(FARMHASH_BIG_ENDIAN)
94#error
95#endif
96
97#if !defined(FARMHASH_LITTLE_ENDIAN) && !defined(FARMHASH_BIG_ENDIAN)
98#define FARMHASH_UNKNOWN_ENDIAN 1
99#endif
100
101#if !defined(bswap_32) || !defined(bswap_64)
102#undef bswap_32
103#undef bswap_64
104
105#if defined(HAVE_BUILTIN_BSWAP) || defined(__clang__) || \
106 (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
107 __GNUC__ >= 5))
108// Easy case for bswap: no header file needed.
109#define bswap_32(x) __builtin_bswap32(x)
110#define bswap_64(x) __builtin_bswap64(x)
111#endif
112
113#endif
114
115#if defined(FARMHASH_UNKNOWN_ENDIAN) || !defined(bswap_64)
116
117#ifdef _MSC_VER
118
119#undef bswap_32
120#undef bswap_64
121#define bswap_32(x) _byteswap_ulong(x)
122#define bswap_64(x) _byteswap_uint64(x)
123
124#elif defined(__APPLE__)
125
126// Mac OS X / Darwin features
127#include <libkern/OSByteOrder.h>
128#undef bswap_32
129#undef bswap_64
130#define bswap_32(x) OSSwapInt32(x)
131#define bswap_64(x) OSSwapInt64(x)
132
133#elif defined(__sun) || defined(sun)
134
135#include <sys/byteorder.h>
136#undef bswap_32
137#undef bswap_64
138#define bswap_32(x) BSWAP_32(x)
139#define bswap_64(x) BSWAP_64(x)
140
141#elif defined(__FreeBSD__)
142
143#include <sys/endian.h>
144#undef bswap_32
145#undef bswap_64
146#define bswap_32(x) bswap32(x)
147#define bswap_64(x) bswap64(x)
148
149#elif defined(__OpenBSD__)
150
151#include <sys/types.h>
152#undef bswap_32
153#undef bswap_64
154#define bswap_32(x) swap32(x)
155#define bswap_64(x) swap64(x)
156
157#elif defined(__NetBSD__)
158
159#include <sys/types.h>
160#include <machine/bswap.h>
161#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
162#undef bswap_32
163#undef bswap_64
164#define bswap_32(x) bswap32(x)
165#define bswap_64(x) bswap64(x)
166#endif
167
168#else
169
170#undef bswap_32
171#undef bswap_64
172#include <byteswap.h>
173
174#endif
175
176#ifdef WORDS_BIGENDIAN
177#define FARMHASH_BIG_ENDIAN 1
178#endif
179
180#endif
181
182#ifdef FARMHASH_BIG_ENDIAN
183#define uint32_in_expected_order(x) (bswap_32(x))
184#define uint64_in_expected_order(x) (bswap_64(x))
185#else
186#define uint32_in_expected_order(x) (x)
187#define uint64_in_expected_order(x) (x)
188#endif
189
190namespace NAMESPACE_FOR_HASH_FUNCTIONS {
191
192STATIC_INLINE uint64_t Fetch64(const char *p) {
193 uint64_t result;
194 memcpy(&result, p, sizeof(result));
195 return uint64_in_expected_order(result);
196}
197
198STATIC_INLINE uint32_t Fetch32(const char *p) {
199 uint32_t result;
200 memcpy(&result, p, sizeof(result));
201 return uint32_in_expected_order(result);
202}
203
204STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
205STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
206
207// FARMHASH PORTABILITY LAYER: bitwise rot
208
209STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
210 // Avoid shifting by 32: doing so yields an undefined result.
211 return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
212}
213
214STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
215 // Avoid shifting by 64: doing so yields an undefined result.
216 return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
217}
218
219#if defined(_MSC_VER) && defined(FARMHASH_ROTR)
220
221STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
222 return sizeof(unsigned long) == sizeof(val) ?
223 _lrotr(val, shift) :
224 BasicRotate32(val, shift);
225}
226
227STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
228 return sizeof(unsigned long) == sizeof(val) ?
229 _lrotr(val, shift) :
230 BasicRotate64(val, shift);
231}
232
233#else
234
235STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
236 return BasicRotate32(val, shift);
237}
238STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
239 return BasicRotate64(val, shift);
240}
241
242#endif
243
244} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
245
246// FARMHASH PORTABILITY LAYER: debug mode or max speed?
247// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
248
249#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
250#define FARMHASH_DEBUG 1
251#endif
252
253#undef debug_mode
254#if FARMHASH_DEBUG
255#define debug_mode 1
256#else
257#define debug_mode 0
258#endif
259
260// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
261
262#undef x86_64
263#if defined (__x86_64) || defined (__x86_64__)
264#define x86_64 1
265#else
266#define x86_64 0
267#endif
268
269#undef x86
270#if defined(__i386__) || defined(__i386) || defined(__X86__)
271#define x86 1
272#else
273#define x86 x86_64
274#endif
275
276#if !defined(is_64bit)
277#define is_64bit (x86_64 || (sizeof(void*) == 8))
278#endif
279
280#undef can_use_ssse3
281#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
282
283#include <immintrin.h>
284#define can_use_ssse3 1
285// Now we can use _mm_hsub_epi16 and so on.
286
287#else
288#define can_use_ssse3 0
289#endif
290
291#undef can_use_sse41
292#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
293
294#include <immintrin.h>
295#define can_use_sse41 1
296// Now we can use _mm_insert_epi64 and so on.
297
298#else
299#define can_use_sse41 0
300#endif
301
302#undef can_use_sse42
303#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
304
305#include <nmmintrin.h>
306#define can_use_sse42 1
307// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
308
309#else
310#define can_use_sse42 0
311#endif
312
313#undef can_use_aesni
314#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
315
316#include <wmmintrin.h>
317#define can_use_aesni 1
318// Now we can use _mm_aesimc_si128 and so on.
319
320#else
321#define can_use_aesni 0
322#endif
323
324#undef can_use_avx
325#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
326
327#include <immintrin.h>
328#define can_use_avx 1
329
330#else
331#define can_use_avx 0
332#endif
333
334#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
335STATIC_INLINE __m128i Fetch128(const char* s) {
336 return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
337}
338#endif
339// Building blocks for hash functions
340
341// std::swap() was in <algorithm> but is in <utility> from C++11 on.
342#if !FARMHASH_CAN_USE_CXX11
343#include <algorithm>
344#endif
345
346#undef PERMUTE3
347#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
348
349namespace NAMESPACE_FOR_HASH_FUNCTIONS {
350
351// Some primes between 2^63 and 2^64 for various uses.
352static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
353static const uint64_t k1 = 0xb492b66fbe98f273ULL;
354static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
355
356// Magic numbers for 32-bit hashing. Copied from Murmur3.
357static const uint32_t c1 = 0xcc9e2d51;
358static const uint32_t c2 = 0x1b873593;
359
360// A 32-bit to 32-bit integer hash copied from Murmur3.
361STATIC_INLINE uint32_t fmix(uint32_t h)
362{
363 h ^= h >> 16;
364 h *= 0x85ebca6b;
365 h ^= h >> 13;
366 h *= 0xc2b2ae35;
367 h ^= h >> 16;
368 return h;
369}
370
371STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
372 // Helper from Murmur3 for combining two 32-bit values.
373 a *= c1;
374 a = Rotate32(a, 17);
375 a *= c2;
376 h ^= a;
377 h = Rotate32(h, 19);
378 return h * 5 + 0xe6546b64;
379}
380
381template <typename T> STATIC_INLINE T DebugTweak(T x) {
382 if (debug_mode) {
383 if (sizeof(x) == 4) {
384 x = ~Bswap32(x * c1);
385 } else {
386 x = ~Bswap64(x * k1);
387 }
388 }
389 return x;
390}
391
392template <> uint128_t DebugTweak(uint128_t x) {
393 if (debug_mode) {
394 uint64_t y = DebugTweak(Uint128Low64(x));
395 uint64_t z = DebugTweak(Uint128High64(x));
396 y += z;
397 z += y;
398 x = Uint128(y, z * k1);
399 }
400 return x;
401}
402
403} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
404
405using namespace std;
406using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
407namespace farmhashna {
408#undef Fetch
409#define Fetch Fetch64
410
411#undef Rotate
412#define Rotate Rotate64
413
414#undef Bswap
415#define Bswap Bswap64
416
417STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
418 return val ^ (val >> 47);
419}
420
421STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
422 return Hash128to64(Uint128(u, v));
423}
424
425STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
426 // Murmur-inspired hashing.
427 uint64_t a = (u ^ v) * mul;
428 a ^= (a >> 47);
429 uint64_t b = (v ^ a) * mul;
430 b ^= (b >> 47);
431 b *= mul;
432 return b;
433}
434
435STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
436 if (len >= 8) {
437 uint64_t mul = k2 + len * 2;
438 uint64_t a = Fetch(s) + k2;
439 uint64_t b = Fetch(s + len - 8);
440 uint64_t c = Rotate(b, 37) * mul + a;
441 uint64_t d = (Rotate(a, 25) + b) * mul;
442 return HashLen16(c, d, mul);
443 }
444 if (len >= 4) {
445 uint64_t mul = k2 + len * 2;
446 uint64_t a = Fetch32(s);
447 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
448 }
449 if (len > 0) {
450 uint8_t a = s[0];
451 uint8_t b = s[len >> 1];
452 uint8_t c = s[len - 1];
453 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
454 uint32_t z = len + (static_cast<uint32_t>(c) << 2);
455 return ShiftMix(y * k2 ^ z * k0) * k2;
456 }
457 return k2;
458}
459
460// This probably works well for 16-byte strings as well, but it may be overkill
461// in that case.
462STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
463 uint64_t mul = k2 + len * 2;
464 uint64_t a = Fetch(s) * k1;
465 uint64_t b = Fetch(s + 8);
466 uint64_t c = Fetch(s + len - 8) * mul;
467 uint64_t d = Fetch(s + len - 16) * k2;
468 return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
469 a + Rotate(b + k2, 18) + c, mul);
470}
471
472// Return a 16-byte hash for 48 bytes. Quick and dirty.
473// Callers do best to use "random-looking" values for a and b.
474STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
475 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
476 a += w;
477 b = Rotate(b + a + z, 21);
478 uint64_t c = a;
479 a += x;
480 a += y;
481 b += Rotate(a, 44);
482 return make_pair(a + z, b + c);
483}
484
485// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
486STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
487 const char* s, uint64_t a, uint64_t b) {
488 return WeakHashLen32WithSeeds(Fetch(s),
489 Fetch(s + 8),
490 Fetch(s + 16),
491 Fetch(s + 24),
492 a,
493 b);
494}
495
496// Return an 8-byte hash for 33 to 64 bytes.
497STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
498 uint64_t mul = k2 + len * 2;
499 uint64_t a = Fetch(s) * k2;
500 uint64_t b = Fetch(s + 8);
501 uint64_t c = Fetch(s + len - 8) * mul;
502 uint64_t d = Fetch(s + len - 16) * k2;
503 uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
504 uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
505 uint64_t e = Fetch(s + 16) * mul;
506 uint64_t f = Fetch(s + 24);
507 uint64_t g = (y + Fetch(s + len - 32)) * mul;
508 uint64_t h = (z + Fetch(s + len - 24)) * mul;
509 return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
510 e + Rotate(f + a, 18) + g, mul);
511}
512
513uint64_t Hash64(const char *s, size_t len) {
514 const uint64_t seed = 81;
515 if (len <= 32) {
516 if (len <= 16) {
517 return HashLen0to16(s, len);
518 } else {
519 return HashLen17to32(s, len);
520 }
521 } else if (len <= 64) {
522 return HashLen33to64(s, len);
523 }
524
525 // For strings over 64 bytes we loop. Internal state consists of
526 // 56 bytes: v, w, x, y, and z.
527 uint64_t x = seed;
528 uint64_t y = seed * k1 + 113;
529 uint64_t z = ShiftMix(y * k2 + 113) * k2;
530 pair<uint64_t, uint64_t> v = make_pair(0, 0);
531 pair<uint64_t, uint64_t> w = make_pair(0, 0);
532 x = x * k2 + Fetch(s);
533
534 // Set end so that after the loop we have 1 to 64 bytes left to process.
535 const char* end = s + ((len - 1) / 64) * 64;
536 const char* last64 = end + ((len - 1) & 63) - 63;
537 assert(s + len - 64 == last64);
538 do {
539 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
540 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
541 x ^= w.second;
542 y += v.first + Fetch(s + 40);
543 z = Rotate(z + w.first, 33) * k1;
544 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
545 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
546 std::swap(z, x);
547 s += 64;
548 } while (s != end);
549 uint64_t mul = k1 + ((z & 0xff) << 1);
550 // Make s point to the last 64 bytes of input.
551 s = last64;
552 w.first += ((len - 1) & 63);
553 v.first += w.first;
554 w.first += v.first;
555 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
556 y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
557 x ^= w.second * 9;
558 y += v.first * 9 + Fetch(s + 40);
559 z = Rotate(z + w.first, 33) * mul;
560 v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
561 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
562 std::swap(z, x);
563 return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
564 HashLen16(v.second, w.second, mul) + x,
565 mul);
566}
567
568uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
569
570uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
571 return Hash64WithSeeds(s, len, k2, seed);
572}
573
574uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
575 return HashLen16(Hash64(s, len) - seed0, seed1);
576}
577} // namespace farmhashna
578namespace farmhashuo {
579#undef Fetch
580#define Fetch Fetch64
581
582#undef Rotate
583#define Rotate Rotate64
584
585STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
586 uint64_t a = (x ^ y) * mul;
587 a ^= (a >> 47);
588 uint64_t b = (y ^ a) * mul;
589 return Rotate(b, r) * mul;
590}
591
592uint64_t Hash64WithSeeds(const char *s, size_t len,
593 uint64_t seed0, uint64_t seed1) {
594 if (len <= 64) {
595 return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
596 }
597
598 // For strings over 64 bytes we loop. Internal state consists of
599 // 64 bytes: u, v, w, x, y, and z.
600 uint64_t x = seed0;
601 uint64_t y = seed1 * k2 + 113;
602 uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
603 pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
604 pair<uint64_t, uint64_t> w = make_pair(0, 0);
605 uint64_t u = x - z;
606 x *= k2;
607 uint64_t mul = k2 + (u & 0x82);
608
609 // Set end so that after the loop we have 1 to 64 bytes left to process.
610 const char* end = s + ((len - 1) / 64) * 64;
611 const char* last64 = end + ((len - 1) & 63) - 63;
612 assert(s + len - 64 == last64);
613 do {
614 uint64_t a0 = Fetch(s);
615 uint64_t a1 = Fetch(s + 8);
616 uint64_t a2 = Fetch(s + 16);
617 uint64_t a3 = Fetch(s + 24);
618 uint64_t a4 = Fetch(s + 32);
619 uint64_t a5 = Fetch(s + 40);
620 uint64_t a6 = Fetch(s + 48);
621 uint64_t a7 = Fetch(s + 56);
622 x += a0 + a1;
623 y += a2;
624 z += a3;
625 v.first += a4;
626 v.second += a5 + a1;
627 w.first += a6;
628 w.second += a7;
629
630 x = Rotate(x, 26);
631 x *= 9;
632 y = Rotate(y, 29);
633 z *= mul;
634 v.first = Rotate(v.first, 33);
635 v.second = Rotate(v.second, 30);
636 w.first ^= x;
637 w.first *= 9;
638 z = Rotate(z, 32);
639 z += w.second;
640 w.second += z;
641 z *= 9;
642 std::swap(u, y);
643
644 z += a0 + a6;
645 v.first += a2;
646 v.second += a3;
647 w.first += a4;
648 w.second += a5 + a6;
649 x += a1;
650 y += a7;
651
652 y += v.first;
653 v.first += x - y;
654 v.second += w.first;
655 w.first += v.second;
656 w.second += x - y;
657 x += w.second;
658 w.second = Rotate(w.second, 34);
659 std::swap(u, z);
660 s += 64;
661 } while (s != end);
662 // Make s point to the last 64 bytes of input.
663 s = last64;
664 u *= 9;
665 v.second = Rotate(v.second, 28);
666 v.first = Rotate(v.first, 20);
667 w.first += ((len - 1) & 63);
668 u += y;
669 y += u;
670 x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
671 y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
672 x ^= w.second * 9;
673 y += v.first + Fetch(s + 40);
674 z = Rotate(z + w.first, 33) * mul;
675 v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
676 w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
677 return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
678 H(v.second + y, w.second + z, k2, 30) ^ x,
679 k2,
680 31);
681}
682
683uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
684 return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
685 Hash64WithSeeds(s, len, 0, seed);
686}
687
688uint64_t Hash64(const char *s, size_t len) {
689 return len <= 64 ? farmhashna::Hash64(s, len) :
690 Hash64WithSeeds(s, len, 81, 0);
691}
692} // namespace farmhashuo
693namespace farmhashxo {
694#undef Fetch
695#define Fetch Fetch64
696
697#undef Rotate
698#define Rotate Rotate64
699
700STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
701 uint64_t seed0 = 0, uint64_t seed1 = 0) {
702 uint64_t a = Fetch(s) * k1;
703 uint64_t b = Fetch(s + 8);
704 uint64_t c = Fetch(s + len - 8) * mul;
705 uint64_t d = Fetch(s + len - 16) * k2;
706 uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
707 uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
708 a = farmhashna::ShiftMix((u ^ v) * mul);
709 b = farmhashna::ShiftMix((v ^ a) * mul);
710 return b;
711}
712
713// Return an 8-byte hash for 33 to 64 bytes.
714STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
715 uint64_t mul0 = k2 - 30;
716 uint64_t mul1 = k2 - 30 + 2 * len;
717 uint64_t h0 = H32(s, 32, mul0);
718 uint64_t h1 = H32(s + len - 32, 32, mul1);
719 return ((h1 * mul1) + h0) * mul1;
720}
721
722// Return an 8-byte hash for 65 to 96 bytes.
723STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
724 uint64_t mul0 = k2 - 114;
725 uint64_t mul1 = k2 - 114 + 2 * len;
726 uint64_t h0 = H32(s, 32, mul0);
727 uint64_t h1 = H32(s + 32, 32, mul1);
728 uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
729 return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
730}
731
732uint64_t Hash64(const char *s, size_t len) {
733 if (len <= 32) {
734 if (len <= 16) {
735 return farmhashna::HashLen0to16(s, len);
736 } else {
737 return farmhashna::HashLen17to32(s, len);
738 }
739 } else if (len <= 64) {
740 return HashLen33to64(s, len);
741 } else if (len <= 96) {
742 return HashLen65to96(s, len);
743 } else if (len <= 256) {
744 return farmhashna::Hash64(s, len);
745 } else {
746 return farmhashuo::Hash64(s, len);
747 }
748}
749
750uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
751 return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
752}
753
754uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
755 return farmhashuo::Hash64WithSeed(s, len, seed);
756}
757} // namespace farmhashxo
758namespace farmhashte {
759#if !can_use_sse41 || !x86_64
760
761uint64_t Hash64(const char *s, size_t len) {
762 FARMHASH_DIE_IF_MISCONFIGURED;
763 return s == NULL ? 0 : len;
764}
765
766uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
767 FARMHASH_DIE_IF_MISCONFIGURED;
768 return seed + Hash64(s, len);
769}
770
771uint64_t Hash64WithSeeds(const char *s, size_t len,
772 uint64_t seed0, uint64_t seed1) {
773 FARMHASH_DIE_IF_MISCONFIGURED;
774 return seed0 + seed1 + Hash64(s, len);
775}
776
777#else
778
779#undef Fetch
780#define Fetch Fetch64
781
782#undef Rotate
783#define Rotate Rotate64
784
785#undef Bswap
786#define Bswap Bswap64
787
788// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
789STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
790STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
791STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
792STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
793
794// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
795// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
796STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
797 uint64_t seed0, uint64_t seed1) {
798 const __m128i kShuf =
799 _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
800 const __m128i kMult =
801 _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
802 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
803 uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
804 uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
805 __m128i d0 = _mm_cvtsi64_si128(seed0);
806 __m128i d1 = _mm_cvtsi64_si128(seed1);
807 __m128i d2 = Shuf(kShuf, d0);
808 __m128i d3 = Shuf(kShuf, d1);
809 __m128i d4 = Xor(d0, d1);
810 __m128i d5 = Xor(d1, d2);
811 __m128i d6 = Xor(d2, d4);
812 __m128i d7 = _mm_set1_epi32(seed2 >> 32);
813 __m128i d8 = Mul(kMult, d2);
814 __m128i d9 = _mm_set1_epi32(seed3 >> 32);
815 __m128i d10 = _mm_set1_epi32(seed3);
816 __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
817 const char* end = s + (n & ~static_cast<size_t>(255));
818 do {
819 __m128i z;
820 z = Fetch128(s);
821 d0 = Add(d0, z);
822 d1 = Shuf(kShuf, d1);
823 d2 = Xor(d2, d0);
824 d4 = Xor(d4, z);
825 d4 = Xor(d4, d1);
826 std::swap(d0, d6);
827 z = Fetch128(s + 16);
828 d5 = Add(d5, z);
829 d6 = Shuf(kShuf, d6);
830 d8 = Shuf(kShuf, d8);
831 d7 = Xor(d7, d5);
832 d0 = Xor(d0, z);
833 d0 = Xor(d0, d6);
834 std::swap(d5, d11);
835 z = Fetch128(s + 32);
836 d1 = Add(d1, z);
837 d2 = Shuf(kShuf, d2);
838 d4 = Shuf(kShuf, d4);
839 d5 = Xor(d5, z);
840 d5 = Xor(d5, d2);
841 std::swap(d10, d4);
842 z = Fetch128(s + 48);
843 d6 = Add(d6, z);
844 d7 = Shuf(kShuf, d7);
845 d0 = Shuf(kShuf, d0);
846 d8 = Xor(d8, d6);
847 d1 = Xor(d1, z);
848 d1 = Add(d1, d7);
849 z = Fetch128(s + 64);
850 d2 = Add(d2, z);
851 d5 = Shuf(kShuf, d5);
852 d4 = Add(d4, d2);
853 d6 = Xor(d6, z);
854 d6 = Xor(d6, d11);
855 std::swap(d8, d2);
856 z = Fetch128(s + 80);
857 d7 = Xor(d7, z);
858 d8 = Shuf(kShuf, d8);
859 d1 = Shuf(kShuf, d1);
860 d0 = Add(d0, d7);
861 d2 = Add(d2, z);
862 d2 = Add(d2, d8);
863 std::swap(d1, d7);
864 z = Fetch128(s + 96);
865 d4 = Shuf(kShuf, d4);
866 d6 = Shuf(kShuf, d6);
867 d8 = Mul(kMult, d8);
868 d5 = Xor(d5, d11);
869 d7 = Xor(d7, z);
870 d7 = Add(d7, d4);
871 std::swap(d6, d0);
872 z = Fetch128(s + 112);
873 d8 = Add(d8, z);
874 d0 = Shuf(kShuf, d0);
875 d2 = Shuf(kShuf, d2);
876 d1 = Xor(d1, d8);
877 d10 = Xor(d10, z);
878 d10 = Xor(d10, d0);
879 std::swap(d11, d5);
880 z = Fetch128(s + 128);
881 d4 = Add(d4, z);
882 d5 = Shuf(kShuf, d5);
883 d7 = Shuf(kShuf, d7);
884 d6 = Add(d6, d4);
885 d8 = Xor(d8, z);
886 d8 = Xor(d8, d5);
887 std::swap(d4, d10);
888 z = Fetch128(s + 144);
889 d0 = Add(d0, z);
890 d1 = Shuf(kShuf, d1);
891 d2 = Add(d2, d0);
892 d4 = Xor(d4, z);
893 d4 = Xor(d4, d1);
894 z = Fetch128(s + 160);
895 d5 = Add(d5, z);
896 d6 = Shuf(kShuf, d6);
897 d8 = Shuf(kShuf, d8);
898 d7 = Xor(d7, d5);
899 d0 = Xor(d0, z);
900 d0 = Xor(d0, d6);
901 std::swap(d2, d8);
902 z = Fetch128(s + 176);
903 d1 = Add(d1, z);
904 d2 = Shuf(kShuf, d2);
905 d4 = Shuf(kShuf, d4);
906 d5 = Mul(kMult, d5);
907 d5 = Xor(d5, z);
908 d5 = Xor(d5, d2);
909 std::swap(d7, d1);
910 z = Fetch128(s + 192);
911 d6 = Add(d6, z);
912 d7 = Shuf(kShuf, d7);
913 d0 = Shuf(kShuf, d0);
914 d8 = Add(d8, d6);
915 d1 = Xor(d1, z);
916 d1 = Xor(d1, d7);
917 std::swap(d0, d6);
918 z = Fetch128(s + 208);
919 d2 = Add(d2, z);
920 d5 = Shuf(kShuf, d5);
921 d4 = Xor(d4, d2);
922 d6 = Xor(d6, z);
923 d6 = Xor(d6, d9);
924 std::swap(d5, d11);
925 z = Fetch128(s + 224);
926 d7 = Add(d7, z);
927 d8 = Shuf(kShuf, d8);
928 d1 = Shuf(kShuf, d1);
929 d0 = Xor(d0, d7);
930 d2 = Xor(d2, z);
931 d2 = Xor(d2, d8);
932 std::swap(d10, d4);
933 z = Fetch128(s + 240);
934 d3 = Add(d3, z);
935 d4 = Shuf(kShuf, d4);
936 d6 = Shuf(kShuf, d6);
937 d7 = Mul(kMult, d7);
938 d5 = Add(d5, d3);
939 d7 = Xor(d7, z);
940 d7 = Xor(d7, d4);
941 std::swap(d3, d9);
942 s += 256;
943 } while (s != end);
944 d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
945 if (n % 256 != 0) {
946 d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
947 d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
948 }
949 __m128i t[8];
950 d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
951 d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
952 d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
953 d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
954 d0 = Add(d11, d0);
955 d3 = Xor(d7, d3);
956 d9 = Add(d8, d9);
957 d1 = Add(d10, d1);
958 d4 = Add(d3, d4);
959 d5 = Add(d9, d5);
960 d6 = Xor(d1, d6);
961 d2 = Add(d0, d2);
962 t[0] = d0;
963 t[1] = d3;
964 t[2] = d9;
965 t[3] = d1;
966 t[4] = d4;
967 t[5] = d5;
968 t[6] = d6;
969 t[7] = d2;
970 return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
971}
972
973uint64_t Hash64(const char *s, size_t len) {
974 // Empirically, farmhashxo seems faster until length 512.
975 return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
976}
977
978uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
979 return len >= 512 ? Hash64Long(s, len, k1, seed) :
980 farmhashxo::Hash64WithSeed(s, len, seed);
981}
982
983uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
984 return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
985 farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
986}
987
988#endif
989} // namespace farmhashte
990namespace farmhashnt {
991#if !can_use_sse41 || !x86_64
992
993uint32_t Hash32(const char *s, size_t len) {
994 FARMHASH_DIE_IF_MISCONFIGURED;
995 return s == NULL ? 0 : len;
996}
997
998uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
999 FARMHASH_DIE_IF_MISCONFIGURED;
1000 return seed + Hash32(s, len);
1001}
1002
1003#else
1004
1005uint32_t Hash32(const char *s, size_t len) {
1006 return static_cast<uint32_t>(farmhashte::Hash64(s, len));
1007}
1008
1009uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1010 return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
1011}
1012
1013#endif
1014} // namespace farmhashnt
1015namespace farmhashmk {
1016#undef Fetch
1017#define Fetch Fetch32
1018
1019#undef Rotate
1020#define Rotate Rotate32
1021
1022#undef Bswap
1023#define Bswap Bswap32
1024
1025STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
1026 uint32_t a = Fetch(s - 4 + (len >> 1));
1027 uint32_t b = Fetch(s + 4);
1028 uint32_t c = Fetch(s + len - 8);
1029 uint32_t d = Fetch(s + (len >> 1));
1030 uint32_t e = Fetch(s);
1031 uint32_t f = Fetch(s + len - 4);
1032 uint32_t h = d * c1 + len + seed;
1033 a = Rotate(a, 12) + f;
1034 h = Mur(c, h) + a;
1035 a = Rotate(a, 3) + c;
1036 h = Mur(e, h) + a;
1037 a = Rotate(a + f, 12) + d;
1038 h = Mur(b ^ seed, h) + a;
1039 return fmix(h);
1040}
1041
1042STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
1043 uint32_t b = seed;
1044 uint32_t c = 9;
1045 for (size_t i = 0; i < len; i++) {
1046 signed char v = s[i];
1047 b = b * c1 + v;
1048 c ^= b;
1049 }
1050 return fmix(Mur(b, Mur(len, c)));
1051}
1052
1053STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
1054 uint32_t a = len, b = len * 5, c = 9, d = b + seed;
1055 a += Fetch(s);
1056 b += Fetch(s + len - 4);
1057 c += Fetch(s + ((len >> 1) & 4));
1058 return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
1059}
1060
1061uint32_t Hash32(const char *s, size_t len) {
1062 if (len <= 24) {
1063 return len <= 12 ?
1064 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1065 Hash32Len13to24(s, len);
1066 }
1067
1068 // len > 24
1069 uint32_t h = len, g = c1 * len, f = g;
1070 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1071 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1072 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1073 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1074 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1075 h ^= a0;
1076 h = Rotate(h, 19);
1077 h = h * 5 + 0xe6546b64;
1078 h ^= a2;
1079 h = Rotate(h, 19);
1080 h = h * 5 + 0xe6546b64;
1081 g ^= a1;
1082 g = Rotate(g, 19);
1083 g = g * 5 + 0xe6546b64;
1084 g ^= a3;
1085 g = Rotate(g, 19);
1086 g = g * 5 + 0xe6546b64;
1087 f += a4;
1088 f = Rotate(f, 19) + 113;
1089 size_t iters = (len - 1) / 20;
1090 do {
1091 uint32_t a = Fetch(s);
1092 uint32_t b = Fetch(s + 4);
1093 uint32_t c = Fetch(s + 8);
1094 uint32_t d = Fetch(s + 12);
1095 uint32_t e = Fetch(s + 16);
1096 h += a;
1097 g += b;
1098 f += c;
1099 h = Mur(d, h) + e;
1100 g = Mur(c, g) + a;
1101 f = Mur(b + e * c1, f) + d;
1102 f += g;
1103 g += f;
1104 s += 20;
1105 } while (--iters != 0);
1106 g = Rotate(g, 11) * c1;
1107 g = Rotate(g, 17) * c1;
1108 f = Rotate(f, 11) * c1;
1109 f = Rotate(f, 17) * c1;
1110 h = Rotate(h + g, 19);
1111 h = h * 5 + 0xe6546b64;
1112 h = Rotate(h, 17) * c1;
1113 h = Rotate(h + f, 19);
1114 h = h * 5 + 0xe6546b64;
1115 h = Rotate(h, 17) * c1;
1116 return h;
1117}
1118
1119uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1120 if (len <= 24) {
1121 if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
1122 else if (len >= 5) return Hash32Len5to12(s, len, seed);
1123 else return Hash32Len0to4(s, len, seed);
1124 }
1125 uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
1126 return Mur(Hash32(s + 24, len - 24) + seed, h);
1127}
1128} // namespace farmhashmk
1129namespace farmhashsu {
1130#if !can_use_sse42 || !can_use_aesni
1131
1132uint32_t Hash32(const char *s, size_t len) {
1133 FARMHASH_DIE_IF_MISCONFIGURED;
1134 return s == NULL ? 0 : len;
1135}
1136
1137uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1138 FARMHASH_DIE_IF_MISCONFIGURED;
1139 return seed + Hash32(s, len);
1140}
1141
1142#else
1143
1144#undef Fetch
1145#define Fetch Fetch32
1146
1147#undef Rotate
1148#define Rotate Rotate32
1149
1150#undef Bswap
1151#define Bswap Bswap32
1152
1153// Helpers for data-parallel operations (4x 32-bits).
1154STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1155STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1156STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1157STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1158STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1159STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
1160 return Or(_mm_slli_epi32(x, c),
1161 _mm_srli_epi32(x, 32 - c));
1162}
1163STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
1164STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
1165STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1166 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1167}
1168
1169uint32_t Hash32(const char *s, size_t len) {
1170 const uint32_t seed = 81;
1171 if (len <= 24) {
1172 return len <= 12 ?
1173 (len <= 4 ?
1174 farmhashmk::Hash32Len0to4(s, len) :
1175 farmhashmk::Hash32Len5to12(s, len)) :
1176 farmhashmk::Hash32Len13to24(s, len);
1177 }
1178
1179 if (len < 40) {
1180 uint32_t a = len, b = seed * c2, c = a + b;
1181 a += Fetch(s + len - 4);
1182 b += Fetch(s + len - 20);
1183 c += Fetch(s + len - 16);
1184 uint32_t d = a;
1185 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1186 a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
1187 a += Fetch(s + len - 12);
1188 b += Fetch(s + len - 8);
1189 d += a;
1190 a += d;
1191 b = Mur(b, d) * c2;
1192 a = _mm_crc32_u32(a, b + c);
1193 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1194 }
1195
1196#undef Mulc1
1197#define Mulc1(x) Mul((x), cc1)
1198
1199#undef Mulc2
1200#define Mulc2(x) Mul((x), cc2)
1201
1202#undef Murk
1203#define Murk(a, h) \
1204 Add(k, \
1205 Mul5( \
1206 Rol19( \
1207 Xor( \
1208 Mulc2( \
1209 Rol17( \
1210 Mulc1(a))), \
1211 (h)))))
1212
1213 const __m128i cc1 = _mm_set1_epi32(c1);
1214 const __m128i cc2 = _mm_set1_epi32(c2);
1215 __m128i h = _mm_set1_epi32(seed);
1216 __m128i g = _mm_set1_epi32(c1 * seed);
1217 __m128i f = g;
1218 __m128i k = _mm_set1_epi32(0xe6546b64);
1219 __m128i q;
1220 if (len < 80) {
1221 __m128i a = Fetch128(s);
1222 __m128i b = Fetch128(s + 16);
1223 __m128i c = Fetch128(s + (len - 15) / 2);
1224 __m128i d = Fetch128(s + len - 32);
1225 __m128i e = Fetch128(s + len - 16);
1226 h = Add(h, a);
1227 g = Add(g, b);
1228 q = g;
1229 g = Shuffle0321(g);
1230 f = Add(f, c);
1231 __m128i be = Add(b, Mulc1(e));
1232 h = Add(h, f);
1233 f = Add(f, h);
1234 h = Add(Murk(d, h), e);
1235 k = Xor(k, _mm_shuffle_epi8(g, f));
1236 g = Add(Xor(c, g), a);
1237 f = Add(Xor(be, f), d);
1238 k = Add(k, be);
1239 k = Add(k, _mm_shuffle_epi8(f, h));
1240 f = Add(f, g);
1241 g = Add(g, f);
1242 g = Add(_mm_set1_epi32(len), Mulc1(g));
1243 } else {
1244 // len >= 80
1245 // The following is loosely modelled after farmhashmk::Hash32.
1246 size_t iters = (len - 1) / 80;
1247 len -= iters * 80;
1248
1249#undef Chunk
1250#define Chunk() do { \
1251 __m128i a = Fetch128(s); \
1252 __m128i b = Fetch128(s + 16); \
1253 __m128i c = Fetch128(s + 32); \
1254 __m128i d = Fetch128(s + 48); \
1255 __m128i e = Fetch128(s + 64); \
1256 h = Add(h, a); \
1257 g = Add(g, b); \
1258 g = Shuffle0321(g); \
1259 f = Add(f, c); \
1260 __m128i be = Add(b, Mulc1(e)); \
1261 h = Add(h, f); \
1262 f = Add(f, h); \
1263 h = Add(h, d); \
1264 q = Add(q, e); \
1265 h = Rol17(h); \
1266 h = Mulc1(h); \
1267 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1268 g = Add(Xor(c, g), a); \
1269 f = Add(Xor(be, f), d); \
1270 std::swap(f, q); \
1271 q = _mm_aesimc_si128(q); \
1272 k = Add(k, be); \
1273 k = Add(k, _mm_shuffle_epi8(f, h)); \
1274 f = Add(f, g); \
1275 g = Add(g, f); \
1276 f = Mulc1(f); \
1277} while (0)
1278
1279 q = g;
1280 while (iters-- != 0) {
1281 Chunk();
1282 s += 80;
1283 }
1284
1285 if (len != 0) {
1286 h = Add(h, _mm_set1_epi32(len));
1287 s = s + len - 80;
1288 Chunk();
1289 }
1290 }
1291
1292 g = Shuffle0321(g);
1293 k = Xor(k, g);
1294 k = Xor(k, q);
1295 h = Xor(h, q);
1296 f = Mulc1(f);
1297 k = Mulc2(k);
1298 g = Mulc1(g);
1299 h = Mulc2(h);
1300 k = Add(k, _mm_shuffle_epi8(g, f));
1301 h = Add(h, f);
1302 f = Add(f, h);
1303 g = Add(g, k);
1304 k = Add(k, g);
1305 k = Xor(k, _mm_shuffle_epi8(f, h));
1306 __m128i buf[4];
1307 buf[0] = f;
1308 buf[1] = g;
1309 buf[2] = k;
1310 buf[3] = h;
1311 s = reinterpret_cast<char*>(buf);
1312 uint32_t x = Fetch(s);
1313 uint32_t y = Fetch(s+4);
1314 uint32_t z = Fetch(s+8);
1315 x = _mm_crc32_u32(x, Fetch(s+12));
1316 y = _mm_crc32_u32(y, Fetch(s+16));
1317 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1318 x = _mm_crc32_u32(x, Fetch(s+24));
1319 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1320 uint32_t o = y;
1321 z = _mm_crc32_u32(z, Fetch(s+32));
1322 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1323 y = _mm_crc32_u32(y, Fetch(s+40));
1324 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1325 x = _mm_crc32_u32(x, Fetch(s+48));
1326 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1327 z = _mm_crc32_u32(z, Fetch(s+56));
1328 x = _mm_crc32_u32(x, Fetch(s+60));
1329 return (o - x + y - z) * c1;
1330}
1331
1332#undef Chunk
1333#undef Murk
1334#undef Mulc2
1335#undef Mulc1
1336
1337uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1338 if (len <= 24) {
1339 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1340 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1341 else return farmhashmk::Hash32Len0to4(s, len, seed);
1342 }
1343 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1344 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1345}
1346
1347#endif
1348} // namespace farmhashsu
1349namespace farmhashsa {
1350#if !can_use_sse42
1351
1352uint32_t Hash32(const char *s, size_t len) {
1353 FARMHASH_DIE_IF_MISCONFIGURED;
1354 return s == NULL ? 0 : len;
1355}
1356
1357uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1358 FARMHASH_DIE_IF_MISCONFIGURED;
1359 return seed + Hash32(s, len);
1360}
1361
1362#else
1363
1364#undef Fetch
1365#define Fetch Fetch32
1366
1367#undef Rotate
1368#define Rotate Rotate32
1369
1370#undef Bswap
1371#define Bswap Bswap32
1372
1373// Helpers for data-parallel operations (4x 32-bits).
1374STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1375STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1376STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1377STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1378STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1379STATIC_INLINE __m128i Rotate(__m128i x, int c) {
1380 return Or(_mm_slli_epi32(x, c),
1381 _mm_srli_epi32(x, 32 - c));
1382}
1383STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
1384STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
1385STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1386 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1387}
1388
1389uint32_t Hash32(const char *s, size_t len) {
1390 const uint32_t seed = 81;
1391 if (len <= 24) {
1392 return len <= 12 ?
1393 (len <= 4 ?
1394 farmhashmk::Hash32Len0to4(s, len) :
1395 farmhashmk::Hash32Len5to12(s, len)) :
1396 farmhashmk::Hash32Len13to24(s, len);
1397 }
1398
1399 if (len < 40) {
1400 uint32_t a = len, b = seed * c2, c = a + b;
1401 a += Fetch(s + len - 4);
1402 b += Fetch(s + len - 20);
1403 c += Fetch(s + len - 16);
1404 uint32_t d = a;
1405 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1406 a = Mur(a, Mur(b, Mur(c, d)));
1407 a += Fetch(s + len - 12);
1408 b += Fetch(s + len - 8);
1409 d += a;
1410 a += d;
1411 b = Mur(b, d) * c2;
1412 a = _mm_crc32_u32(a, b + c);
1413 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1414 }
1415
1416#undef Mulc1
1417#define Mulc1(x) Mul((x), cc1)
1418
1419#undef Mulc2
1420#define Mulc2(x) Mul((x), cc2)
1421
1422#undef Murk
1423#define Murk(a, h) \
1424 Add(k, \
1425 Mul5( \
1426 Rot19( \
1427 Xor( \
1428 Mulc2( \
1429 Rot17( \
1430 Mulc1(a))), \
1431 (h)))))
1432
1433 const __m128i cc1 = _mm_set1_epi32(c1);
1434 const __m128i cc2 = _mm_set1_epi32(c2);
1435 __m128i h = _mm_set1_epi32(seed);
1436 __m128i g = _mm_set1_epi32(c1 * seed);
1437 __m128i f = g;
1438 __m128i k = _mm_set1_epi32(0xe6546b64);
1439 if (len < 80) {
1440 __m128i a = Fetch128(s);
1441 __m128i b = Fetch128(s + 16);
1442 __m128i c = Fetch128(s + (len - 15) / 2);
1443 __m128i d = Fetch128(s + len - 32);
1444 __m128i e = Fetch128(s + len - 16);
1445 h = Add(h, a);
1446 g = Add(g, b);
1447 g = Shuffle0321(g);
1448 f = Add(f, c);
1449 __m128i be = Add(b, Mulc1(e));
1450 h = Add(h, f);
1451 f = Add(f, h);
1452 h = Add(Murk(d, h), e);
1453 k = Xor(k, _mm_shuffle_epi8(g, f));
1454 g = Add(Xor(c, g), a);
1455 f = Add(Xor(be, f), d);
1456 k = Add(k, be);
1457 k = Add(k, _mm_shuffle_epi8(f, h));
1458 f = Add(f, g);
1459 g = Add(g, f);
1460 g = Add(_mm_set1_epi32(len), Mulc1(g));
1461 } else {
1462 // len >= 80
1463 // The following is loosely modelled after farmhashmk::Hash32.
1464 size_t iters = (len - 1) / 80;
1465 len -= iters * 80;
1466
1467#undef Chunk
1468#define Chunk() do { \
1469 __m128i a = Fetch128(s); \
1470 __m128i b = Fetch128(s + 16); \
1471 __m128i c = Fetch128(s + 32); \
1472 __m128i d = Fetch128(s + 48); \
1473 __m128i e = Fetch128(s + 64); \
1474 h = Add(h, a); \
1475 g = Add(g, b); \
1476 g = Shuffle0321(g); \
1477 f = Add(f, c); \
1478 __m128i be = Add(b, Mulc1(e)); \
1479 h = Add(h, f); \
1480 f = Add(f, h); \
1481 h = Add(Murk(d, h), e); \
1482 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1483 g = Add(Xor(c, g), a); \
1484 f = Add(Xor(be, f), d); \
1485 k = Add(k, be); \
1486 k = Add(k, _mm_shuffle_epi8(f, h)); \
1487 f = Add(f, g); \
1488 g = Add(g, f); \
1489 f = Mulc1(f); \
1490} while (0)
1491
1492 while (iters-- != 0) {
1493 Chunk();
1494 s += 80;
1495 }
1496
1497 if (len != 0) {
1498 h = Add(h, _mm_set1_epi32(len));
1499 s = s + len - 80;
1500 Chunk();
1501 }
1502 }
1503
1504 g = Shuffle0321(g);
1505 k = Xor(k, g);
1506 f = Mulc1(f);
1507 k = Mulc2(k);
1508 g = Mulc1(g);
1509 h = Mulc2(h);
1510 k = Add(k, _mm_shuffle_epi8(g, f));
1511 h = Add(h, f);
1512 f = Add(f, h);
1513 g = Add(g, k);
1514 k = Add(k, g);
1515 k = Xor(k, _mm_shuffle_epi8(f, h));
1516 __m128i buf[4];
1517 buf[0] = f;
1518 buf[1] = g;
1519 buf[2] = k;
1520 buf[3] = h;
1521 s = reinterpret_cast<char*>(buf);
1522 uint32_t x = Fetch(s);
1523 uint32_t y = Fetch(s+4);
1524 uint32_t z = Fetch(s+8);
1525 x = _mm_crc32_u32(x, Fetch(s+12));
1526 y = _mm_crc32_u32(y, Fetch(s+16));
1527 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1528 x = _mm_crc32_u32(x, Fetch(s+24));
1529 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1530 uint32_t o = y;
1531 z = _mm_crc32_u32(z, Fetch(s+32));
1532 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1533 y = _mm_crc32_u32(y, Fetch(s+40));
1534 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1535 x = _mm_crc32_u32(x, Fetch(s+48));
1536 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1537 z = _mm_crc32_u32(z, Fetch(s+56));
1538 x = _mm_crc32_u32(x, Fetch(s+60));
1539 return (o - x + y - z) * c1;
1540}
1541
1542#undef Chunk
1543#undef Murk
1544#undef Mulc2
1545#undef Mulc1
1546
1547uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1548 if (len <= 24) {
1549 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1550 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1551 else return farmhashmk::Hash32Len0to4(s, len, seed);
1552 }
1553 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1554 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1555}
1556
1557#endif
1558} // namespace farmhashsa
1559namespace farmhashcc {
1560// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
1561// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
1562// a seeded 32-bit hash function similar to CityHash32.
1563
1564#undef Fetch
1565#define Fetch Fetch32
1566
1567#undef Rotate
1568#define Rotate Rotate32
1569
1570#undef Bswap
1571#define Bswap Bswap32
1572
1573STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
1574 uint32_t a = Fetch(s - 4 + (len >> 1));
1575 uint32_t b = Fetch(s + 4);
1576 uint32_t c = Fetch(s + len - 8);
1577 uint32_t d = Fetch(s + (len >> 1));
1578 uint32_t e = Fetch(s);
1579 uint32_t f = Fetch(s + len - 4);
1580 uint32_t h = len;
1581
1582 return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
1583}
1584
1585STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
1586 uint32_t b = 0;
1587 uint32_t c = 9;
1588 for (size_t i = 0; i < len; i++) {
1589 signed char v = s[i];
1590 b = b * c1 + v;
1591 c ^= b;
1592 }
1593 return fmix(Mur(b, Mur(len, c)));
1594}
1595
1596STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
1597 uint32_t a = len, b = len * 5, c = 9, d = b;
1598 a += Fetch(s);
1599 b += Fetch(s + len - 4);
1600 c += Fetch(s + ((len >> 1) & 4));
1601 return fmix(Mur(c, Mur(b, Mur(a, d))));
1602}
1603
1604uint32_t Hash32(const char *s, size_t len) {
1605 if (len <= 24) {
1606 return len <= 12 ?
1607 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1608 Hash32Len13to24(s, len);
1609 }
1610
1611 // len > 24
1612 uint32_t h = len, g = c1 * len, f = g;
1613 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1614 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1615 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1616 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1617 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1618 h ^= a0;
1619 h = Rotate(h, 19);
1620 h = h * 5 + 0xe6546b64;
1621 h ^= a2;
1622 h = Rotate(h, 19);
1623 h = h * 5 + 0xe6546b64;
1624 g ^= a1;
1625 g = Rotate(g, 19);
1626 g = g * 5 + 0xe6546b64;
1627 g ^= a3;
1628 g = Rotate(g, 19);
1629 g = g * 5 + 0xe6546b64;
1630 f += a4;
1631 f = Rotate(f, 19);
1632 f = f * 5 + 0xe6546b64;
1633 size_t iters = (len - 1) / 20;
1634 do {
1635 uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
1636 uint32_t a1 = Fetch(s + 4);
1637 uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
1638 uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
1639 uint32_t a4 = Fetch(s + 16);
1640 h ^= a0;
1641 h = Rotate(h, 18);
1642 h = h * 5 + 0xe6546b64;
1643 f += a1;
1644 f = Rotate(f, 19);
1645 f = f * c1;
1646 g += a2;
1647 g = Rotate(g, 18);
1648 g = g * 5 + 0xe6546b64;
1649 h ^= a3 + a1;
1650 h = Rotate(h, 19);
1651 h = h * 5 + 0xe6546b64;
1652 g ^= a4;
1653 g = Bswap(g) * 5;
1654 h += a4 * 5;
1655 h = Bswap(h);
1656 f += a0;
1657 PERMUTE3(f, h, g);
1658 s += 20;
1659 } while (--iters != 0);
1660 g = Rotate(g, 11) * c1;
1661 g = Rotate(g, 17) * c1;
1662 f = Rotate(f, 11) * c1;
1663 f = Rotate(f, 17) * c1;
1664 h = Rotate(h + g, 19);
1665 h = h * 5 + 0xe6546b64;
1666 h = Rotate(h, 17) * c1;
1667 h = Rotate(h + f, 19);
1668 h = h * 5 + 0xe6546b64;
1669 h = Rotate(h, 17) * c1;
1670 return h;
1671}
1672
1673uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1674 if (len <= 24) {
1675 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1676 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1677 else return farmhashmk::Hash32Len0to4(s, len, seed);
1678 }
1679 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1680 return Mur(Hash32(s + 24, len - 24) + seed, h);
1681}
1682
1683#undef Fetch
1684#define Fetch Fetch64
1685
1686#undef Rotate
1687#define Rotate Rotate64
1688
1689#undef Bswap
1690#define Bswap Bswap64
1691
1692STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
1693 return val ^ (val >> 47);
1694}
1695
1696STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
1697 return Hash128to64(Uint128(u, v));
1698}
1699
1700STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
1701 // Murmur-inspired hashing.
1702 uint64_t a = (u ^ v) * mul;
1703 a ^= (a >> 47);
1704 uint64_t b = (v ^ a) * mul;
1705 b ^= (b >> 47);
1706 b *= mul;
1707 return b;
1708}
1709
1710STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
1711 if (len >= 8) {
1712 uint64_t mul = k2 + len * 2;
1713 uint64_t a = Fetch(s) + k2;
1714 uint64_t b = Fetch(s + len - 8);
1715 uint64_t c = Rotate(b, 37) * mul + a;
1716 uint64_t d = (Rotate(a, 25) + b) * mul;
1717 return HashLen16(c, d, mul);
1718 }
1719 if (len >= 4) {
1720 uint64_t mul = k2 + len * 2;
1721 uint64_t a = Fetch32(s);
1722 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
1723 }
1724 if (len > 0) {
1725 uint8_t a = s[0];
1726 uint8_t b = s[len >> 1];
1727 uint8_t c = s[len - 1];
1728 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
1729 uint32_t z = len + (static_cast<uint32_t>(c) << 2);
1730 return ShiftMix(y * k2 ^ z * k0) * k2;
1731 }
1732 return k2;
1733}
1734
1735// Return a 16-byte hash for 48 bytes. Quick and dirty.
1736// Callers do best to use "random-looking" values for a and b.
1737STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1738 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
1739 a += w;
1740 b = Rotate(b + a + z, 21);
1741 uint64_t c = a;
1742 a += x;
1743 a += y;
1744 b += Rotate(a, 44);
1745 return make_pair(a + z, b + c);
1746}
1747
1748// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
1749STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1750 const char* s, uint64_t a, uint64_t b) {
1751 return WeakHashLen32WithSeeds(Fetch(s),
1752 Fetch(s + 8),
1753 Fetch(s + 16),
1754 Fetch(s + 24),
1755 a,
1756 b);
1757}
1758
1759
1760
1761// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
1762// of any length representable in signed long. Based on City and Murmur.
1763STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
1764 uint64_t a = Uint128Low64(seed);
1765 uint64_t b = Uint128High64(seed);
1766 uint64_t c = 0;
1767 uint64_t d = 0;
1768 signed long l = len - 16;
1769 if (l <= 0) { // len <= 16
1770 a = ShiftMix(a * k1) * k1;
1771 c = b * k1 + HashLen0to16(s, len);
1772 d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
1773 } else { // len > 16
1774 c = HashLen16(Fetch(s + len - 8) + k1, a);
1775 d = HashLen16(b + len, c + Fetch(s + len - 16));
1776 a += d;
1777 do {
1778 a ^= ShiftMix(Fetch(s) * k1) * k1;
1779 a *= k1;
1780 b ^= a;
1781 c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
1782 c *= k1;
1783 d ^= c;
1784 s += 16;
1785 l -= 16;
1786 } while (l > 0);
1787 }
1788 a = HashLen16(a, c);
1789 b = HashLen16(d, b);
1790 return uint128_t(a ^ b, HashLen16(b, a));
1791}
1792
1793uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
1794 if (len < 128) {
1795 return CityMurmur(s, len, seed);
1796 }
1797
1798 // We expect len >= 128 to be the common case. Keep 56 bytes of state:
1799 // v, w, x, y, and z.
1800 pair<uint64_t, uint64_t> v, w;
1801 uint64_t x = Uint128Low64(seed);
1802 uint64_t y = Uint128High64(seed);
1803 uint64_t z = len * k1;
1804 v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
1805 v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
1806 w.first = Rotate(y + z, 35) * k1 + x;
1807 w.second = Rotate(x + Fetch(s + 88), 53) * k1;
1808
1809 // This is the same inner loop as CityHash64(), manually unrolled.
1810 do {
1811 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1812 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1813 x ^= w.second;
1814 y += v.first + Fetch(s + 40);
1815 z = Rotate(z + w.first, 33) * k1;
1816 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1817 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1818 std::swap(z, x);
1819 s += 64;
1820 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1821 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1822 x ^= w.second;
1823 y += v.first + Fetch(s + 40);
1824 z = Rotate(z + w.first, 33) * k1;
1825 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1826 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1827 std::swap(z, x);
1828 s += 64;
1829 len -= 128;
1830 } while (LIKELY(len >= 128));
1831 x += Rotate(v.first + z, 49) * k0;
1832 y = y * k0 + Rotate(w.second, 37);
1833 z = z * k0 + Rotate(w.first, 27);
1834 w.first *= 9;
1835 v.first *= k0;
1836 // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
1837 for (size_t tail_done = 0; tail_done < len; ) {
1838 tail_done += 32;
1839 y = Rotate(x + y, 42) * k0 + v.second;
1840 w.first += Fetch(s + len - tail_done + 16);
1841 x = x * k0 + w.first;
1842 z += w.second + Fetch(s + len - tail_done);
1843 w.second += v.first;
1844 v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
1845 v.first *= k0;
1846 }
1847 // At this point our 56 bytes of state should contain more than
1848 // enough information for a strong 128-bit hash. We use two
1849 // different 56-byte-to-8-byte hashes to get a 16-byte final result.
1850 x = HashLen16(x, v.first);
1851 y = HashLen16(y + z, w.first);
1852 return uint128_t(HashLen16(x + v.second, w.second) + y,
1853 HashLen16(x + w.second, y + v.second));
1854}
1855
1856STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
1857 return len >= 16 ?
1858 CityHash128WithSeed(s + 16, len - 16,
1859 uint128_t(Fetch(s), Fetch(s + 8) + k0)) :
1860 CityHash128WithSeed(s, len, uint128_t(k0, k1));
1861}
1862
1863uint128_t Fingerprint128(const char* s, size_t len) {
1864 return CityHash128(s, len);
1865}
1866} // namespace farmhashcc
1867namespace NAMESPACE_FOR_HASH_FUNCTIONS {
1868
1869// BASIC STRING HASHING
1870
1871// Hash function for a byte array. See also Hash(), below.
1872// May change from time to time, may differ on different platforms, may differ
1873// depending on NDEBUG.
1874uint32_t Hash32(const char* s, size_t len) {
1875 return DebugTweak(
1876 (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
1877 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
1878 can_use_sse42 ? farmhashsa::Hash32(s, len) :
1879 farmhashmk::Hash32(s, len));
1880}
1881
1882// Hash function for a byte array. For convenience, a 32-bit seed is also
1883// hashed into the result.
1884// May change from time to time, may differ on different platforms, may differ
1885// depending on NDEBUG.
1886uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
1887 return DebugTweak(
1888 (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
1889 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
1890 can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
1891 farmhashmk::Hash32WithSeed(s, len, seed));
1892}
1893
1894// Hash function for a byte array. For convenience, a 64-bit seed is also
1895// hashed into the result. See also Hash(), below.
1896// May change from time to time, may differ on different platforms, may differ
1897// depending on NDEBUG.
1898uint64_t Hash64(const char* s, size_t len) {
1899 return DebugTweak(
1900 (can_use_sse42 & x86_64) ?
1901 farmhashte::Hash64(s, len) :
1902 farmhashxo::Hash64(s, len));
1903}
1904
1905// Hash function for a byte array.
1906// May change from time to time, may differ on different platforms, may differ
1907// depending on NDEBUG.
1908size_t Hash(const char* s, size_t len) {
1909 return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
1910}
1911
1912// Hash function for a byte array. For convenience, a 64-bit seed is also
1913// hashed into the result.
1914// May change from time to time, may differ on different platforms, may differ
1915// depending on NDEBUG.
1916uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
1917 return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
1918}
1919
1920// Hash function for a byte array. For convenience, two seeds are also
1921// hashed into the result.
1922// May change from time to time, may differ on different platforms, may differ
1923// depending on NDEBUG.
1924uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
1925 return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
1926}
1927
1928// Hash function for a byte array.
1929// May change from time to time, may differ on different platforms, may differ
1930// depending on NDEBUG.
1931uint128_t Hash128(const char* s, size_t len) {
1932 return DebugTweak(farmhashcc::Fingerprint128(s, len));
1933}
1934
1935// Hash function for a byte array. For convenience, a 128-bit seed is also
1936// hashed into the result.
1937// May change from time to time, may differ on different platforms, may differ
1938// depending on NDEBUG.
1939uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
1940 return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
1941}
1942
1943// BASIC NON-STRING HASHING
1944
1945// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
1946
1947// Fingerprint function for a byte array. Most useful in 32-bit binaries.
1948uint32_t Fingerprint32(const char* s, size_t len) {
1949 return farmhashmk::Hash32(s, len);
1950}
1951
1952// Fingerprint function for a byte array.
1953uint64_t Fingerprint64(const char* s, size_t len) {
1954 return farmhashna::Hash64(s, len);
1955}
1956
1957// Fingerprint function for a byte array.
1958uint128_t Fingerprint128(const char* s, size_t len) {
1959 return farmhashcc::Fingerprint128(s, len);
1960}
1961
1962// Older and still available but perhaps not as fast as the above:
1963// farmhashns::Hash32{,WithSeed}()
1964
1965} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
1966
1967#if FARMHASHSELFTEST
1968
1969#ifndef FARMHASH_SELF_TEST_GUARD
1970#define FARMHASH_SELF_TEST_GUARD
1971#include <cstdio>
1972#include <iostream>
1973#include <string.h>
1974
1975using std::cout;
1976using std::cerr;
1977using std::endl;
1978using std::hex;
1979
1980static const uint64_t kSeed0 = 1234567;
1981static const uint64_t kSeed1 = k0;
1982static const int kDataSize = 1 << 20;
1983static const int kTestSize = 300;
1984#define kSeed128 Uint128(kSeed0, kSeed1)
1985
1986static char data[kDataSize];
1987
1988static int completed_self_tests = 0;
1989static int errors = 0;
1990
1991// Initialize data to pseudorandom values.
1992void Setup() {
1993 if (completed_self_tests == 0) {
1994 uint64_t a = 9;
1995 uint64_t b = 777;
1996 for (int i = 0; i < kDataSize; i++) {
1997 a += b;
1998 b += a;
1999 a = (a ^ (a >> 41)) * k0;
2000 b = (b ^ (b >> 41)) * k0 + i;
2001 uint8_t u = b >> 37;
2002 memcpy(data + i, &u, 1); // uint8_t -> char
2003 }
2004 }
2005}
2006
2007int NoteErrors() {
2008#define NUM_SELF_TESTS 9
2009 if (++completed_self_tests == NUM_SELF_TESTS)
2010 std::exit(errors > 0);
2011 return errors;
2012}
2013
2014template <typename T> inline bool IsNonZero(T x) {
2015 return x != 0;
2016}
2017
2018template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
2019 return x != Uint128(0, 0);
2020}
2021
2022#endif // FARMHASH_SELF_TEST_GUARD
2023
2024namespace farmhashccTest {
2025
2026uint32_t CreateSeed(int offset, int salt) {
2027 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
2028 h = h * c1;
2029 h ^= (h >> 17);
2030 h = h * c1;
2031 h ^= (h >> 17);
2032 h = h * c1;
2033 h ^= (h >> 17);
2034 h += static_cast<uint32_t>(offset & 0xffffffff);
2035 h = h * c1;
2036 h ^= (h >> 17);
2037 h = h * c1;
2038 h ^= (h >> 17);
2039 h = h * c1;
2040 h ^= (h >> 17);
2041 return h;
2042}
2043
2044#undef SEED
2045#undef SEED1
2046#undef SEED0
2047#define SEED CreateSeed(offset, -1)
2048#define SEED0 CreateSeed(offset, 0)
2049#define SEED1 CreateSeed(offset, 1)
2050
2051#undef TESTING
2052#define TESTING 1
2053#if TESTING
2054uint32_t expected[] = {
20554223616069u,
20563696677242u,
20571039179260u, 1690343979u, 1018511555u, 2464489001u,
205820368522u, 2663783964u, 175201532u, 1619210592u,
20594081014168u,
20602576519988u,
20613285042206u, 502478099u, 739479538u, 1500332790u,
206213754768u, 3789353455u, 3473868058u, 1909255088u,
20632212771159u,
20641112731063u,
2065826915357u, 2893489933u, 118369799u, 1848668220u,
20661308219822u, 249416982u, 64306364u, 4221800195u,
20671020067935u,
20683955445564u,
2069563346294u, 550236731u, 2339016688u, 1826259714u,
20703872358639u, 2295981050u, 1870005390u, 4015628802u,
20711451961420u,
2072653440099u,
20731292493871u, 164377749u, 1717712483u, 463414587u,
20743924343675u, 1050492084u, 3566618804u, 2046983362u,
207531917516u,
20762957164615u,
2077230718965u, 999595115u, 3534822176u, 2175709186u,
2078965707431u, 441796222u, 2481718051u, 1827777486u,
20792590087362u,
20803879448744u,
20813515079898u, 1601433082u, 982764532u, 254808716u,
20821293372530u, 4205605817u, 947001462u, 1138890052u,
2083176305566u,
20842447367541u,
20852973802542u, 4123621138u, 3083865840u, 1706367795u,
2086792114347u, 2880110657u, 440613768u, 195054868u,
20871359016305u,
20883363804638u,
2089649488537u, 1624045597u, 1441938215u, 3147758996u,
20903199173578u, 2597283203u, 2191333609u, 3763129144u,
20911117290165u,
20921062549743u,
20932565615889u, 1046361554u, 1581968261u, 1058773671u,
20941123053168u, 3807622275u, 1486749916u, 3900816089u,
20952437877004u,
20961894455839u,
20971912520953u, 1914997013u, 561048608u, 1643267444u,
20983671572006u, 194811086u, 1468911468u, 2179206286u,
2099673206794u,
21003486923651u,
21013741426466u, 3292160512u, 697001377u, 1900763774u,
21023726097344u, 629282039u, 3578723715u, 2868028489u,
21033269862919u,
21042303349487u,
21053643953525u, 2307255916u, 849996280u, 732080434u,
2106909961480u, 3542445214u, 2628347095u, 4236856917u,
21071380660650u,
21082631821908u,
21092007289004u, 3509705198u, 3788541675u, 789457322u,
21103090670546u, 638977894u, 3503881773u, 947102987u,
21111525325287u,
21121816697045u,
21132706647405u, 288763142u, 3505438495u, 481308609u,
21142882636782u, 3745162621u, 3503467033u, 428247823u,
2115176408838u,
2116333551502u,
21171001068721u, 1681483651u, 75380831u, 4191469679u,
21183627361839u, 2736617386u, 3120737438u, 1297502456u,
2119864896482u,
212085674920u,
21212886047255u, 4119881331u, 2496990525u, 3442502055u,
21221806582817u, 3186345024u, 4099591287u, 2560171465u,
21233489229104u,
21243065015872u,
21252755089808u, 3098442882u, 378524719u, 2664097023u,
21261771960725u, 2901182183u, 55258521u, 1266621443u,
2127581644891u,
212837790450u,
21291800731704u, 3601350920u, 53428754u, 2759476837u,
21303391093099u, 1496510311u, 2511119507u, 2636877410u,
2131631613207u,
21321573846064u,
2133260484875u, 1088212603u, 2369525206u, 322522428u,
21343191396600u, 2076543340u, 1552496658u, 2739811558u,
21353867875546u,
21362051584261u,
21372126250818u, 901517871u, 3651631165u, 1323139145u,
21381521111765u, 477802997u, 3508559783u, 383954241u,
21393804516756u,
21404250206331u,
21412655954340u, 2484996477u, 1417544845u, 1520282298u,
21422745204366u, 2869345147u, 1872738335u, 2592877343u,
21431619744564u,
21441804962124u,
21453458679890u, 423948620u, 273645618u, 4187865426u,
2146376057175u, 2943431463u, 3581950599u, 1035398331u,
21471088213445u,
2148861988903u,
21491323370244u, 777069428u, 506235917u, 369720851u,
21502789995854u, 230915180u, 1505086948u, 940361236u,
21513727873235u,
21521159167499u,
21531860302871u, 3456858862u, 3923555152u, 2131072714u,
21542910461068u, 3671950363u, 2010742682u, 4088068851u,
21553616470388u,
21562087714788u,
2157221675509u, 1230154072u, 3450704646u, 1463226695u,
21581998357699u, 266026801u, 619568740u, 3560427266u,
21594148162586u,
21603150417316u,
21611356375822u, 2056097622u, 627905802u, 3881675638u,
21622309738053u, 971916703u, 3447805361u, 1673575328u,
2163673084328u,
21643317849401u,
21652836362782u, 2377208890u, 3275350588u, 158350552u,
21662553241779u, 2497264995u, 3262882649u, 3897937187u,
21671598963653u,
21683068514414u,
2169601541505u, 374517071u, 3380795976u, 235752573u,
2170284670003u, 2990192160u, 904937105u, 2306579150u,
21712117362589u,
21721635274830u,
21733355572906u, 170799903u, 1226685528u, 664567688u,
2174413219134u, 878324258u, 4026159448u, 3620649295u,
21751823625377u,
21763175888439u,
21771759344347u, 2640637095u, 3549558u, 2192984935u,
2178978623493u, 804017880u, 3877562323u, 3843116489u,
21791641748342u,
21801853539444u,
21813001178468u, 3443560727u, 2685426077u, 1653064722u,
2182349231508u, 2726789654u, 3136215581u, 768402830u,
2183269384321u,
2184531936536u,
21852592883487u, 1343156334u, 3628619802u, 1477143570u,
21864269458419u, 3285611028u, 959104925u, 2712290710u,
21873480237248u,
2188835796333u,
21892020636251u, 1191914589u, 126521603u, 4288023938u,
21903731699932u, 2136758855u, 985780142u, 193807575u,
21911850544433u,
2192653947619u,
21933929316796u, 381871169u, 950486363u, 1787262279u,
2194360480382u, 1800636585u, 1039258631u, 3682073259u,
21951262819303u,
21961786000319u,
21971570627191u, 893065837u, 301304916u, 1478469809u,
2198623018819u, 2742232545u, 2058913014u, 1706060059u,
21992421125401u,
22001315829592u,
22013208766775u, 1805586156u, 575853086u, 3085025513u,
22024010908260u, 2344058256u, 3814407434u, 1458485673u,
22032474514786u,
22043581895658u,
22052710719679u, 190812706u, 2135454262u, 2620080728u,
22063400757986u, 1669914857u, 1559978393u, 1629811331u,
22073096616493u,
22081391424435u,
22094158376003u, 1015657076u, 794783832u, 479952178u,
22101150290207u, 2497437906u, 231815090u, 755078067u,
22113832053281u,
221263649475u,
22132415822606u, 4105027719u, 1706992318u, 1106598740u,
22143941945667u, 1271300761u, 505882259u, 760186809u,
22152657183368u,
22161925422058u,
22171039773764u, 880219458u, 4275949176u, 1556833823u,
2218925882132u, 4216310340u, 757497522u, 461833914u,
22193884002070u,
22202790957660u,
22212100050089u, 651959176u, 1380301291u, 1289124125u,
2222452314403u, 226156280u, 3306924715u, 1750807758u,
22232290180542u,
22241953760569u,
22252253069096u, 3960924806u, 1786291620u, 60736185u,
22262569018293u, 3870479674u, 2247005661u, 2239850953u,
22274261808536u,
22283282975782u,
2229780945879u, 3349849383u, 1579362556u, 2265045884u,
2230905088740u, 725212379u, 3156479246u, 2501620391u,
22313062836263u,
22324070422690u,
2233996797869u, 4082582315u, 976105756u, 303983602u,
22341862104804u, 3864508254u, 3383979677u, 2835500286u,
22352798364010u,
2236519359476u,
22373447342725u, 194373889u, 3313466630u, 232399983u,
22382841787856u, 1672751454u, 3345183154u, 1805381384u,
22392226129336u,
22402847829057u,
22412350774567u, 2838540121u, 2757948482u, 1017002062u,
22422329150951u, 2171488196u, 3668619047u, 3874977844u,
22433287966998u,
2244262346753u,
22452493054715u, 2298644430u, 2926101182u, 1528457638u,
2246598656233u, 2615845874u, 989110727u, 820441411u,
2247253617372u,
22482201077208u,
22492047569338u, 3114356329u, 3335563734u, 2967673540u,
2250768438341u, 1417708203u, 3873718246u, 1538441843u,
22511279167650u,
22523917966776u,
22532218481734u, 1015935150u, 1957845042u, 1318150213u,
22543146423971u, 4218994877u, 1162470863u, 1519718292u,
22552594658906u,
2256665870414u,
22573430347817u, 3933868731u, 1597041394u, 3138684682u,
22583398212027u, 1064647658u, 1576321132u, 14792918u,
2259224938029u,
22603706456050u,
2261847274786u, 2645698692u, 1743374687u, 2343133224u,
22623066596790u, 2857270120u, 200596308u, 452055528u,
22632319312082u,
22643488655402u,
22654146865894u, 608206438u, 2699777051u, 3687240713u,
2266327957508u, 3664730153u, 568134564u, 2993484554u,
22674159860363u,
22684274533921u,
22691079994063u, 2360220210u, 3609597760u, 3639708902u,
22702836180437u, 1069910270u, 1892427666u, 1874729790u,
22711267712826u,
2272121886940u,
22733572289214u, 2475945610u, 783779452u, 588827737u,
22741531395014u, 2085084212u, 2219189792u, 3981444548u,
22752218885336u,
22761691622694u,
22772053232885u, 1386558530u, 2182946189u, 2365247285u,
22781871081313u, 2935751853u, 38413723u, 543465863u,
2279900691890u,
22802899905665u,
2281575120562u, 93133904u, 457154948u, 2983705792u,
22824232229200u, 2038565963u, 614693984u, 3405328302u,
22834083090010u,
22842088004171u,
2285244031209u, 1861889294u, 2417109253u, 3299562328u,
22864158642443u, 4199064449u, 3161611046u, 885015950u,
22873677904099u,
22882969861785u,
2289772348805u, 1712263832u, 3219357614u, 484271305u,
22903645706114u, 2059620251u, 409557488u, 2278896731u,
2291224475749u,
22923523022952u,
22932057140088u, 449131785u, 1149879244u, 4255363996u,
22943602720135u, 1690010854u, 2503998822u, 2750828466u,
22953340671802u,
22961447583863u,
22972649684943u, 2764747249u, 3046070595u, 3441726138u,
22983840332559u, 3156747501u, 1288666680u, 1472744459u,
22993452391933u,
23001617542784u,
2301217869690u, 3718469527u, 348639731u, 590532355u,
230243789787u, 22606314u, 1621559290u, 2231743261u,
23032234620879u,
2304544748955u,
23053169387920u, 203343594u, 3272552527u, 1078282365u,
2306809576321u, 854207584u, 3625491053u, 1193737267u,
23071628966807u,
23082661421060u,
23092433442061u, 3886639039u, 2149304418u, 303000565u,
23101432830882u, 137378235u, 1135974068u, 318705754u,
23112491227157u,
23122627534472u,
23133520352233u, 2488397682u, 3969194920u, 3843962181u,
23142135981459u, 2611933220u, 799460731u, 2300968851u,
23153412851628u,
23163070914013u,
23173555224260u, 4125937572u, 240359903u, 722496673u,
23182061023600u, 3843919221u, 2759960043u, 1191155322u,
23191504041490u,
23203735253656u,
23211773124736u, 101110011u, 1627699578u, 2645634551u,
2322263603947u, 1388368439u, 677146538u, 1644201982u,
23232625699644u,
23242403862553u,
23252426069017u, 3613511705u, 915141802u, 2981654265u,
23263474818167u, 2611101773u, 627891434u, 762754924u,
23272143021902u,
232851067670u,
23294017746573u, 2269879853u, 3037857950u, 2388899692u,
2330582729171u, 1886116725u, 2281219772u, 264704948u,
23313509984037u,
23324078683368u,
23332172959411u, 1807195632u, 3357092302u, 2253764928u,
23342320369390u, 3076335959u, 2623583210u, 168378015u,
23351435562650u,
23361100977467u,
23373160490319u, 2550328495u, 2396855930u, 1347823908u,
23381617990918u, 3849653099u, 3224111576u, 1681539821u,
23394171542880u,
2340552200045u,
23413562947778u, 1676237880u, 3747732307u, 2453332913u,
2342865530667u, 3566636849u, 3485502777u, 336779723u,
23432535942410u,
23441685000184u,
2345820545711u, 1893670486u, 1273910461u, 1193758569u,
2346970365241u, 381205962u, 3612810852u, 1160577445u,
2347541488143u,
23484005031080u,
23492333965236u, 2419855455u, 3484533538u, 3073937876u,
2350908466956u, 661391539u, 2342122412u, 1467049112u,
23511785800827u,
2352135343033u,
2353139643209u, 2438375667u, 974654058u, 3216478230u,
23543807620420u, 779043363u, 2812846449u, 333254784u,
23551025244024u,
23562242303095u,
23572476683742u, 350018683u, 174652916u, 933097576u,
2358826905896u, 559603581u, 2777181260u, 164915169u,
23594070353203u,
23601459055748u,
2361297303985u, 3103837241u, 3812514233u, 232265137u,
23622032819099u, 1523091376u, 3531238208u, 1403510182u,
23632886832080u,
23642599705941u,
23652789695716u, 68437968u, 3823813791u, 1040994569u,
23663024194990u, 2461740520u, 3735391266u, 2042207153u,
23672461678616u,
23683519231840u,
23691344224923u, 411442756u, 1179779351u, 7661528u,
2370778352196u, 3288808867u, 589356197u, 2627504511u,
23713374744599u,
23723312172905u,
2373357423007u, 3539567796u, 4044452215u, 1445118403u,
23742937983820u, 184089910u, 346201845u, 2427295202u,
23751345448010u,
23762884434843u,
23773085001879u, 2640105409u, 315310640u, 3530289798u,
23783362974764u, 963602652u, 75228477u, 3509381180u,
23794012777756u,
23802380345941u,
23811073137836u, 2083960378u, 1220315185u, 3628720934u,
23823508867818u, 67148343u, 3558085158u, 1753943368u,
2383863309561u,
23842844713625u,
2385441921850u, 854732254u, 816793316u, 2555428747u,
23863440623414u, 1707304366u, 3189874375u, 1623229221u,
23871220335976u,
2388806745430u,
23893909262947u, 1680369031u, 2926179486u, 3410391660u,
23903991630434u, 2876458763u, 1179167079u, 536360759u,
23911592117159u,
23921514343977u,
23931032622306u, 2057494855u, 784938958u, 178402996u,
23941152907972u, 2326185495u, 2939973666u, 4181120253u,
2395552831733u,
2396664251856u,
23971297139539u, 1969357631u, 1474065957u, 3055419017u,
23983395829380u, 3316562752u, 2168409017u, 614624786u,
23993585854336u,
2400668291094u,
24011162889217u, 3773171307u, 2263271126u, 355089668u,
24023195850578u, 3396793277u, 3519870267u, 527857605u,
24033972392320u,
24042224315010u,
24054047225561u, 3271434798u, 3192704713u, 2798505213u,
24063932215896u, 3792924012u, 3796843756u, 453872975u,
24074050552799u,
24081056432676u,
2409928166947u, 121311642u, 930989547u, 2087070683u,
24101288978057u, 1556325239u, 1812435626u, 1682385724u,
24111214364933u,
2412904760776u,
24133957045528u, 3949822847u, 2411065880u, 3716420732u,
24143424837835u, 3833550693u, 1799375326u, 2012368921u,
24152768764136u,
24161786111037u,
24174055479315u, 3751639533u, 2808224623u, 3492656387u,
24181306824780u, 2624000170u, 3134795218u, 1778409297u,
24193900821801u,
2420593336325u,
24212772069220u, 2980873673u, 3574497158u, 3994780459u,
24224246519854u, 3482758570u, 4228015183u, 33101083u,
24231769887734u,
24244158035314u,
24253690638998u, 1119035482u, 4134969651u, 2483207353u,
24263932823321u, 285829887u, 3485140138u, 1304815138u,
2427995608264u,
24283133997465u,
24291195477617u, 2147693728u, 3506673112u, 4234467492u,
24301183174337u, 1395340482u, 769199343u, 193262308u,
24312798920256u,
24323827889422u,
24333399695609u, 3036045724u, 2999477386u, 3567001759u,
24342682864314u, 1414023907u, 3699872975u, 3369870701u,
24352662284872u,
24362179640019u,
24372485080099u, 3234415609u, 3755915606u, 1339453220u,
24381567403399u, 2076272391u, 293946298u, 3861962750u,
24391291949822u,
24402916864995u,
2441132642326u, 2215117062u, 2205863575u, 2488805750u,
2442405632860u, 3248129390u, 2952606864u, 896734759u,
24432047417173u,
24443865951392u,
2445657296855u, 1328547532u, 3966511825u, 3959682388u,
24464171801020u, 2981416957u, 1868896247u, 790081075u,
24473143666398u,
24482950766549u,
24492065854887u, 2737081890u, 995061774u, 1510712611u,
24502865954809u, 565044286u, 1565631102u, 1500654931u,
2451494822108u,
24522803515503u,
24531058154996u, 3506280187u, 856885925u, 4204610546u,
2454800905649u, 1130711562u, 558146282u, 2053400666u,
2455449794061u,
24562643520245u,
24572101248725u, 3123292429u, 3583524041u, 983372394u,
24581587743780u, 672870813u, 444833475u, 100741452u,
2459366232251u,
24601717951248u,
2461524144122u, 1362432726u, 1304947719u, 674306020u,
2462405665887u, 4081931036u, 1580408204u, 2343242778u,
24633901654006u,
24642627173567u,
24653015148205u, 814686701u, 1327920712u, 1346494176u,
24662468632605u, 2259795544u, 2519278184u, 2129281928u,
24672860266380u,
24684001619412u,
24691154910973u, 2841022216u, 1199925485u, 1372200293u,
24702713179055u, 3609776550u, 2896463880u, 1056406892u,
2471177413841u,
247240180172u,
24733274788406u, 660921784u, 1686225028u, 4003382965u,
24742532691887u, 4256809101u, 1186018983u, 667359096u,
24752375266493u,
24762760222015u,
2477745187078u, 312264012u, 396822261u, 2588536966u,
24782026998998u, 1766454365u, 3218807676u, 3915487497u,
24792630550356u,
24804130063378u,
24814231937074u, 752212123u, 3085144349u, 3267186363u,
24824103872100u, 4193207863u, 1306401710u, 3014853131u,
24831067760598u,
24842306188342u,
24852437881506u, 4258185052u, 2506507580u, 130876929u,
24861076894205u, 4106981702u, 2799540844u, 945747327u,
24871436722291u,
24882499772225u,
24892571537041u, 2038830635u, 2066826058u, 2892892912u,
2490524875858u, 3392572161u, 2869992096u, 1308273341u,
2491923668994u,
24921980407857u,
24932275009652u, 240598096u, 2658376530u, 3505603048u,
24941022603789u, 582423424u, 846379327u, 4092636095u,
24954177298326u,
24961004173023u,
24972154027018u, 2993634669u, 1098364089u, 3035642175u,
24981335688126u, 1376393415u, 1252369770u, 3815033328u,
24991999309358u,
25001234054757u,
25011388595255u, 2859334775u, 366532860u, 3453410395u,
25024226967708u, 1321729870u, 2078463405u, 156766592u,
25033157683394u,
25043549293384u,
25053348214547u, 2879648344u, 1144813399u, 2758966254u,
2506647753581u, 813615926u, 2035441590u, 1961053117u,
2507600168686u,
25082192833387u,
25093156481401u, 3627320321u, 383550248u, 81209584u,
25102339331745u, 1284116690u, 1980144976u, 2955724163u,
2511789301728u,
25123842040415u,
25131115881490u, 965249078u, 4098663322u, 1870257033u,
25142923150701u, 4217108433u, 183816559u, 2104089285u,
25152640095343u,
25163173757052u,
2517927847464u, 2383114981u, 4287174363u, 1886129652u,
251870635161u, 1182924521u, 1121440038u, 4246220730u,
25193890583049u,
2520975913757u,
25212436253031u, 1074894869u, 1301280627u, 992471939u,
2522735658128u, 244441856u, 1541612456u, 3457776165u,
25233503534059u,
25241931651133u,
2525349142786u, 3669028584u, 1828812038u, 99128389u,
25261364272849u, 1963678455u, 3971963311u, 2316950886u,
25271308901796u,
25282789591580u,
25291460494965u, 2380227479u, 1577190651u, 1755822080u,
25302911014607u, 859387544u, 13023113u, 2319243370u,
25312522582211u,
25322299110490u,
25333342378874u, 2589323490u, 1884430765u, 3739058655u,
25342419330954u, 355389916u, 273950915u, 3670136553u,
2535410946824u,
25363174041420u,
25372609010298u, 3059091350u, 2300275014u, 725729828u,
25382548380995u, 1738849964u, 1257081412u, 79430455u,
2539810321297u,
25403246190593u,
25411007937684u, 912115394u, 40880059u, 3450073327u,
25424289832174u, 2253485111u, 1065639151u, 2953189309u,
2543124779113u,
2544654299738u,
2545115760833u, 1250932069u, 884995826u, 3998908281u,
25461382882981u, 1134187162u, 3202324501u, 487502928u,
25473032756345u,
25484057517628u,
2549933197381u, 2319223127u, 2044528655u, 2554572663u,
25504049450620u, 1620812836u, 2832905391u, 2273005481u,
25511913090121u,
25521055456023u,
2553510593296u, 3285343192u, 2912822536u, 1645225063u,
2554638418430u, 452701300u, 1025483165u, 1639370512u,
2555167948643u,
25562809842730u,
25572983135664u, 407521332u, 1543756616u, 3949773145u,
25584283462892u, 659962275u, 3878013463u, 1000748756u,
25594053212051u,
25604099239406u,
25613467581965u, 354635541u, 21301844u, 3831212473u,
25623189450571u, 2264401966u, 4096484849u, 1736448515u,
25633976926096u,
25643727194724u,
25652243487039u, 585209095u, 3143046007u, 969558123u,
25663037113502u, 3594170243u, 2835860223u, 3775493975u,
25672787220812u,
25682274252217u,
25692915380701u, 3077533278u, 1252871826u, 1519790952u,
2570205297661u, 2950557658u, 3956882191u, 2724439401u,
25713694608025u,
2572124028038u,
2573216019153u, 1533010676u, 2259986336u, 2014061617u,
25742068617849u, 3078123052u, 2692046098u, 1582812948u,
2575396916232u,
25761470894001u,
25771694309312u, 300268215u, 1553892743u, 671176040u,
25781544988994u, 2793402821u, 4194972569u, 2296476154u,
2579748354332u,
25803491325898u,
25814261053291u, 1104998242u, 797816835u, 243564059u,
25822197717393u, 299029458u, 1675252188u, 3139770041u,
2583583018574u,
25842532106100u,
25852099391658u, 3760526730u, 3422719327u, 3556917689u,
25862374009285u, 2130865894u, 3710563151u, 1437538307u,
25873938030842u,
25882006930694u,
25892151243336u, 1939741287u, 1957068175u, 2135147479u,
2590649553342u, 1713643042u, 4188696599u, 1698739939u,
25913549427584u,
25921016382174u,
2593322644378u, 2476164549u, 2037263020u, 88036019u,
25942548960923u, 539867919u, 2871157727u, 4031659929u,
2595754087252u,
2596972656559u,
25974246379429u, 3877308578u, 2059459630u, 3614934323u,
25981410565271u, 2102980459u, 215395636u, 1083393481u,
25993775523015u,
26002062750105u,
26012475645882u, 3041186774u, 3534315423u, 758607219u,
26021686100614u, 180500983u, 1155581185u, 1476664671u,
26032918661695u,
26043812731350u,
26054003853737u, 4148884881u, 1468469436u, 3278880418u,
26061045838071u, 1049161262u, 360450415u, 3158065524u,
2607814443735u,
26083391401707u,
2609729968410u, 738771593u, 3662738792u, 1672830580u,
26104199496163u, 188487238u, 219098233u, 2141731267u,
26113890250614u,
26122988780375u,
26134026279523u, 3489429375u, 2468433807u, 1178270701u,
26142685094218u, 2716621497u, 3718335529u, 2273344755u,
2615701110882u,
26161925717409u,
26171515176562u, 2325460593u, 3954798930u, 784566105u,
26183769422266u, 1641530321u, 2703876862u, 2907480267u,
26191828076455u,
26201805635221u,
26213883381245u, 1476756210u, 2072514392u, 3658557081u,
26222003610746u, 2556845550u, 729594004u, 3303898266u,
26231968227254u,
2624423204951u,
2625231828688u, 4223697811u, 698619045u, 3636824418u,
26262738779239u, 2333529003u, 2833158642u, 580285428u,
26273038148234u,
26281012378004u,
26291113647298u, 1424593483u, 4053247723u, 1167152941u,
26302677383578u, 3419485379u, 2135673840u, 440478166u,
26311682229112u,
26323226724137u,
26331217439806u, 3828726923u, 3636576271u, 3467643156u,
26342005614908u, 2655346461u, 2345488441u, 1027557096u,
26353594084220u,
26361372306343u,
26372342583762u, 4291342905u, 4094931814u, 3254771759u,
2638821978248u, 2404930117u, 1143937655u, 3156949255u,
26393460606610u,
2640449701786u,
26413474906110u, 1932585294u, 2283357584u, 1808481478u,
26423522851029u, 3040164731u, 1530172182u, 2950426149u,
26431402416557u,
2644756419859u,
26454132576145u, 724994790u, 2852015871u, 2177908339u,
2646899914731u, 139675671u, 1423281870u, 3198458070u,
2647807581308u,
26482021611521u,
26491801452575u, 1425984297u, 2833835949u, 1536827865u,
26503902351840u, 164546042u, 1872840974u, 3986194780u,
2651792156290u,
26523378681896u,
2653941547959u, 3931328334u, 3661060482u, 2386420777u,
26543920146272u, 3458621279u, 3348500844u, 2269586542u,
2655797371473u,
26563188953649u,
265780514771u, 2913333490u, 1246325623u, 3253846094u,
26581723906239u, 1606413555u, 587500718u, 1412413859u,
26592310046829u,
26602113313263u,
26613855635608u, 47271944u, 1112281934u, 3440228404u,
26622633519166u, 425094457u, 307659635u, 67338587u,
26632412987939u,
26642363930989u,
26652853008596u, 2844637339u, 922568813u, 130379293u,
26662825204405u, 2904442145u, 1176875333u, 1511685505u,
2667599177514u,
26681872681372u,
2669682394826u, 1888849790u, 3635304282u, 1761257265u,
26701571292431u, 355247075u, 1177210823u, 1691529530u,
26713629531121u,
26723760474006u,
26731129340625u, 868116266u, 3908237785u, 1942124366u,
26741266630014u, 3214841995u, 334023850u, 1110037019u,
2675369650727u,
26761288666741u,
267770535706u, 20230114u, 4284225520u, 727856157u,
2678293696779u, 1244943770u, 3976592462u, 560421917u,
26794171688499u,
26802438786950u,
26811218144639u, 3809125983u, 1302395746u, 534542359u,
26822121993015u, 2899519374u, 3192177626u, 1761707794u,
26833101683464u,
26841555403906u,
26853225675390u, 1875263768u, 4278894569u, 651707603u,
26862111591484u, 3802716028u, 2900262228u, 1181469202u,
26873254743797u,
26881822684466u,
2689860641829u, 3046128268u, 1284833012u, 1125261608u,
2690461384524u, 2331344566u, 1274400010u, 990498321u,
26913462536298u,
26923796842585u,
26932346607194u, 279495949u, 3951194590u, 3522664971u,
26943169688303u, 726831706u, 1123875117u, 1816166599u,
26953759808754u,
26962918558151u,
26973713203220u, 3369939267u, 466047109u, 384042536u,
2698587271104u, 2191634696u, 2449929095u, 1157932232u,
26992084466674u,
2700841370485u,
27013241372562u, 4277738486u, 2150836793u, 1173569449u,
2702778768930u, 2594706485u, 3065269405u, 3019263663u,
27032660146610u,
27042789946230u,
270577056913u, 728174395u, 3647185904u, 804562358u,
27062697276483u, 881311175u, 1178696435u, 2059173891u,
27072308303791u,
2708221481230u,
270950241451u, 3689414100u, 1969074761u, 2732071529u,
27101900890356u, 840789500u, 2100609300u, 985565597u,
27111220850414u,
27122456636259u,
2713223607678u, 1016310244u, 1937434395u, 85717256u,
2714275058190u, 3712011133u, 171916016u, 2389569096u,
27153679765802u,
27163575358777u,
27173481108261u, 3178286380u, 2489642395u, 2931039055u,
27183086601621u, 3079518902u, 3027718495u, 2506894644u,
27192976869602u,
27202134336365u,
27212420172217u, 918054427u, 661522682u, 1403791357u,
27223587174388u, 2623673551u, 1355661457u, 4159477684u,
27231109013587u,
27243112183488u,
27252217849279u, 3500291996u, 2419603731u, 2929886201u,
27263854470013u, 1358382103u, 1357666555u, 21053566u,
27272716621233u,
27283094836862u,
27293309729704u, 57086558u, 839187419u, 2757944838u,
27303651040558u, 3607536716u, 3691257732u, 2312878285u,
27311202511724u,
2732183479927u,
27332509829803u, 109313218u, 478173887u, 2072044014u,
2734190631406u, 2495604975u, 1010416260u, 3679857586u,
2735726566957u,
2736258500881u,
27371805873908u, 3081447051u, 2352101327u, 534922207u,
27381584552873u, 813470716u, 255914637u, 249169434u,
27393193498057u,
27401038802706u,
27412590158653u, 3147907290u, 663060128u, 1156177857u,
2742634616100u, 312879189u, 1545020368u, 2054634247u,
27433271451914u,
27443438291534u,
27452181454946u, 3864535432u, 2398586877u, 896491075u,
27462810631478u, 2770357487u, 3372930052u, 898070638u,
27472051007323u,
2748392959778u,
274936645539u, 3743556044u, 4134529680u, 4124451188u,
2750566806297u, 2936523982u, 1304761965u, 537399498u,
27511940818842u,
275240862381u,
275336288410u, 3063605629u, 2826611650u, 3961972098u,
27541871578006u, 2392095486u, 1136931591u, 513864488u,
2755173276451u,
27563039055682u,
27573543322032u, 1943592006u, 657217094u, 1751698246u,
27582969618445u, 456616022u, 900309519u, 113892716u,
27591126392103u,
27601235651045u,
27611882073852u, 2136610853u, 2353639710u, 2819956700u,
27623980083530u, 828773559u, 224069850u, 902434120u,
27632802008036u,
276494358995u,
27652777723394u, 2812641403u, 2525832595u, 4157388110u,
27664235563782u, 937800324u, 141690749u, 568062536u,
2767550123849u,
27681330316521u,
27691949488696u, 2296431366u, 1958465262u, 3564751729u,
27703748252207u, 120455129u, 1607318832u, 2525729790u,
27712640987481u,
27722332096657u,
27731775969159u, 1555085077u, 2913525137u, 1347085183u,
27742376253113u, 3194050574u, 1806090610u, 678641356u,
27751499146713u,
2776383849715u,
27773299835823u, 2284860330u, 2614269636u, 3913628844u,
27782761334210u, 1959484587u, 529797021u, 239966995u,
27793102194829u,
27803602307804u,
27811122192627u, 3577510006u, 164486066u, 1680137310u,
27821473396395u, 1467801424u, 903493660u, 1185943071u,
27832798556505u,
27842306744492u,
27853167201310u, 3577947177u, 3067592134u, 2905506289u,
27861210366329u, 204484056u, 2347778932u, 3862374472u,
27873277439508u,
27884187414621u,
27891646699310u, 621385800u, 3934869089u, 3975491588u,
27903580085916u, 1925674500u, 2436305348u, 3983301539u,
27912739439523u,
27923291507446u,
27933395637920u, 3753389171u, 2955202032u, 2654255623u,
27943771089254u, 2140443405u, 2779834738u, 3261942805u,
27953526889244u,
27961842009139u,
27974048484340u, 2106218403u, 2161244271u, 772152700u,
27981158647659u, 3776791619u, 3882186721u, 699525237u,
27992954670460u,
28001007105869u,
28013359152025u, 1146388699u, 1401550303u, 2326582541u,
28024181783540u, 1085644043u, 1942143795u, 1038368308u,
28031526153809u,
28044042547244u,
28051891441000u, 2573991874u, 1281441253u, 3635098284u,
28061980545715u, 825985487u, 3934748116u, 4228386979u,
28071480870944u,
28081042194545u,
28092397771642u, 2248490001u, 3817869868u, 878654626u,
28103785629484u, 1672470870u, 3229367873u, 1894538933u,
28111010692731u,
28121733824268u,
2813656620328u, 3048283803u, 3353340056u, 2324965120u,
28144192585951u, 2284524675u, 3483884368u, 1510168293u,
28151554942691u,
28161309709396u,
28171241133168u, 3162179280u, 4046378054u, 3171681593u,
28181165297136u, 3496703563u, 150437903u, 1948622072u,
28191076332463u,
28202292479143u,
28211464229958u, 3479738093u, 2328067598u, 2334503110u,
2822833324834u, 3981605747u, 3002629155u, 2854644186u,
28232832201336u,
282495796957u,
28253269249397u, 2358313329u, 3411860910u, 4283292480u,
28262802208697u, 1305947955u, 2156803420u, 1991340283u,
2827189678024u,
2828447602599u,
28291055411517u, 1531748363u, 1555852656u, 412402681u,
28303774988152u, 20597551u, 2925024131u, 1423989620u,
28313749428061u,
28321541439448u,
2833112270416u, 1936224776u, 132162941u, 3772011507u,
28343814102518u, 1908807815u, 444154079u, 823765347u,
28353362275567u,
28363419047430u,
28372108287005u, 2315102125u, 658593738u, 3195094029u,
28383721937534u, 3176229204u, 3398835373u, 1271898712u,
28391142546577u,
28403185986817u,
28413562705803u, 2046119567u, 912990621u, 1829977672u,
28423459576979u, 1118045834u, 1369529376u, 3320601076u,
28433954988953u,
28444002467635u,
28453359456351u, 1314849568u, 1766750942u, 2998874853u,
28461181800239u, 707328036u, 3314954697u, 2066721120u,
2847598194215u,
28481124451278u,
28493156679616u, 3742684743u, 2960199690u, 2683497915u,
28502566077529u, 937014607u, 102095219u, 4262922475u,
28513132264275u,
28521262099830u,
2853862722905u, 2717653494u, 3245583534u, 3427209989u,
28543220278124u, 85457091u, 2222333500u, 3513997967u,
28553522324951u,
28562830855552u,
28572215004781u, 3482411840u, 4227160614u, 2030964411u,
28581741393851u, 2643723748u, 942813508u, 403442675u,
28593112048748u,
2860530556423u,
28613817755244u, 3543286628u, 2247276090u, 1532920842u,
28624101962711u, 1446540991u, 3297821473u, 1861255389u,
28631984398u,
28642366525138u,
2865377589481u, 3549193828u, 1427765914u, 506831657u,
2866277278988u, 1447652775u, 3214362239u, 3142198690u,
28672843087541u,
2868468915015u,
2869807895062u, 2198723907u, 4031145069u, 2417156212u,
28704027298697u, 637175947u, 1229254212u, 1773257887u,
28711659444818u,
2872451148891u,
28732099741368u, 735351990u, 2534775713u, 3261804619u,
2874712519954u, 3527962772u, 3758642738u, 4245823575u,
28751281314264u,
28761167866160u,
28771489546151u, 1197354389u, 1043278102u, 2563326586u,
2878371937794u, 2320164817u, 3189512691u, 573685198u,
28794108603513u,
28803758899588u,
28813507030163u, 2947201212u, 2529492585u, 578234375u,
28823362349842u, 3318878925u, 3611203517u, 3059253190u,
28834270755916u,
28844291274625u,
28854237586791u, 4137422245u, 2927218651u, 2444687041u,
2886797128811u, 2043057612u, 396533859u, 2665256178u,
28873346510674u,
28881779586176u,
28893076562062u, 1882746214u, 921095362u, 2026988397u,
2890514514911u, 3886379478u, 4218272420u, 1480386793u,
28913900160816u,
28922292273451u,
28931276138356u, 1125461821u, 1912885715u, 3365266013u,
28941333211627u, 4085009861u, 1390530102u, 3347984752u,
28952721771301u,
28961419492325u,
28974066766256u, 3250852311u, 820111852u, 1382201318u,
28982366036798u, 938032241u, 3100979439u, 487048687u,
28992292851045u,
29003241399180u,
29013912670510u, 2416437067u, 2973194517u, 3507707986u,
29021935099406u, 2533441488u, 104616731u, 2892622820u,
29033801190339u,
29044239188808u,
2905807238241u, 3300121546u, 2249406147u, 4032114017u,
29063713738189u, 3324425575u, 4275607376u, 3663120298u,
29074173658372u,
29083984289690u,
29091827636846u, 3264588778u, 3297165529u, 558623533u,
29102728945672u, 1566297318u, 3447249966u, 481719551u,
29111596842050u,
29121838185946u,
2913265271620u, 1050246315u, 4046655705u, 1844193138u,
29143807563245u, 1075384804u, 1292554949u, 1506525927u,
29152921816148u,
29162051885269u,
29171930534041u, 3872721086u, 1564489377u, 2272482181u,
29182849358683u, 589618304u, 2262072443u, 290363051u,
2919299168363u,
29203867603931u,
29212868688756u, 2545263115u, 1092098533u, 3885725603u,
29222352430409u, 1981595469u, 2047946646u, 1332642839u,
2923793806516u,
2924214858837u,
29251061484659u, 3192394476u, 1115054785u, 3690637234u,
2926996792368u, 2023479706u, 3046498231u, 4205835102u,
29273870714754u,
2928257472875u,
29293549864599u, 2040276129u, 2414778670u, 812235477u,
29302674248196u, 1864096101u, 2257492689u, 1332556794u,
29311079540713u,
2932465530720u,
29332304763972u, 830724724u, 3354588920u, 2510713652u,
29343103749409u, 468835585u, 1707620787u, 3038024846u,
29351000303198u,
29363462270146u,
29372748698899u, 2100348093u, 511537258u, 1237187486u,
2938102049383u, 2268226698u, 3162251739u, 4219404629u,
2939838822407u,
29401481440623u,
29412989224077u, 2676681975u, 3246551821u, 3812079906u,
2942370572963u, 2283154352u, 3084789986u, 1961085583u,
29431955640586u,
29442409348147u,
29452284780581u, 1634818716u, 4018221729u, 2320761377u,
29463566831899u, 1799560520u, 91431959u, 1754113747u,
29471459430477u,
29483613658517u,
2949924489906u, 3406317699u, 866289774u, 3924821603u,
29501265394945u, 1870668109u, 151949856u, 2747006534u,
29513111906201u,
295264039467u,
29532314447545u, 2600195638u, 4095795204u, 4162096026u,
29541026756826u, 2460047982u, 52686887u, 823198739u,
29551518045160u,
29562867527376u,
2957566410761u, 2200433819u, 2114146405u, 2893790965u,
2958881504901u, 974783212u, 490815659u, 937300283u,
29591523735309u,
29602511976468u,
29612634644947u, 355119367u, 1373773092u, 309232995u,
29623088671051u, 787126032u, 3442836843u, 4289194567u,
29632177850062u,
29641174136430u,
29653248982914u, 3129039732u, 1166851580u, 2196451882u,
2966469595580u, 2130837700u, 3783349021u, 3745262548u,
29671236930515u,
29683032131496u,
29691525591437u, 1823628217u, 1939019255u, 1950270463u,
29703659899927u, 3688643445u, 3004399289u, 1155199552u,
2971357547234u,
29722213110526u,
29733122658210u, 2667800490u, 2718690333u, 3512372076u,
29741098611683u, 2657518392u, 4248458835u, 3109874532u,
29751592908438u,
29762864927516u,
29773635248840u, 1251777186u, 3797340158u, 3508496870u,
2978303354834u, 1482394062u, 2087100120u, 1595931912u,
2979608574156u,
2980723367884u,
2981907938402u, 3357047807u, 1619629851u, 3092082995u,
298289030300u, 916336992u, 1861180168u, 3436334155u,
29831375000544u,
29843472936241u,
29851321217853u, 791356402u, 2872410224u, 2326250297u,
29862657644088u, 1748314108u, 4146771421u, 2913114440u,
29872924821844u,
29882101101496u,
29893268017251u, 2109603066u, 690665520u, 1830067573u,
2990951427661u, 2982533150u, 3884512506u, 2358657479u,
29912833210784u,
29923419798214u,
29933785893994u, 2103940206u, 86759766u, 4031230616u,
29943745237192u, 2739453927u, 497038072u, 3303159408u,
29951251537249u,
29961993408196u,
29973185905715u, 2885948408u, 3154277110u, 2444150313u,
29982505582079u, 2120610195u, 3266465773u, 1814611964u,
29993080050407u,
30001079915522u,
30011819346505u, 2529946763u, 892097374u, 3740257161u,
30023618100441u, 1079900094u, 3607172225u, 737863389u,
3003360704560u,
30043341993089u,
30051139047381u, 3132219631u, 1248981859u, 1109338159u,
30062004908615u, 4022302594u, 4166640860u, 2959140950u,
30073949235962u,
30082832278473u,
30092200524012u, 2634933043u, 2495844522u, 2613799818u,
30104034096813u, 683271795u, 1673546817u, 1363163726u,
30111805395136u,
3012511749501u,
30131231032599u, 2305979751u, 345737783u, 3339868854u,
30142931857933u, 2323251738u, 1332068477u, 51846558u,
30153927238177u,
30161387182179u,
30171701238601u, 1419275173u, 2580882268u, 3357874599u,
30181726558907u, 1292901039u, 1371322339u, 1311713044u,
30193526735232u,
30204017884184u,
30213366093428u, 77140994u, 2128996229u, 1357915765u,
30224019691901u, 483989024u, 2390311750u, 2766065288u,
30233938587520u,
30243064810344u,
30251054589198u, 1274997019u, 4040589616u, 1277751144u,
30262274907047u, 4170399945u, 2886368209u, 4168922115u,
30273901237033u,
30283252972311u,
30292205185840u, 3403097556u, 3385493699u, 2809751370u,
3030555319628u, 399539034u, 2998971454u, 1521596214u,
3031178870216u,
30321471733541u,
3033519629198u, 514159209u, 1500582242u, 1928616587u,
30342686427928u, 4133138798u, 1225914083u, 1432713584u,
30353559310915u,
30363925489366u,
30371055613123u, 4126676029u, 2723867653u, 3290604111u,
30381377022957u, 2373608155u, 3615237379u, 594338683u,
30392645257602u,
30402408427260u,
3041917033274u, 750455097u, 625657657u, 121713200u,
30422191273413u, 4043949724u, 3293146785u, 3809297972u,
30433947296919u,
3044115456894u,
30451529576616u, 1459278275u, 2157117997u, 1747859293u,
30464106665903u, 996939232u, 2007976332u, 4274649009u,
30471017725787u,
30484244666096u,
30491219631331u, 3072426253u, 3547691720u, 1620822012u,
30501397717508u, 2031597325u, 3345983430u, 2459068000u,
30513645130467u,
30522308642742u,
3053359955852u, 1348467968u, 1133123059u, 2435919062u,
30542800365907u, 4213217210u, 4056565603u, 2811666556u,
30552318007236u,
30563823652401u,
30573654086429u, 1273260424u, 1591610446u, 943349350u,
30583441227678u, 3779964757u, 233818224u, 3469971032u,
30593764095096u,
30604009204587u,
3061678472092u, 1990559652u, 2583121088u, 2978143652u,
30622496370864u, 2139539656u, 4287972050u, 295832576u,
30633536742861u,
30642257466133u,
30652738052161u, 1988611898u, 2466189642u, 3294419573u,
30662311186273u, 474374532u, 3081964174u, 2515138278u,
3067835731677u,
30681178182694u,
30693352119543u, 2884763225u, 3462399574u, 2900817210u,
30701993698511u, 2868445043u, 2746444849u, 1205258179u,
30712353442946u,
30724079040070u,
30733624133102u, 2907136076u, 2902521697u, 426813211u,
30741418185512u, 3711189488u, 1351506552u, 1934749519u,
307546595543u,
3076401688809u,
30773514602124u, 1396852607u, 1951477943u, 2502249173u,
30783199695820u, 2890250638u, 4205072507u, 1715623846u,
30793266686789u,
30803218688128u,
30811697759742u, 851227671u, 2358709645u, 4174233268u,
3082500583683u, 3805940955u, 736234120u, 2710563712u,
30831949664540u,
30843139414003u,
30854293073253u, 1284406972u, 1785182449u, 1051548274u,
30862994248357u, 2499882522u, 717208669u, 2039517285u,
3087518424929u,
3088143136433u,
30892303774671u, 1272930860u, 2286410920u, 788459311u,
3090273225293u, 2439291703u, 2254505236u, 3446287701u,
30913655156558u,
30921546628787u,
3093340081500u, 3285722006u, 1324810435u, 1053980860u,
30941779472859u, 2700355724u, 686005017u, 3762376315u,
30953963193100u,
30961370881135u,
3097661300087u, 1152753704u, 2349891598u, 3910051187u,
30982109444785u, 1311123870u, 2639837565u, 1896770931u,
30991081414128u,
3100869877586u,
31014284220400u, 63045374u, 235968615u, 184451062u,
31021271099822u, 1319179857u, 3274963209u, 4172272710u,
31033388797445u,
31042965973320u,
31053793110097u, 3327241723u, 2991804005u, 1199544355u,
3106771553759u, 2031749842u, 2596517372u, 1199888213u,
3107858347951u,
31083340178832u,
31092903875412u, 763490382u, 76949161u, 2056544406u,
31101145227689u, 998233136u, 2354530024u, 427713587u,
31113537837347u,
3112604661755u,
3113923986833u, 1023730418u, 798294227u, 432557449u,
3114801802449u, 1861313429u, 3899128441u, 4068407979u,
31152352677083u,
31163783539925u,
311710731973u, 3390767975u, 3949540249u, 1920121661u,
31183248580201u, 641956426u, 2104847395u, 604835744u,
31191491663404u,
31204255204651u,
31211520970746u, 2845653368u, 3247412938u, 3730629005u,
3122855569514u, 3073294700u, 2429691698u, 3818342476u,
31233938869985u,
31242731201328u,
31252335202643u, 778117742u, 13298408u, 228780590u,
31262871715314u, 3253688653u, 4150999702u, 3846220408u,
3127930808u,
31281397128726u,
31291964216488u, 2781092828u, 116285375u, 2271239476u,
31303724347554u, 2931203895u, 3893169206u, 1883912528u,
31312093892660u,
31323658787024u,
31333095016046u, 1094059199u, 3640239610u, 558564267u,
31342102812456u, 464734873u, 925262247u, 1609838036u,
3135588364741u,
31361731409233u,
31371576165139u, 3933979268u, 375316394u, 4247099643u,
31383670508019u, 4080496835u, 2371248533u, 183762693u,
31392078935389u,
31402699810414u,
31411491815683u, 2999180789u, 1831158425u, 1603373553u,
31422006136905u, 3210230591u, 416748595u, 1536971415u,
31433271869367u,
31441266062739u,
31452138414557u, 3337114778u, 1634586826u, 36472629u,
31464482244u, 568009609u, 2721216780u, 4037289545u,
31472235138807u,
31481789351460u,
31494067539527u, 1323062829u, 3864620647u, 4192026301u,
31504278901241u, 1399025382u, 2826652805u, 1363860382u,
31511801770651u,
31521613381526u,
31531165249276u, 4046576622u, 2535596946u, 3260388176u,
31541078898578u, 2259750862u, 643387587u, 237144235u,
31554199571427u,
31563440917581u,
31573067939258u, 2018625455u, 1460528353u, 3138629939u,
31581666223528u, 3841139376u, 2528281125u, 885565193u,
31592609492686u,
31602517257479u,
3161560864620u, 2261471820u, 3491559165u, 1329620416u,
3162622383582u, 1759597655u, 2877873893u, 584692817u,
31631901728399u,
31642599000260u,
31653169771644u, 296332336u, 774719455u, 4175920823u,
31662287316070u, 4115615023u, 1073335619u, 4240292725u,
31671359158837u,
31681960974237u,
31693173724597u, 1619084286u, 2876340752u, 4065675347u,
3170480741335u, 1237329941u, 701055566u, 3729009837u,
31711314736422u,
31724003180069u,
31733118519317u, 3035354420u, 3380357671u, 4020909015u,
3174253958714u, 3545798863u, 3008185002u, 2624719888u,
31753219955575u,
31763060719376u,
3177573101682u, 1580316843u, 2610493412u, 3490983536u,
31783601975611u, 851470366u, 635384901u, 3427048824u,
31791470002757u,
31803592460087u,
31812265226856u, 4124282457u, 2106385486u, 3334305617u,
31824208282753u, 3798749815u, 225396466u, 118791182u,
31832523395972u,
3184194595464u,
31852563824631u, 2521301383u, 4224409406u, 468670274u,
31861761966400u, 1300908277u, 2570709228u, 1847901526u,
31871470099163u,
31882690466752u,
31891472536718u, 2399279735u, 4150607803u, 1775080054u,
31902082537685u, 4080034578u, 1256001880u, 392967725u,
31912055838940u,
31923349115816u,
31931745947263u, 2213925887u, 1836572741u, 2417722792u,
3194636223705u, 2423329294u, 3960951311u, 1543591052u,
31951547914361u,
31962760945653u,
31973519014111u, 313543871u, 4119598884u, 1071003714u,
31982192556597u, 1526995535u, 3929839778u, 536388591u,
31993040873792u,
32003752682932u,
32011640614237u, 2432794021u, 385337403u, 2794410617u,
32022386128075u, 1055206708u, 1422747714u, 3759330929u,
32032533597496u,
320430440955u,
32051482899460u, 3350385050u, 616259409u, 3980103795u,
32061211364140u, 1040071544u, 594746920u, 1645973936u,
32072547331531u,
32081097726368u,
3209700666526u, 2976247482u, 1144906608u, 996506677u,
32101997130756u, 800321417u, 1392942823u, 1601662248u,
32112079778663u,
3212529512908u,
32132925120134u, 4106433085u, 630221833u, 2423086156u,
32141119859778u, 1726827981u, 1870859181u, 2559832707u,
32151792284257u,
32162059356387u,
32173572353364u, 3229407475u, 575621095u, 3221893291u,
32182372428048u, 2020123035u, 961449593u, 2243824063u,
32193803906611u,
32203735348189u,
32212981620804u, 4180681078u, 1555330629u, 230736535u,
32222075526640u, 749652975u, 713664372u, 2152096659u,
32232142067223u,
32243322302242u,
32251421646830u, 2092832615u, 1213735101u, 3192136753u,
32261106723940u, 3455398230u, 2541685524u, 2529956739u,
32273789430647u,
32281950084508u,
32292157395621u, 850457360u, 2758902426u, 2848030169u,
32306506379u, 1162213157u, 2981459221u, 272690871u,
32313059420255u,
32324242691285u,
3233588065598u, 1206949936u, 3968214184u, 566348532u,
3234126142880u, 1480567086u, 2959621988u, 2050218418u,
32352242731195u,
32363833514449u,
32371898070331u, 3687399477u, 3891859374u, 868185955u,
32382335308774u, 3676335246u, 3871121805u, 2189032743u,
32393275728647u,
3240860492892u,
32411590764344u, 4130384758u, 262871548u, 3004764525u,
32422685542071u, 991231482u, 435122019u, 3031116998u,
32432898921700u,
32442917932604u,
32454238665148u, 2459072654u, 3444612545u, 4207731740u,
32461808564313u, 2798532269u, 3944553556u, 3926395409u,
32471633200670u,
32484138335224u,
32492524878605u, 4184292650u, 3563398268u, 4288943552u,
32503802121210u, 957502058u, 2410820887u, 4227117506u,
32514018625153u,
32524284329158u,
3253530216712u, 2978986531u, 863452221u, 1910162118u,
32544088211378u, 4091971261u, 3150811451u, 4200871487u,
32553794038652u,
32563041564310u,
32572045287082u, 887805614u, 2889167251u, 4120352181u,
32581699912580u, 3478922097u, 3211994687u, 3136177842u,
32591500806861u,
32603211881347u,
32612147976385u, 3342722260u, 3359650541u, 4197378460u,
3262781354073u, 1533623029u, 2204677828u, 3228172832u,
32633248592437u,
32643355841359u,
3265560815159u, 1144951236u, 4027015711u, 2882625391u,
3266339363613u, 2354572719u, 1769831876u, 4238589331u,
32671519732871u,
32682185834614u,
32691601096831u, 129709881u, 39655633u, 367604993u,
32701737681770u, 3259114599u, 2767070452u, 872365177u,
32711574125529u,
32723405020189u,
32734181346685u, 1134030380u, 403769171u, 2193351164u,
32741426232618u, 2885309450u, 3033612627u, 924948363u,
3275935514094u,
32763202053329u,
3277912294839u, 1618472324u, 4159158431u, 3744999487u,
3278777064358u, 3974213124u, 1990246048u, 309725290u,
32792449849392u,
32801943692420u,
32812288635750u, 2433793635u, 2168904061u, 683315308u,
32823081493019u, 3477759434u, 3815496269u, 2823504699u,
3283586945121u,
32843088963200u,
32853492287335u, 636875049u, 1111206944u, 2037346120u,
32861282050044u, 1409681512u, 1786128584u, 755810950u,
32872332676758u,
32882178142310u,
3289957827166u, 1014983590u, 1888800725u, 3608595803u,
32903200072714u, 2534008478u, 659336139u, 1281728287u,
32914060560529u,
32922915575125u,
32933521503774u, 2926487340u, 1096297674u, 653489861u,
32942352326980u, 2561136777u, 1224141198u, 1250479629u,
32951297625391u,
32962409997371u,
32971942483722u, 2481835750u, 1394715707u, 1673070941u,
32982456039704u, 3980558014u, 3547934764u, 1882038812u,
32991078160498u,
33002488279087u,
33011848235245u, 1211914722u, 2264928765u, 2807773070u,
3302270145554u, 583747883u, 3826009010u, 2996618216u,
3303425727157u,
3304992726957u,
33053384462280u, 726650661u, 1955043265u, 1923879512u,
33061854693773u, 2987614542u, 2660044993u, 2457260810u,
3307426299370u,
33082671892900u,
33091827308087u, 3083953443u, 1791749638u, 3265087416u,
33102119752201u, 2547122538u, 3990783236u, 1912713468u,
33113688865211u,
33121815780016u,
3313303699291u, 2416763742u, 2690891610u, 1535193548u,
33141107803989u, 1504143133u, 2235270371u, 2545884083u,
33152276278682u,
3316411724404u,
33173416925704u, 2565792091u, 3383911757u, 546058824u,
33183374654444u, 2364630415u, 2693473470u, 2622125691u,
3319261864817u,
332055682470u,
3321857617568u, 141304067u, 1885488541u, 155368182u,
33221281949051u, 3384522408u, 3254816901u, 1959816782u,
33231452224057u,
33242830267691u,
33253709231247u, 58988202u, 4218130458u, 2984061349u,
33261888707848u, 4223605071u, 4241442486u, 375269213u,
33273208327038u,
33282199916493u,
3329550337252u, 2855061437u, 276088636u, 114362204u,
33302321163647u, 2127813633u, 3289403024u, 2686973202u,
33312717376797u,
33323593428039u,
33333648831666u, 890925902u, 3289404818u, 3289516821u,
33344248913260u, 1858916580u, 3303932308u, 1752797086u,
33351628149686u,
33363245893605u,
33371568537311u, 2844194502u, 1593855770u, 2408174109u,
3338124797514u, 2085649512u, 3188565660u, 2264996276u,
33391926696513u,
33403053957740u,
33412238806881u, 2189050973u, 203685243u, 379855590u,
33423920271562u, 1058600179u, 3698061923u, 4255106849u,
3343608401664u,
33441598041932u,
33453318266418u, 2535016555u, 852760884u, 1918098822u,
33462200437599u, 1532285043u, 3425662132u, 3561293706u,
33472231633206u,
33484108785088u,
33493359152801u, 173534780u, 208383607u, 2862988169u,
33502406642243u, 426814583u, 2777335795u, 3322703596u,
3351954190623u,
3352615093090u,
33534179102978u, 2452847930u, 100239619u, 42471741u,
3354818352432u, 2190624654u, 504379960u, 3631619975u,
3355633412456u,
33561018421783u,
3357842645419u, 711808707u, 3424580813u, 2132457941u,
33581158335882u, 3567952480u, 2302183699u, 1145788151u,
33593474264138u,
33603105085243u,
33613115506027u, 2783713015u, 3871785309u, 539583269u,
33621400252405u, 3857849984u, 4231186588u, 1278653799u,
33631760227022u,
3364761044088u,
33653838185417u, 2439542532u, 585283357u, 2055995220u,
3366937117124u, 3831944855u, 1823586038u, 3287917855u,
3367485082427u,
33683209172809u,
33691984570176u, 2818337297u, 2691869057u, 3790476953u,
3370839035557u, 3203129010u, 669981176u, 4121157385u,
33713519870450u,
33723792633352u,
33733017650322u, 1603459507u, 4225677666u, 376555451u,
3374473780127u, 2018786277u, 3299822439u, 1010254499u,
33752383887565u,
33763155009499u,
33773108110655u, 2641738274u, 3684908622u, 1606463047u,
33783311068174u, 52708046u, 754181455u, 1018079176u,
33793915670272u,
33803366999425u,
33811012880204u, 1339439715u, 466437962u, 1402662350u,
33822504046911u, 736323938u, 2037800124u, 1725908589u,
3383716341840u,
33841750123474u,
33853366342464u, 1743666195u, 2975303189u, 3821364027u,
33863253707772u, 3635548377u, 3840413796u, 1955642085u,
33871018315169u,
33881258092848u,
33892095540656u, 1076256607u, 117289557u, 1311658655u,
33902118301000u, 68721550u, 2886814107u, 2712432819u,
33914201862886u,
3392753807148u,
33931940229047u, 731347296u, 1068901393u, 3873155894u,
33942852787666u, 1973464853u, 79735652u, 3966380587u,
33953245740712u,
33962525773438u,
3397734938109u, 3045656416u, 3335746354u, 4099732691u,
33981911896517u, 1697006473u, 1145487066u, 1605663299u,
33993053606724u,
34002386289465u,
34013821211369u, 1006215345u, 1256304829u, 1053001668u,
34021289194958u, 118761054u, 1853688730u, 2803418011u,
3403188650809u,
34043763686458u,
34051006829556u, 2961984133u, 3390525025u, 2061199893u,
3406141792681u, 2439893463u, 2652982650u, 1804942682u,
34071546510005u,
34081246961405u,
34092407577046u, 565772575u, 3751844810u, 2943166103u,
34103750052451u, 3022527280u, 25162928u, 397381043u,
34111818337632u,
34123447363730u,
34133936437150u, 2569420703u, 2215592390u, 2171555672u,
34143665571006u, 4021712412u, 2939158353u, 4057813172u,
34151823237318u,
3416103999245u,
34173251978010u, 3591914940u, 3582495283u, 2519035265u,
34183905726135u, 3180393349u, 2743117123u, 55247368u,
34193325286701u,
3420705195946u,
34211857526853u, 1480518550u, 3809990433u, 1398189338u,
34223126362926u, 3959531492u, 1503658285u, 1977847740u,
34233043964489u,
34242613086143u,
34251518119282u, 4238434900u, 3905746486u, 3064949667u,
34261028122931u, 3309119457u, 4071194920u, 3096098907u,
34274137180520u,
3428494467959u,
34291231408687u, 1691606157u, 1793452569u, 2722196118u,
34303478603952u, 1059665738u, 2282032278u, 3990268388u,
34311719514651u,
34324248311578u,
34333799146721u, 898026304u, 3367808954u, 4162472815u,
3434170495870u, 1308116609u, 3428285344u, 1714716475u,
3435395576794u,
34364153638621u,
34372999745812u, 3483315953u, 304980828u, 595337120u,
34383486516729u, 2331563143u, 2583609459u, 1885928417u,
34393834283777u,
3440979337825u,
3441932057378u, 3124081189u, 1930356777u, 3865887996u,
34424178282217u, 4214219408u, 3669465884u, 1472413856u,
34433356866587u,
34441012769806u,
34453043639963u, 996996396u, 207308216u, 982967331u,
34462991319933u, 318066902u, 721489670u, 1249967713u,
3447749240921u,
3448591392325u,
34492379365192u, 2250868849u, 2163259329u, 143191325u,
34503778285606u, 982149096u, 3536906200u, 2244353244u,
34511443862317u,
34523161549210u,
34532183127464u, 2015409516u, 547003700u, 2032484282u,
3454523677821u, 4275663308u, 3827205526u, 3903778273u,
34552444530525u,
34562543645801u,
34571173958423u, 784740616u, 2878693675u, 3127696736u,
34583832037316u, 3161002398u, 4084166400u, 4213346853u,
3459223390424u,
34604273380883u,
34612130315482u, 3429606032u, 3367732613u, 1912357694u,
3462422632590u, 1266957023u, 3437535648u, 736404240u,
34632281709372u,
3464415859912u,
3465212948797u, 351612650u, 3920561440u, 112963586u,
34662230727543u, 2851076612u, 1990662634u, 2264296857u,
34673131463650u,
34682704034623u,
34693541637839u, 2954232792u, 533986918u, 4158757533u,
347065174248u, 4232639593u, 865906667u, 1948225652u,
3471779656112u,
34723873989249u,
34732372984749u, 2346988193u, 1104345713u, 1165654138u,
34744045762610u, 3588205178u, 461363991u, 1111215752u,
34751389675192u,
34762404325151u,
34772152228101u, 3808973622u, 1901235912u, 3458690696u,
3478314513238u, 2539459143u, 2847998873u, 952026138u,
34792325705328u,
3480407844712u,
34813727960715u, 2996448351u, 2374336760u, 3138756390u,
34822600015243u, 539980418u, 1876285352u, 1670330799u,
34831709360377u,
34842868531654u,
3485494777964u, 2773053597u, 599486162u, 3962209577u,
34861871328846u, 2171933018u, 110279472u, 384074780u,
34874147021936u,
34882333589647u,
34894251778066u, 40493468u, 3099342316u, 4108779767u,
34902812424588u, 954542332u, 2040682331u, 2251152306u,
349145915516u,
3492259525626u,
34931045384743u, 4134656562u, 749389261u, 874399445u,
3494616549904u, 2200447504u, 436024539u, 78972290u,
34953210485762u,
34961907985531u,
34973013721395u, 4214533685u, 4198804243u, 534879265u,
34981517190881u, 3756787754u, 1152563554u, 1718750948u,
3499777737463u,
35001402478860u,
35011824562784u, 1879401449u, 3515818786u, 513165201u,
35021423491227u, 2103067918u, 2291777410u, 1097943000u,
3503};
3504
3505// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
3506bool Test(int offset, int len = 0) {
3507#undef Check
3508#undef IsAlive
3509
3510#define Check(x) do { \
3511 const uint32_t actual = (x), e = expected[index++]; \
3512 bool ok = actual == e; \
3513 if (!ok) { \
3514 cerr << "expected " << hex << e << " but got " << actual << endl; \
3515 ++errors; \
3516 } \
3517 assert(ok); \
3518} while (0)
3519
3520#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
3521
3522 // After the following line is where the uses of "Check" and such will go.
3523 static int index = 0;
3524if (offset == -1) { int alive = 0; IsAlive(farmhashcc::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashcc::Hash32(data, len++)); { uint128_t u = farmhashcc::Fingerprint128(data, len++); uint64_t h = Uint128Low64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); h = Uint128High64(u); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
3525Check(farmhashcc::Hash32WithSeed(data + offset, len, SEED));
3526Check(farmhashcc::Hash32(data + offset, len));
3527{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
3528{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); Check(h >> 32); Check((h << 32) >> 32); h = Uint128High64(u); Check(h >> 32); Check((h << 32) >> 32); }
3529
3530 return true;
3531#undef Check
3532#undef IsAlive
3533}
3534
3535int RunTest() {
3536 Setup();
3537 int i = 0;
3538 cout << "Running farmhashccTest";
3539 if (!Test(-1)) {
3540 cout << "... Unavailable\n";
3541 return NoteErrors();
3542 }
3543 // Good. The function is attempting to hash, so run the full test.
3544 int errors_prior_to_test = errors;
3545 for ( ; i < kTestSize - 1; i++) {
3546 Test(i * i, i);
3547 }
3548 for ( ; i < kDataSize; i += i / 7) {
3549 Test(0, i);
3550 }
3551 Test(0, kDataSize);
3552 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
3553 return NoteErrors();
3554}
3555
3556#else
3557
3558// After the following line is where the code to print hash codes will go.
3559void Dump(int offset, int len) {
3560cout << farmhashcc::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
3561cout << farmhashcc::Hash32(data + offset, len) << "u," << endl;
3562{ uint128_t u = farmhashcc::Fingerprint128(data + offset, len); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
3563{ uint128_t u = farmhashcc::CityHash128WithSeed(data + offset, len, Uint128(SEED0, SEED1)); uint64_t h = Uint128Low64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u, "; h = Uint128High64(u); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
3564}
3565
3566#endif
3567
3568#undef SEED
3569#undef SEED1
3570#undef SEED0
3571
3572} // namespace farmhashccTest
3573
3574#if TESTING
3575
3576static int farmhashccTestResult = farmhashccTest::RunTest();
3577
3578#else
3579int main(int argc, char** argv) {
3580 Setup();
3581 cout << "uint32_t expected[] = {\n";
3582 int i = 0;
3583 for ( ; i < kTestSize - 1; i++) {
3584 farmhashccTest::Dump(i * i, i);
3585 }
3586 for ( ; i < kDataSize; i += i / 7) {
3587 farmhashccTest::Dump(0, i);
3588 }
3589 farmhashccTest::Dump(0, kDataSize);
3590 cout << "};\n";
3591}
3592#endif
3593#ifndef FARMHASH_SELF_TEST_GUARD
3594#define FARMHASH_SELF_TEST_GUARD
3595#include <cstdio>
3596#include <iostream>
3597#include <string.h>
3598
3599using std::cout;
3600using std::cerr;
3601using std::endl;
3602using std::hex;
3603
3604static const uint64_t kSeed0 = 1234567;
3605static const uint64_t kSeed1 = k0;
3606static const int kDataSize = 1 << 20;
3607static const int kTestSize = 300;
3608#define kSeed128 Uint128(kSeed0, kSeed1)
3609
3610static char data[kDataSize];
3611
3612static int completed_self_tests = 0;
3613static int errors = 0;
3614
3615// Initialize data to pseudorandom values.
3616void Setup() {
3617 if (completed_self_tests == 0) {
3618 uint64_t a = 9;
3619 uint64_t b = 777;
3620 for (int i = 0; i < kDataSize; i++) {
3621 a += b;
3622 b += a;
3623 a = (a ^ (a >> 41)) * k0;
3624 b = (b ^ (b >> 41)) * k0 + i;
3625 uint8_t u = b >> 37;
3626 memcpy(data + i, &u, 1); // uint8_t -> char
3627 }
3628 }
3629}
3630
3631int NoteErrors() {
3632#define NUM_SELF_TESTS 9
3633 if (++completed_self_tests == NUM_SELF_TESTS)
3634 std::exit(errors > 0);
3635 return errors;
3636}
3637
3638template <typename T> inline bool IsNonZero(T x) {
3639 return x != 0;
3640}
3641
3642template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
3643 return x != Uint128(0, 0);
3644}
3645
3646#endif // FARMHASH_SELF_TEST_GUARD
3647
3648namespace farmhashmkTest {
3649
3650uint32_t CreateSeed(int offset, int salt) {
3651 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
3652 h = h * c1;
3653 h ^= (h >> 17);
3654 h = h * c1;
3655 h ^= (h >> 17);
3656 h = h * c1;
3657 h ^= (h >> 17);
3658 h += static_cast<uint32_t>(offset & 0xffffffff);
3659 h = h * c1;
3660 h ^= (h >> 17);
3661 h = h * c1;
3662 h ^= (h >> 17);
3663 h = h * c1;
3664 h ^= (h >> 17);
3665 return h;
3666}
3667
3668#undef SEED
3669#undef SEED1
3670#undef SEED0
3671#define SEED CreateSeed(offset, -1)
3672#define SEED0 CreateSeed(offset, 0)
3673#define SEED1 CreateSeed(offset, 1)
3674
3675#undef TESTING
3676#define TESTING 1
3677#if TESTING
3678uint32_t expected[] = {
36794223616069u,
36803696677242u,
36814081014168u,
36822576519988u,
36832212771159u,
36841112731063u,
36851020067935u,
36863955445564u,
36871451961420u,
3688653440099u,
368931917516u,
36902957164615u,
36912590087362u,
36923879448744u,
3693176305566u,
36942447367541u,
36951359016305u,
36963363804638u,
36971117290165u,
36981062549743u,
36992437877004u,
37001894455839u,
3701673206794u,
37023486923651u,
37033269862919u,
37042303349487u,
37051380660650u,
3706595525107u,
37071525325287u,
37082025609358u,
3709176408838u,
37101592885012u,
3711864896482u,
37122101378090u,
37133489229104u,
37142118965695u,
3715581644891u,
37162718789079u,
3717631613207u,
37184228658372u,
37193867875546u,
37203531368319u,
37213804516756u,
37223317755099u,
37231619744564u,
37242884717286u,
37251088213445u,
37262667691076u,
37273727873235u,
37282330406762u,
37293616470388u,
3730967660719u,
37314148162586u,
3732315219121u,
3733673084328u,
37343047602355u,
37351598963653u,
37361267826661u,
37372117362589u,
37382861192253u,
37391823625377u,
37401380350078u,
37411641748342u,
37421176094482u,
3743269384321u,
37442178982315u,
37453480237248u,
37462660755208u,
37471850544433u,
37483429699438u,
37491262819303u,
3750640556464u,
37512421125401u,
37522188368608u,
37532612932825u,
37541474432581u,
3755173790449u,
37562124882189u,
3757831272654u,
3758622960146u,
37594238751051u,
37603250317967u,
37612120810248u,
37621948231495u,
37631389029321u,
37642200398357u,
37652134232963u,
37662948072329u,
3767617717625u,
3768681164587u,
3769114859387u,
3770430545646u,
377157239089u,
37723163338012u,
37733482496399u,
3774557662576u,
37751102441413u,
37762670159360u,
3777991116729u,
3778846014240u,
37794233741566u,
37801802317242u,
37813129528802u,
37821459456375u,
37831305643039u,
37843258671612u,
37851578285833u,
3786868590079u,
37871631034517u,
37881695432937u,
3789561078856u,
37901004115553u,
37913086090507u,
37923818348650u,
3793731596645u,
3794780926790u,
37952544205955u,
3796158479164u,
37973983514188u,
37982004735250u,
37993436218400u,
3800673684751u,
38011463431419u,
38022880490219u,
38033223748024u,
38042218318859u,
38051474466194u,
38062636437533u,
38072206794961u,
3808140995728u,
38091186394086u,
38101805716888u,
38111640037724u,
38123942729099u,
38131944727013u,
3814918951560u,
3815498666871u,
38163486974657u,
38172967205462u,
38181167253804u,
38191884281041u,
38202866015002u,
38214158319270u,
38222627220079u,
38233733319624u,
38243317092271u,
3825438323662u,
38263195868065u,
38273426606709u,
3828360708338u,
38291905491012u,
3830650004803u,
38311351266252u,
38323133279000u,
38333722811115u,
38342722412434u,
3835918432408u,
38363678271248u,
3837269599647u,
3838621514057u,
38393117077855u,
38401545425390u,
38412597567410u,
38421221437820u,
38433493254589u,
3844102787342u,
3845918861168u,
3846348795089u,
38473439883229u,
38482353641807u,
38492209585469u,
38504035884492u,
38512686995435u,
38521649888022u,
38533852893848u,
38543042700028u,
3855314103172u,
3856726977769u,
38572489830276u,
38582872753660u,
38591316214989u,
38601488801501u,
38611811420390u,
3862639581627u,
38632362837215u,
38643634581834u,
38653648576802u,
38661257314182u,
3867762118371u,
38684268447045u,
3869730167096u,
3870755561509u,
3871882614845u,
38723696972894u,
3873228263661u,
38741478636142u,
38752767751651u,
38761532617116u,
38773838657661u,
38781944359935u,
38791401102137u,
38803772933173u,
38811050098254u,
38821658079354u,
38831846025728u,
38842204244794u,
38852017217424u,
38861275162853u,
38871429816745u,
38882175565479u,
38891716109139u,
38901187506761u,
38912434641075u,
38922725597783u,
38931795687662u,
38941393312782u,
38953511565397u,
3896627885430u,
38974145733164u,
38982519005353u,
3899231414775u,
39001242015635u,
39012760723497u,
39022185540568u,
3903727314436u,
39042358790354u,
39051186393454u,
39064234795645u,
3907350567813u,
3908866773875u,
39093145590392u,
39101158374055u,
39113903123687u,
39121862119793u,
39132204587556u,
39144266276976u,
39154151548555u,
3916915250402u,
39172874695320u,
39182360311410u,
39191099212769u,
39201271542714u,
39213473148363u,
39221637325418u,
39231807795989u,
39242493819794u,
39253800917924u,
39264001205856u,
39272582153621u,
39283365872040u,
39292890146216u,
39302626363824u,
39313133351295u,
39324046827296u,
39333053118771u,
39344113026751u,
3935884356716u,
39363828347401u,
393710608262u,
3938830987972u,
39391841080500u,
39403202717763u,
39413561778749u,
39421906000052u,
39433058284660u,
39441432904514u,
39452567431677u,
39462550162530u,
3947665557986u,
3948936887821u,
39492101205308u,
39504253535847u,
39511662043545u,
39521253611611u,
39532091370094u,
39542635077370u,
39552602176041u,
39563624115809u,
3957748442714u,
39582709749154u,
39591023493343u,
3960860291012u,
39613924715584u,
39621536436740u,
39632551145800u,
39642391782865u,
39651467705048u,
39662583909796u,
39673616666170u,
39681162857372u,
39694228631071u,
39701510132376u,
39712739165009u,
39722656606142u,
39733454996358u,
39743155038853u,
39751022087316u,
3976100044110u,
3977494208296u,
39782746186477u,
39794216782431u,
3980225448834u,
39813728320521u,
3982335282866u,
39833148194874u,
3984953503703u,
39851293353960u,
3986202372387u,
39871326119870u,
39884045123735u,
39893819994846u,
39901629004186u,
39911081099186u,
39923591584153u,
39931670825804u,
39943404257979u,
39953262192301u,
39962572846095u,
39973714992543u,
39984264142572u,
3999529616678u,
40002882154574u,
40013006354178u,
40023865969421u,
40032007174907u,
4004308283107u,
40052629833703u,
40063159124075u,
40071146492131u,
4008494104332u,
4009493149727u,
40101342910585u,
4011521642387u,
40122201695937u,
40132517980959u,
40142426821287u,
4015777374655u,
40162228189792u,
40174027055486u,
4018228976000u,
40193842083468u,
40201723920223u,
40211192126094u,
4022787744493u,
40232740368380u,
40242284153001u,
40252773829458u,
4026442000614u,
4027387830783u,
40282169780670u,
40292253144627u,
40303532502484u,
40311969684059u,
40321165351416u,
40333055056536u,
40343582324253u,
4035231419363u,
4036770979865u,
40373213983597u,
40383690452836u,
4039935794639u,
40403230602762u,
40412841762457u,
4042407598927u,
40431164479891u,
40443721799696u,
4045354738136u,
40461801566618u,
40473206038542u,
40482621379981u,
40491943487262u,
40503534745636u,
40511074424589u,
40521304517521u,
40534133400969u,
40542339317978u,
40552135116860u,
40564180643791u,
40572415309340u,
40581855926417u,
40593418648630u,
40601968113037u,
4061597304222u,
40623668824865u,
40633810008716u,
40643014702569u,
40653151212026u,
4066156057449u,
4067373134533u,
40682068234004u,
4069191580563u,
40703832754488u,
40712924104199u,
40722026044494u,
40734065780435u,
4074122565840u,
40754194985167u,
40762744823717u,
40772494098735u,
40783753793370u,
40791885739217u,
40802488161225u,
40813643797615u,
40822653367310u,
40832494061477u,
4084189968132u,
4085899646597u,
4086392100396u,
40874012318310u,
40883855777086u,
40893566860954u,
40902698574996u,
40912414249905u,
40921330623339u,
40931263222732u,
40941277741760u,
40952194959402u,
40961629656136u,
4097120494320u,
40981072368005u,
40991084245077u,
41004011372748u,
41011366613353u,
41023108643228u,
41033332219532u,
41042114746095u,
41053964007334u,
4106371687128u,
41071084813876u,
4108126459896u,
41094292782331u,
4110321283184u,
4111398168499u,
41123604983506u,
4113560701543u,
41142073961354u,
41154240841868u,
41164151211362u,
41171338986875u,
41184093476832u,
41192269279497u,
41203500846299u,
41212510225147u,
4122598000444u,
41231330391422u,
41241432533385u,
41254171226231u,
4126426821154u,
41272932270996u,
41283378981077u,
41292217871549u,
41301619647984u,
41314051608043u,
41323180237819u,
413312919578u,
41341375401767u,
4135371320427u,
41362986640571u,
41372336669859u,
41383796464715u,
41391892383284u,
4140306814912u,
41412125823211u,
41421863678891u,
41433249703818u,
41443840225752u,
4145281579900u,
4146264680257u,
41474266359110u,
41484182229890u,
41492239659703u,
41503627947372u,
41512373929191u,
4152224082765u,
41534053639058u,
41541862360303u,
41553187739624u,
41563392706679u,
4157948039509u,
4158817505760u,
41591215842393u,
41603462222651u,
4161536021853u,
4162182346832u,
41632731944883u,
41642346674384u,
41652640961678u,
41663446695687u,
41672271722179u,
41681301069656u,
41692803881468u,
41702832614405u,
41711691544398u,
4172698756814u,
41733980620906u,
41743565421410u,
4175754769376u,
41764115923404u,
41773909962218u,
41782747614077u,
41792888289845u,
41801016920862u,
41812790946178u,
41823067070960u,
41833173251481u,
41841572132982u,
4185255048203u,
41862996538818u,
41873405398987u,
4188136106013u,
41893581605228u,
41904277437977u,
41912147300534u,
41923728426265u,
41933483629996u,
41941478452694u,
419520756076u,
41962774992067u,
4197432987927u,
41981516771026u,
41993511588664u,
42002130994978u,
4201509385406u,
4202873090347u,
42032163904107u,
42044192239086u,
42052532489989u,
42061090772651u,
42073910797408u,
42083710882132u,
4209155010959u,
42101369823531u,
42111599664937u,
42124035593587u,
42131212746925u,
4214795822552u,
4215116689518u,
42163674240941u,
42171135576664u,
4218756750261u,
42191027431362u,
4220390555140u,
42212228460216u,
42221506940482u,
42233733857700u,
42243048762971u,
42252511703196u,
4226548609887u,
42271607354252u,
4228659053982u,
4229259884450u,
42301793130460u,
42314083364495u,
42323148555881u,
42331764350138u,
42342436485683u,
42354031563025u,
42363261860724u,
42372475833430u,
42382101726086u,
42393191176464u,
42402646658847u,
42412127042126u,
4242771316100u,
42432115922959u,
42443208515045u,
42452355437783u,
42463621147793u,
42471580163615u,
42483211555675u,
42493299188490u,
4250191613920u,
4251466733956u,
42522939029038u,
42531509152039u,
4254130591314u,
42551892874677u,
42561646908044u,
42573452406523u,
42583998376606u,
42591199243832u,
42602187108812u,
42613189230066u,
42624161151481u,
42633371454980u,
42643681788646u,
4265180842187u,
42663685022399u,
42673058749895u,
42683250165163u,
42692895367943u,
42702627101723u,
4271771755098u,
42721332921024u,
42733638871848u,
4274514215135u,
42753591227378u,
42762300310870u,
42773689533503u,
4278851607114u,
4279114330368u,
42802709027386u,
42811743034877u,
42821013693860u,
4283288169008u,
42843545190686u,
42851052165084u,
42863995862307u,
428796902755u,
42881097819851u,
42892645431442u,
42902184148618u,
42912151206566u,
4292350979797u,
42933467920900u,
4294421116779u,
42951246252u,
42964057835428u,
4297329324407u,
42984104482417u,
4299844624570u,
43003306265806u,
43013787625025u,
43024263241191u,
43033251413927u,
43042921204431u,
43052931915325u,
4306992134330u,
43073986338354u,
43081327895216u,
43091458363596u,
43101480608532u,
4311728594368u,
43123804366693u,
4313794404223u,
43141643240863u,
4315793417255u,
43164167916443u,
43172683488959u,
43183124925324u,
43194184843652u,
43203750971752u,
4321308509829u,
43221054550805u,
43232797511972u,
43244043123412u,
43251587158240u,
43264050518606u,
43273030062190u,
43282589912753u,
4329603440067u,
4330937013191u,
43311071662315u,
43322100661456u,
43332602005741u,
4334435516078u,
43352260470147u,
43361256268350u,
43373612035u,
43383368856141u,
4339151516099u,
43403081868591u,
43413363755681u,
43422049963149u,
43432885320434u,
434484682005u,
43452411758308u,
43462695174275u,
43473099904644u,
43481787308684u,
43491132379308u,
4350564634346u,
4351510236510u,
43522804443681u,
43533931864252u,
43542064427949u,
43551893979229u,
43562916544974u,
43571885887717u,
43582978018250u,
4359494192125u,
43602642662373u,
4361901112508u,
4362636035003u,
43631658643797u,
4364172746975u,
4365517504890u,
43663440019372u,
43674144498044u,
43681854755456u,
43693672653905u,
43704176892856u,
4371382159097u,
4372282871690u,
43733629300472u,
43742500754041u,
43751677659759u,
43761067175061u,
4377161654075u,
43781672575536u,
4379346120493u,
43802730229631u,
4381203466442u,
43821244549529u,
4383199761971u,
43842744895408u,
43853195315331u,
43862124618519u,
43873261045496u,
4388985339699u,
43893385585455u,
43901545740710u,
43913636652160u,
43922167020081u,
43931207897204u,
439428752417u,
43952895834146u,
43963640845375u,
43973750293073u,
4398548997850u,
43994207814196u,
44004183030708u,
44012462810989u,
44023929965401u,
4403};
4404
4405// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
4406bool Test(int offset, int len = 0) {
4407#undef Check
4408#undef IsAlive
4409
4410#define Check(x) do { \
4411 const uint32_t actual = (x), e = expected[index++]; \
4412 bool ok = actual == e; \
4413 if (!ok) { \
4414 cerr << "expected " << hex << e << " but got " << actual << endl; \
4415 ++errors; \
4416 } \
4417 assert(ok); \
4418} while (0)
4419
4420#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
4421
4422 // After the following line is where the uses of "Check" and such will go.
4423 static int index = 0;
4424if (offset == -1) { int alive = 0; IsAlive(farmhashmk::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashmk::Hash32(data, len++)); IsAlive(farmhashmk::Hash32(data, len++)); len -= 3; return alive > 0; }
4425Check(farmhashmk::Hash32WithSeed(data + offset, len, SEED));
4426Check(farmhashmk::Hash32(data + offset, len));
4427
4428 return true;
4429#undef Check
4430#undef IsAlive
4431}
4432
4433int RunTest() {
4434 Setup();
4435 int i = 0;
4436 cout << "Running farmhashmkTest";
4437 if (!Test(-1)) {
4438 cout << "... Unavailable\n";
4439 return NoteErrors();
4440 }
4441 // Good. The function is attempting to hash, so run the full test.
4442 int errors_prior_to_test = errors;
4443 for ( ; i < kTestSize - 1; i++) {
4444 Test(i * i, i);
4445 }
4446 for ( ; i < kDataSize; i += i / 7) {
4447 Test(0, i);
4448 }
4449 Test(0, kDataSize);
4450 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
4451 return NoteErrors();
4452}
4453
4454#else
4455
4456// After the following line is where the code to print hash codes will go.
4457void Dump(int offset, int len) {
4458cout << farmhashmk::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
4459cout << farmhashmk::Hash32(data + offset, len) << "u," << endl;
4460}
4461
4462#endif
4463
4464#undef SEED
4465#undef SEED1
4466#undef SEED0
4467
4468} // namespace farmhashmkTest
4469
4470#if TESTING
4471
4472static int farmhashmkTestResult = farmhashmkTest::RunTest();
4473
4474#else
4475int main(int argc, char** argv) {
4476 Setup();
4477 cout << "uint32_t expected[] = {\n";
4478 int i = 0;
4479 for ( ; i < kTestSize - 1; i++) {
4480 farmhashmkTest::Dump(i * i, i);
4481 }
4482 for ( ; i < kDataSize; i += i / 7) {
4483 farmhashmkTest::Dump(0, i);
4484 }
4485 farmhashmkTest::Dump(0, kDataSize);
4486 cout << "};\n";
4487}
4488#endif
4489#ifndef FARMHASH_SELF_TEST_GUARD
4490#define FARMHASH_SELF_TEST_GUARD
4491#include <cstdio>
4492#include <iostream>
4493#include <string.h>
4494
4495using std::cout;
4496using std::cerr;
4497using std::endl;
4498using std::hex;
4499
4500static const uint64_t kSeed0 = 1234567;
4501static const uint64_t kSeed1 = k0;
4502static const int kDataSize = 1 << 20;
4503static const int kTestSize = 300;
4504#define kSeed128 Uint128(kSeed0, kSeed1)
4505
4506static char data[kDataSize];
4507
4508static int completed_self_tests = 0;
4509static int errors = 0;
4510
4511// Initialize data to pseudorandom values.
4512void Setup() {
4513 if (completed_self_tests == 0) {
4514 uint64_t a = 9;
4515 uint64_t b = 777;
4516 for (int i = 0; i < kDataSize; i++) {
4517 a += b;
4518 b += a;
4519 a = (a ^ (a >> 41)) * k0;
4520 b = (b ^ (b >> 41)) * k0 + i;
4521 uint8_t u = b >> 37;
4522 memcpy(data + i, &u, 1); // uint8_t -> char
4523 }
4524 }
4525}
4526
4527int NoteErrors() {
4528#define NUM_SELF_TESTS 9
4529 if (++completed_self_tests == NUM_SELF_TESTS)
4530 std::exit(errors > 0);
4531 return errors;
4532}
4533
4534template <typename T> inline bool IsNonZero(T x) {
4535 return x != 0;
4536}
4537
4538template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
4539 return x != Uint128(0, 0);
4540}
4541
4542#endif // FARMHASH_SELF_TEST_GUARD
4543
4544namespace farmhashnaTest {
4545
4546uint32_t CreateSeed(int offset, int salt) {
4547 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
4548 h = h * c1;
4549 h ^= (h >> 17);
4550 h = h * c1;
4551 h ^= (h >> 17);
4552 h = h * c1;
4553 h ^= (h >> 17);
4554 h += static_cast<uint32_t>(offset & 0xffffffff);
4555 h = h * c1;
4556 h ^= (h >> 17);
4557 h = h * c1;
4558 h ^= (h >> 17);
4559 h = h * c1;
4560 h ^= (h >> 17);
4561 return h;
4562}
4563
4564#undef SEED
4565#undef SEED1
4566#undef SEED0
4567#define SEED CreateSeed(offset, -1)
4568#define SEED0 CreateSeed(offset, 0)
4569#define SEED1 CreateSeed(offset, 1)
4570
4571#undef TESTING
4572#define TESTING 1
4573#if TESTING
4574uint32_t expected[] = {
45751140953930u, 861465670u,
45763277735313u, 2681724312u,
45772598464059u, 797982799u,
4578890626835u, 800175912u,
45792603993599u, 921001710u,
45801410420968u, 2134990486u,
45813283896453u, 1867689945u,
45822914424215u, 2244477846u,
4583255297188u, 2992121793u,
45841110588164u, 4186314283u,
4585161451183u, 3943596029u,
45864019337850u, 452431531u,
4587283198166u, 2741341286u,
45883379021470u, 2557197665u,
4589299850021u, 2532580744u,
4590452473466u, 1706958772u,
45911298374911u, 3099673830u,
45922199864459u, 3696623795u,
4593236935126u, 2976578695u,
45944055299123u, 3281581178u,
45951053458494u, 1882212500u,
45962305012065u, 2169731866u,
45973456121707u, 275903667u,
4598458884671u, 3033004529u,
45993058973506u, 2379411653u,
46001898235244u, 1402319660u,
46012700149065u, 2699376854u,
4602147814787u, 720739346u,
46032433714046u, 4222949502u,
46044220361840u, 1712034059u,
46053425469811u, 3690733394u,
46064148372108u, 1330324210u,
4607594028478u, 2921867846u,
46081635026870u, 192883107u,
4609780716741u, 1728752234u,
46103280331829u, 326029180u,
46113969463346u, 1436364519u,
4612393215742u, 3349570000u,
46133824583307u, 1612122221u,
46142859809759u, 3808705738u,
46151379537552u, 1646032583u,
46162233466664u, 1432476832u,
46174023053163u, 2650381482u,
46182052294713u, 3552092450u,
46191628777059u, 1499109081u,
46203476440786u, 3829307897u,
46212960536756u, 1554038301u,
46221145519619u, 3190844552u,
46232902102606u, 3600725550u,
4624237495366u, 540224401u,
462565721842u, 489963606u,
46261448662590u, 397635823u,
46271596489240u, 1562872448u,
46281790705123u, 2128624475u,
4629180854224u, 2604346966u,
46301435705557u, 1262831810u,
4631155445229u, 1672724608u,
46321669465176u, 1341975128u,
4633663607706u, 2077310004u,
46343610042449u, 1911523866u,
46351043692997u, 1454396064u,
46362563776023u, 294527927u,
46371099072299u, 1389770549u,
4638703505868u, 678706990u,
46392952353448u, 2026137563u,
46403603803785u, 629449419u,
46411933894405u, 3043213226u,
4642226132789u, 2489287368u,
46431552847036u, 645684964u,
46443828089804u, 3632594520u,
4645187883449u, 230403464u,
46463151491850u, 3272648435u,
46473729087873u, 1303930448u,
46482002861219u, 165370827u,
4649916494250u, 1230085527u,
46503103338579u, 3064290191u,
46513807265751u, 3628174014u,
4652231181488u, 851743255u,
46532295806711u, 1781190011u,
46542988893883u, 1554380634u,
46551142264800u, 3667013118u,
46561968445277u, 315203929u,
46572638023604u, 2290487377u,
4658732137533u, 1909203251u,
4659440398219u, 1891630171u,
46601380301172u, 1498556724u,
46614072067757u, 4165088768u,
46624204318635u, 441430649u,
46633931792696u, 197618179u,
4664956300927u, 914413116u,
46653010839769u, 2837339569u,
46662148126371u, 1913303225u,
46673074915312u, 3117299654u,
46684139181436u, 2993479124u,
46693178848746u, 1357272220u,
46701438494951u, 507436733u,
4671667183474u, 2084369203u,
46723854939912u, 1413396341u,
4673126024219u, 146044391u,
46741016656857u, 3022024459u,
46753254014218u, 429095991u,
4676165589978u, 1578546616u,
4677985653208u, 1718653828u,
4678623071693u, 366414107u,
4679249776086u, 1207522198u,
46803047342438u, 2991127487u,
46813120876698u, 1684583131u,
468246987739u, 1157614300u,
4683863214540u, 1087193030u,
4684199124911u, 520792961u,
46853614377032u, 586863115u,
46863331828431u, 1013201099u,
46871716848157u, 4033596884u,
46881164298657u, 4140791139u,
46891146169032u, 1434258493u,
46903824360466u, 3242407770u,
46913725511003u, 232064808u,
4692872586426u, 762243036u,
46932736953692u, 816692935u,
4694512845449u, 3748861010u,
46952266795890u, 3781899767u,
46964290630595u, 517646945u,
469722638523u, 648000590u,
4698959214578u, 558910384u,
46991283799121u, 3047062993u,
47001024246061u, 4027776454u,
47013544509313u, 622325861u,
4702834785312u, 382936554u,
4703411505255u, 1973395102u,
47041825135056u, 2725923798u,
4705580988377u, 2826990641u,
47063474970689u, 1029055034u,
4707812546227u, 2506885666u,
47082584372201u, 1758123094u,
4709589567754u, 325737734u,
4710345313518u, 2022370576u,
47113886113119u, 3338548567u,
4712257578986u, 3698087965u,
47131776047957u, 1771384107u,
47143604937815u, 3198590202u,
47152305332220u, 191910725u,
47164232136669u, 427759438u,
47174244322689u, 542201663u,
47183315355162u, 2135941665u,
4719556609672u, 45845311u,
47201175961330u, 3948351189u,
472123075771u, 3252374102u,
47221634635545u, 4151937410u,
4723713127376u, 1467786451u,
4724663013031u, 3444053918u,
47252638154051u, 810082938u,
47263077742128u, 1062268187u,
47272115441882u, 4081398201u,
47283735739145u, 2794294783u,
47292335576331u, 2560479831u,
47301379288194u, 4225182569u,
47312442302747u, 3948961926u,
47323958366652u, 3067277639u,
47333667516477u, 1709989541u,
47341516711748u, 2339636583u,
47354188504038u, 59581167u,
47362725013602u, 3639843023u,
47372658147000u, 2643979752u,
47383758739543u, 4189944477u,
47392470483982u, 877580602u,
47402995362413u, 118817200u,
47413252925478u, 2062343506u,
47423981838403u, 3762572073u,
47431231633714u, 4168280671u,
47442931588131u, 3284356565u,
47451129162571u, 732225574u,
47464173605289u, 1407328702u,
47471677744031u, 3532596884u,
47483232041815u, 1652884780u,
47492256541290u, 3459463480u,
47503740979556u, 259034107u,
47512227121257u, 1426140634u,
47523606709555u, 3424793077u,
4753315836068u, 3200749877u,
47541386256573u, 24035717u,
47552982018998u, 1811050648u,
4756234531934u, 1115203611u,
47571598686658u, 3146815575u,
47581603559457u, 323296368u,
47592632963283u, 1778459926u,
4760739944537u, 579625482u,
47613486330348u, 492621815u,
47621231665285u, 2457048126u,
47633903349120u, 389846205u,
47643355404249u, 3275550588u,
47651052645068u, 862072556u,
47662834153464u, 1481069623u,
47672657392572u, 4279236653u,
47681688445808u, 701920051u,
47693740748788u, 3388062747u,
47701873358321u, 2152785640u,
4771883382081u, 1005815394u,
47721020177209u, 734239551u,
47732371453141u, 100326520u,
47743488500412u, 1279682138u,
47752610427744u, 49703572u,
47763026361211u, 605900428u,
4777302392721u, 2509302188u,
47781416453607u, 2815915291u,
47791862819968u, 519710058u,
47802450888314u, 4017598378u,
4781937074653u, 3035635454u,
47821590230729u, 3268013438u,
47832710029305u, 12886044u,
47843711259084u, 2627383582u,
47853895772404u, 648534979u,
4786260307902u, 855990313u,
47873669691805u, 263366740u,
47882938543471u, 414331688u,
47893080542944u, 3405007814u,
47903565059103u, 1190977418u,
4791390836981u, 1606450012u,
47922649808239u, 2514169310u,
47932747519432u, 4129538640u,
47941721522849u, 492099164u,
4795792990594u, 3625507637u,
47962271095827u, 2993032712u,
47972302363854u, 4013112951u,
47981111617969u, 2183845740u,
4799795918276u, 1116991810u,
48003110898804u, 3963062126u,
48012737064702u, 462795667u,
4802937372240u, 1343017609u,
48031091041189u, 2790555455u,
4804277024217u, 25485284u,
48051166522068u, 1623631848u,
4806241727183u, 2836158787u,
48073112996740u, 573836428u,
48082721658101u, 1937681565u,
48094175169209u, 3190765433u,
48101970000788u, 1668258120u,
4811114616703u, 954762543u,
4812199237753u, 4094644498u,
48132522281978u, 732086117u,
48141756889687u, 2936126607u,
48152437031370u, 4103143808u,
48163883389541u, 3171090854u,
48172483004780u, 1927385370u,
48182360538162u, 2740855009u,
48194241185118u, 1492209542u,
48201672737098u, 2148675559u,
48211789864670u, 2434313103u,
48222319172611u, 2760941207u,
48232636210123u, 1338083267u,
48241128080590u, 822806371u,
48251199583556u, 314727461u,
48261335160250u, 2084630531u,
48271156261526u, 316766066u,
4828112090465u, 3129033323u,
48292746885618u, 636616055u,
48302582210744u, 1721064910u,
48313468394263u, 470463518u,
48322076016059u, 408721884u,
48332121041886u, 378460278u,
48341915948002u, 357324860u,
48352301682622u, 2691859523u,
48361869756364u, 2429314418u,
48372193146527u, 1185564327u,
48382614088922u, 1975527044u,
4839919067651u, 2855948894u,
48403662539576u, 1943802836u,
48413529473373u, 1490330107u,
4842366036094u, 3384241033u,
48434276268604u, 448403661u,
48444271796078u, 1910401882u,
48453077107698u, 299427366u,
48462035665349u, 3201262636u,
48473738454258u, 2554452696u,
48483588997135u, 3363895827u,
48491267505995u, 1852004679u,
48502237827073u, 2803250686u,
48513468044908u, 2143572850u,
48521728158656u, 1022551180u,
48531996680960u, 839529273u,
48542400647871u, 2201096054u,
48553606433628u, 2597259793u,
48563544595875u, 3909443124u,
4857819278607u, 3447346709u,
4858806136613u, 2711436388u,
48593656063205u, 837475154u,
4860694525336u, 4070212073u,
48614011303412u, 1068395209u,
4862438095290u, 484603494u,
48632673730227u, 737767009u,
4864642310823u, 3914002299u,
4865308425103u, 268427550u,
48661334387085u, 4069797497u,
48674280783219u, 2914011058u,
48684243643405u, 2849988118u,
48692504230175u, 1817156623u,
48702804200483u, 3406991497u,
48712948254999u, 2102063419u,
48721071272117u, 514889942u,
4873571972433u, 1246595599u,
48741735616066u, 1539151988u,
48751230831543u, 277987182u,
48764269526481u, 991511607u,
487795237878u, 2005032160u,
48781291113144u, 626619670u,
48793560835907u, 164940926u,
48801433635018u, 116647396u,
48813039097112u, 2868163232u,
48821141645918u, 1764165478u,
4883881378302u, 2159170082u,
48842953647681u, 1011320066u,
4885184856151u, 1723308975u,
4886336034862u, 2017579106u,
48871476681709u, 147523618u,
48883896252223u, 2264728166u,
4889944743644u, 1694443528u,
48902690700128u, 1947321519u,
4891735478508u, 4058183171u,
4892260177668u, 505662155u,
48932391691262u, 1920739747u,
48943216960415u, 1898176786u,
48953722741628u, 1511077569u,
4896449636564u, 983350414u,
48972580237367u, 2055059789u,
48981103819072u, 2089123665u,
48993873755579u, 2718467458u,
49003124338704u, 3204250304u,
49012475035432u, 1120017626u,
49023873758287u, 1982999824u,
49032950794582u, 780634378u,
49042842141483u, 4029205195u,
49051656892865u, 3330993377u,
490680890710u, 1953796601u,
49073873078673u, 136118734u,
49082317676604u, 4199091610u,
49091864448181u, 3063437608u,
49101699452298u, 1403506686u,
49111513069466u, 2348491299u,
49124273657745u, 4055855649u,
49131805475756u, 2562064338u,
4914973124563u, 4197091358u,
4915172861513u, 2858726767u,
49164271866024u, 3071338162u,
49173590386266u, 2328277259u,
49181096050703u, 1189614342u,
4919459509140u, 771592405u,
4920817999971u, 3740825152u,
4921520400189u, 1941874618u,
4922185232757u, 4032960199u,
49233928245258u, 3527721294u,
49241301118856u, 752188080u,
49253512945009u, 308584855u,
49262105373972u, 752872278u,
49273823368815u, 3760952096u,
49284250142168u, 2565680167u,
49293646354146u, 1259957455u,
49301085857127u, 3471066607u,
493138924274u, 3770488806u,
49321083869477u, 3312508103u,
493371956383u, 3738784936u,
49343099963860u, 1255084262u,
49354286969992u, 3621849251u,
49361190908967u, 1831557743u,
49372363435042u, 54945052u,
49384059585566u, 4023974274u,
49391788578453u, 3442180039u,
49402534883189u, 2432427547u,
49413909757989u, 731996369u,
49424168347425u, 1356028512u,
49432741583197u, 1280920000u,
4944312887059u, 3259015297u,
49453946278527u, 4135481831u,
49461281043691u, 1121403845u,
49473312292477u, 1819941269u,
49481741932545u, 3293015483u,
49492127558730u, 713121337u,
49502635469238u, 486003418u,
49514015067527u, 2976737859u,
49522108187161u, 927011680u,
49531970188338u, 4177613234u,
49541799789551u, 2118505126u,
49554134691985u, 1958963937u,
49561929210029u, 2555835851u,
49572768832862u, 910892050u,
49582567532373u, 4075249328u,
495986689814u, 3726640307u,
49601392137718u, 1240000030u,
49614104757832u, 3026358429u,
4962313797689u, 1435798509u,
49633101500919u, 1241665335u,
49643573008472u, 3615577014u,
49653767659003u, 3134294021u,
49664063565523u, 2296824134u,
49671541946015u, 3087190425u,
49682693152531u, 2199672572u,
49692123763822u, 1034244398u,
4970857839960u, 2515339233u,
49712228007483u, 1628096047u,
49722116502287u, 2502657424u,
49732809830736u, 460237542u,
4974450205998u, 3646921704u,
49753818199357u, 1808504491u,
49761950698961u, 2069753399u,
49773657033172u, 3734547671u,
49784067859590u, 3292597295u,
49791106466069u, 356742959u,
49802469567432u, 3495418823u,
4981183440071u, 3248055817u,
49823662626864u, 1750561299u,
49833926138664u, 4088592524u,
4984567122118u, 3810297651u,
4985992181339u, 3384018814u,
49863272124369u, 3177596743u,
4987320086295u, 2316548367u,
4988100741310u, 451656820u,
49894086604273u, 3759628395u,
49902553391092u, 1745659881u,
49913650357479u, 2390172694u,
4992330172533u, 767377322u,
4993526742034u, 4102497288u,
49942088767754u, 164402616u,
49952482632320u, 2352347393u,
49961873658044u, 3861555476u,
49972751052984u, 1767810825u,
499820037241u, 545143220u,
49992594532522u, 472304191u,
50003441135892u, 3323383489u,
5001258785117u, 2977745165u,
50022781737565u, 2963590112u,
50032756998822u, 207428029u,
50042581558559u, 3824717027u,
50051258619503u, 3472047571u,
50062648427775u, 2360400900u,
50072393763818u, 2332399088u,
50083932701729u, 884421165u,
50091396468647u, 1377764574u,
50104061795938u, 1559119087u,
50113343596838u, 3604258095u,
50121435134775u, 1099809675u,
5013908163739u, 1418405656u,
5014368446627u, 3741651161u,
50153374512975u, 3542220540u,
50163244772570u, 200009340u,
50173198975081u, 2521038253u,
50184081637863u, 337070226u,
50193235259030u, 3897262827u,
5020736956644u, 641040550u,
5021644850146u, 1306761320u,
50224219448634u, 193750500u,
50233293278106u, 1383997679u,
50241242645122u, 4109252858u,
5025450747727u, 3716617561u,
5026362725793u, 2252520167u,
50273377483696u, 1788337208u,
50288130777u, 3226734120u,
5029759239140u, 1012411364u,
50301658628529u, 2911512007u,
50311002580201u, 1681898320u,
50323039016929u, 4294520281u,
5033367022558u, 3071359622u,
50343205848570u, 152989999u,
50353839042136u, 2357687350u,
50364273132307u, 3898950547u,
50371176841812u, 1314157485u,
503875443951u, 1027027239u,
50391858986613u, 2040551642u,
504036574105u, 2603059541u,
50413456147251u, 2137668425u,
50424077477194u, 3565689036u,
5043491832241u, 363703593u,
50442579177168u, 3589545214u,
5045265993036u, 1864569342u,
50464149035573u, 3189253455u,
50471072259310u, 3153745937u,
5048923017956u, 490608221u,
5049855846773u, 845706553u,
50501018226240u, 1604548872u,
50513833372385u, 3287246572u,
50522757959551u, 2452872151u,
50531553870564u, 1713154780u,
50542649450292u, 500120236u,
505584251717u, 661869670u,
50561444911517u, 2489716881u,
50572810524030u, 1561519055u,
50583884088359u, 2509890699u,
50594247155916u, 1005636939u,
50603224066062u, 2774151984u,
50612035978240u, 2514910366u,
50621478837908u, 3144450144u,
50632107011431u, 96459446u,
50643587732908u, 2389230590u,
50653287635953u, 250533792u,
50661235983679u, 4237425634u,
50673704645833u, 3882376657u,
50682976369049u, 1187061987u,
5069276949224u, 4100839753u,
50701698347543u, 1629662314u,
50711556151829u, 3784939568u,
5072427484362u, 4246879223u,
50733155311770u, 4285163791u,
50741693376813u, 124492786u,
50751858777639u, 3476334357u,
50761941442701u, 1121980173u,
50773485932087u, 820852908u,
5078358032121u, 2511026735u,
50791873607283u, 2556067450u,
50802248275536u, 1528632094u,
50811535473864u, 556796152u,
50821499201704u, 1472623890u,
50831526518503u, 3692729434u,
50841476438092u, 2913077464u,
5085335109599u, 2167614601u,
50864121131078u, 3158127917u,
50873051522276u, 4046477658u,
50882857717851u, 1863977403u,
50891341023343u, 692059110u,
50901802040304u, 990407433u,
50913285847572u, 319814144u,
5092561105582u, 1540183799u,
50934052924496u, 2926590471u,
50942244539806u, 439121871u,
50953317903224u, 3178387550u,
50964265214507u, 82077489u,
50971978918971u, 4279668976u,
5098128732476u, 2853224222u,
5099464407878u, 4190838199u,
5100997819001u, 3250520802u,
51012330081301u, 4095846095u,
5102733509243u, 1583801700u,
5103722314527u, 3552883023u,
51041403784280u, 432327540u,
51051877837196u, 3912423882u,
5106505219998u, 696031431u,
5107908238873u, 4189387259u,
51088759461u, 2540185277u,
51093385159748u, 381355877u,
51102519951681u, 1679786240u,
51112019419351u, 4051584612u,
51121933923923u, 3768201861u,
51131670133081u, 3454981037u,
5114700836153u, 1675560450u,
5115371560700u, 338262316u,
5116847351840u, 2222395828u,
51173130433948u, 405251683u,
51183037574880u, 184098830u,
5119453340528u, 1385561439u,
51202224044848u, 4071581802u,
51211431235296u, 5570097u,
5122570114376u, 2287305551u,
51232272418128u, 803575837u,
51243943113491u, 414959787u,
5125708083137u, 2452657767u,
51264019147902u, 3841480082u,
51273791794715u, 2965956183u,
51282763690963u, 2350937598u,
51293424361375u, 779434428u,
51301274947212u, 686105485u,
51313426668051u, 3692865672u,
51323057021940u, 2285701422u,
5133349809124u, 1379278508u,
51343623750518u, 215970497u,
51351783152480u, 823305654u,
5136216118434u, 1787189830u,
51373692048450u, 2272612521u,
51383032187389u, 4159715581u,
51391388133148u, 1611772864u,
51402544383526u, 552925303u,
51413420960112u, 3198900547u,
51423503230228u, 2603352423u,
51432318375898u, 4064071435u,
51443006227299u, 4194096960u,
51451283392422u, 1510460996u,
5146174272138u, 3671038966u,
51471775955687u, 1719108984u,
51481763892006u, 1385029063u,
51494083790740u, 406757708u,
5150684087286u, 531310503u,
51513329923157u, 3492083607u,
51521059031410u, 3037314475u,
51533105682208u, 3382290593u,
51542292208503u, 426380557u,
515597373678u, 3842309471u,
5156777173623u, 3241407531u,
5157303065016u, 1477104583u,
51584234905200u, 2512514774u,
51592649684057u, 1397502982u,
51601802596032u, 3973022223u,
51612543566442u, 3139578968u,
51623193669211u, 811750340u,
51634013496209u, 567361887u,
51644169410406u, 3622282782u,
51653403136990u, 2540585554u,
5166895210040u, 3862229802u,
51671145435213u, 4146963980u,
5168784952939u, 943914610u,
5169573034522u, 464420660u,
51702356867109u, 3054347639u,
51713985088434u, 1911188923u,
5172583391304u, 176468511u,
51732990150068u, 2338031599u,
5174519948041u, 3181425568u,
5175496106033u, 4110294665u,
51762736756930u, 1196757691u,
51771089679033u, 240953857u,
51783399092928u, 4040779538u,
51792843673626u, 240495962u,
51803017658263u, 3828377737u,
51814243717901u, 2448373688u,
51822759616657u, 2246245780u,
5183308018483u, 4262383425u,
51842731780771u, 328023017u,
51852884443148u, 841480070u,
51863188015819u, 4051263539u,
51872298178908u, 2944209234u,
51881372958390u, 4164532914u,
51894074952232u, 1683612329u,
51902155036654u, 1872815858u,
51912041174279u, 2368092311u,
5192206775997u, 2283918569u,
5193645945606u, 115406202u,
51944206471368u, 3923500892u,
51952217060665u, 350160869u,
5196706531239u, 2824302286u,
5197509981657u, 1469342315u,
5198140980u, 1891558063u,
5199164887091u, 3094962711u,
52003437115622u, 13327420u,
5201422986366u, 330624974u,
52023630863408u, 2425505046u,
5203824008515u, 3543885677u,
5204918718096u, 376390582u,
52053224043675u, 3724791476u,
52061837192976u, 2968738516u,
52073424344721u, 3187805406u,
52081550978788u, 1743089918u,
52094251270061u, 645016762u,
52103855037968u, 1928519266u,
52111373803416u, 2289007286u,
52121889218686u, 1610271373u,
52133059200728u, 2108753646u,
5214582042641u, 812347242u,
52153188172418u, 191994904u,
52161343511943u, 2247006571u,
5217463291708u, 2697254095u,
52181534175504u, 1106275740u,
5219622521957u, 917121602u,
52204095777215u, 3955972648u,
52213852234638u, 2845309942u,
52223299763344u, 2864033668u,
52232554947496u, 799569078u,
52242551629074u, 1102873346u,
52252661022773u, 2006922227u,
52262900438444u, 1448194126u,
52271321567432u, 1983773590u,
52281237256330u, 3449066284u,
52291691553115u, 3274671549u,
52304271625619u, 2741371614u,
52313285899651u, 786322314u,
52321586632825u, 564385522u,
52332530557509u, 2974240289u,
52341244759631u, 3263135197u,
52353592389776u, 3570296884u,
52362749873561u, 521432811u,
5237987586766u, 3206261120u,
52381327840078u, 4078716491u,
52391753812954u, 976892272u,
52401827135136u, 1781944746u,
52411328622957u, 1015377974u,
52423439601008u, 2209584557u,
52432482286699u, 1109175923u,
5244874877499u, 2036083451u,
5245483570344u, 1091877599u,
52464190721328u, 1129462471u,
5247640035849u, 1867372700u,
5248920761165u, 3273688770u,
52491623777358u, 3389003793u,
52503241132743u, 2734783008u,
5251696674661u, 2502161880u,
52521646071378u, 1164309901u,
5253350411888u, 1978005963u,
52542253937037u, 7371540u,
5255989577914u, 3626554867u,
52563214796883u, 531343826u,
5257398899695u, 1145247203u,
52581516846461u, 3656006011u,
5259529303412u, 3318455811u,
52603062828129u, 1696355359u,
52613698796465u, 3155218919u,
52621457595996u, 3191404246u,
52631395609912u, 2917345728u,
52641237411891u, 1854985978u,
52651091884675u, 3504488111u,
52663109924189u, 1628881950u,
52673939149151u, 878608872u,
5268778235395u, 1052990614u,
5269903730231u, 2069566979u,
52702437686324u, 3163786257u,
52712257884264u, 2123173186u,
5272939764916u, 2933010098u,
52731235300371u, 1256485167u,
52741950274665u, 2180372319u,
52752648400302u, 122035049u,
52761883344352u, 2083771672u,
52773712110541u, 321199441u,
52781896357377u, 508560958u,
52793066325351u, 2770847216u,
52803177982504u, 296902736u,
52811486926688u, 456842861u,
5282601221482u, 3992583643u,
52832794121515u, 1533934172u,
52841706465470u, 4281971893u,
52852557027816u, 900741486u,
5286227175484u, 550595824u,
5287690918144u, 2825943628u,
528890375300u, 300318232u,
52891985329734u, 1440763373u,
52903670603707u, 2533900859u,
52913253901179u, 542270815u,
52923677388841u, 307706478u,
52932570910669u, 3320103693u,
52941273768482u, 1216399252u,
52951652924805u, 1043647584u,
52961120323676u, 639941430u,
5297325675502u, 3652676161u,
52984241680335u, 1545838362u,
52991991398008u, 4100211814u,
53001097584090u, 3262252593u,
53012254324292u, 1765019121u,
53024060211241u, 2315856188u,
53033704419305u, 411263051u,
5304238929055u, 3540688404u,
53053094544537u, 3250435765u,
53063460621305u, 1967599860u,
53072016157366u, 847389916u,
53081659615591u, 4020453639u,
5309901109753u, 2682611693u,
53101661364280u, 177155177u,
53113210561911u, 3802058181u,
5312797089608u, 3286110054u,
53132110358240u, 1353279028u,
53142479975820u, 471725410u,
53152219863904u, 3623364733u,
53163167128228u, 1052188336u,
53173656587111u, 721788662u,
53183061255808u, 1615375832u,
5319924941453u, 2547780700u,
53203328169224u, 1310964134u,
53212701956286u, 4145497671u,
53221421461094u, 1221397398u,
53231589183618u, 1492533854u,
5324449740816u, 2686506989u,
53253035198924u, 1682886232u,
53262529760244u, 3342031659u,
53271235084019u, 2151665147u,
53282315686577u, 3282027660u,
53291140138691u, 2754346599u,
53302091754612u, 1178454681u,
53314226896579u, 2942520471u,
53322122168506u, 3751680858u,
53333213794286u, 2601416506u,
53344142747914u, 3951404257u,
53354243249649u, 748595836u,
53364004834921u, 238887261u,
53371927321047u, 2217148444u,
5338205977665u, 1885975275u,
5339186020771u, 2367569534u,
53402941662631u, 2608559272u,
53413342096731u, 741809437u,
53421962659444u, 3539886328u,
53433036596491u, 2282550094u,
53442366462727u, 2748286642u,
53452144472852u, 1390394371u,
53461257385924u, 2205425874u,
53472119055686u, 46865323u,
53483597555910u, 3188438773u,
53492372320753u, 3641116924u,
53503116286108u, 2680722658u,
53513371014971u, 2058751609u,
53522966943726u, 2345078707u,
53532330535244u, 4013841927u,
53541169588594u, 857915866u,
53551875260989u, 3175831309u,
53563193475664u, 1955181430u,
5357923161569u, 4068653043u,
5358776445899u, 954196929u,
535961509556u, 4248237857u,
53603808667664u, 581227317u,
53612893240187u, 4159497403u,
53624212264930u, 3973886195u,
53632077539039u, 851579036u,
53642957587591u, 772351886u,
53651173659554u, 946748363u,
53662794103714u, 2094375930u,
53674234750213u, 3671645488u,
53682614250782u, 2620465358u,
53693122317317u, 2365436865u,
53703393973390u, 523513960u,
53713645735309u, 2766686992u,
53722023960931u, 2312244996u,
53731875932218u, 3253711056u,
53743622416881u, 3274929205u,
5375612094988u, 1555465129u,
53762114270406u, 3553762793u,
53771832633644u, 1087551556u,
53783306195841u, 1702313921u,
53793675066046u, 1735998785u,
53801690923980u, 1482649756u,
53811171351291u, 2043136409u,
53821962596992u, 461214626u,
53833278253346u, 1392428048u,
53843744621107u, 1028502697u,
53853991171462u, 1014064003u,
53863642345425u, 3186995039u,
53876114625u, 3359104346u,
5388414856965u, 2814387514u,
53893583605071u, 2497896367u,
53901024572712u, 1927582962u,
53912892797583u, 845302635u,
5392328548052u, 1523379748u,
53933392622118u, 1347167673u,
53941012316581u, 37767602u,
53952647726017u, 1070326065u,
53962075035198u, 4202817168u,
53972502924707u, 2612406822u,
53982187115553u, 1180137213u,
5399701024148u, 1481965992u,
54003223787553u, 2083541843u,
5401203230202u, 3876887380u,
54021334816273u, 2870251538u,
54032186205850u, 3985213979u,
5404333533378u, 806507642u,
54051010064531u, 713520765u,
54063084131515u, 2637421459u,
54071703168933u, 1517562266u,
54084089081247u, 3231042924u,
54093079916123u, 3154574447u,
54102253948262u, 1725190035u,
54112452539325u, 1343734533u,
5412213706059u, 2519409656u,
5413108055211u, 2916327746u,
5414587001593u, 1917607088u,
54154202913084u, 926304016u,
5416469255411u, 4042080256u,
54173498936874u, 246692543u,
5418495780578u, 438717281u,
54192259272650u, 4011324645u,
54202836854664u, 2317249321u,
5421946828752u, 1280403658u,
54221905648354u, 2034241661u,
5423774652981u, 1285694082u,
54242200307766u, 2158671727u,
54251135162148u, 232040752u,
5426397012087u, 1717527689u,
54271720414106u, 918797022u,
54282580119304u, 3568069742u,
54292904461070u, 3893453420u,
5430973817938u, 667499332u,
54313785870412u, 2088861715u,
54321565179401u, 600903026u,
5433591806775u, 3512242245u,
5434997964515u, 2339605347u,
54351134342772u, 3234226304u,
54364084179455u, 302315791u,
54372445626811u, 2590372496u,
5438345572299u, 2274770442u,
54393600587867u, 3706939009u,
54401430507980u, 2656330434u,
54411079209397u, 2122849632u,
54421423705223u, 3826321888u,
54433683385276u, 1057038163u,
54441242840526u, 3987000643u,
54452398253089u, 1538190921u,
54461295898647u, 3570196893u,
54473065138774u, 3111336863u,
54482524949549u, 4203895425u,
54493025864372u, 968800353u,
54501023721001u, 3763083325u,
5451526350786u, 635552097u,
54522308118370u, 2166472723u,
54532196937373u, 2643841788u,
54543040011470u, 4010301879u,
54552782379560u, 3474682856u,
54564201389782u, 4223278891u,
54571457302296u, 2251842132u,
54581090062008u, 3188219189u,
5459292733931u, 1424229089u,
54601590782640u, 1365212370u,
54613975957073u, 3982969588u,
54622927147928u, 1048291071u,
54632766680094u, 884908196u,
546435237839u, 2221180633u,
54652490333812u, 4098360768u,
54664029081103u, 3490831871u,
54672392516272u, 3455379186u,
54683948800722u, 335456628u,
54692105117968u, 4181629008u,
54701044201772u, 3335754111u,
5471540133451u, 3313113759u,
54723786107905u, 2627207327u,
54733540337875u, 3473113388u,
54743430536378u, 2514123129u,
54752124531276u, 3872633376u,
54763272957388u, 3501994650u,
54772418881542u, 487365389u,
54783877672368u, 1512866656u,
54793486531087u, 2102955203u,
54801136054817u, 3004241477u,
54811549075351u, 1302002008u,
54823936430045u, 2258587644u,
54834109233936u, 3679809321u,
54843467083076u, 2484463221u,
54851594979755u, 529218470u,
54863527024461u, 1147434678u,
5487106799023u, 1823161970u,
54881704656738u, 1675883700u,
54893308746763u, 1875093248u,
54901352868568u, 1898561846u,
54912508994984u, 3177750780u,
54924217929592u, 400784472u,
549380090315u, 3564414786u,
54943841585648u, 3379293868u,
5495160353261u, 2413172925u,
54962378499279u, 673436726u,
54971505702418u, 1330977363u,
54981853298225u, 3201741245u,
54992135714208u, 4069554166u,
55003715612384u, 3692488887u,
55013680311316u, 4274382900u,
5502914186796u, 2264886523u,
55033869634032u, 1254199592u,
55041131020455u, 194781179u,
5505429923922u, 2763792336u,
55062052895198u, 3997373194u,
55073440090658u, 2165746386u,
55081575500242u, 3463310191u,
55092064974716u, 3779513671u,
55103106421434u, 880320527u,
55113281914119u, 286569042u,
55123909096631u, 122359727u,
55131429837716u, 252230074u,
55144111461225u, 762273136u,
551593658514u, 2766407143u,
55163623657004u, 3869801679u,
55173925695921u, 2390397316u,
55182499025338u, 2741806539u,
55192507199021u, 1659221866u,
5520361292116u, 4048761557u,
55213797133396u, 1517903247u,
55223121647246u, 3884308578u,
55231697201500u, 1558800262u,
55244150812360u, 3161302278u,
55252610217849u, 641564641u,
5526183814518u, 2075245419u,
5527611996508u, 2223461433u,
5528329123979u, 121860586u,
5529860985829u, 1137889144u,
55304018949439u, 2904348960u,
5531947795261u, 1992594155u,
55324255427501u, 2281583851u,
55332892637604u, 1478186924u,
55343050771207u, 2767035539u,
5535373510582u, 1963520320u,
55363763848370u, 3756817798u,
5537627269409u, 1806905031u,
55381814444610u, 3646665053u,
55391822693920u, 278515794u,
5540584050483u, 4142579188u,
55412149745808u, 3193071606u,
55421179706341u, 2693495182u,
55433259749808u, 644172091u,
5544880509048u, 3340630542u,
55453365160815u, 2384445068u,
55463053081915u, 2840648309u,
55471986990122u, 1084703471u,
55482370410550u, 1627743573u,
55492244943480u, 4057483496u,
55502611595995u, 2470013639u,
55514024732359u, 3987190386u,
5552873421687u, 2447660175u,
55533226583022u, 767655877u,
55542528024413u, 1962070688u,
55551233635843u, 2163464207u,
5556659054446u, 854207134u,
5557258410943u, 4197831420u,
55582515400215u, 3100476924u,
55591961549594u, 2219491151u,
55603997658851u, 163850514u,
5561470325051u, 2598261204u,
55623052145580u, 59836528u,
55631376188597u, 966733415u,
5564850667549u, 3622479237u,
55651083731990u, 1525777459u,
55664005126532u, 1428155540u,
55672781907007u, 943739431u,
55681493961005u, 2839096988u,
55692000057832u, 1941829603u,
55701901484772u, 939810041u,
55713377407371u, 3090115837u,
55723310840540u, 2068409688u,
55733261383939u, 2212130277u,
55742594774045u, 2912652418u,
55754179816101u, 3534504531u,
55763349254805u, 2796552902u,
55771385421283u, 4259908631u,
55783714780837u, 3070073945u,
55793372846298u, 3835884044u,
55803047965714u, 3009018735u,
5581744091167u, 1861124263u,
55822764936304u, 1338171648u,
55834222019554u, 1395200692u,
55841371426007u, 3338031581u,
55852525665319u, 4196233786u,
55862332743921u, 1474702008u,
55872274266301u, 4255175517u,
55882290169528u, 1793910997u,
55892188254024u, 354202001u,
55903864458796u, 4280290498u,
55911554419340u, 1733094688u,
55922010552302u, 1561807039u,
5593664313606u, 2548990879u,
55941084699349u, 3233936866u,
5595973895284u, 2386881969u,
55961831995860u, 2961465052u,
55971428704144u, 3269904970u,
5598231648253u, 2602483763u,
55994125013173u, 3319187387u,
56003347011944u, 1892898231u,
56014019114049u, 868879116u,
56024085937045u, 2378411019u,
56031072588531u, 3547435717u,
56042208070766u, 1069899078u,
56053142980597u, 2337088907u,
56061593338562u, 919414554u,
5607688077849u, 3625708135u,
56081472447348u, 1947711896u,
56093953006207u, 877438080u,
5610845995820u, 3150361443u,
56113053496713u, 2484577841u,
5612224271045u, 2914958001u,
56132682612949u, 806655563u,
56142436224507u, 1907729235u,
56152920583824u, 1251814062u,
56162070814520u, 4034325578u,
5617497847539u, 2714317144u,
5618385182008u, 640855184u,
56191327075087u, 1062468773u,
56201757405994u, 1374270191u,
56214263183176u, 3041193150u,
56221037871524u, 3633173991u,
56234231821821u, 2830131945u,
56243505072908u, 2830570613u,
56254195208715u, 575398021u,
56263992840257u, 3691788221u,
56271949847968u, 2999344380u,
56283183782163u, 3723754342u,
5629759716128u, 3284107364u,
56301714496583u, 15918244u,
5631820509475u, 2553936299u,
56322201876606u, 4237151697u,
56332605688266u, 3253705097u,
56341008333207u, 712158730u,
56351722280252u, 1933868287u,
56364152736859u, 2097020806u,
5637584426382u, 2836501956u,
56382522777566u, 1996172430u,
56392122199776u, 1069285218u,
56401474209360u, 690831894u,
5641107482532u, 3695525410u,
5642670591796u, 768977505u,
56432412057331u, 3647886687u,
56443110327607u, 1072658422u,
5645379861934u, 1557579480u,
56464124127129u, 2271365865u,
56473880613089u, 739218494u,
5648547346027u, 388559045u,
56493147335977u, 176230425u,
56503094853730u, 2554321205u,
56511495176194u, 4093461535u,
56523521297827u, 4108148413u,
56531913727929u, 1177947623u,
56541911655402u, 1053371241u,
56553265708874u, 1266515850u,
56561045540427u, 3194420196u,
56573717104621u, 1144474110u,
56581464392345u, 52070157u,
56594144237690u, 3350490823u,
56604166253320u, 2747410691u,
5661};
5662
5663// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
5664bool Test(int offset, int len = 0) {
5665#undef Check
5666#undef IsAlive
5667
5668#define Check(x) do { \
5669 const uint32_t actual = (x), e = expected[index++]; \
5670 bool ok = actual == e; \
5671 if (!ok) { \
5672 cerr << "expected " << hex << e << " but got " << actual << endl; \
5673 ++errors; \
5674 } \
5675 assert(ok); \
5676} while (0)
5677
5678#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
5679
5680 // After the following line is where the uses of "Check" and such will go.
5681 static int index = 0;
5682if (offset == -1) { int alive = 0; { uint64_t h = farmhashna::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashna::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
5683{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
5684{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
5685{ uint64_t h = farmhashna::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
5686
5687 return true;
5688#undef Check
5689#undef IsAlive
5690}
5691
5692int RunTest() {
5693 Setup();
5694 int i = 0;
5695 cout << "Running farmhashnaTest";
5696 if (!Test(-1)) {
5697 cout << "... Unavailable\n";
5698 return NoteErrors();
5699 }
5700 // Good. The function is attempting to hash, so run the full test.
5701 int errors_prior_to_test = errors;
5702 for ( ; i < kTestSize - 1; i++) {
5703 Test(i * i, i);
5704 }
5705 for ( ; i < kDataSize; i += i / 7) {
5706 Test(0, i);
5707 }
5708 Test(0, kDataSize);
5709 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
5710 return NoteErrors();
5711}
5712
5713#else
5714
5715// After the following line is where the code to print hash codes will go.
5716void Dump(int offset, int len) {
5717{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5718{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5719{ uint64_t h = farmhashna::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5720}
5721
5722#endif
5723
5724#undef SEED
5725#undef SEED1
5726#undef SEED0
5727
5728} // namespace farmhashnaTest
5729
5730#if TESTING
5731
5732static int farmhashnaTestResult = farmhashnaTest::RunTest();
5733
5734#else
5735int main(int argc, char** argv) {
5736 Setup();
5737 cout << "uint32_t expected[] = {\n";
5738 int i = 0;
5739 for ( ; i < kTestSize - 1; i++) {
5740 farmhashnaTest::Dump(i * i, i);
5741 }
5742 for ( ; i < kDataSize; i += i / 7) {
5743 farmhashnaTest::Dump(0, i);
5744 }
5745 farmhashnaTest::Dump(0, kDataSize);
5746 cout << "};\n";
5747}
5748#endif
5749#ifndef FARMHASH_SELF_TEST_GUARD
5750#define FARMHASH_SELF_TEST_GUARD
5751#include <cstdio>
5752#include <iostream>
5753#include <string.h>
5754
5755using std::cout;
5756using std::cerr;
5757using std::endl;
5758using std::hex;
5759
5760static const uint64_t kSeed0 = 1234567;
5761static const uint64_t kSeed1 = k0;
5762static const int kDataSize = 1 << 20;
5763static const int kTestSize = 300;
5764#define kSeed128 Uint128(kSeed0, kSeed1)
5765
5766static char data[kDataSize];
5767
5768static int completed_self_tests = 0;
5769static int errors = 0;
5770
5771// Initialize data to pseudorandom values.
5772void Setup() {
5773 if (completed_self_tests == 0) {
5774 uint64_t a = 9;
5775 uint64_t b = 777;
5776 for (int i = 0; i < kDataSize; i++) {
5777 a += b;
5778 b += a;
5779 a = (a ^ (a >> 41)) * k0;
5780 b = (b ^ (b >> 41)) * k0 + i;
5781 uint8_t u = b >> 37;
5782 memcpy(data + i, &u, 1); // uint8_t -> char
5783 }
5784 }
5785}
5786
5787int NoteErrors() {
5788#define NUM_SELF_TESTS 9
5789 if (++completed_self_tests == NUM_SELF_TESTS)
5790 std::exit(errors > 0);
5791 return errors;
5792}
5793
5794template <typename T> inline bool IsNonZero(T x) {
5795 return x != 0;
5796}
5797
5798template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
5799 return x != Uint128(0, 0);
5800}
5801
5802#endif // FARMHASH_SELF_TEST_GUARD
5803
5804namespace farmhashntTest {
5805
5806uint32_t CreateSeed(int offset, int salt) {
5807 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
5808 h = h * c1;
5809 h ^= (h >> 17);
5810 h = h * c1;
5811 h ^= (h >> 17);
5812 h = h * c1;
5813 h ^= (h >> 17);
5814 h += static_cast<uint32_t>(offset & 0xffffffff);
5815 h = h * c1;
5816 h ^= (h >> 17);
5817 h = h * c1;
5818 h ^= (h >> 17);
5819 h = h * c1;
5820 h ^= (h >> 17);
5821 return h;
5822}
5823
5824#undef SEED
5825#undef SEED1
5826#undef SEED0
5827#define SEED CreateSeed(offset, -1)
5828#define SEED0 CreateSeed(offset, 0)
5829#define SEED1 CreateSeed(offset, 1)
5830
5831#undef TESTING
5832#define TESTING 1
5833#if TESTING
5834uint32_t expected[] = {
58352681724312u,
5836797982799u,
5837921001710u,
58382134990486u,
58392244477846u,
58402992121793u,
58413943596029u,
5842452431531u,
58432557197665u,
58442532580744u,
58453099673830u,
58463696623795u,
58473281581178u,
58481882212500u,
5849275903667u,
58503033004529u,
58511402319660u,
58522699376854u,
58534222949502u,
58541712034059u,
58551330324210u,
58562921867846u,
58571728752234u,
5858326029180u,
58593349570000u,
58601612122221u,
58611646032583u,
58621432476832u,
58633552092450u,
58641499109081u,
58651554038301u,
58663190844552u,
5867540224401u,
5868489963606u,
58691562872448u,
58702128624475u,
58711262831810u,
58721672724608u,
58732077310004u,
58741911523866u,
5875294527927u,
58761389770549u,
58772026137563u,
5878629449419u,
58792489287368u,
5880645684964u,
5881230403464u,
58823272648435u,
5883165370827u,
58841230085527u,
58853628174014u,
5886851743255u,
58871554380634u,
58883667013118u,
58892290487377u,
58901909203251u,
58911498556724u,
58924165088768u,
5893197618179u,
5894914413116u,
58951913303225u,
58963117299654u,
58971357272220u,
5898507436733u,
58991413396341u,
5900146044391u,
5901429095991u,
59023056862311u,
5903366414107u,
59042293458109u,
59051684583131u,
59061170404994u,
5907520792961u,
59081577421232u,
59094033596884u,
59104229339322u,
59113242407770u,
59122649785113u,
5913816692935u,
59143555213933u,
5915517646945u,
59162180594090u,
59173047062993u,
59182391606125u,
5919382936554u,
5920788479970u,
59212826990641u,
59223167748333u,
59231758123094u,
5924389974094u,
59253338548567u,
59262583576230u,
59273198590202u,
59284155628142u,
5929542201663u,
59302856634168u,
59313948351189u,
59324194218315u,
59331467786451u,
59342743592929u,
59351062268187u,
59363810665822u,
59372560479831u,
5938997658837u,
59393067277639u,
59401211737169u,
594159581167u,
59421389679610u,
59434189944477u,
5944100876854u,
59452062343506u,
59463088828656u,
59473284356565u,
59483130054947u,
59493532596884u,
59503887208531u,
5951259034107u,
59523233195759u,
59533200749877u,
5954760633989u,
59551115203611u,
59561516407838u,
59571778459926u,
59582146672889u,
59592457048126u,
59602217471853u,
5961862072556u,
59623745267835u,
5963701920051u,
5964581695350u,
59651410111809u,
59663326135446u,
59672187968410u,
59684267859263u,
5969479241367u,
59702868987960u,
5971704325635u,
59721418509533u,
5973735688735u,
59743283299459u,
5975813690332u,
59761439630796u,
59773195309868u,
59781616408198u,
59793254795114u,
59802799925823u,
59813929484338u,
59821798536177u,
59834205965408u,
59841499475160u,
59854247675634u,
59863779953975u,
5987785893184u,
59882778575413u,
59891160134629u,
5990823113169u,
59914116162021u,
59924167766971u,
59932487440590u,
59944004655503u,
59954044418876u,
59961462554406u,
59972011102035u,
59984265993528u,
5999576405853u,
60004038839101u,
60012425317635u,
60021401013391u,
60033062418115u,
60043167030094u,
60052602636307u,
60064264167741u,
60074017058800u,
60081029665228u,
60094036354071u,
60102670703363u,
6011688472265u,
60121054670286u,
6013338058159u,
60141539305024u,
6015146827036u,
60164060134777u,
60172502815838u,
60181603444633u,
60192448966429u,
60203891353218u,
60211082330589u,
6022201837927u,
60232848283092u,
6024883849006u,
60251982110346u,
6026541496720u,
6027133643215u,
60283847827123u,
60294015671361u,
60302849988118u,
60313452457457u,
60322102063419u,
60333281002516u,
60341539151988u,
60351147951686u,
60362005032160u,
60372415262714u,
6038116647396u,
60391029284767u,
60402159170082u,
60411919171906u,
60422017579106u,
60432473524405u,
60441694443528u,
60453671562289u,
6046505662155u,
60471019936943u,
60481511077569u,
6049773792826u,
60502089123665u,
6051484732447u,
60521120017626u,
60532809286837u,
60544029205195u,
60551097806406u,
6056136118734u,
60574017075736u,
60581403506686u,
60591516736273u,
60602562064338u,
60612984955003u,
60623071338162u,
60631923531348u,
6064771592405u,
60652586632018u,
60664032960199u,
60672687561076u,
6068308584855u,
60691692079268u,
60702565680167u,
60713674576684u,
60723770488806u,
607369201295u,
60741255084262u,
60753593730713u,
607654945052u,
60771939595371u,
60782432427547u,
60792295501078u,
60801280920000u,
608182177963u,
60821121403845u,
60832889101923u,
6084713121337u,
60851747052377u,
6086927011680u,
60874142246789u,
60881958963937u,
60891636932722u,
60904075249328u,
60912025886508u,
60923026358429u,
60931845587644u,
60943615577014u,
60951363253259u,
60963087190425u,
6097341851980u,
60982515339233u,
60991276595523u,
6100460237542u,
61014198897105u,
61022069753399u,
61034278599955u,
6104356742959u,
61053735275001u,
61061750561299u,
6107668829411u,
61083384018814u,
61094233785523u,
6110451656820u,
6111107312677u,
61122390172694u,
61131216645846u,
6114164402616u,
61151689811113u,
61161767810825u,
61171397772514u,
61183323383489u,
61192986430557u,
6120207428029u,
61212260498180u,
61222360400900u,
61231263709570u,
61241377764574u,
61254252610345u,
61261099809675u,
61272776960536u,
61283542220540u,
61293752806924u,
6130337070226u,
61313267551635u,
61321306761320u,
61332220373824u,
61344109252858u,
6135896322512u,
61361788337208u,
61371336556841u,
61382911512007u,
61393712582785u,
61403071359622u,
61412561488770u,
61423898950547u,
6143536047554u,
61442040551642u,
61453528794619u,
61463565689036u,
61471197100813u,
61481864569342u,
61493329594980u,
6150490608221u,
61511174785921u,
61523287246572u,
61532163330264u,
6154500120236u,
61552520062970u,
61561561519055u,
61574042710240u,
61582774151984u,
61593160666939u,
616096459446u,
61611878067032u,
61624237425634u,
61632952135524u,
61644100839753u,
61651265237690u,
61664246879223u,
6167834830418u,
61683476334357u,
61694277111759u,
61702511026735u,
61713065234219u,
6172556796152u,
6173198182691u,
61742913077464u,
61751535115487u,
61764046477658u,
6177140762681u,
6178990407433u,
61792198985327u,
61802926590471u,
6181559702706u,
618282077489u,
61831096697687u,
61844190838199u,
61853046872820u,
61861583801700u,
61872185339100u,
61883912423882u,
61893703603898u,
61902540185277u,
61911446869792u,
61924051584612u,
61932719373510u,
61941675560450u,
61951996164093u,
6196405251683u,
61972864244470u,
61984071581802u,
61992028708916u,
6200803575837u,
6201557660441u,
62023841480082u,
6203255451671u,
6204779434428u,
62053452203069u,
62062285701422u,
62071568745354u,
6208823305654u,
62093184047862u,
62104159715581u,
62113160134214u,
62123198900547u,
62131566527339u,
62144194096960u,
62151496132623u,
62161719108984u,
62172584236470u,
6218531310503u,
62193456882941u,
62203382290593u,
6221467441309u,
62223241407531u,
62232540270567u,
62241397502982u,
62253348545480u,
6226811750340u,
62271017047954u,
62282540585554u,
62293531646869u,
6230943914610u,
62311903578924u,
62321911188923u,
6233241574049u,
62343181425568u,
62353529565564u,
6236240953857u,
62372964595704u,
62383828377737u,
62394260564140u,
62404262383425u,
6241383233885u,
62424051263539u,
6243919677938u,
62441683612329u,
62454204155962u,
62462283918569u,
62474153726847u,
6248350160869u,
62491387233546u,
62501891558063u,
6251740563169u,
6252330624974u,
62532948665536u,
6254376390582u,
62553799363969u,
62563187805406u,
62572263421398u,
62581928519266u,
62592746577402u,
62602108753646u,
6261768287270u,
62622247006571u,
6263212490675u,
6264917121602u,
62652549835613u,
62662864033668u,
62673738062408u,
62682006922227u,
62692616619070u,
62703449066284u,
6271431292293u,
6272786322314u,
62731415970351u,
62743263135197u,
62752954777083u,
62763206261120u,
62772287507921u,
62781781944746u,
62794081586725u,
62801109175923u,
62811813855658u,
62821129462471u,
62831037031473u,
62843389003793u,
62853122687303u,
62861164309901u,
62873193251135u,
62883626554867u,
62893071568023u,
62903656006011u,
62911167681812u,
62923155218919u,
62932704165015u,
62941854985978u,
62951712976649u,
6296878608872u,
62974155949943u,
62983163786257u,
62991626463554u,
63001256485167u,
6301582664250u,
63022083771672u,
6303804336148u,
63042770847216u,
63051674051445u,
63063992583643u,
63072966108111u,
6308900741486u,
63094014551783u,
6310300318232u,
63113517585534u,
6312542270815u,
6313760762191u,
63141216399252u,
6315643179562u,
63163652676161u,
63172990167340u,
63183262252593u,
63192134299399u,
6320411263051u,
63211342880802u,
63221967599860u,
6323853593042u,
63242682611693u,
6325850464484u,
63263286110054u,
63273842907484u,
63283623364733u,
63293693536939u,
63301615375832u,
63312318423400u,
63324145497671u,
63331728968857u,
63342686506989u,
63351502282913u,
63362151665147u,
63373651607391u,
63381178454681u,
63394146839064u,
63402601416506u,
63411448097974u,
6342238887261u,
63434093725287u,
63442367569534u,
6345679517009u,
63463539886328u,
63473086277222u,
63481390394371u,
6349119173722u,
63501766260771u,
6351751439914u,
6352215917713u,
63532656990891u,
63541570750352u,
63553533987737u,
63563576119563u,
6357963183826u,
63583796810515u,
6359136547246u,
63602592925324u,
6361427154472u,
63621228758574u,
63631464255968u,
63642984611177u,
63652001585786u,
63661525438381u,
63671348536411u,
63682861338018u,
6369764077711u,
63703785343245u,
6371457568934u,
63724104954272u,
63732381948487u,
63743148473363u,
63752180270337u,
63761387729170u,
6377951677556u,
63782721005055u,
637966786703u,
63801149351924u,
63811895026827u,
63823711056516u,
63833638638708u,
63842263003308u,
63853448840877u,
6386225333538u,
63873797521928u,
63883262952567u,
63892078619498u,
63901178073973u,
63913288261538u,
63921496966875u,
63932481012988u,
6394114945840u,
63951632780103u,
63962087949619u,
63973787017905u,
63982575395164u,
63992971726178u,
64003642087909u,
64013894199764u,
6402203853421u,
6403425935223u,
64043565833278u,
64051748785729u,
6406580966986u,
64072124704694u,
64081107045577u,
64091067532701u,
64101406028344u,
641118613994u,
64123476683808u,
64133762914298u,
64141844996900u,
6415904215228u,
64161118521573u,
64173657647605u,
64183136157065u,
64192287683323u,
6420126005630u,
64213555092974u,
642249515858u,
64231010661841u,
64241902040126u,
64251400735275u,
64262771676666u,
64272225229957u,
64283454177594u,
64292883475137u,
64304144472319u,
64311051332394u,
6432542648229u,
64331669710469u,
6434553041029u,
6435584127807u,
64362993670925u,
64373587959456u,
64381745399498u,
64391404723176u,
64401334333531u,
64413239516985u,
64421275954779u,
6443367320647u,
64443684418197u,
64454030809053u,
6446484559105u,
64474255931645u,
64484271715616u,
64493171911678u,
6450928543347u,
64512159512867u,
6452313902234u,
6453647086234u,
6454577214736u,
64551130129573u,
6456995791646u,
64571645086060u,
64584122335794u,
64591064648931u,
64602752145076u,
64613312498873u,
64624238535494u,
64631471227427u,
6464633688562u,
64651959779970u,
6466766642813u,
64671380896111u,
64683647601207u,
64691733961041u,
6470521947915u,
6471189164145u,
6472486382294u,
64733770038872u,
64743235740744u,
64751912506671u,
64762276864677u,
64771588060152u,
64782504457929u,
64791471020554u,
64803623212998u,
64813026631806u,
64822342164722u,
64831674890530u,
64843011542850u,
64853549160092u,
64864290680005u,
64873943068002u,
64882273781461u,
64892127663659u,
64901646681121u,
6491447810651u,
64922366308558u,
6493970504950u,
64942008155560u,
64952695940969u,
64963444688454u,
64971739318893u,
64982683090634u,
64992774816580u,
6500437560100u,
6501512012738u,
65023305170944u,
6503665292744u,
65043580039116u,
65051579404983u,
65063397891494u,
6507710590371u,
65082514565805u,
65093624609754u,
65103516075816u,
65111314000850u,
65121935166880u,
65133257747610u,
65143776931214u,
65153183054185u,
6516675129307u,
65173333261712u,
65181154611403u,
65192759854023u,
65201963228038u,
6521505138315u,
65221803966773u,
65234032705384u,
6524798395739u,
65253473799845u,
6526476400898u,
6527602972493u,
65283289878097u,
65292520311409u,
65303214794876u,
6531748160407u,
65321326769504u,
6533902775872u,
65341372805534u,
65351213925114u,
65363009384989u,
65373781981134u,
65382835608783u,
65392716786748u,
65401669490957u,
65411089334066u,
6542250756920u,
65434041016629u,
65442495807367u,
65452008251381u,
6546106212622u,
65471927268995u,
65482251978818u,
65493788056262u,
65503678660147u,
65512656772270u,
65521997584981u,
65532668998785u,
65542954162084u,
6555845687881u,
6556776018378u,
65572066910012u,
6558918315064u,
6559};
6560
6561// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
6562bool Test(int offset, int len = 0) {
6563#undef Check
6564#undef IsAlive
6565
6566#define Check(x) do { \
6567 const uint32_t actual = (x), e = expected[index++]; \
6568 bool ok = actual == e; \
6569 if (!ok) { \
6570 cerr << "expected " << hex << e << " but got " << actual << endl; \
6571 ++errors; \
6572 } \
6573 assert(ok); \
6574} while (0)
6575
6576#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
6577
6578 // After the following line is where the uses of "Check" and such will go.
6579 static int index = 0;
6580if (offset == -1) { int alive = 0; IsAlive(farmhashnt::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashnt::Hash32(data, len++)); IsAlive(farmhashnt::Hash32(data, len++)); len -= 3; return alive > 0; }
6581Check(farmhashnt::Hash32WithSeed(data + offset, len, SEED));
6582Check(farmhashnt::Hash32(data + offset, len));
6583
6584 return true;
6585#undef Check
6586#undef IsAlive
6587}
6588
6589int RunTest() {
6590 Setup();
6591 int i = 0;
6592 cout << "Running farmhashntTest";
6593 if (!Test(-1)) {
6594 cout << "... Unavailable\n";
6595 return NoteErrors();
6596 }
6597 // Good. The function is attempting to hash, so run the full test.
6598 int errors_prior_to_test = errors;
6599 for ( ; i < kTestSize - 1; i++) {
6600 Test(i * i, i);
6601 }
6602 for ( ; i < kDataSize; i += i / 7) {
6603 Test(0, i);
6604 }
6605 Test(0, kDataSize);
6606 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
6607 return NoteErrors();
6608}
6609
6610#else
6611
6612// After the following line is where the code to print hash codes will go.
6613void Dump(int offset, int len) {
6614cout << farmhashnt::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
6615cout << farmhashnt::Hash32(data + offset, len) << "u," << endl;
6616}
6617
6618#endif
6619
6620#undef SEED
6621#undef SEED1
6622#undef SEED0
6623
6624} // namespace farmhashntTest
6625
6626#if TESTING
6627
6628static int farmhashntTestResult = farmhashntTest::RunTest();
6629
6630#else
6631int main(int argc, char** argv) {
6632 Setup();
6633 cout << "uint32_t expected[] = {\n";
6634 int i = 0;
6635 for ( ; i < kTestSize - 1; i++) {
6636 farmhashntTest::Dump(i * i, i);
6637 }
6638 for ( ; i < kDataSize; i += i / 7) {
6639 farmhashntTest::Dump(0, i);
6640 }
6641 farmhashntTest::Dump(0, kDataSize);
6642 cout << "};\n";
6643}
6644#endif
6645#ifndef FARMHASH_SELF_TEST_GUARD
6646#define FARMHASH_SELF_TEST_GUARD
6647#include <cstdio>
6648#include <iostream>
6649#include <string.h>
6650
6651using std::cout;
6652using std::cerr;
6653using std::endl;
6654using std::hex;
6655
6656static const uint64_t kSeed0 = 1234567;
6657static const uint64_t kSeed1 = k0;
6658static const int kDataSize = 1 << 20;
6659static const int kTestSize = 300;
6660#define kSeed128 Uint128(kSeed0, kSeed1)
6661
6662static char data[kDataSize];
6663
6664static int completed_self_tests = 0;
6665static int errors = 0;
6666
6667// Initialize data to pseudorandom values.
6668void Setup() {
6669 if (completed_self_tests == 0) {
6670 uint64_t a = 9;
6671 uint64_t b = 777;
6672 for (int i = 0; i < kDataSize; i++) {
6673 a += b;
6674 b += a;
6675 a = (a ^ (a >> 41)) * k0;
6676 b = (b ^ (b >> 41)) * k0 + i;
6677 uint8_t u = b >> 37;
6678 memcpy(data + i, &u, 1); // uint8_t -> char
6679 }
6680 }
6681}
6682
6683int NoteErrors() {
6684#define NUM_SELF_TESTS 9
6685 if (++completed_self_tests == NUM_SELF_TESTS)
6686 std::exit(errors > 0);
6687 return errors;
6688}
6689
6690template <typename T> inline bool IsNonZero(T x) {
6691 return x != 0;
6692}
6693
6694template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
6695 return x != Uint128(0, 0);
6696}
6697
6698#endif // FARMHASH_SELF_TEST_GUARD
6699
6700namespace farmhashsaTest {
6701
6702uint32_t CreateSeed(int offset, int salt) {
6703 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
6704 h = h * c1;
6705 h ^= (h >> 17);
6706 h = h * c1;
6707 h ^= (h >> 17);
6708 h = h * c1;
6709 h ^= (h >> 17);
6710 h += static_cast<uint32_t>(offset & 0xffffffff);
6711 h = h * c1;
6712 h ^= (h >> 17);
6713 h = h * c1;
6714 h ^= (h >> 17);
6715 h = h * c1;
6716 h ^= (h >> 17);
6717 return h;
6718}
6719
6720#undef SEED
6721#undef SEED1
6722#undef SEED0
6723#define SEED CreateSeed(offset, -1)
6724#define SEED0 CreateSeed(offset, 0)
6725#define SEED1 CreateSeed(offset, 1)
6726
6727#undef TESTING
6728#define TESTING 1
6729#if TESTING
6730uint32_t expected[] = {
67314223616069u,
67323696677242u,
67334081014168u,
67342576519988u,
67352212771159u,
67361112731063u,
67371020067935u,
67383955445564u,
67391451961420u,
6740653440099u,
674131917516u,
67422957164615u,
67432590087362u,
67443879448744u,
6745176305566u,
67462447367541u,
67471359016305u,
67483363804638u,
67491117290165u,
67501062549743u,
67512437877004u,
67521894455839u,
6753673206794u,
67543486923651u,
67553269862919u,
67562303349487u,
67571380660650u,
6758595525107u,
67591525325287u,
67602025609358u,
6761176408838u,
67621592885012u,
6763864896482u,
67642101378090u,
67653489229104u,
67662118965695u,
6767581644891u,
67682718789079u,
6769631613207u,
67704228658372u,
67713867875546u,
67723531368319u,
67733804516756u,
67743317755099u,
67751619744564u,
67762884717286u,
67771088213445u,
67782667691076u,
67793727873235u,
67802330406762u,
6781858590707u,
6782123802208u,
67834150036245u,
6784182283099u,
67851478882570u,
67863282617403u,
6787819171187u,
67881172627392u,
67894254302102u,
67902957028020u,
6791437030323u,
67922452147680u,
67932868246750u,
67943530169402u,
67953154852132u,
6796215019192u,
6797357580983u,
67981354454461u,
67991108813287u,
68002324008118u,
68012315997713u,
68024181601562u,
68031360882441u,
680492423273u,
68053048866755u,
68063369188505u,
68073664371439u,
68082920710428u,
68091027891570u,
68102653166430u,
68113461888315u,
68121475780447u,
6813292769636u,
68141737473313u,
68154064110516u,
68164170160075u,
6817762850927u,
68183630603695u,
68192803307356u,
6820844987665u,
6821460980967u,
68223005635467u,
68232802568977u,
6824588668033u,
68252148940781u,
68263239099984u,
68271266953698u,
68283197808789u,
68293519942533u,
68302511995334u,
68312553810188u,
6832871667697u,
68331358675720u,
68341499319171u,
68352044931270u,
68361210355103u,
6837807152540u,
68383262320756u,
68392810214575u,
68401813386141u,
68414089465863u,
6842903928165u,
68431388899322u,
68443209183659u,
6845834536144u,
68462733354550u,
68472742289921u,
68483689042563u,
68492655593281u,
68504169686303u,
6851415985561u,
6852138892376u,
6853516115393u,
685465683883u,
68554162865100u,
6856889944635u,
6857313566528u,
68583346420907u,
68591504303591u,
68602256809275u,
6861742243229u,
6862779775302u,
68633140940172u,
68642312556111u,
68652304095772u,
68661151741606u,
68672194712422u,
68681714084652u,
68693272736835u,
68701311540658u,
6871191179665u,
68723996605106u,
68731657345233u,
68744205442903u,
68751553339212u,
68762351843044u,
68771647502006u,
68782525516233u,
6879292202846u,
68801498646290u,
68811429323381u,
6882974274898u,
68833759331561u,
68842881238887u,
6885826787221u,
68861069622448u,
6887221991032u,
68881462969082u,
68892799661508u,
6890364022781u,
68912594244377u,
6892797773898u,
68934097839290u,
68941529150125u,
68952456805570u,
6896541503425u,
68973936326142u,
68983112719954u,
6899775223581u,
69003074018423u,
69013198488875u,
69021772191849u,
69032456535211u,
69043154686028u,
69051520862019u,
69064005829426u,
69071306433767u,
69081943028506u,
69092246000782u,
69101057766454u,
69113761996982u,
69123441075333u,
6913898641979u,
69143450209088u,
69153941329307u,
69163289922449u,
69173085075827u,
69181814193220u,
6919690422997u,
69202627846676u,
69212653520704u,
69223739145533u,
69233996776010u,
69242287072592u,
69251346671698u,
69263082629900u,
69272298811274u,
69283639722036u,
69291729419228u,
69301836765953u,
69313708118742u,
6932213436u,
6933950223749u,
69343734247682u,
69352924575678u,
69361382024841u,
69372431637732u,
69383448846682u,
69391341301397u,
69404206956590u,
69411730650902u,
69422581075456u,
69431542359141u,
6944707222542u,
69452925350541u,
69463846303536u,
69473579103295u,
69483932175763u,
69491339615732u,
6950848825750u,
69511070170828u,
69521964973818u,
6953577060344u,
6954607721296u,
69554031023048u,
6956406883794u,
69573991905552u,
69581198544082u,
6959872468460u,
69601044847096u,
69613159976313u,
69623020028266u,
69632108700400u,
69643373767922u,
6965264431841u,
69662817097007u,
69673700061048u,
69681733731531u,
69693459415893u,
697080378591u,
69711479875104u,
697219735612u,
69731382658977u,
69743416562245u,
69751959852842u,
69762384002344u,
6977124683828u,
69783725782174u,
69792300301222u,
6980393852269u,
69811302492002u,
69823623776492u,
69833787086417u,
69841730024749u,
69851710531361u,
6986443700716u,
69871461987482u,
6988671998131u,
69893018380746u,
69902592292305u,
69913390799372u,
69923945101155u,
69933743494852u,
69943716045582u,
6995996005166u,
6996320698449u,
69973420221765u,
69981518157951u,
69992555810666u,
70003381929684u,
70012019638523u,
70023088262796u,
70032072178906u,
70043433649364u,
7005203906916u,
700634663784u,
7007290301305u,
70081188021504u,
70093754681145u,
70103920313139u,
70112840496520u,
70121656802962u,
70132288475489u,
70143399185138u,
70151296000826u,
70162362384746u,
7017309633360u,
70182719851778u,
7019776035930u,
70203200733043u,
7021365690832u,
70223326378243u,
70231500331457u,
70241625708592u,
70254230903462u,
7026715344888u,
70273363777768u,
70282243620288u,
70292890765789u,
7030553154234u,
70314044100108u,
70324056887320u,
70331185656496u,
70343671476744u,
70351064586897u,
70361154949698u,
70373493481974u,
70381294573722u,
70391869224012u,
70402530084956u,
7041995321553u,
7042833419249u,
7043563815282u,
7044250258043u,
70452970801822u,
7046441007535u,
704742246961u,
70482820426655u,
70492878882436u,
70502363245780u,
70512138489282u,
70522972360481u,
70532312619393u,
70543598664848u,
70553071556076u,
7056776990325u,
70573220427357u,
70582257939577u,
70593817305903u,
70601502979698u,
70613159755934u,
70623955997276u,
70632423850008u,
70641959927572u,
70651219782288u,
70664119776679u,
70671124253854u,
70683678052422u,
70692620644947u,
70701262408666u,
70713480072280u,
70722627137665u,
7073807538749u,
70743276646337u,
7075518510128u,
70761137828655u,
70771498449110u,
70783031692317u,
70791125635969u,
70801130096111u,
7081780007336u,
70823111856399u,
70831014917264u,
7084780877352u,
70852909458336u,
70864235949214u,
70872423879289u,
7088275888892u,
70893891926795u,
70903538163953u,
709154815161u,
7092162228302u,
7093258154068u,
70943554455591u,
70951801469029u,
70962801563220u,
7097726560058u,
70982450221940u,
70993677582978u,
7100440993800u,
7101424762443u,
71022624525253u,
71032587715329u,
71042292264424u,
71051074856749u,
71063294752007u,
71073164112672u,
71082399146799u,
71091920182465u,
71103858835361u,
7111193755240u,
71123333610311u,
71131757504059u,
71142576027039u,
71152775253365u,
71162939191561u,
71171046147275u,
7118235149906u,
71194262218222u,
71202900542726u,
71212260154702u,
71221019551635u,
71231194720570u,
71243519118691u,
71253039483153u,
712684918216u,
71273053381097u,
71282572396843u,
71293849763371u,
71302782686780u,
71313710049554u,
71323403430713u,
71332346080784u,
71342496307442u,
71351597281872u,
7136696018239u,
7137704625714u,
7138623026921u,
71393182413559u,
71403794540330u,
7141305497722u,
71421592680199u,
71432377854072u,
71443060601746u,
71453953057908u,
71463941551588u,
71471033716182u,
71482765716854u,
71491309699058u,
71503519400181u,
71513073370877u,
7152115583008u,
71534032909296u,
71542944563574u,
71553762753718u,
7156192842727u,
71571711348701u,
71583086147235u,
71591658229443u,
71601479783872u,
71613839977157u,
7162225619117u,
71631349684817u,
71641964813173u,
7165565753187u,
71662530252046u,
7167840014353u,
71681645183704u,
71693668429078u,
71703438418557u,
7171639704059u,
7172360837811u,
71732531807958u,
71741572353913u,
71752116037299u,
71761948437512u,
7177744553393u,
71782380697034u,
71793775234105u,
71803816065157u,
7181301868653u,
71822960939561u,
71833306528247u,
71842389296549u,
7185805918610u,
71861759358265u,
71871760876328u,
71882827601706u,
71892944594708u,
71903313666458u,
71912022601495u,
7192730938791u,
7193193539397u,
71942026103244u,
7195802928398u,
71962630934308u,
7197782805818u,
71983499326016u,
7199293509489u,
72003646131514u,
72013182478647u,
7202854800333u,
72032284531628u,
7204438528022u,
72052339298129u,
72061692289216u,
72072427728723u,
720846501288u,
7209350652353u,
72101355971222u,
7211889682372u,
7212944799254u,
72132763906061u,
72142807550612u,
72152683762637u,
7216100870317u,
72172449357318u,
72182638348436u,
72194206088869u,
72201788948473u,
72213537588549u,
72222782490204u,
7223134406470u,
72242409190528u,
72252362439849u,
72261861661528u,
72272101513194u,
72281424834765u,
72293581765745u,
72303185999525u,
72312057487100u,
72322303941176u,
72333639628788u,
72341180265315u,
7235230437935u,
72362108319366u,
72371131685143u,
72381055685292u,
72391509007009u,
72401258485140u,
7241560525005u,
72423598799040u,
72433835680585u,
72441851859628u,
7245332858996u,
7246641769248u,
72474252450037u,
7248865386707u,
7249720719117u,
72503133612164u,
72513833045874u,
72523492515435u,
72532465970289u,
72544234420011u,
7255573859916u,
7256252532886u,
7257870392318u,
72584051320920u,
7259894929092u,
72603748361688u,
7261699355960u,
72621885212350u,
72631609756949u,
7264461896870u,
72651337065461u,
72661775211059u,
72671786193749u,
72682815154643u,
72692128729882u,
7270969639529u,
72713960427545u,
7272859416958u,
72732739758802u,
72742698032197u,
72752813292418u,
72761985467524u,
7277396604317u,
72784122172759u,
72791201259789u,
72804282051702u,
72813270018895u,
7282961215209u,
7283961075860u,
72844211926998u,
72854088374597u,
7286577510509u,
72873058349487u,
72884025377754u,
72892815478438u,
7290471023164u,
72913947959608u,
72924161486934u,
72932299888461u,
72941103571511u,
72952450153872u,
72961839939275u,
7297108299608u,
7298858086440u,
72991030152945u,
73003895328530u,
73013009080718u,
73023690840454u,
73033847025277u,
7304152331362u,
7305161365689u,
7306831319961u,
73072166017294u,
73083945322722u,
73094059970216u,
73101420824131u,
73112770648308u,
73121567250186u,
73132181067149u,
73141939743488u,
73153080158120u,
73163435218248u,
73172495237495u,
73183814085102u,
73193180983013u,
73203199054292u,
73212204745908u,
73221140337267u,
73232213569784u,
73241941879842u,
73252105562605u,
73263618835614u,
73272247103645u,
73282492473487u,
7329856414299u,
7330166022030u,
73314080104712u,
73323218935344u,
73333284220561u,
73344261581452u,
73351206944836u,
73363496705432u,
73372215996876u,
73383154627465u,
73393384005496u,
7340742170556u,
73411333047620u,
7342802680366u,
7343156833431u,
73442682100354u,
73452493654830u,
7346584848366u,
73471691693131u,
73482169934170u,
7349779968026u,
73502099545800u,
73511423039695u,
73524292110968u,
73534266576788u,
7354149142597u,
7355748501873u,
73563865014822u,
73571913588198u,
7358130285614u,
73593500768879u,
7360915458923u,
73613071792750u,
73621339986633u,
73634143929149u,
73644048379479u,
7365725193827u,
73661375113643u,
73672425277412u,
73684144659274u,
7369465714768u,
7370226991589u,
73712212127704u,
73723936145258u,
73732891024846u,
73743816000225u,
7375979331165u,
73761749907536u,
737753847318u,
73781462525833u,
73792961425455u,
7380368859113u,
73813572721452u,
7382453048644u,
73831628629918u,
73843497673923u,
73853619079585u,
7386139870565u,
73871518176798u,
73883933074281u,
73891878623729u,
73902074035641u,
73913016759257u,
73921313053591u,
73932557706970u,
73942348296582u,
7395962370022u,
73962337285014u,
73971618936717u,
73981915877085u,
73992743743122u,
74003250783882u,
74011346652536u,
7402143311109u,
74032443788461u,
74041048248964u,
74052806619339u,
74063263266976u,
74071668146349u,
74083397428868u,
74093276188862u,
74101774196343u,
74111993847813u,
74122771079610u,
7413476672419u,
74142119050359u,
74152918326659u,
74162245402721u,
74172692910474u,
74182374383269u,
7419342400227u,
74202961437795u,
74213899230368u,
7422337787132u,
74233664444935u,
74241269451153u,
74252971526729u,
74261486511182u,
7427791070133u,
74282570319890u,
74293482497490u,
74302134230518u,
74314273391202u,
74321825511330u,
74333947753714u,
74341389755724u,
74353995075516u,
74362081052615u,
74373626343470u,
74384213603435u,
74392137917278u,
74402898987303u,
74413059215715u,
74423383237881u,
74433003674434u,
7444409174425u,
74451911915604u,
74462087728055u,
74472942005882u,
74483386522440u,
7449714936074u,
7450261924004u,
74513268784033u,
74521141188757u,
74532413217552u,
74541515163433u,
7455};
7456
7457// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
7458bool Test(int offset, int len = 0) {
7459#undef Check
7460#undef IsAlive
7461
7462#define Check(x) do { \
7463 const uint32_t actual = (x), e = expected[index++]; \
7464 bool ok = actual == e; \
7465 if (!ok) { \
7466 cerr << "expected " << hex << e << " but got " << actual << endl; \
7467 ++errors; \
7468 } \
7469 assert(ok); \
7470} while (0)
7471
7472#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
7473
7474 // After the following line is where the uses of "Check" and such will go.
7475 static int index = 0;
7476if (offset == -1) { int alive = 0; IsAlive(farmhashsa::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsa::Hash32(data, len++)); IsAlive(farmhashsa::Hash32(data, len++)); len -= 3; return alive > 0; }
7477Check(farmhashsa::Hash32WithSeed(data + offset, len, SEED));
7478Check(farmhashsa::Hash32(data + offset, len));
7479
7480 return true;
7481#undef Check
7482#undef IsAlive
7483}
7484
7485int RunTest() {
7486 Setup();
7487 int i = 0;
7488 cout << "Running farmhashsaTest";
7489 if (!Test(-1)) {
7490 cout << "... Unavailable\n";
7491 return NoteErrors();
7492 }
7493 // Good. The function is attempting to hash, so run the full test.
7494 int errors_prior_to_test = errors;
7495 for ( ; i < kTestSize - 1; i++) {
7496 Test(i * i, i);
7497 }
7498 for ( ; i < kDataSize; i += i / 7) {
7499 Test(0, i);
7500 }
7501 Test(0, kDataSize);
7502 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
7503 return NoteErrors();
7504}
7505
7506#else
7507
7508// After the following line is where the code to print hash codes will go.
7509void Dump(int offset, int len) {
7510cout << farmhashsa::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
7511cout << farmhashsa::Hash32(data + offset, len) << "u," << endl;
7512}
7513
7514#endif
7515
7516#undef SEED
7517#undef SEED1
7518#undef SEED0
7519
7520} // namespace farmhashsaTest
7521
7522#if TESTING
7523
7524static int farmhashsaTestResult = farmhashsaTest::RunTest();
7525
7526#else
7527int main(int argc, char** argv) {
7528 Setup();
7529 cout << "uint32_t expected[] = {\n";
7530 int i = 0;
7531 for ( ; i < kTestSize - 1; i++) {
7532 farmhashsaTest::Dump(i * i, i);
7533 }
7534 for ( ; i < kDataSize; i += i / 7) {
7535 farmhashsaTest::Dump(0, i);
7536 }
7537 farmhashsaTest::Dump(0, kDataSize);
7538 cout << "};\n";
7539}
7540#endif
7541#ifndef FARMHASH_SELF_TEST_GUARD
7542#define FARMHASH_SELF_TEST_GUARD
7543#include <cstdio>
7544#include <iostream>
7545#include <string.h>
7546
7547using std::cout;
7548using std::cerr;
7549using std::endl;
7550using std::hex;
7551
7552static const uint64_t kSeed0 = 1234567;
7553static const uint64_t kSeed1 = k0;
7554static const int kDataSize = 1 << 20;
7555static const int kTestSize = 300;
7556#define kSeed128 Uint128(kSeed0, kSeed1)
7557
7558static char data[kDataSize];
7559
7560static int completed_self_tests = 0;
7561static int errors = 0;
7562
7563// Initialize data to pseudorandom values.
7564void Setup() {
7565 if (completed_self_tests == 0) {
7566 uint64_t a = 9;
7567 uint64_t b = 777;
7568 for (int i = 0; i < kDataSize; i++) {
7569 a += b;
7570 b += a;
7571 a = (a ^ (a >> 41)) * k0;
7572 b = (b ^ (b >> 41)) * k0 + i;
7573 uint8_t u = b >> 37;
7574 memcpy(data + i, &u, 1); // uint8_t -> char
7575 }
7576 }
7577}
7578
7579int NoteErrors() {
7580#define NUM_SELF_TESTS 9
7581 if (++completed_self_tests == NUM_SELF_TESTS)
7582 std::exit(errors > 0);
7583 return errors;
7584}
7585
7586template <typename T> inline bool IsNonZero(T x) {
7587 return x != 0;
7588}
7589
7590template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
7591 return x != Uint128(0, 0);
7592}
7593
7594#endif // FARMHASH_SELF_TEST_GUARD
7595
7596namespace farmhashsuTest {
7597
7598uint32_t CreateSeed(int offset, int salt) {
7599 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
7600 h = h * c1;
7601 h ^= (h >> 17);
7602 h = h * c1;
7603 h ^= (h >> 17);
7604 h = h * c1;
7605 h ^= (h >> 17);
7606 h += static_cast<uint32_t>(offset & 0xffffffff);
7607 h = h * c1;
7608 h ^= (h >> 17);
7609 h = h * c1;
7610 h ^= (h >> 17);
7611 h = h * c1;
7612 h ^= (h >> 17);
7613 return h;
7614}
7615
7616#undef SEED
7617#undef SEED1
7618#undef SEED0
7619#define SEED CreateSeed(offset, -1)
7620#define SEED0 CreateSeed(offset, 0)
7621#define SEED1 CreateSeed(offset, 1)
7622
7623#undef TESTING
7624#define TESTING 1
7625#if TESTING
7626uint32_t expected[] = {
76274223616069u,
76283696677242u,
76294081014168u,
76302576519988u,
76312212771159u,
76321112731063u,
76331020067935u,
76343955445564u,
76351451961420u,
7636653440099u,
763731917516u,
76382957164615u,
76392590087362u,
76403879448744u,
7641176305566u,
76422447367541u,
76431359016305u,
76443363804638u,
76451117290165u,
76461062549743u,
76472437877004u,
76481894455839u,
7649673206794u,
76503486923651u,
76513269862919u,
76522303349487u,
76531380660650u,
7654595525107u,
76551525325287u,
76562025609358u,
7657176408838u,
76581592885012u,
7659864896482u,
76602101378090u,
76613489229104u,
76622118965695u,
7663581644891u,
76642718789079u,
7665631613207u,
76664228658372u,
76673867875546u,
76683531368319u,
76693804516756u,
76703317755099u,
76711619744564u,
76722884717286u,
76731088213445u,
76742667691076u,
76753727873235u,
76762330406762u,
7677858590707u,
7678457744844u,
76794150036245u,
76802000404290u,
76811478882570u,
7682901678172u,
7683819171187u,
7684195942998u,
76854254302102u,
76863967266927u,
7687437030323u,
76884018009204u,
76892868246750u,
76903540087514u,
76913154852132u,
76923319116625u,
7693357580983u,
76943177665294u,
76951108813287u,
76961253366798u,
76972315997713u,
7698510718750u,
76991360882441u,
77002770216279u,
77013048866755u,
77023406961221u,
77033664371439u,
77041151145514u,
77051027891570u,
77062699067992u,
77073461888315u,
7708198061905u,
7709292769636u,
77101106771795u,
77114064110516u,
77123258279756u,
7713762850927u,
77141818699721u,
77152803307356u,
77163919169404u,
7717460980967u,
77183125535078u,
77192802568977u,
77203582546426u,
77212148940781u,
77223963274378u,
77231266953698u,
7724204185123u,
77251100034381u,
77263009193601u,
77274200651967u,
7728274889605u,
77292700589508u,
7730952511689u,
77313765324859u,
77323465498478u,
77334014967037u,
77342070988082u,
77352972423530u,
77363068638223u,
77374156773651u,
7738489509804u,
77391323863238u,
77403731914806u,
77412846098469u,
77422728930632u,
7743346814072u,
7744848146907u,
7745551160669u,
77464165126521u,
77472039095001u,
77484179859388u,
77492434936359u,
77502764414551u,
7751238491210u,
7752732483969u,
77533366512764u,
7754478307468u,
77554124179572u,
77564142733597u,
77571953448206u,
77584199329278u,
7759865077060u,
77602627662116u,
77612802499360u,
77623141206831u,
77631959218197u,
7764911371451u,
7765125987200u,
77662821366175u,
77672530992747u,
77682409206225u,
7769117991880u,
77702133402461u,
7771895510531u,
7772428719601u,
77733036014536u,
77741223783733u,
7775733793540u,
7776970650405u,
7777547701766u,
7778570764615u,
77793224485368u,
77803192714940u,
7781319942831u,
77823940200341u,
7783362056204u,
77842832368105u,
77851853281226u,
77863296434636u,
77873752508307u,
7788604292768u,
77892231940616u,
77901204094681u,
7791866194005u,
77922405201650u,
77932466384396u,
7794380829379u,
7795230033818u,
77962783417588u,
77974249886729u,
7798829569301u,
77992988322580u,
78002299983554u,
780174748560u,
7802737514425u,
78033153050211u,
7804652642663u,
78051270205115u,
7806227197032u,
78072773091790u,
7808325849216u,
780949998791u,
78104043203010u,
78113662748068u,
78121709364383u,
78131179105165u,
78141478504366u,
78152980456610u,
78161167476429u,
78171590390732u,
78181306256496u,
7819292008135u,
7820374690995u,
78211809200819u,
78221680595904u,
7823646040226u,
78241742445560u,
78252435776844u,
78263703683804u,
7827478742495u,
7828814967947u,
78292698190177u,
78301003617993u,
78311436118705u,
7832217056304u,
78331412287094u,
78342738417466u,
78352933279339u,
78363461877733u,
78371203141205u,
78382119492857u,
78391134895723u,
78401560001021u,
78413786320122u,
78423748116258u,
78433486219595u,
7844702138030u,
78451062984182u,
7846232789133u,
78471566523968u,
78483885443778u,
78491820171888u,
78503655858585u,
78512316903005u,
78522678779620u,
7853395625433u,
78541609107564u,
78553108726411u,
78562937837224u,
78573911907151u,
7858557272509u,
78593893435978u,
78601542613576u,
78611079886893u,
78622624566322u,
78631413700616u,
78642796974006u,
78651922556114u,
7866562820464u,
78672845409784u,
786854180312u,
78691898782464u,
78703681814953u,
78712417064617u,
78721815464483u,
7873911626132u,
78742964575550u,
78751852696128u,
78762319647785u,
78771998904590u,
7878619992689u,
78793073207513u,
78801238163512u,
78813199435982u,
7882828667254u,
78833561155502u,
78843943095163u,
78851045711849u,
78862238679131u,
78872114975398u,
7888713808403u,
78893871787494u,
78902572031161u,
78912360934075u,
78922337781107u,
7893262596504u,
7894693836699u,
78952129369850u,
78963543189427u,
7897962205222u,
78983685581020u,
7899692974477u,
7900725182211u,
7901646123906u,
79022368836544u,
79032505872733u,
79041999977610u,
79051639885802u,
79061475058032u,
7907207023609u,
79082773581234u,
79093524857793u,
79103433371102u,
79113243027613u,
79121787668353u,
7913985757946u,
79143896012929u,
7915702356957u,
79163559331129u,
7917884084870u,
79184009998120u,
7919648888720u,
79201403349048u,
79211624342778u,
79221766674171u,
79232518582204u,
79243251243146u,
7925792751003u,
79261377201813u,
79273629686054u,
79281583734324u,
79293647107626u,
79304258564381u,
79311469878609u,
79321940598241u,
79332755003690u,
79341907120418u,
7935109916701u,
7936775347954u,
79372090960874u,
7938611281803u,
79393470490146u,
79403301663253u,
79411835412158u,
79421803066146u,
7943591872433u,
7944550703713u,
79451495089683u,
7946826492808u,
7947817200035u,
79484177474571u,
7949688070143u,
7950971427632u,
79511442499481u,
79523568640348u,
79532789993738u,
795485808128u,
79552058346726u,
7956394058570u,
79573466511434u,
7958318905230u,
79594149248030u,
7960415308316u,
7961165997598u,
79621219639412u,
79631648022659u,
79642857432523u,
79651422508004u,
7966468095522u,
7967296968649u,
7968430250611u,
79691775562314u,
79702976361671u,
79711040036362u,
79721372510167u,
7973292746272u,
79743408238954u,
7975626061886u,
79761317637569u,
79771237775792u,
79781218490455u,
79792224234499u,
7980590942419u,
7981713995643u,
79823541889330u,
79834140218960u,
79843529791107u,
7985354462673u,
7986842607274u,
7987365048533u,
79882638303414u,
79893560458014u,
799031621379u,
79914210854794u,
79921273118792u,
79932572743762u,
79943513175801u,
7995402066986u,
7996602524471u,
7997565029192u,
7998180576438u,
79991288605959u,
80002896244423u,
80011420543484u,
80021329862227u,
80031791567324u,
80044248690247u,
800512917038u,
80063483481310u,
80072082050731u,
80081611921143u,
80092443766548u,
80102216338811u,
80112528006095u,
80122984009021u,
8013674210884u,
80142857608106u,
80152155534809u,
80161023105067u,
80172968955846u,
80183303624302u,
80192502112850u,
8020245749006u,
80213175229091u,
80223342796184u,
80233613785362u,
80241614168851u,
80252582149283u,
8026895403488u,
8027416205023u,
80283792242000u,
8029529397534u,
8030299415203u,
80314284673348u,
80322096851282u,
80331864524731u,
80342012577738u,
80353426363316u,
80361387308508u,
80371143610148u,
80382027467219u,
80393772856163u,
80403453862623u,
80412661437174u,
80422047145955u,
80432533381447u,
80442059534115u,
8045439426587u,
80461537543414u,
80472384289877u,
80483174229055u,
80492658017753u,
80502293148474u,
80512359450158u,
80523930242475u,
80531510302397u,
80543354288821u,
8055920095603u,
80562415746928u,
80572729472638u,
80582261143371u,
8059848667611u,
8060919157153u,
80613322393117u,
80624103299943u,
8063413569608u,
806468911216u,
80653334990170u,
80661228068652u,
80671570056373u,
80681905477543u,
80692622302276u,
80702935063895u,
80713224810004u,
80724211768578u,
8073828688131u,
80743556122839u,
80751930935348u,
80762605825202u,
80771540993970u,
80783209115883u,
8079122847500u,
8080665638794u,
8081506571051u,
80822691795295u,
80833996966556u,
8084714660621u,
80853662432239u,
8086470651837u,
80871807432621u,
80883755290953u,
8089359878860u,
80902793081615u,
80914065031431u,
8092904653062u,
80932317800777u,
8094568501094u,
80953492871707u,
80962738806116u,
80972883859610u,
80983242080257u,
8099364246691u,
81003601786516u,
81013159362524u,
81021578272201u,
81031283574375u,
81042912186103u,
81052256279032u,
81061540671086u,
81072356088973u,
81082892277779u,
81093441449267u,
81102225005503u,
81113846428419u,
81122014549218u,
81132290734767u,
81142126684614u,
81154235463487u,
81163811556204u,
8117174739661u,
8118767525888u,
811947684458u,
81204211168099u,
8121889063422u,
8122469864411u,
8123767407110u,
8124413337343u,
81251618456644u,
81262814499820u,
81272401124192u,
8128632089437u,
81291234980238u,
81301288585402u,
81313153169944u,
81322917822069u,
81331843320264u,
81343794359132u,
81353074573530u,
8136258629454u,
81373813357060u,
81383806887248u,
81391665524736u,
81403324533324u,
81413005091922u,
8142793108368u,
81431529669805u,
81442332660395u,
81452217730223u,
81462634687611u,
8147442806463u,
81481968135266u,
8149454523002u,
81503177866230u,
81512808960136u,
81524259114138u,
81534103264843u,
81543103714075u,
81552462967542u,
81561466891491u,
8157477973764u,
8158834565647u,
8159741089037u,
8160218837573u,
81611710536528u,
81622469088212u,
81631229072375u,
81642828341u,
8165176923431u,
8166985763350u,
81674095477420u,
81681984145538u,
81691870791084u,
8170674956677u,
81711978138947u,
81721296493993u,
81731818183554u,
81743443333721u,
81752124949983u,
81762549590262u,
81772700850794u,
81782662736367u,
8179739638109u,
81804061447096u,
81812960078422u,
81822453781158u,
8183929570940u,
81843200328383u,
81852406328791u,
81861419180666u,
81872152455739u,
81882805741044u,
81893305999074u,
81903183816361u,
81912303165050u,
81924922104u,
819363096005u,
8194936656347u,
81953104453886u,
81961088673880u,
81971113407526u,
81981457890086u,
8199453478383u,
82001107686695u,
82013626027824u,
82021159687359u,
82032248467888u,
82042004578380u,
82053274954621u,
82061787958646u,
82072628726704u,
82081138419798u,
82093735442315u,
8210692385301u,
8211313807213u,
82122329068673u,
821359375364u,
82143261084359u,
82152088644507u,
82162471153194u,
8217788336435u,
82184024527246u,
8219141504460u,
82202307553888u,
82211930559950u,
822248975711u,
82232745693338u,
8224230161982u,
82253429230862u,
82261335968626u,
8227609591304u,
822857435073u,
82294279281136u,
82303152151665u,
82313984484924u,
82323459883943u,
8233397478330u,
82341738762229u,
82353033590066u,
82363611539498u,
82371363463523u,
82383319364965u,
82392671169141u,
82403819548561u,
82411691193757u,
82422423834608u,
82432820147055u,
82441378120632u,
82451240565187u,
82463180720050u,
8247680831086u,
82483309658414u,
82491986166490u,
8250762099827u,
8251510883662u,
82522047373648u,
82533606742294u,
82543894965352u,
82552342078853u,
82561091255717u,
8257776594727u,
82583217317445u,
82591574468485u,
82603844504016u,
82612819598918u,
82621037401010u,
82632550943503u,
82643867184001u,
82651687911772u,
8266165313836u,
82671679575281u,
82682418947263u,
82692038774952u,
82703913543652u,
82713209155736u,
8272149905221u,
82733859604717u,
8274713919631u,
82754069810796u,
82761882959164u,
82771019939034u,
82782379867302u,
82793666323035u,
82801157389013u,
82812422300650u,
82823366777340u,
82832526452062u,
82841313747885u,
82851039617868u,
82861620553692u,
82872032976978u,
8288578789528u,
82891592846839u,
82902270630604u,
8291897850577u,
82921603294178u,
82933105664807u,
82941442670138u,
82951728019360u,
829679313861u,
82971683031101u,
82981913067024u,
82994070719870u,
8300708986470u,
83012586453359u,
83023993348863u,
83033358251279u,
83043003552537u,
8305750174793u,
8306836888956u,
83074190747426u,
83084251291318u,
83094145164938u,
83101366883260u,
83111912910955u,
8312510192669u,
83131851315039u,
83143574241274u,
83153220062924u,
83162821142039u,
83171317082195u,
83182274293302u,
83191839219569u,
8320126586168u,
83213989293643u,
83222680178207u,
8323347056948u,
8324799681430u,
83252864517481u,
83263180404853u,
8327213140045u,
83281956305184u,
83291474675286u,
83303085723423u,
83312841859626u,
8332308421914u,
83333670309263u,
83341765052231u,
8335245459238u,
8336113434331u,
83374079521092u,
83382115235526u,
83392943408816u,
83401055476938u,
83411506442339u,
83422291296392u,
83433267864332u,
83441282145528u,
83453700108015u,
83461932843667u,
83472677701670u,
83486041177u,
83493889648557u,
83501461025478u,
8351};
8352
8353// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
8354bool Test(int offset, int len = 0) {
8355#undef Check
8356#undef IsAlive
8357
8358#define Check(x) do { \
8359 const uint32_t actual = (x), e = expected[index++]; \
8360 bool ok = actual == e; \
8361 if (!ok) { \
8362 cerr << "expected " << hex << e << " but got " << actual << endl; \
8363 ++errors; \
8364 } \
8365 assert(ok); \
8366} while (0)
8367
8368#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
8369
8370 // After the following line is where the uses of "Check" and such will go.
8371 static int index = 0;
8372if (offset == -1) { int alive = 0; IsAlive(farmhashsu::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashsu::Hash32(data, len++)); IsAlive(farmhashsu::Hash32(data, len++)); len -= 3; return alive > 0; }
8373Check(farmhashsu::Hash32WithSeed(data + offset, len, SEED));
8374Check(farmhashsu::Hash32(data + offset, len));
8375
8376 return true;
8377#undef Check
8378#undef IsAlive
8379}
8380
8381int RunTest() {
8382 Setup();
8383 int i = 0;
8384 cout << "Running farmhashsuTest";
8385 if (!Test(-1)) {
8386 cout << "... Unavailable\n";
8387 return NoteErrors();
8388 }
8389 // Good. The function is attempting to hash, so run the full test.
8390 int errors_prior_to_test = errors;
8391 for ( ; i < kTestSize - 1; i++) {
8392 Test(i * i, i);
8393 }
8394 for ( ; i < kDataSize; i += i / 7) {
8395 Test(0, i);
8396 }
8397 Test(0, kDataSize);
8398 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
8399 return NoteErrors();
8400}
8401
8402#else
8403
8404// After the following line is where the code to print hash codes will go.
8405void Dump(int offset, int len) {
8406cout << farmhashsu::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
8407cout << farmhashsu::Hash32(data + offset, len) << "u," << endl;
8408}
8409
8410#endif
8411
8412#undef SEED
8413#undef SEED1
8414#undef SEED0
8415
8416} // namespace farmhashsuTest
8417
8418#if TESTING
8419
8420static int farmhashsuTestResult = farmhashsuTest::RunTest();
8421
8422#else
8423int main(int argc, char** argv) {
8424 Setup();
8425 cout << "uint32_t expected[] = {\n";
8426 int i = 0;
8427 for ( ; i < kTestSize - 1; i++) {
8428 farmhashsuTest::Dump(i * i, i);
8429 }
8430 for ( ; i < kDataSize; i += i / 7) {
8431 farmhashsuTest::Dump(0, i);
8432 }
8433 farmhashsuTest::Dump(0, kDataSize);
8434 cout << "};\n";
8435}
8436#endif
8437#ifndef FARMHASH_SELF_TEST_GUARD
8438#define FARMHASH_SELF_TEST_GUARD
8439#include <cstdio>
8440#include <iostream>
8441#include <string.h>
8442
8443using std::cout;
8444using std::cerr;
8445using std::endl;
8446using std::hex;
8447
8448static const uint64_t kSeed0 = 1234567;
8449static const uint64_t kSeed1 = k0;
8450static const int kDataSize = 1 << 20;
8451static const int kTestSize = 300;
8452#define kSeed128 Uint128(kSeed0, kSeed1)
8453
8454static char data[kDataSize];
8455
8456static int completed_self_tests = 0;
8457static int errors = 0;
8458
8459// Initialize data to pseudorandom values.
8460void Setup() {
8461 if (completed_self_tests == 0) {
8462 uint64_t a = 9;
8463 uint64_t b = 777;
8464 for (int i = 0; i < kDataSize; i++) {
8465 a += b;
8466 b += a;
8467 a = (a ^ (a >> 41)) * k0;
8468 b = (b ^ (b >> 41)) * k0 + i;
8469 uint8_t u = b >> 37;
8470 memcpy(data + i, &u, 1); // uint8_t -> char
8471 }
8472 }
8473}
8474
8475int NoteErrors() {
8476#define NUM_SELF_TESTS 9
8477 if (++completed_self_tests == NUM_SELF_TESTS)
8478 std::exit(errors > 0);
8479 return errors;
8480}
8481
8482template <typename T> inline bool IsNonZero(T x) {
8483 return x != 0;
8484}
8485
8486template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
8487 return x != Uint128(0, 0);
8488}
8489
8490#endif // FARMHASH_SELF_TEST_GUARD
8491
8492namespace farmhashteTest {
8493
8494uint32_t CreateSeed(int offset, int salt) {
8495 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
8496 h = h * c1;
8497 h ^= (h >> 17);
8498 h = h * c1;
8499 h ^= (h >> 17);
8500 h = h * c1;
8501 h ^= (h >> 17);
8502 h += static_cast<uint32_t>(offset & 0xffffffff);
8503 h = h * c1;
8504 h ^= (h >> 17);
8505 h = h * c1;
8506 h ^= (h >> 17);
8507 h = h * c1;
8508 h ^= (h >> 17);
8509 return h;
8510}
8511
8512#undef SEED
8513#undef SEED1
8514#undef SEED0
8515#define SEED CreateSeed(offset, -1)
8516#define SEED0 CreateSeed(offset, 0)
8517#define SEED1 CreateSeed(offset, 1)
8518
8519#undef TESTING
8520#define TESTING 1
8521#if TESTING
8522uint32_t expected[] = {
85231140953930u, 861465670u,
85243277735313u, 2681724312u,
85252598464059u, 797982799u,
8526890626835u, 800175912u,
85272603993599u, 921001710u,
85281410420968u, 2134990486u,
85293283896453u, 1867689945u,
85302914424215u, 2244477846u,
8531255297188u, 2992121793u,
85321110588164u, 4186314283u,
8533161451183u, 3943596029u,
85344019337850u, 452431531u,
8535283198166u, 2741341286u,
85363379021470u, 2557197665u,
8537299850021u, 2532580744u,
8538452473466u, 1706958772u,
85391298374911u, 3099673830u,
85402199864459u, 3696623795u,
8541236935126u, 2976578695u,
85424055299123u, 3281581178u,
85431053458494u, 1882212500u,
85442305012065u, 2169731866u,
85453456121707u, 275903667u,
8546458884671u, 3033004529u,
85473058973506u, 2379411653u,
85481898235244u, 1402319660u,
85492700149065u, 2699376854u,
8550147814787u, 720739346u,
85512433714046u, 4222949502u,
85524220361840u, 1712034059u,
85533425469811u, 3690733394u,
85544148372108u, 1330324210u,
8555594028478u, 2921867846u,
85561635026870u, 192883107u,
8557780716741u, 1728752234u,
85583280331829u, 326029180u,
85593969463346u, 1436364519u,
8560393215742u, 3349570000u,
85613824583307u, 1612122221u,
85622859809759u, 3808705738u,
85631379537552u, 1646032583u,
85642233466664u, 1432476832u,
85654023053163u, 2650381482u,
85662052294713u, 3552092450u,
85671628777059u, 1499109081u,
85683476440786u, 3829307897u,
85692960536756u, 1554038301u,
85701145519619u, 3190844552u,
85712902102606u, 3600725550u,
8572237495366u, 540224401u,
857365721842u, 489963606u,
85741448662590u, 397635823u,
85751596489240u, 1562872448u,
85761790705123u, 2128624475u,
8577180854224u, 2604346966u,
85781435705557u, 1262831810u,
8579155445229u, 1672724608u,
85801669465176u, 1341975128u,
8581663607706u, 2077310004u,
85823610042449u, 1911523866u,
85831043692997u, 1454396064u,
85842563776023u, 294527927u,
85851099072299u, 1389770549u,
8586703505868u, 678706990u,
85872952353448u, 2026137563u,
85883603803785u, 629449419u,
85891933894405u, 3043213226u,
8590226132789u, 2489287368u,
85911552847036u, 645684964u,
85923828089804u, 3632594520u,
8593187883449u, 230403464u,
85943151491850u, 3272648435u,
85953729087873u, 1303930448u,
85962002861219u, 165370827u,
8597916494250u, 1230085527u,
85983103338579u, 3064290191u,
85993807265751u, 3628174014u,
8600231181488u, 851743255u,
86012295806711u, 1781190011u,
86022988893883u, 1554380634u,
86031142264800u, 3667013118u,
86041968445277u, 315203929u,
86052638023604u, 2290487377u,
8606732137533u, 1909203251u,
8607440398219u, 1891630171u,
86081380301172u, 1498556724u,
86094072067757u, 4165088768u,
86104204318635u, 441430649u,
86113931792696u, 197618179u,
8612956300927u, 914413116u,
86133010839769u, 2837339569u,
86142148126371u, 1913303225u,
86153074915312u, 3117299654u,
86164139181436u, 2993479124u,
86173178848746u, 1357272220u,
86181438494951u, 507436733u,
8619667183474u, 2084369203u,
86203854939912u, 1413396341u,
8621126024219u, 146044391u,
86221016656857u, 3022024459u,
86233254014218u, 429095991u,
8624990500595u, 3056862311u,
8625985653208u, 1718653828u,
8626623071693u, 366414107u,
86271771289760u, 2293458109u,
86283047342438u, 2991127487u,
86293120876698u, 1684583131u,
86303638043310u, 1170404994u,
8631863214540u, 1087193030u,
8632199124911u, 520792961u,
86333169775996u, 1577421232u,
86343331828431u, 1013201099u,
86351716848157u, 4033596884u,
86361770708857u, 4229339322u,
86371146169032u, 1434258493u,
86383824360466u, 3242407770u,
86391926419493u, 2649785113u,
8640872586426u, 762243036u,
86412736953692u, 816692935u,
86421571283333u, 3555213933u,
86432266795890u, 3781899767u,
86444290630595u, 517646945u,
86453006163611u, 2180594090u,
8646959214578u, 558910384u,
86471283799121u, 3047062993u,
86483830962609u, 2391606125u,
86493544509313u, 622325861u,
8650834785312u, 382936554u,
86511421463872u, 788479970u,
86521825135056u, 2725923798u,
8653580988377u, 2826990641u,
8654247825043u, 3167748333u,
8655812546227u, 2506885666u,
86562584372201u, 1758123094u,
86571891789696u, 389974094u,
8658345313518u, 2022370576u,
86593886113119u, 3338548567u,
86601083486947u, 2583576230u,
86611776047957u, 1771384107u,
86623604937815u, 3198590202u,
86633027522813u, 4155628142u,
86644232136669u, 427759438u,
86654244322689u, 542201663u,
86661549591985u, 2856634168u,
8667556609672u, 45845311u,
86681175961330u, 3948351189u,
86694165739882u, 4194218315u,
86701634635545u, 4151937410u,
8671713127376u, 1467786451u,
86721327394015u, 2743592929u,
86732638154051u, 810082938u,
86743077742128u, 1062268187u,
86754084325664u, 3810665822u,
86763735739145u, 2794294783u,
86772335576331u, 2560479831u,
8678690240711u, 997658837u,
86792442302747u, 3948961926u,
86803958366652u, 3067277639u,
86812059157774u, 1211737169u,
86821516711748u, 2339636583u,
86834188504038u, 59581167u,
86842767897792u, 1389679610u,
86852658147000u, 2643979752u,
86863758739543u, 4189944477u,
86871454470782u, 100876854u,
86882995362413u, 118817200u,
86893252925478u, 2062343506u,
86902804483644u, 3088828656u,
86911231633714u, 4168280671u,
86922931588131u, 3284356565u,
86931255909792u, 3130054947u,
86944173605289u, 1407328702u,
86951677744031u, 3532596884u,
86963162657845u, 3887208531u,
86972256541290u, 3459463480u,
86983740979556u, 259034107u,
8699392987633u, 3233195759u,
87003606709555u, 3424793077u,
8701315836068u, 3200749877u,
87024065431359u, 760633989u,
87032982018998u, 1811050648u,
8704234531934u, 1115203611u,
87053897494162u, 1516407838u,
87061603559457u, 323296368u,
87072632963283u, 1778459926u,
87082879836826u, 2146672889u,
87093486330348u, 492621815u,
87101231665285u, 2457048126u,
87113438440082u, 2217471853u,
87123355404249u, 3275550588u,
87131052645068u, 862072556u,
87144110617119u, 3745267835u,
87152657392572u, 4279236653u,
87161688445808u, 701920051u,
8717956734128u, 581695350u,
87183157862788u, 2585726058u,
87191192588249u, 1410111809u,
87201651193125u, 3326135446u,
87211073280453u, 97376972u,
87222513844237u, 2187968410u,
87233976859649u, 4267859263u,
87243429034542u, 564493077u,
87253000537321u, 479241367u,
87263845637831u, 2868987960u,
872751544337u, 1029173765u,
8728393624922u, 704325635u,
87292357610553u, 1418509533u,
87302007814586u, 3866658271u,
87313082385053u, 735688735u,
8732916110004u, 3283299459u,
87331051684175u, 1083796807u,
87344074716319u, 813690332u,
8735144264390u, 1439630796u,
87361508556987u, 675582689u,
87373748881891u, 3195309868u,
8738362884708u, 1616408198u,
873943233176u, 837301135u,
8740881504822u, 3254795114u,
87411385506591u, 2799925823u,
87421469874582u, 3464841997u,
8743497175391u, 3929484338u,
87443975771289u, 1798536177u,
87452926265846u, 1374242438u,
87463675707838u, 4205965408u,
87473153165629u, 1499475160u,
8748187287713u, 548490821u,
87493255259608u, 4247675634u,
87501940181471u, 3779953975u,
8751687167150u, 2319566715u,
87521742785722u, 785893184u,
87532296977392u, 2778575413u,
87541794720651u, 48131484u,
87554084891412u, 1160134629u,
87563737623280u, 823113169u,
87573423207646u, 3803213486u,
8758710625654u, 4116162021u,
87593693420287u, 4167766971u,
87601666602807u, 295320990u,
87613513255468u, 2487440590u,
8762234080704u, 4004655503u,
87632971762528u, 1479656873u,
87644090178629u, 4044418876u,
8765391947536u, 1462554406u,
87663909295855u, 1239580330u,
87671515601363u, 2011102035u,
87681442068334u, 4265993528u,
87691191921695u, 2291355695u,
87704257172787u, 576405853u,
8771314332944u, 4038839101u,
877255559918u, 2378985842u,
8773711098718u, 2425317635u,
87741644327317u, 1401013391u,
87754193760037u, 2958260436u,
87763167371443u, 3062418115u,
87773800755475u, 3167030094u,
87783489648204u, 1405430357u,
8779526177822u, 2602636307u,
8780915406019u, 4264167741u,
87811484090483u, 3070944737u,
8782254529415u, 4017058800u,
87831702710265u, 1029665228u,
87842000382906u, 3185573940u,
87851381258384u, 4036354071u,
87862900841028u, 2670703363u,
87872921748807u, 2899069938u,
87884130543625u, 688472265u,
87894186808827u, 1054670286u,
87901132985391u, 2840525968u,
87914175776103u, 338058159u,
87921735964501u, 1539305024u,
87933497121710u, 1568260669u,
87942227290760u, 146827036u,
87953977176001u, 4060134777u,
8796857488494u, 250055052u,
87974284109679u, 2502815838u,
87982592281721u, 1603444633u,
87991390562014u, 1556658131u,
8800616327404u, 2448966429u,
88013051191726u, 3891353218u,
88021213304082u, 762328245u,
88032239052397u, 1082330589u,
88042455957292u, 201837927u,
8805405397452u, 3079886794u,
88062583939798u, 2848283092u,
88073750724631u, 883849006u,
88083204198988u, 3341327098u,
88091855234968u, 1982110346u,
88101485529487u, 541496720u,
88114117290321u, 3607433551u,
88122168864636u, 133643215u,
88131055817409u, 3847827123u,
88142960769387u, 4046101649u,
88151176127003u, 4015671361u,
88164243643405u, 2849988118u,
8817517111221u, 1796672358u,
88182045051700u, 3452457457u,
88192948254999u, 2102063419u,
88201556410577u, 1536380876u,
88213776661467u, 3281002516u,
88221735616066u, 1539151988u,
88231087795162u, 3332431596u,
8824685631442u, 1147951686u,
882595237878u, 2005032160u,
88264012206915u, 4224354805u,
88273204999386u, 2415262714u,
88281433635018u, 116647396u,
882983167836u, 2881562655u,
88302729416454u, 1029284767u,
8831881378302u, 2159170082u,
8832555057366u, 1169104445u,
88333963877000u, 1919171906u,
8834336034862u, 2017579106u,
88354059340529u, 3020819343u,
8836865146997u, 2473524405u,
8837944743644u, 1694443528u,
88381804513294u, 2904752429u,
8839617975720u, 3671562289u,
8840260177668u, 505662155u,
88411885941445u, 2504509403u,
88422260041112u, 1019936943u,
88433722741628u, 1511077569u,
88443100701179u, 1379422864u,
88451535670711u, 773792826u,
88461103819072u, 2089123665u,
88471157547425u, 329152940u,
88484142587430u, 484732447u,
88492475035432u, 1120017626u,
8850412145504u, 965125959u,
8851324924679u, 2809286837u,
88522842141483u, 4029205195u,
88532974306813u, 515627448u,
88543791551981u, 1097806406u,
88553873078673u, 136118734u,
88561872130856u, 3632422367u,
88573574135531u, 4017075736u,
88581699452298u, 1403506686u,
8859344414660u, 1189129691u,
88603487080616u, 1516736273u,
88611805475756u, 2562064338u,
8862163335594u, 2732147834u,
88634077452507u, 2984955003u,
88644271866024u, 3071338162u,
88652347111903u, 873829983u,
88661948409509u, 1923531348u,
8867459509140u, 771592405u,
88681750124750u, 2334938333u,
8869213811117u, 2586632018u,
8870185232757u, 4032960199u,
88712447383637u, 284777551u,
88721654276320u, 2687561076u,
88733512945009u, 308584855u,
88741861027147u, 4102279334u,
88753203802620u, 1692079268u,
88764250142168u, 2565680167u,
88771507046104u, 841195925u,
8878520565830u, 3674576684u,
887938924274u, 3770488806u,
88802414430882u, 3978473838u,
88813703994407u, 69201295u,
88823099963860u, 1255084262u,
8883690971838u, 3539996781u,
88843696902571u, 3593730713u,
88852363435042u, 54945052u,
88861785765213u, 184911581u,
88871586241476u, 1939595371u,
88882534883189u, 2432427547u,
88892374171993u, 2039128933u,
88902955715987u, 2295501078u,
88912741583197u, 1280920000u,
8892686818699u, 1238742497u,
88933843660102u, 82177963u,
88941281043691u, 1121403845u,
88951697846708u, 284852964u,
8896278661677u, 2889101923u,
88972127558730u, 713121337u,
8898872502474u, 511142139u,
88991261140657u, 1747052377u,
89002108187161u, 927011680u,
8901955328267u, 3821994995u,
89022707230761u, 4142246789u,
89034134691985u, 1958963937u,
89042498463509u, 1977988705u,
89051419293714u, 1636932722u,
89062567532373u, 4075249328u,
8907240575705u, 1956681213u,
89082598802768u, 2025886508u,
89094104757832u, 3026358429u,
89103242615202u, 4026813725u,
8911255108733u, 1845587644u,
89123573008472u, 3615577014u,
89131222733548u, 1205557630u,
8914917608574u, 1363253259u,
89151541946015u, 3087190425u,
89161138008081u, 1444019663u,
8917109793386u, 341851980u,
8918857839960u, 2515339233u,
8919156283211u, 1906768669u,
89203886713057u, 1276595523u,
89212809830736u, 460237542u,
89223420452099u, 142985419u,
8923205970448u, 4198897105u,
89241950698961u, 2069753399u,
89251142216925u, 1113051162u,
89261033680610u, 4278599955u,
89271106466069u, 356742959u,
8928531521052u, 3494863964u,
8929225629455u, 3735275001u,
89303662626864u, 1750561299u,
89311012864651u, 2101846429u,
89321074553219u, 668829411u,
8933992181339u, 3384018814u,
89343330664522u, 860966321u,
89351885071395u, 4233785523u,
8936100741310u, 451656820u,
89372148187612u, 1063001151u,
8938360256231u, 107312677u,
89393650357479u, 2390172694u,
894022452685u, 237319043u,
89413600462351u, 1216645846u,
89422088767754u, 164402616u,
89432418980170u, 926137824u,
894494638678u, 1689811113u,
89452751052984u, 1767810825u,
8946271289013u, 3896132233u,
8947103797041u, 1397772514u,
89483441135892u, 3323383489u,
89492491268371u, 1662561885u,
89501612872497u, 2986430557u,
89512756998822u, 207428029u,
8952937973965u, 2791656726u,
89531949717207u, 2260498180u,
89542648427775u, 2360400900u,
89552080496169u, 486358863u,
89561582022990u, 1263709570u,
89571396468647u, 1377764574u,
8958363008508u, 1293502429u,
8959224580012u, 4252610345u,
89601435134775u, 1099809675u,
8961533671980u, 1533438766u,
89621820532305u, 2776960536u,
89633374512975u, 3542220540u,
8964822810075u, 3716663290u,
89651157398049u, 3752806924u,
89664081637863u, 337070226u,
89673866585976u, 359270190u,
89682110942730u, 3267551635u,
8969644850146u, 1306761320u,
8970746972907u, 934259457u,
89712341378668u, 2220373824u,
89721242645122u, 4109252858u,
89731625266099u, 1173698481u,
8974383517064u, 896322512u,
89753377483696u, 1788337208u,
8976455496839u, 3194373887u,
89771837689083u, 1336556841u,
89781658628529u, 2911512007u,
89793838343487u, 2757664765u,
89801537187340u, 3712582785u,
8981367022558u, 3071359622u,
89823926147070u, 35432879u,
89833093195926u, 2561488770u,
89844273132307u, 3898950547u,
89852838251049u, 2103926083u,
89862549435227u, 536047554u,
89871858986613u, 2040551642u,
89881147412575u, 1972369852u,
89894166184983u, 3528794619u,
89904077477194u, 3565689036u,
8991808048238u, 3826350461u,
89921359641525u, 1197100813u,
8993265993036u, 1864569342u,
8994725164342u, 2264788336u,
89951831223342u, 3329594980u,
8996923017956u, 490608221u,
89973818634478u, 258154469u,
89981441714797u, 1174785921u,
89993833372385u, 3287246572u,
90001677395563u, 3569218731u,
9001868981704u, 2163330264u,
90022649450292u, 500120236u,
9003465161780u, 746438382u,
90041145009669u, 2520062970u,
90052810524030u, 1561519055u,
90061479878006u, 3864969305u,
90072686075657u, 4042710240u,
90083224066062u, 2774151984u,
90092226179547u, 1643626042u,
90102328730865u, 3160666939u,
90112107011431u, 96459446u,
90123920328742u, 3336407558u,
9013829404209u, 1878067032u,
90141235983679u, 4237425634u,
9015466519055u, 3870676863u,
9016934312076u, 2952135524u,
9017276949224u, 4100839753u,
9018424001484u, 1955120893u,
90194015478120u, 1265237690u,
9020427484362u, 4246879223u,
90213452969617u, 1724363362u,
90221553513184u, 834830418u,
90231858777639u, 3476334357u,
90244144030366u, 2450047160u,
90252950762705u, 4277111759u,
9026358032121u, 2511026735u,
9027167923105u, 2059208280u,
9028251949572u, 3065234219u,
90291535473864u, 556796152u,
90301513237478u, 3150857516u,
90311103404394u, 198182691u,
90321476438092u, 2913077464u,
9033207119516u, 3963810232u,
90342954651680u, 1535115487u,
90353051522276u, 4046477658u,
9036917804636u, 864395565u,
9037632704095u, 140762681u,
90381802040304u, 990407433u,
90393771506212u, 4106024923u,
90401287729497u, 2198985327u,
90414052924496u, 2926590471u,
90423084557148u, 1472898694u,
90431009870118u, 559702706u,
90444265214507u, 82077489u,
90453067891003u, 3295678907u,
90462402308151u, 1096697687u,
9047464407878u, 4190838199u,
90484269578403u, 3060919438u,
90492899950405u, 3046872820u,
9050733509243u, 1583801700u,
905140453902u, 3879773881u,
90521993425202u, 2185339100u,
90531877837196u, 3912423882u,
90543293122640u, 4104318469u,
90551679617763u, 3703603898u,
90568759461u, 2540185277u,
90571152198475u, 2038345882u,
90582503579743u, 1446869792u,
90592019419351u, 4051584612u,
90603178289407u, 3992503830u,
90612879018745u, 2719373510u,
9062700836153u, 1675560450u,
90634121245793u, 2064715719u,
9064343595772u, 1996164093u,
90653130433948u, 405251683u,
90662804817126u, 1607133689u,
9067463852893u, 2864244470u,
90682224044848u, 4071581802u,
90692537107938u, 2246347953u,
90703207234525u, 2028708916u,
90712272418128u, 803575837u,
907238655481u, 2170452091u,
90733272166407u, 557660441u,
90744019147902u, 3841480082u,
9075298459606u, 2600943364u,
90762440657523u, 255451671u,
90773424361375u, 779434428u,
90783088526123u, 490671625u,
90791322855877u, 3452203069u,
90803057021940u, 2285701422u,
90812014993457u, 2390431709u,
90822002090272u, 1568745354u,
90831783152480u, 823305654u,
90844053862835u, 2200236540u,
90853009412313u, 3184047862u,
90863032187389u, 4159715581u,
90872966902888u, 252986948u,
90881849329144u, 3160134214u,
90893420960112u, 3198900547u,
9090749160960u, 379139040u,
90911208883495u, 1566527339u,
90923006227299u, 4194096960u,
9093556075248u, 497404038u,
90941717327230u, 1496132623u,
90951775955687u, 1719108984u,
90961014328900u, 4189966956u,
90972108574735u, 2584236470u,
9098684087286u, 531310503u,
90994264509527u, 773405691u,
91003088905079u, 3456882941u,
91013105682208u, 3382290593u,
91022289363624u, 3296306400u,
91034168438718u, 467441309u,
9104777173623u, 3241407531u,
91051183994815u, 1132983260u,
91061610606159u, 2540270567u,
91072649684057u, 1397502982u,
9108146657385u, 3318434267u,
91092109315753u, 3348545480u,
91103193669211u, 811750340u,
91111073256162u, 3571673088u,
9112546596661u, 1017047954u,
91133403136990u, 2540585554u,
91141477047647u, 4145867423u,
91152826408201u, 3531646869u,
9116784952939u, 943914610u,
91172717443875u, 3657384638u,
91181806867885u, 1903578924u,
91193985088434u, 1911188923u,
91201764002686u, 3672748083u,
91211832925325u, 241574049u,
9122519948041u, 3181425568u,
91232939747257u, 1634174593u,
91243429894862u, 3529565564u,
91251089679033u, 240953857u,
91262025369941u, 2695166650u,
9127517086873u, 2964595704u,
91283017658263u, 3828377737u,
91292144895011u, 994799311u,
91301184683823u, 4260564140u,
9131308018483u, 4262383425u,
91321374752558u, 3431057723u,
91331572637805u, 383233885u,
91343188015819u, 4051263539u,
9135233319221u, 3794788167u,
91362017406667u, 919677938u,
91374074952232u, 1683612329u,
91384213676186u, 327142514u,
91393032591014u, 4204155962u,
9140206775997u, 2283918569u,
91412395147154u, 3427505379u,
91422211319468u, 4153726847u,
91432217060665u, 350160869u,
91442493667051u, 1648200185u,
91453441709766u, 1387233546u,
9146140980u, 1891558063u,
9147760080239u, 2088061981u,
91481580964938u, 740563169u,
9149422986366u, 330624974u,
91504264507722u, 150928357u,
91512738323042u, 2948665536u,
9152918718096u, 376390582u,
91533966098971u, 717653678u,
91543219466255u, 3799363969u,
91553424344721u, 3187805406u,
9156375347278u, 3490350144u,
91571992212097u, 2263421398u,
91583855037968u, 1928519266u,
91593866327955u, 1129127000u,
91601782515131u, 2746577402u,
91613059200728u, 2108753646u,
91622738070963u, 1336849395u,
91631705302106u, 768287270u,
91641343511943u, 2247006571u,
91651956142255u, 1780259453u,
91663475618043u, 212490675u,
9167622521957u, 917121602u,
91681852992332u, 1267987847u,
91693170016833u, 2549835613u,
91703299763344u, 2864033668u,
91713378768767u, 1236609378u,
91724169365948u, 3738062408u,
91732661022773u, 2006922227u,
91742760592161u, 3828932355u,
91752636387819u, 2616619070u,
91761237256330u, 3449066284u,
91772871755260u, 3729280948u,
91783862686086u, 431292293u,
91793285899651u, 786322314u,
91802531158535u, 724901242u,
91812377363130u, 1415970351u,
91821244759631u, 3263135197u,
9183965248856u, 174024139u,
91842297418515u, 2954777083u,
9185987586766u, 3206261120u,
91864059515114u, 3903854066u,
91871931934525u, 2287507921u,
91881827135136u, 1781944746u,
9189574617451u, 2299034788u,
91902650140034u, 4081586725u,
91912482286699u, 1109175923u,
9192458483596u, 618705848u,
91934059852729u, 1813855658u,
91944190721328u, 1129462471u,
91954089998050u, 3575732749u,
91962375584220u, 1037031473u,
91971623777358u, 3389003793u,
9198546597541u, 352770237u,
91991383747654u, 3122687303u,
92001646071378u, 1164309901u,
9201290870767u, 830691298u,
9202929335420u, 3193251135u,
9203989577914u, 3626554867u,
9204591974737u, 3996958215u,
92053163711272u, 3071568023u,
92061516846461u, 3656006011u,
92072698625268u, 2510865430u,
9208340274176u, 1167681812u,
92093698796465u, 3155218919u,
92104102288238u, 1673474350u,
92113069708839u, 2704165015u,
92121237411891u, 1854985978u,
92133646837503u, 3625406022u,
9214921552000u, 1712976649u,
92153939149151u, 878608872u,
92163406359248u, 1068844551u,
92171834682077u, 4155949943u,
92182437686324u, 3163786257u,
92192645117577u, 1988168803u,
9220747285578u, 1626463554u,
92211235300371u, 1256485167u,
92221914142538u, 4141546431u,
92233838102563u, 582664250u,
92241883344352u, 2083771672u,
92252611657933u, 2139079047u,
92262250573853u, 804336148u,
92273066325351u, 2770847216u,
92284275641370u, 1455750577u,
92293346357270u, 1674051445u,
9230601221482u, 3992583643u,
92311402445097u, 3622527604u,
92322509017299u, 2966108111u,
92332557027816u, 900741486u,
92341790771021u, 2912643797u,
92352631381069u, 4014551783u,
923690375300u, 300318232u,
92373269968032u, 2679371729u,
92382664752123u, 3517585534u,
92393253901179u, 542270815u,
92401188641600u, 365479232u,
92412210121140u, 760762191u,
92421273768482u, 1216399252u,
92433484324231u, 4287337666u,
924416322182u, 643179562u,
9245325675502u, 3652676161u,
92463120716054u, 3330259752u,
92471011990087u, 2990167340u,
92481097584090u, 3262252593u,
92491829409951u, 3665087267u,
92501214854475u, 2134299399u,
92513704419305u, 411263051u,
92521625446136u, 549838529u,
92534283196353u, 1342880802u,
92543460621305u, 1967599860u,
92554282843369u, 1275671016u,
92562544665755u, 853593042u,
9257901109753u, 2682611693u,
9258110631633u, 797487791u,
92591472073141u, 850464484u,
9260797089608u, 3286110054u,
9261350397471u, 2775631060u,
9262366448238u, 3842907484u,
92632219863904u, 3623364733u,
92641850985302u, 4009616991u,
9265294963924u, 3693536939u,
92663061255808u, 1615375832u,
92671920066675u, 4113028420u,
92684032223840u, 2318423400u,
92692701956286u, 4145497671u,
92703991532344u, 2536338351u,
92711679099863u, 1728968857u,
9272449740816u, 2686506989u,
9273685242457u, 97590863u,
92743258354115u, 1502282913u,
92751235084019u, 2151665147u,
9276528459289u, 231097464u,
92772477280726u, 3651607391u,
92782091754612u, 1178454681u,
9279980597335u, 1604483865u,
92801842333726u, 4146839064u,
92813213794286u, 2601416506u,
9282754220096u, 3571436033u,
9283488595746u, 1448097974u,
92844004834921u, 238887261u,
92853320337489u, 1416989070u,
92862928916831u, 4093725287u,
9287186020771u, 2367569534u,
92883046087671u, 4090084518u,
92893548184546u, 679517009u,
92901962659444u, 3539886328u,
92914192003933u, 1678423485u,
92923827951761u, 3086277222u,
92932144472852u, 1390394371u,
92942976322029u, 1574517163u,
92953553313841u, 119173722u,
92961702434637u, 1766260771u,
92973629581771u, 1407497759u,
9298895654784u, 751439914u,
92994008409498u, 215917713u,
93001482103833u, 695551833u,
93011288382231u, 2656990891u,
93022581779077u, 1570750352u,
93033710689053u, 1741390464u,
93042666411616u, 3533987737u,
93054289478316u, 3576119563u,
93064118694920u, 108199666u,
93073869794273u, 963183826u,
93082081410737u, 3796810515u,
9309791123882u, 2525792704u,
93101036883117u, 136547246u,
9311875691100u, 2592925324u,
9312614302599u, 3013176417u,
93132689342539u, 427154472u,
9314532957601u, 1228758574u,
93151898117151u, 1181643858u,
93161908591042u, 1464255968u,
9317446980910u, 2984611177u,
931858509511u, 1046943619u,
93193508927906u, 2001585786u,
93202544767379u, 1525438381u,
9321552181222u, 1959725830u,
9322879448844u, 1348536411u,
93234242243590u, 2861338018u,
93241082052441u, 1034351453u,
9325601175800u, 764077711u,
9326530635011u, 3785343245u,
93272178026726u, 117256687u,
93282378297261u, 457568934u,
932976438221u, 4104954272u,
9330956793873u, 3783168634u,
93312485968477u, 2381948487u,
93324226929450u, 3148473363u,
93332518273601u, 3569490233u,
9334879369091u, 2180270337u,
93353674375989u, 1387729170u,
9336977997984u, 4270646856u,
9337568650985u, 951677556u,
93384213877384u, 2721005055u,
93391073364549u, 2563403831u,
93401678669911u, 66786703u,
93412273631661u, 1149351924u,
93423651298990u, 1581883443u,
9343246723096u, 1895026827u,
93443810605772u, 3711056516u,
93454058833288u, 2193790614u,
93462080120290u, 3638638708u,
93472915672708u, 2263003308u,
93482361934197u, 4136767460u,
93491976115991u, 3448840877u,
93502019238520u, 225333538u,
9351874340815u, 2976159827u,
93521555273378u, 3797521928u,
93531942347150u, 3262952567u,
9354435997738u, 340403353u,
93552817830907u, 2078619498u,
9356749534111u, 1178073973u,
9357894654712u, 3361226032u,
9358841092198u, 3288261538u,
93591696412169u, 1496966875u,
9360697501571u, 1059158875u,
93613739946319u, 2481012988u,
9362568983526u, 114945840u,
93631559249010u, 2218244008u,
93642841706923u, 1632780103u,
93654020169654u, 2087949619u,
93662438736103u, 24032648u,
9367833416317u, 3787017905u,
93682373238993u, 2575395164u,
93693434544481u, 3228481067u,
93702542976862u, 2971726178u,
93712880371864u, 3642087909u,
93722407477975u, 2239080836u,
93731043714217u, 3894199764u,
93742235879182u, 203853421u,
93752933669448u, 2504940536u,
9376834683330u, 425935223u,
93773560796393u, 3565833278u,
93781668000829u, 3683399154u,
93793414330886u, 1748785729u,
93801023171602u, 580966986u,
93812531038985u, 3227325488u,
93822657385925u, 2124704694u,
9383233442446u, 1107045577u,
93843407293834u, 552770757u,
93853899097693u, 1067532701u,
9386115667924u, 1406028344u,
93871707768231u, 3724015962u,
93882419657149u, 18613994u,
93892532882091u, 3476683808u,
93901560838678u, 811220224u,
9391895961699u, 3762914298u,
93921328752423u, 1844996900u,
93931420427894u, 1848067707u,
93941210281744u, 904215228u,
93954055325594u, 1118521573u,
93962496554183u, 2579259919u,
93973996647489u, 3657647605u,
9398325254059u, 3136157065u,
93993951522674u, 4052925250u,
94003341068436u, 2287683323u,
94011313073005u, 126005630u,
94022505120084u, 1194725057u,
9403853746559u, 3555092974u,
94042689238752u, 49515858u,
94051244776042u, 1069300695u,
940661073168u, 1010661841u,
94071269521335u, 1902040126u,
9408990632502u, 2378708922u,
94093858321250u, 1400735275u,
94102974699176u, 2771676666u,
9411170995186u, 2877798589u,
9412545726212u, 2225229957u,
94131086473152u, 3454177594u,
94143859483262u, 1499729584u,
94152088002891u, 2883475137u,
94163222194252u, 4144472319u,
94172212229854u, 4146740722u,
9418567988835u, 1051332394u,
94193932046135u, 542648229u,
94203017852446u, 1277887997u,
9421162888005u, 1669710469u,
94221492500905u, 553041029u,
94231434876932u, 533989516u,
94243817492747u, 584127807u,
94254147115982u, 2993670925u,
94264020312558u, 710021255u,
94273509733475u, 3587959456u,
94282088550465u, 1745399498u,
94292952242967u, 1259815443u,
9430869648362u, 1404723176u,
94313947542735u, 1334333531u,
94323873471582u, 229399758u,
943359634866u, 3239516985u,
94343844250972u, 1275954779u,
9435492891666u, 1029533080u,
94361552951157u, 367320647u,
9437699480890u, 3684418197u,
94383707014310u, 471105777u,
94391824587258u, 4030809053u,
94403489914436u, 484559105u,
94411235750398u, 1428453396u,
94424230459084u, 4255931645u,
94431848597055u, 4271715616u,
9444331780381u, 482425775u,
94452435323270u, 3171911678u,
94463507210587u, 928543347u,
94474197807526u, 3680046204u,
94482766042024u, 2159512867u,
9449179373257u, 313902234u,
94504024837592u, 294795361u,
94511622282562u, 647086234u,
94522825039429u, 577214736u,
94534043412446u, 2426981244u,
94541277736097u, 1130129573u,
94552601395338u, 995791646u,
945636668922u, 3344746679u,
94571521532225u, 1645086060u,
94582622763015u, 4122335794u,
94592936887705u, 494465807u,
94602580840343u, 1064648931u,
94611247887787u, 2752145076u,
94621277612417u, 1249660507u,
94632288678613u, 3312498873u,
94642459273912u, 4238535494u,
94653117488020u, 2571979978u,
94662680188909u, 1471227427u,
94671616494033u, 633688562u,
94682268653416u, 3268237290u,
94693021962815u, 1959779970u,
94703321382074u, 766642813u,
9471204429780u, 1323319858u,
94723676032891u, 1380896111u,
94734030639049u, 3647601207u,
94741830028502u, 2830263774u,
94751375962216u, 1733961041u,
9476939765180u, 521947915u,
94773903267364u, 497472767u,
94781619700946u, 189164145u,
94793115593885u, 486382294u,
94801262445920u, 4062496162u,
94812464795849u, 3770038872u,
94824032121374u, 3235740744u,
94833757765258u, 1777199847u,
94842167243108u, 1912506671u,
94854180515317u, 2276864677u,
9486536034089u, 2384915026u,
9487162938278u, 1588060152u,
94884018349945u, 2504457929u,
9489841450426u, 2790120722u,
94902719983588u, 1471020554u,
94911390856732u, 3623212998u,
94922506944218u, 1035080801u,
9493348812127u, 3026631806u,
9494746483541u, 2342164722u,
9495122104390u, 4074122771u,
94963986865419u, 1674890530u,
94973693306023u, 3011542850u,
94981294951725u, 899303190u,
94993577146915u, 3549160092u,
95001241677652u, 4290680005u,
95013193053279u, 2029187390u,
95023298063095u, 3943068002u,
95033946220635u, 2273781461u,
9504889053698u, 1376304022u,
95051486839612u, 2127663659u,
9506344127443u, 1646681121u,
95072780117810u, 2142045764u,
95082694572773u, 447810651u,
95092185527146u, 2366308558u,
9510290335413u, 584901173u,
95112012370276u, 970504950u,
95123258236042u, 2008155560u,
95133945579565u, 614796295u,
951424452072u, 2695940969u,
95153983727134u, 3444688454u,
95161327044473u, 3545633451u,
95171875293322u, 1739318893u,
95181707527799u, 2683090634u,
95192848082386u, 2814622471u,
95204111401777u, 2774816580u,
95213849839194u, 437560100u,
95222238350150u, 2462124836u,
9523665017710u, 512012738u,
95242945294779u, 3305170944u,
9525819477765u, 59419271u,
9526155125658u, 665292744u,
9527444722813u, 3580039116u,
95282355675635u, 663735032u,
95293247800169u, 1579404983u,
95301985115003u, 3397891494u,
9531358696453u, 1474896279u,
9532516388613u, 710590371u,
95333490497111u, 2514565805u,
95342386143445u, 477509654u,
9535412854590u, 3624609754u,
95363214388668u, 3516075816u,
95372731288520u, 1369482895u,
95384033204378u, 1314000850u,
9539829769325u, 1935166880u,
95401608191643u, 2607067237u,
9541423820371u, 3257747610u,
95421355298041u, 3776931214u,
95434105054901u, 2107080812u,
95441911521879u, 3183054185u,
95453910177801u, 675129307u,
95461209358971u, 4205727791u,
95471435726287u, 3333261712u,
95481400982708u, 1154611403u,
95491663501483u, 2837596667u,
95503164734053u, 2759854023u,
95514012043629u, 1963228038u,
95523981675284u, 2677557877u,
9553520119591u, 505138315u,
9554897271356u, 1803966773u,
95551016663294u, 616691903u,
95562254742522u, 4032705384u,
95572468470796u, 798395739u,
95583025169002u, 3570037122u,
95591461093710u, 3473799845u,
95603702624858u, 476400898u,
95611043039728u, 2304070437u,
9562181576948u, 602972493u,
95633996616030u, 3289878097u,
95642068516226u, 3922247304u,
95651299968266u, 2520311409u,
95661968824721u, 3214794876u,
95671581813122u, 2668800905u,
95683297613974u, 748160407u,
95691145536484u, 1326769504u,
95702973323521u, 3775262814u,
95713218653169u, 902775872u,
95723498603433u, 1372805534u,
9573704686363u, 3626542352u,
95742271580579u, 1213925114u,
957546329775u, 3009384989u,
95761330254048u, 1194824134u,
9577514204310u, 3781981134u,
9578442526164u, 2835608783u,
95793460471867u, 510634034u,
9580546406434u, 2716786748u,
95812840500021u, 1669490957u,
95822536189149u, 3251421224u,
95831358736072u, 1089334066u,
95843260749330u, 250756920u,
95852974806681u, 1513718866u,
958682635635u, 4041016629u,
95873391765744u, 2495807367u,
95883962674316u, 2822889695u,
9589753413337u, 2008251381u,
95903123390177u, 106212622u,
9591490570565u, 1684884205u,
9592793892547u, 1927268995u,
95932344148164u, 2251978818u,
9594437424236u, 2774023200u,
95952674940754u, 3788056262u,
95962597882666u, 3678660147u,
95973797434193u, 3838215866u,
9598279687080u, 2656772270u,
95992190204787u, 1997584981u,
96003384401882u, 3160208845u,
96013629379425u, 2668998785u,
96021050036757u, 2954162084u,
9603917091826u, 1744374041u,
96041454282570u, 845687881u,
96052997173625u, 776018378u,
96061137560602u, 1938378389u,
96071748082354u, 2066910012u,
96082677675207u, 918315064u,
9609};
9610
9611// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
9612bool Test(int offset, int len = 0) {
9613#undef Check
9614#undef IsAlive
9615
9616#define Check(x) do { \
9617 const uint32_t actual = (x), e = expected[index++]; \
9618 bool ok = actual == e; \
9619 if (!ok) { \
9620 cerr << "expected " << hex << e << " but got " << actual << endl; \
9621 ++errors; \
9622 } \
9623 assert(ok); \
9624} while (0)
9625
9626#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
9627
9628 // After the following line is where the uses of "Check" and such will go.
9629 static int index = 0;
9630if (offset == -1) { int alive = 0; { uint64_t h = farmhashte::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashte::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
9631{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
9632{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
9633{ uint64_t h = farmhashte::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
9634
9635 return true;
9636#undef Check
9637#undef IsAlive
9638}
9639
9640int RunTest() {
9641 Setup();
9642 int i = 0;
9643 cout << "Running farmhashteTest";
9644 if (!Test(-1)) {
9645 cout << "... Unavailable\n";
9646 return NoteErrors();
9647 }
9648 // Good. The function is attempting to hash, so run the full test.
9649 int errors_prior_to_test = errors;
9650 for ( ; i < kTestSize - 1; i++) {
9651 Test(i * i, i);
9652 }
9653 for ( ; i < kDataSize; i += i / 7) {
9654 Test(0, i);
9655 }
9656 Test(0, kDataSize);
9657 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
9658 return NoteErrors();
9659}
9660
9661#else
9662
9663// After the following line is where the code to print hash codes will go.
9664void Dump(int offset, int len) {
9665{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9666{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9667{ uint64_t h = farmhashte::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9668}
9669
9670#endif
9671
9672#undef SEED
9673#undef SEED1
9674#undef SEED0
9675
9676} // namespace farmhashteTest
9677
9678#if TESTING
9679
9680static int farmhashteTestResult = farmhashteTest::RunTest();
9681
9682#else
9683int main(int argc, char** argv) {
9684 Setup();
9685 cout << "uint32_t expected[] = {\n";
9686 int i = 0;
9687 for ( ; i < kTestSize - 1; i++) {
9688 farmhashteTest::Dump(i * i, i);
9689 }
9690 for ( ; i < kDataSize; i += i / 7) {
9691 farmhashteTest::Dump(0, i);
9692 }
9693 farmhashteTest::Dump(0, kDataSize);
9694 cout << "};\n";
9695}
9696#endif
9697#ifndef FARMHASH_SELF_TEST_GUARD
9698#define FARMHASH_SELF_TEST_GUARD
9699#include <cstdio>
9700#include <iostream>
9701#include <string.h>
9702
9703using std::cout;
9704using std::cerr;
9705using std::endl;
9706using std::hex;
9707
9708static const uint64_t kSeed0 = 1234567;
9709static const uint64_t kSeed1 = k0;
9710static const int kDataSize = 1 << 20;
9711static const int kTestSize = 300;
9712#define kSeed128 Uint128(kSeed0, kSeed1)
9713
9714static char data[kDataSize];
9715
9716static int completed_self_tests = 0;
9717static int errors = 0;
9718
9719// Initialize data to pseudorandom values.
9720void Setup() {
9721 if (completed_self_tests == 0) {
9722 uint64_t a = 9;
9723 uint64_t b = 777;
9724 for (int i = 0; i < kDataSize; i++) {
9725 a += b;
9726 b += a;
9727 a = (a ^ (a >> 41)) * k0;
9728 b = (b ^ (b >> 41)) * k0 + i;
9729 uint8_t u = b >> 37;
9730 memcpy(data + i, &u, 1); // uint8_t -> char
9731 }
9732 }
9733}
9734
9735int NoteErrors() {
9736#define NUM_SELF_TESTS 9
9737 if (++completed_self_tests == NUM_SELF_TESTS)
9738 std::exit(errors > 0);
9739 return errors;
9740}
9741
9742template <typename T> inline bool IsNonZero(T x) {
9743 return x != 0;
9744}
9745
9746template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
9747 return x != Uint128(0, 0);
9748}
9749
9750#endif // FARMHASH_SELF_TEST_GUARD
9751
9752namespace farmhashuoTest {
9753
9754uint32_t CreateSeed(int offset, int salt) {
9755 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
9756 h = h * c1;
9757 h ^= (h >> 17);
9758 h = h * c1;
9759 h ^= (h >> 17);
9760 h = h * c1;
9761 h ^= (h >> 17);
9762 h += static_cast<uint32_t>(offset & 0xffffffff);
9763 h = h * c1;
9764 h ^= (h >> 17);
9765 h = h * c1;
9766 h ^= (h >> 17);
9767 h = h * c1;
9768 h ^= (h >> 17);
9769 return h;
9770}
9771
9772#undef SEED
9773#undef SEED1
9774#undef SEED0
9775#define SEED CreateSeed(offset, -1)
9776#define SEED0 CreateSeed(offset, 0)
9777#define SEED1 CreateSeed(offset, 1)
9778
9779#undef TESTING
9780#define TESTING 1
9781#if TESTING
9782uint32_t expected[] = {
97833277735313u, 2681724312u,
97842598464059u, 797982799u,
97852603993599u, 921001710u,
97861410420968u, 2134990486u,
97872914424215u, 2244477846u,
9788255297188u, 2992121793u,
9789161451183u, 3943596029u,
97904019337850u, 452431531u,
97913379021470u, 2557197665u,
9792299850021u, 2532580744u,
97931298374911u, 3099673830u,
97942199864459u, 3696623795u,
97954055299123u, 3281581178u,
97961053458494u, 1882212500u,
97973456121707u, 275903667u,
9798458884671u, 3033004529u,
97991898235244u, 1402319660u,
98002700149065u, 2699376854u,
98012433714046u, 4222949502u,
98024220361840u, 1712034059u,
98034148372108u, 1330324210u,
9804594028478u, 2921867846u,
9805780716741u, 1728752234u,
98063280331829u, 326029180u,
9807393215742u, 3349570000u,
98083824583307u, 1612122221u,
98091379537552u, 1646032583u,
98102233466664u, 1432476832u,
98112052294713u, 3552092450u,
98121628777059u, 1499109081u,
98132960536756u, 1554038301u,
98141145519619u, 3190844552u,
9815237495366u, 540224401u,
981665721842u, 489963606u,
98171596489240u, 1562872448u,
98181790705123u, 2128624475u,
98191435705557u, 1262831810u,
9820155445229u, 1672724608u,
9821663607706u, 2077310004u,
98223610042449u, 1911523866u,
98232563776023u, 294527927u,
98241099072299u, 1389770549u,
98252952353448u, 2026137563u,
98263603803785u, 629449419u,
9827226132789u, 2489287368u,
98281552847036u, 645684964u,
9829187883449u, 230403464u,
98303151491850u, 3272648435u,
98312002861219u, 165370827u,
9832916494250u, 1230085527u,
98333807265751u, 3628174014u,
9834231181488u, 851743255u,
98352988893883u, 1554380634u,
98361142264800u, 3667013118u,
98372638023604u, 2290487377u,
9838732137533u, 1909203251u,
98391380301172u, 1498556724u,
98404072067757u, 4165088768u,
98413931792696u, 197618179u,
9842956300927u, 914413116u,
98432148126371u, 1913303225u,
98443074915312u, 3117299654u,
98453178848746u, 1357272220u,
98461438494951u, 507436733u,
98473854939912u, 1413396341u,
9848126024219u, 146044391u,
98493254014218u, 429095991u,
9850165589978u, 1578546616u,
9851623071693u, 366414107u,
9852249776086u, 1207522198u,
98533120876698u, 1684583131u,
985446987739u, 1157614300u,
9855199124911u, 520792961u,
98563614377032u, 586863115u,
98571716848157u, 4033596884u,
98581164298657u, 4140791139u,
98593824360466u, 3242407770u,
98603725511003u, 232064808u,
98612736953692u, 816692935u,
9862512845449u, 3748861010u,
98634290630595u, 517646945u,
986422638523u, 648000590u,
98651283799121u, 3047062993u,
98661024246061u, 4027776454u,
9867834785312u, 382936554u,
9868411505255u, 1973395102u,
9869580988377u, 2826990641u,
98703474970689u, 1029055034u,
98712584372201u, 1758123094u,
9872589567754u, 325737734u,
98733886113119u, 3338548567u,
9874257578986u, 3698087965u,
98753604937815u, 3198590202u,
98762305332220u, 191910725u,
98774244322689u, 542201663u,
98783315355162u, 2135941665u,
98791175961330u, 3948351189u,
988023075771u, 3252374102u,
9881713127376u, 1467786451u,
9882663013031u, 3444053918u,
98833077742128u, 1062268187u,
98842115441882u, 4081398201u,
98852335576331u, 2560479831u,
98861379288194u, 4225182569u,
98873958366652u, 3067277639u,
98883667516477u, 1709989541u,
98894188504038u, 59581167u,
98902725013602u, 3639843023u,
98913758739543u, 4189944477u,
98922470483982u, 877580602u,
98933252925478u, 2062343506u,
98943981838403u, 3762572073u,
98952931588131u, 3284356565u,
98961129162571u, 732225574u,
98971677744031u, 3532596884u,
98983232041815u, 1652884780u,
98993740979556u, 259034107u,
99002227121257u, 1426140634u,
9901315836068u, 3200749877u,
99021386256573u, 24035717u,
9903234531934u, 1115203611u,
99041598686658u, 3146815575u,
99052632963283u, 1778459926u,
9906739944537u, 579625482u,
99071231665285u, 2457048126u,
99083903349120u, 389846205u,
99091052645068u, 862072556u,
99102834153464u, 1481069623u,
99111688445808u, 701920051u,
99123740748788u, 3388062747u,
99131192588249u, 1410111809u,
99142633463887u, 4050419847u,
99152513844237u, 2187968410u,
99162951683019u, 3015806005u,
99173000537321u, 479241367u,
9918252167538u, 1231057113u,
9919393624922u, 704325635u,
99201467197045u, 2066433573u,
99213082385053u, 735688735u,
9922956434529u, 4028590195u,
99234074716319u, 813690332u,
99242124740535u, 804073145u,
99253748881891u, 3195309868u,
9926841856605u, 2585865274u,
9927881504822u, 3254795114u,
99281241815736u, 970796142u,
9929497175391u, 3929484338u,
99304264993211u, 1835322201u,
99313675707838u, 4205965408u,
9932300298607u, 3858319990u,
99333255259608u, 4247675634u,
99341095823272u, 1197245408u,
99351742785722u, 785893184u,
99361702965674u, 850401405u,
99374084891412u, 1160134629u,
99382555998391u, 1972759056u,
9939710625654u, 4116162021u,
99403352753742u, 85121177u,
99413513255468u, 2487440590u,
99422480032715u, 2287747045u,
99434090178629u, 4044418876u,
99441703944517u, 486290428u,
99451515601363u, 2011102035u,
9946573985957u, 3536053779u,
99474257172787u, 576405853u,
99481523550693u, 1014952061u,
9949711098718u, 2425317635u,
99503460807169u, 3688987163u,
99513167371443u, 3062418115u,
99523330028292u, 1713171303u,
9953526177822u, 2602636307u,
99541245357025u, 3346699703u,
9955254529415u, 4017058800u,
99561829738451u, 2164236533u,
99571381258384u, 4036354071u,
99581749181924u, 4118435443u,
99594130543625u, 688472265u,
99602731071299u, 2547657502u,
99614175776103u, 338058159u,
99623729582129u, 4181845558u,
99632227290760u, 146827036u,
99642459178427u, 1025353883u,
99654284109679u, 2502815838u,
9966825124804u, 2533140036u,
9967616327404u, 2448966429u,
9968413992636u, 2334782461u,
99692239052397u, 1082330589u,
99703381164715u, 199381437u,
99712583939798u, 2848283092u,
99722300168091u, 2156336315u,
99731855234968u, 1982110346u,
99742482046810u, 3158163887u,
99752168864636u, 133643215u,
99763904021624u, 3646514568u,
99771176127003u, 4015671361u,
9978100525019u, 3534706803u,
99792045051700u, 3452457457u,
99801492267772u, 2308393828u,
99813776661467u, 3281002516u,
99824246334524u, 743955039u,
9983685631442u, 1147951686u,
99842040912376u, 2911148054u,
99853204999386u, 2415262714u,
9986313209105u, 777065474u,
99872729416454u, 1029284767u,
99881632078298u, 1817552554u,
99893963877000u, 1919171906u,
99903843219958u, 3073580867u,
9991865146997u, 2473524405u,
99922593817617u, 3643076308u,
9993617975720u, 3671562289u,
9994121812599u, 2902367378u,
99952260041112u, 1019936943u,
9996320945955u, 2337845588u,
99971535670711u, 773792826u,
99983152195900u, 4090794518u,
99994142587430u, 484732447u,
10000419191319u, 3377973345u,
10001324924679u, 2809286837u,
100021562277603u, 1378362199u,
100033791551981u, 1097806406u,
100041386297408u, 2304900033u,
100053574135531u, 4017075736u,
100061161238398u, 1358056883u,
100073487080616u, 1516736273u,
10008851615042u, 2927899494u,
100094077452507u, 2984955003u,
100103907754394u, 3578173844u,
100111948409509u, 1923531348u,
100123578472493u, 3710074193u,
10013213811117u, 2586632018u,
100141922589216u, 274958014u,
100151654276320u, 2687561076u,
100162569061755u, 3122046057u,
100173203802620u, 1692079268u,
10018477806878u, 140587742u,
10019520565830u, 3674576684u,
1002091246882u, 1010215946u,
100213703994407u, 69201295u,
10022776213083u, 3677771507u,
100233696902571u, 3593730713u,
100242907901228u, 3239753796u,
100251586241476u, 1939595371u,
100262268396558u, 3468719670u,
100272955715987u, 2295501078u,
100282775848696u, 1358532390u,
100293843660102u, 82177963u,
100304094477877u, 191727221u,
10031278661677u, 2889101923u,
100321352525614u, 2844977667u,
100331261140657u, 1747052377u,
100342334120653u, 645125282u,
100352707230761u, 4142246789u,
100361068639717u, 2288162940u,
100371419293714u, 1636932722u,
100383252686293u, 318543902u,
100392598802768u, 2025886508u,
100402250788464u, 2711763065u,
10041255108733u, 1845587644u,
100423719270134u, 3940707863u,
10043917608574u, 1363253259u,
10044788659330u, 673256220u,
10045109793386u, 341851980u,
100462698465479u, 3011229884u,
100473886713057u, 1276595523u,
100482439962760u, 2700515456u,
10049205970448u, 4198897105u,
10050875511891u, 371715572u,
100511033680610u, 4278599955u,
100523120038721u, 1256300069u,
10053225629455u, 3735275001u,
100543961944123u, 1769389163u,
100551074553219u, 668829411u,
100561098679359u, 2573697509u,
100571885071395u, 4233785523u,
100582513878053u, 2030193788u,
10059360256231u, 107312677u,
10060310517502u, 2618936366u,
100613600462351u, 1216645846u,
100622970730323u, 4278812598u,
1006394638678u, 1689811113u,
100644125738800u, 3103759730u,
10065103797041u, 1397772514u,
100661669653333u, 572567964u,
100671612872497u, 2986430557u,
10068214990655u, 3117607990u,
100691949717207u, 2260498180u,
100701493936866u, 3554860960u,
100711582022990u, 1263709570u,
100721244120487u, 3416600761u,
10073224580012u, 4252610345u,
10074286306391u, 814956796u,
100751820532305u, 2776960536u,
100763082703465u, 1659265982u,
100771157398049u, 3752806924u,
100783508246460u, 2902716664u,
100792110942730u, 3267551635u,
10080902835431u, 405228165u,
100812341378668u, 2220373824u,
100823303626294u, 1175118221u,
10083383517064u, 896322512u,
100841697257567u, 2202820683u,
100851837689083u, 1336556841u,
10086914535232u, 3634083711u,
100871537187340u, 3712582785u,
100881088201893u, 3270984620u,
100893093195926u, 2561488770u,
100901962968100u, 236189500u,
100912549435227u, 536047554u,
10092422609195u, 2958815818u,
100934166184983u, 3528794619u,
100941042329086u, 3914176886u,
100951359641525u, 1197100813u,
100961269739674u, 3301844628u,
100971831223342u, 3329594980u,
100982433669782u, 494908536u,
100991441714797u, 1174785921u,
101001933050423u, 958901065u,
10101868981704u, 2163330264u,
101023243110680u, 1443133429u,
101031145009669u, 2520062970u,
101043851564853u, 2664619323u,
101052686075657u, 4042710240u,
101062125408249u, 4165697916u,
101072328730865u, 3160666939u,
10108588683409u, 2126275847u,
10109829404209u, 1878067032u,
101102567792910u, 897670516u,
10111934312076u, 2952135524u,
10112504832490u, 3312698056u,
101134015478120u, 1265237690u,
101143376133707u, 967674402u,
101151553513184u, 834830418u,
101162396504772u, 3278582098u,
101172950762705u, 4277111759u,
101184159211303u, 1290097509u,
10119251949572u, 3065234219u,
101201832020534u, 312136369u,
101211103404394u, 198182691u,
101221369599600u, 3906710870u,
101232954651680u, 1535115487u,
101242389327507u, 1813520230u,
10125632704095u, 140762681u,
101263123202913u, 3336005523u,
101271287729497u, 2198985327u,
101282470730783u, 3821758006u,
101291009870118u, 559702706u,
101304274686257u, 3187546567u,
101312402308151u, 1096697687u,
10132678932329u, 3716363135u,
101332899950405u, 3046872820u,
101343754655641u, 2021741414u,
101351993425202u, 2185339100u,
101362838253700u, 3099212100u,
101371679617763u, 3703603898u,
101381135665833u, 3559875668u,
101392503579743u, 1446869792u,
10140879818611u, 3788305533u,
101412879018745u, 2719373510u,
101423606051203u, 2166567748u,
10143343595772u, 1996164093u,
101441577656121u, 475248376u,
10145463852893u, 2864244470u,
101461332049663u, 3326459767u,
101473207234525u, 2028708916u,
10148938916154u, 3115246264u,
101493272166407u, 557660441u,
101501265684026u, 245033807u,
101512440657523u, 255451671u,
101523811885130u, 1399880284u,
101531322855877u, 3452203069u,
101541324994449u, 3796404024u,
101552002090272u, 1568745354u,
101563700047753u, 31799506u,
101573009412313u, 3184047862u,
10158728680761u, 3848624873u,
101591849329144u, 3160134214u,
101601272923193u, 1474278816u,
101611208883495u, 1566527339u,
101624136466541u, 630825649u,
101631717327230u, 1496132623u,
101642449386742u, 128106940u,
101652108574735u, 2584236470u,
101662872246579u, 397338552u,
101673088905079u, 3456882941u,
101681715915153u, 2940716269u,
101694168438718u, 467441309u,
10170872996731u, 3206901319u,
101711610606159u, 2540270567u,
101721301658081u, 2379410194u,
101732109315753u, 3348545480u,
101742041927873u, 2644077493u,
10175546596661u, 1017047954u,
101762596792972u, 2783958892u,
101772826408201u, 3531646869u,
101782219352672u, 4217451852u,
101791806867885u, 1903578924u,
101802076465705u, 2373061493u,
101811832925325u, 241574049u,
101821509517110u, 3703614272u,
101833429894862u, 3529565564u,
101844010000614u, 2256197939u,
10185517086873u, 2964595704u,
101863501035294u, 4079457298u,
101871184683823u, 4260564140u,
101882339268412u, 3871564102u,
101891572637805u, 383233885u,
101903351411126u, 3419328182u,
101912017406667u, 919677938u,
1019229804156u, 46276077u,
101933032591014u, 4204155962u,
101941172319502u, 969309871u,
101952211319468u, 4153726847u,
101963094193193u, 4240669441u,
101973441709766u, 1387233546u,
101984048882438u, 1217896566u,
101991580964938u, 740563169u,
102003691850348u, 3176426539u,
102012738323042u, 2948665536u,
102021474029445u, 3513354882u,
102033219466255u, 3799363969u,
102043961796122u, 1055550923u,
102051992212097u, 2263421398u,
102064289759174u, 2516844140u,
102071782515131u, 2746577402u,
10208721928440u, 3529570984u,
102091705302106u, 768287270u,
102103474902815u, 4000011125u,
102113475618043u, 212490675u,
10212549130471u, 2970128275u,
102133170016833u, 2549835613u,
102143691104824u, 2694324482u,
102154169365948u, 3738062408u,
10216602930397u, 2148954730u,
102172636387819u, 2616619070u,
10218301617872u, 374657036u,
102193862686086u, 431292293u,
102204225245165u, 1358580562u,
102212377363130u, 1415970351u,
102223885060756u, 1438379807u,
102232297418515u, 2954777083u,
102243970368221u, 1229801760u,
102251931934525u, 2287507921u,
102261713471510u, 2145608111u,
102272650140034u, 4081586725u,
102284196863572u, 1896558394u,
102294059852729u, 1813855658u,
102302618400836u, 1396056469u,
102312375584220u, 1037031473u,
10232249284003u, 2450077637u,
102331383747654u, 3122687303u,
102342664431743u, 3855028730u,
10235929335420u, 3193251135u,
10236137313762u, 1850894384u,
102373163711272u, 3071568023u,
10238418541677u, 3621223039u,
10239340274176u, 1167681812u,
102404106647531u, 4022465625u,
102413069708839u, 2704165015u,
102422332023349u, 641449034u,
10243921552000u, 1712976649u,
102441876484273u, 2343049860u,
102451834682077u, 4155949943u,
102462061821157u, 4240649383u,
10247747285578u, 1626463554u,
10248165503115u, 359629739u,
102493838102563u, 582664250u,
102503878924635u, 4117237498u,
102512250573853u, 804336148u,
10252331393443u, 4242530387u,
102533346357270u, 1674051445u,
102543348019777u, 1722242971u,
102552509017299u, 2966108111u,
102564189102509u, 3323592310u,
102572631381069u, 4014551783u,
102584250787412u, 3448394212u,
102592664752123u, 3517585534u,
102603605365141u, 1669471183u,
102612210121140u, 760762191u,
10262249697459u, 3416920106u,
1026316322182u, 643179562u,
102641564226597u, 2134630675u,
102651011990087u, 2990167340u,
102662349550842u, 1642428946u,
102671214854475u, 2134299399u,
102682704221532u, 2104175211u,
102694283196353u, 1342880802u,
10270198529755u, 2004468390u,
102712544665755u, 853593042u,
102722090611294u, 2970943872u,
102731472073141u, 850464484u,
102741407609278u, 3062461105u,
10275366448238u, 3842907484u,
10276488797416u, 1432670231u,
10277294963924u, 3693536939u,
102783390549825u, 1583234720u,
102794032223840u, 2318423400u,
102802965642867u, 930822729u,
102811679099863u, 1728968857u,
10282900822335u, 702309817u,
102833258354115u, 1502282913u,
102842811888503u, 3924947660u,
102852477280726u, 3651607391u,
102863788310204u, 1300369123u,
102871842333726u, 4146839064u,
102882468893861u, 4091095953u,
10289488595746u, 1448097974u,
102901159634090u, 1738834113u,
102912928916831u, 4093725287u,
10292530850094u, 291657799u,
102933548184546u, 679517009u,
10294399175380u, 2658337143u,
102953827951761u, 3086277222u,
102962067718397u, 3632376023u,
102973553313841u, 119173722u,
102981702434637u, 1766260771u,
10299895654784u, 751439914u,
103004008409498u, 215917713u,
103011288382231u, 2656990891u,
103022581779077u, 1570750352u,
103032666411616u, 3533987737u,
103044289478316u, 3576119563u,
103053869794273u, 963183826u,
103062081410737u, 3796810515u,
103071036883117u, 136547246u,
10308875691100u, 2592925324u,
103092689342539u, 427154472u,
10310532957601u, 1228758574u,
103111908591042u, 1464255968u,
10312446980910u, 2984611177u,
103133508927906u, 2001585786u,
103142544767379u, 1525438381u,
10315879448844u, 1348536411u,
103164242243590u, 2861338018u,
10317601175800u, 764077711u,
10318530635011u, 3785343245u,
103192378297261u, 457568934u,
1032076438221u, 4104954272u,
103212485968477u, 2381948487u,
103224226929450u, 3148473363u,
10323879369091u, 2180270337u,
103243674375989u, 1387729170u,
10325568650985u, 951677556u,
103264213877384u, 2721005055u,
103271678669911u, 66786703u,
103282273631661u, 1149351924u,
10329246723096u, 1895026827u,
103303810605772u, 3711056516u,
103312080120290u, 3638638708u,
103322915672708u, 2263003308u,
103331976115991u, 3448840877u,
103342019238520u, 225333538u,
103351555273378u, 3797521928u,
103361942347150u, 3262952567u,
103372817830907u, 2078619498u,
10338749534111u, 1178073973u,
10339841092198u, 3288261538u,
103401696412169u, 1496966875u,
103413739946319u, 2481012988u,
10342568983526u, 114945840u,
103432841706923u, 1632780103u,
103444020169654u, 2087949619u,
10345833416317u, 3787017905u,
103462373238993u, 2575395164u,
103472542976862u, 2971726178u,
103482880371864u, 3642087909u,
103491043714217u, 3894199764u,
103502235879182u, 203853421u,
10351834683330u, 425935223u,
103523560796393u, 3565833278u,
103533414330886u, 1748785729u,
103541023171602u, 580966986u,
103552657385925u, 2124704694u,
10356233442446u, 1107045577u,
103573899097693u, 1067532701u,
10358115667924u, 1406028344u,
103592419657149u, 18613994u,
103602532882091u, 3476683808u,
10361895961699u, 3762914298u,
103621328752423u, 1844996900u,
103631210281744u, 904215228u,
103644055325594u, 1118521573u,
103653996647489u, 3657647605u,
10366325254059u, 3136157065u,
103673341068436u, 2287683323u,
103681313073005u, 126005630u,
10369853746559u, 3555092974u,
103702689238752u, 49515858u,
1037161073168u, 1010661841u,
103721269521335u, 1902040126u,
103733858321250u, 1400735275u,
103742974699176u, 2771676666u,
10375545726212u, 2225229957u,
103761086473152u, 3454177594u,
103772088002891u, 2883475137u,
103783222194252u, 4144472319u,
10379567988835u, 1051332394u,
103803932046135u, 542648229u,
10381162888005u, 1669710469u,
103821492500905u, 553041029u,
103833817492747u, 584127807u,
103844147115982u, 2993670925u,
103853509733475u, 3587959456u,
103862088550465u, 1745399498u,
10387869648362u, 1404723176u,
103883947542735u, 1334333531u,
1038959634866u, 3239516985u,
103903844250972u, 1275954779u,
103912512155003u, 1685649437u,
10392639306006u, 2524620206u,
10393576786501u, 655707039u,
103942864351838u, 3736264674u,
103951200907897u, 2384379464u,
1039615823708u, 206117476u,
103971193310960u, 1093099415u,
103983696538026u, 4112584792u,
103992069527017u, 547588820u,
104004178147211u, 2827259351u,
10401940846775u, 1054995047u,
104022976960697u, 1934305529u,
104032199137382u, 1005722394u,
104041875867180u, 2064356511u,
104054019734130u, 3096333006u,
104062069509024u, 2906358341u,
104072232866485u, 1456016086u,
104081422674894u, 867282151u,
104091612503136u, 1739843072u,
10410134947567u, 2978775774u,
104111284167756u, 1090844589u,
10412831688783u, 2079216362u,
104131626991196u, 3644714163u,
104143678110059u, 898470030u,
104153916646913u, 3182422972u,
104163630426828u, 969847973u,
104173427164640u, 3463937250u,
104183044785046u, 897322257u,
104193443872170u, 4185408854u,
104202557463241u, 4080940424u,
104212048168570u, 2429169982u,
104223174690447u, 2513494106u,
104231213061732u, 3143736628u,
104243482268149u, 1250714337u,
1042531648125u, 3872383625u,
104261565760579u, 36665130u,
10427751041229u, 2257179590u,
104282915361862u, 280819225u,
104292907818413u, 4254297769u,
104303493178615u, 3755944354u,
104314043533423u, 1134196225u,
104324177134659u, 127246419u,
104332442615581u, 923049607u,
104341004426206u, 782768297u,
104352410586681u, 1430106871u,
104364103323427u, 3168399477u,
104373716682375u, 3616334719u,
104383413209549u, 656672786u,
104392876965944u, 182894450u,
10440456581318u, 2683752067u,
104413877875910u, 3190666241u,
104423240336907u, 4024807233u,
104431681224377u, 1576191191u,
104443599250276u, 2381111980u,
104453495321877u, 3956024585u,
104461611608524u, 3815677453u,
104472062334396u, 1656117707u,
104485457134u, 3234118251u,
10449470187419u, 2688566989u,
104503259870297u, 660100446u,
10451442236198u, 2542452448u,
10452493137955u, 392411099u,
10453947967568u, 1234595917u,
104544230082284u, 2762976773u,
104552870085764u, 1455086530u,
104562762099647u, 4011882747u,
104571215981925u, 3227517889u,
104583269061963u, 4037515364u,
104593168911474u, 4255057396u,
104602026092260u, 1736192508u,
104613909727042u, 3114708966u,
104621938800693u, 680793595u,
104631525265867u, 2808224480u,
104642122290603u, 1211197714u,
104653520488321u, 3979192396u,
104663540779343u, 4192918639u,
104672736030448u, 1120335563u,
104681698949078u, 3993310631u,
104691966048551u, 2228221363u,
10470597941119u, 3498018399u,
10471393987327u, 454500547u,
104721222959566u, 567151340u,
104733774764786u, 1492844524u,
104743308300614u, 805568076u,
10475868414882u, 177406999u,
104761608110313u, 642061169u,
104771027515771u, 3131251981u,
104782851936150u, 4272755262u,
104791532845092u, 709643652u,
10480682573592u, 1244104217u,
10481796769556u, 2500467040u,
104823002618826u, 1112998535u,
104831780193104u, 1243644607u,
104843691719535u, 2958853053u,
10485466635014u, 2277292580u,
104864082276003u, 1030800045u,
104871750863246u, 379050598u,
104883576413281u, 731493104u,
10489132259176u, 4115195437u,
104901769890695u, 2715470335u,
104911819263183u, 2028531518u,
104922154809766u, 3672399742u,
1049376727603u, 4198182186u,
104942304993586u, 1666387627u,
10495284366017u, 3359785538u,
104963469807328u, 2926494787u,
104973829072836u, 2493478921u,
104983738499303u, 3311304980u,
10499932916545u, 2235559063u,
105002909742396u, 1765719309u,
105011456588655u, 508290328u,
105021490719640u, 3356513470u,
105032908490783u, 251085588u,
10504830410677u, 3172220325u,
105053897208579u, 1940535730u,
10506151909546u, 2384458112u,
10507};
10508
10509// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
10510bool Test(int offset, int len = 0) {
10511#undef Check
10512#undef IsAlive
10513
10514#define Check(x) do { \
10515 const uint32_t actual = (x), e = expected[index++]; \
10516 bool ok = actual == e; \
10517 if (!ok) { \
10518 cerr << "expected " << hex << e << " but got " << actual << endl; \
10519 ++errors; \
10520 } \
10521 assert(ok); \
10522} while (0)
10523
10524#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
10525
10526 // After the following line is where the uses of "Check" and such will go.
10527 static int index = 0;
10528if (offset == -1) { int alive = 0; { uint64_t h = farmhashuo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashuo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
10529{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
10530{ uint64_t h = farmhashuo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
10531
10532 return true;
10533#undef Check
10534#undef IsAlive
10535}
10536
10537int RunTest() {
10538 Setup();
10539 int i = 0;
10540 cout << "Running farmhashuoTest";
10541 if (!Test(-1)) {
10542 cout << "... Unavailable\n";
10543 return NoteErrors();
10544 }
10545 // Good. The function is attempting to hash, so run the full test.
10546 int errors_prior_to_test = errors;
10547 for ( ; i < kTestSize - 1; i++) {
10548 Test(i * i, i);
10549 }
10550 for ( ; i < kDataSize; i += i / 7) {
10551 Test(0, i);
10552 }
10553 Test(0, kDataSize);
10554 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
10555 return NoteErrors();
10556}
10557
10558#else
10559
10560// After the following line is where the code to print hash codes will go.
10561void Dump(int offset, int len) {
10562{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10563{ uint64_t h = farmhashuo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10564}
10565
10566#endif
10567
10568#undef SEED
10569#undef SEED1
10570#undef SEED0
10571
10572} // namespace farmhashuoTest
10573
10574#if TESTING
10575
10576static int farmhashuoTestResult = farmhashuoTest::RunTest();
10577
10578#else
10579int main(int argc, char** argv) {
10580 Setup();
10581 cout << "uint32_t expected[] = {\n";
10582 int i = 0;
10583 for ( ; i < kTestSize - 1; i++) {
10584 farmhashuoTest::Dump(i * i, i);
10585 }
10586 for ( ; i < kDataSize; i += i / 7) {
10587 farmhashuoTest::Dump(0, i);
10588 }
10589 farmhashuoTest::Dump(0, kDataSize);
10590 cout << "};\n";
10591}
10592#endif
10593#ifndef FARMHASH_SELF_TEST_GUARD
10594#define FARMHASH_SELF_TEST_GUARD
10595#include <cstdio>
10596#include <iostream>
10597#include <string.h>
10598
10599using std::cout;
10600using std::cerr;
10601using std::endl;
10602using std::hex;
10603
10604static const uint64_t kSeed0 = 1234567;
10605static const uint64_t kSeed1 = k0;
10606static const int kDataSize = 1 << 20;
10607static const int kTestSize = 300;
10608#define kSeed128 Uint128(kSeed0, kSeed1)
10609
10610static char data[kDataSize];
10611
10612static int completed_self_tests = 0;
10613static int errors = 0;
10614
10615// Initialize data to pseudorandom values.
10616void Setup() {
10617 if (completed_self_tests == 0) {
10618 uint64_t a = 9;
10619 uint64_t b = 777;
10620 for (int i = 0; i < kDataSize; i++) {
10621 a += b;
10622 b += a;
10623 a = (a ^ (a >> 41)) * k0;
10624 b = (b ^ (b >> 41)) * k0 + i;
10625 uint8_t u = b >> 37;
10626 memcpy(data + i, &u, 1); // uint8_t -> char
10627 }
10628 }
10629}
10630
10631int NoteErrors() {
10632#define NUM_SELF_TESTS 9
10633 if (++completed_self_tests == NUM_SELF_TESTS)
10634 std::exit(errors > 0);
10635 return errors;
10636}
10637
10638template <typename T> inline bool IsNonZero(T x) {
10639 return x != 0;
10640}
10641
10642template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
10643 return x != Uint128(0, 0);
10644}
10645
10646#endif // FARMHASH_SELF_TEST_GUARD
10647
10648namespace farmhashxoTest {
10649
10650uint32_t CreateSeed(int offset, int salt) {
10651 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
10652 h = h * c1;
10653 h ^= (h >> 17);
10654 h = h * c1;
10655 h ^= (h >> 17);
10656 h = h * c1;
10657 h ^= (h >> 17);
10658 h += static_cast<uint32_t>(offset & 0xffffffff);
10659 h = h * c1;
10660 h ^= (h >> 17);
10661 h = h * c1;
10662 h ^= (h >> 17);
10663 h = h * c1;
10664 h ^= (h >> 17);
10665 return h;
10666}
10667
10668#undef SEED
10669#undef SEED1
10670#undef SEED0
10671#define SEED CreateSeed(offset, -1)
10672#define SEED0 CreateSeed(offset, 0)
10673#define SEED1 CreateSeed(offset, 1)
10674
10675#undef TESTING
10676#define TESTING 1
10677#if TESTING
10678uint32_t expected[] = {
106791140953930u, 861465670u,
106803277735313u, 2681724312u,
106812598464059u, 797982799u,
10682890626835u, 800175912u,
106832603993599u, 921001710u,
106841410420968u, 2134990486u,
106853283896453u, 1867689945u,
106862914424215u, 2244477846u,
10687255297188u, 2992121793u,
106881110588164u, 4186314283u,
10689161451183u, 3943596029u,
106904019337850u, 452431531u,
10691283198166u, 2741341286u,
106923379021470u, 2557197665u,
10693299850021u, 2532580744u,
10694452473466u, 1706958772u,
106951298374911u, 3099673830u,
106962199864459u, 3696623795u,
10697236935126u, 2976578695u,
106984055299123u, 3281581178u,
106991053458494u, 1882212500u,
107002305012065u, 2169731866u,
107013456121707u, 275903667u,
10702458884671u, 3033004529u,
107033058973506u, 2379411653u,
107041898235244u, 1402319660u,
107052700149065u, 2699376854u,
10706147814787u, 720739346u,
107072433714046u, 4222949502u,
107084220361840u, 1712034059u,
107093425469811u, 3690733394u,
107104148372108u, 1330324210u,
10711594028478u, 2921867846u,
107121635026870u, 192883107u,
10713780716741u, 1728752234u,
107143280331829u, 326029180u,
107153969463346u, 1436364519u,
10716393215742u, 3349570000u,
107173824583307u, 1612122221u,
107182859809759u, 3808705738u,
107191379537552u, 1646032583u,
107202233466664u, 1432476832u,
107214023053163u, 2650381482u,
107222052294713u, 3552092450u,
107231628777059u, 1499109081u,
107243476440786u, 3829307897u,
107252960536756u, 1554038301u,
107261145519619u, 3190844552u,
107272902102606u, 3600725550u,
10728237495366u, 540224401u,
1072965721842u, 489963606u,
107301448662590u, 397635823u,
107311596489240u, 1562872448u,
107321790705123u, 2128624475u,
10733180854224u, 2604346966u,
107341435705557u, 1262831810u,
10735155445229u, 1672724608u,
107361669465176u, 1341975128u,
10737663607706u, 2077310004u,
107383610042449u, 1911523866u,
107391043692997u, 1454396064u,
107402563776023u, 294527927u,
107411099072299u, 1389770549u,
10742703505868u, 678706990u,
107432952353448u, 2026137563u,
107443603803785u, 629449419u,
107451933894405u, 3043213226u,
10746226132789u, 2489287368u,
107471552847036u, 645684964u,
107483828089804u, 3632594520u,
10749187883449u, 230403464u,
107503151491850u, 3272648435u,
107513729087873u, 1303930448u,
107522002861219u, 165370827u,
10753916494250u, 1230085527u,
107543103338579u, 3064290191u,
107553807265751u, 3628174014u,
10756231181488u, 851743255u,
107572295806711u, 1781190011u,
107582988893883u, 1554380634u,
107591142264800u, 3667013118u,
107601968445277u, 315203929u,
107612638023604u, 2290487377u,
10762732137533u, 1909203251u,
10763440398219u, 1891630171u,
107641380301172u, 1498556724u,
107654072067757u, 4165088768u,
107664204318635u, 441430649u,
107673931792696u, 197618179u,
10768956300927u, 914413116u,
107693010839769u, 2837339569u,
107702148126371u, 1913303225u,
107713074915312u, 3117299654u,
107724139181436u, 2993479124u,
107733178848746u, 1357272220u,
107741438494951u, 507436733u,
10775667183474u, 2084369203u,
107763854939912u, 1413396341u,
10777126024219u, 146044391u,
107781016656857u, 3022024459u,
107793254014218u, 429095991u,
10780990500595u, 3056862311u,
10781985653208u, 1718653828u,
10782623071693u, 366414107u,
107831771289760u, 2293458109u,
107843047342438u, 2991127487u,
107853120876698u, 1684583131u,
107863638043310u, 1170404994u,
10787863214540u, 1087193030u,
10788199124911u, 520792961u,
107893169775996u, 1577421232u,
107903331828431u, 1013201099u,
107911716848157u, 4033596884u,
107921770708857u, 4229339322u,
107931146169032u, 1434258493u,
107943824360466u, 3242407770u,
107951926419493u, 2649785113u,
10796872586426u, 762243036u,
107972736953692u, 816692935u,
107981571283333u, 3555213933u,
107992266795890u, 3781899767u,
108004290630595u, 517646945u,
108013006163611u, 2180594090u,
10802959214578u, 558910384u,
108031283799121u, 3047062993u,
108043830962609u, 2391606125u,
108053544509313u, 622325861u,
10806834785312u, 382936554u,
108071421463872u, 788479970u,
108081825135056u, 2725923798u,
10809580988377u, 2826990641u,
10810247825043u, 3167748333u,
10811812546227u, 2506885666u,
108122584372201u, 1758123094u,
108131891789696u, 389974094u,
10814345313518u, 2022370576u,
108153886113119u, 3338548567u,
108161083486947u, 2583576230u,
108171776047957u, 1771384107u,
108183604937815u, 3198590202u,
108193027522813u, 4155628142u,
108204232136669u, 427759438u,
108214244322689u, 542201663u,
108221549591985u, 2856634168u,
10823556609672u, 45845311u,
108241175961330u, 3948351189u,
108254165739882u, 4194218315u,
108261634635545u, 4151937410u,
10827713127376u, 1467786451u,
108281327394015u, 2743592929u,
108292638154051u, 810082938u,
108303077742128u, 1062268187u,
108314084325664u, 3810665822u,
108323735739145u, 2794294783u,
108332335576331u, 2560479831u,
10834690240711u, 997658837u,
108352442302747u, 3948961926u,
108363958366652u, 3067277639u,
108372059157774u, 1211737169u,
108381516711748u, 2339636583u,
108394188504038u, 59581167u,
108402767897792u, 1389679610u,
108412658147000u, 2643979752u,
108423758739543u, 4189944477u,
108431454470782u, 100876854u,
108442995362413u, 118817200u,
108453252925478u, 2062343506u,
108462804483644u, 3088828656u,
108471231633714u, 4168280671u,
108482931588131u, 3284356565u,
108491255909792u, 3130054947u,
108504173605289u, 1407328702u,
108511677744031u, 3532596884u,
108523162657845u, 3887208531u,
108532256541290u, 3459463480u,
108543740979556u, 259034107u,
10855392987633u, 3233195759u,
108563606709555u, 3424793077u,
10857315836068u, 3200749877u,
108584065431359u, 760633989u,
108592982018998u, 1811050648u,
10860234531934u, 1115203611u,
108613897494162u, 1516407838u,
108621603559457u, 323296368u,
108632632963283u, 1778459926u,
108642879836826u, 2146672889u,
108653486330348u, 492621815u,
108661231665285u, 2457048126u,
108673438440082u, 2217471853u,
108683355404249u, 3275550588u,
108691052645068u, 862072556u,
108704110617119u, 3745267835u,
108712657392572u, 4279236653u,
108721688445808u, 701920051u,
10873956734128u, 581695350u,
108743157862788u, 2585726058u,
108751192588249u, 1410111809u,
108761651193125u, 3326135446u,
108771073280453u, 97376972u,
108782513844237u, 2187968410u,
108793976859649u, 4267859263u,
108803429034542u, 564493077u,
108813000537321u, 479241367u,
108823845637831u, 2868987960u,
1088351544337u, 1029173765u,
10884393624922u, 704325635u,
108852357610553u, 1418509533u,
108862007814586u, 3866658271u,
108873082385053u, 735688735u,
10888916110004u, 3283299459u,
108891051684175u, 1083796807u,
108904074716319u, 813690332u,
10891144264390u, 1439630796u,
108921508556987u, 675582689u,
108933748881891u, 3195309868u,
10894362884708u, 1616408198u,
1089543233176u, 837301135u,
10896881504822u, 3254795114u,
108971385506591u, 2799925823u,
108981469874582u, 3464841997u,
10899497175391u, 3929484338u,
109003975771289u, 1798536177u,
109012926265846u, 1374242438u,
109023675707838u, 4205965408u,
109033153165629u, 1499475160u,
10904187287713u, 548490821u,
109053255259608u, 4247675634u,
109061940181471u, 3779953975u,
10907687167150u, 2319566715u,
109081742785722u, 785893184u,
109092296977392u, 2778575413u,
109101794720651u, 48131484u,
109114084891412u, 1160134629u,
109123737623280u, 823113169u,
109133423207646u, 3803213486u,
10914710625654u, 4116162021u,
109153693420287u, 4167766971u,
109161666602807u, 295320990u,
109173513255468u, 2487440590u,
10918234080704u, 4004655503u,
109192971762528u, 1479656873u,
109204090178629u, 4044418876u,
10921391947536u, 1462554406u,
109223909295855u, 1239580330u,
109231515601363u, 2011102035u,
109241442068334u, 4265993528u,
109251191921695u, 2291355695u,
109264257172787u, 576405853u,
10927314332944u, 4038839101u,
1092855559918u, 2378985842u,
10929711098718u, 2425317635u,
109301644327317u, 1401013391u,
109314193760037u, 2958260436u,
109323167371443u, 3062418115u,
109333800755475u, 3167030094u,
109343489648204u, 1405430357u,
10935526177822u, 2602636307u,
10936915406019u, 4264167741u,
109371484090483u, 3070944737u,
10938254529415u, 4017058800u,
109391702710265u, 1029665228u,
109402000382906u, 3185573940u,
109411381258384u, 4036354071u,
109422900841028u, 2670703363u,
109432921748807u, 2899069938u,
109444130543625u, 688472265u,
109454186808827u, 1054670286u,
109461132985391u, 2840525968u,
109474175776103u, 338058159u,
109481735964501u, 1539305024u,
109493497121710u, 1568260669u,
109502227290760u, 146827036u,
109513977176001u, 4060134777u,
10952857488494u, 250055052u,
109534284109679u, 2502815838u,
109542592281721u, 1603444633u,
109551390562014u, 1556658131u,
10956616327404u, 2448966429u,
109573051191726u, 3891353218u,
109581213304082u, 762328245u,
109592239052397u, 1082330589u,
109602455957292u, 201837927u,
10961405397452u, 3079886794u,
109622583939798u, 2848283092u,
109633750724631u, 883849006u,
109643204198988u, 3341327098u,
109651855234968u, 1982110346u,
109661485529487u, 541496720u,
109674117290321u, 3607433551u,
109682168864636u, 133643215u,
109691055817409u, 3847827123u,
109702960769387u, 4046101649u,
109711176127003u, 4015671361u,
109724243643405u, 2849988118u,
10973517111221u, 1796672358u,
109742045051700u, 3452457457u,
109752948254999u, 2102063419u,
109761556410577u, 1536380876u,
109773776661467u, 3281002516u,
109781735616066u, 1539151988u,
109791087795162u, 3332431596u,
10980685631442u, 1147951686u,
1098195237878u, 2005032160u,
109824012206915u, 4224354805u,
109833204999386u, 2415262714u,
109841433635018u, 116647396u,
1098583167836u, 2881562655u,
109862729416454u, 1029284767u,
10987881378302u, 2159170082u,
10988555057366u, 1169104445u,
109893963877000u, 1919171906u,
10990336034862u, 2017579106u,
109914059340529u, 3020819343u,
10992865146997u, 2473524405u,
10993944743644u, 1694443528u,
109941804513294u, 2904752429u,
10995617975720u, 3671562289u,
10996260177668u, 505662155u,
109971885941445u, 2504509403u,
109982260041112u, 1019936943u,
109993722741628u, 1511077569u,
110003100701179u, 1379422864u,
110011535670711u, 773792826u,
110021103819072u, 2089123665u,
110031157547425u, 329152940u,
110044142587430u, 484732447u,
110052475035432u, 1120017626u,
11006412145504u, 965125959u,
11007324924679u, 2809286837u,
110082842141483u, 4029205195u,
110092974306813u, 515627448u,
110103791551981u, 1097806406u,
110113873078673u, 136118734u,
110121872130856u, 3632422367u,
110133574135531u, 4017075736u,
110141699452298u, 1403506686u,
11015344414660u, 1189129691u,
110163487080616u, 1516736273u,
110171805475756u, 2562064338u,
11018163335594u, 2732147834u,
110194077452507u, 2984955003u,
110204271866024u, 3071338162u,
110212347111903u, 873829983u,
110221948409509u, 1923531348u,
11023459509140u, 771592405u,
110241750124750u, 2334938333u,
11025213811117u, 2586632018u,
11026185232757u, 4032960199u,
110272447383637u, 284777551u,
110281654276320u, 2687561076u,
110293512945009u, 308584855u,
110301861027147u, 4102279334u,
110313203802620u, 1692079268u,
110324250142168u, 2565680167u,
110331507046104u, 841195925u,
11034520565830u, 3674576684u,
1103538924274u, 3770488806u,
110362414430882u, 3978473838u,
110373703994407u, 69201295u,
110383099963860u, 1255084262u,
11039690971838u, 3539996781u,
110403696902571u, 3593730713u,
110412363435042u, 54945052u,
110421785765213u, 184911581u,
110431586241476u, 1939595371u,
110442534883189u, 2432427547u,
110452374171993u, 2039128933u,
110462955715987u, 2295501078u,
110472741583197u, 1280920000u,
11048686818699u, 1238742497u,
110493843660102u, 82177963u,
110501281043691u, 1121403845u,
110511697846708u, 284852964u,
11052278661677u, 2889101923u,
110532127558730u, 713121337u,
11054872502474u, 511142139u,
110551261140657u, 1747052377u,
110562108187161u, 927011680u,
11057955328267u, 3821994995u,
110582707230761u, 4142246789u,
110594134691985u, 1958963937u,
110602498463509u, 1977988705u,
110611419293714u, 1636932722u,
110622567532373u, 4075249328u,
11063240575705u, 1956681213u,
110642598802768u, 2025886508u,
110654104757832u, 3026358429u,
110663242615202u, 4026813725u,
11067255108733u, 1845587644u,
110683573008472u, 3615577014u,
110691222733548u, 1205557630u,
11070917608574u, 1363253259u,
110711541946015u, 3087190425u,
110721138008081u, 1444019663u,
11073109793386u, 341851980u,
11074857839960u, 2515339233u,
11075156283211u, 1906768669u,
110763886713057u, 1276595523u,
110772809830736u, 460237542u,
110783420452099u, 142985419u,
11079205970448u, 4198897105u,
110801950698961u, 2069753399u,
110811142216925u, 1113051162u,
110821033680610u, 4278599955u,
110831106466069u, 356742959u,
11084531521052u, 3494863964u,
11085225629455u, 3735275001u,
110863662626864u, 1750561299u,
110871012864651u, 2101846429u,
110881074553219u, 668829411u,
11089992181339u, 3384018814u,
110903330664522u, 860966321u,
110911885071395u, 4233785523u,
11092100741310u, 451656820u,
110932148187612u, 1063001151u,
11094360256231u, 107312677u,
110953650357479u, 2390172694u,
1109622452685u, 237319043u,
110973600462351u, 1216645846u,
110982088767754u, 164402616u,
110992418980170u, 926137824u,
1110094638678u, 1689811113u,
111012751052984u, 1767810825u,
11102271289013u, 3896132233u,
11103103797041u, 1397772514u,
111043441135892u, 3323383489u,
111052491268371u, 1662561885u,
111061612872497u, 2986430557u,
111072756998822u, 207428029u,
11108937973965u, 2791656726u,
111091949717207u, 2260498180u,
111102648427775u, 2360400900u,
111112080496169u, 486358863u,
111121582022990u, 1263709570u,
111131396468647u, 1377764574u,
11114363008508u, 1293502429u,
11115224580012u, 4252610345u,
111161435134775u, 1099809675u,
11117533671980u, 1533438766u,
111181820532305u, 2776960536u,
111193374512975u, 3542220540u,
11120822810075u, 3716663290u,
111211157398049u, 3752806924u,
111224081637863u, 337070226u,
111233866585976u, 359270190u,
111242110942730u, 3267551635u,
11125644850146u, 1306761320u,
11126746972907u, 934259457u,
111272341378668u, 2220373824u,
111281242645122u, 4109252858u,
111291625266099u, 1173698481u,
11130383517064u, 896322512u,
111313377483696u, 1788337208u,
11132455496839u, 3194373887u,
111331837689083u, 1336556841u,
111341658628529u, 2911512007u,
111353838343487u, 2757664765u,
111361537187340u, 3712582785u,
11137367022558u, 3071359622u,
111383926147070u, 35432879u,
111393093195926u, 2561488770u,
111404273132307u, 3898950547u,
111412838251049u, 2103926083u,
111422549435227u, 536047554u,
111431858986613u, 2040551642u,
111441147412575u, 1972369852u,
111454166184983u, 3528794619u,
111464077477194u, 3565689036u,
11147808048238u, 3826350461u,
111481359641525u, 1197100813u,
11149265993036u, 1864569342u,
11150725164342u, 2264788336u,
111511831223342u, 3329594980u,
11152923017956u, 490608221u,
111533818634478u, 258154469u,
111541441714797u, 1174785921u,
111553833372385u, 3287246572u,
111561677395563u, 3569218731u,
11157868981704u, 2163330264u,
111582649450292u, 500120236u,
11159465161780u, 746438382u,
111601145009669u, 2520062970u,
111612810524030u, 1561519055u,
111621479878006u, 3864969305u,
111632686075657u, 4042710240u,
111643224066062u, 2774151984u,
111652226179547u, 1643626042u,
111662328730865u, 3160666939u,
111672107011431u, 96459446u,
111683920328742u, 3336407558u,
11169829404209u, 1878067032u,
111701235983679u, 4237425634u,
11171466519055u, 3870676863u,
11172934312076u, 2952135524u,
11173276949224u, 4100839753u,
11174424001484u, 1955120893u,
111754015478120u, 1265237690u,
11176427484362u, 4246879223u,
111773452969617u, 1724363362u,
111781553513184u, 834830418u,
111791858777639u, 3476334357u,
111804144030366u, 2450047160u,
111812950762705u, 4277111759u,
11182358032121u, 2511026735u,
11183167923105u, 2059208280u,
11184251949572u, 3065234219u,
111851535473864u, 556796152u,
111861513237478u, 3150857516u,
111871103404394u, 198182691u,
111881476438092u, 2913077464u,
11189207119516u, 3963810232u,
111902954651680u, 1535115487u,
111913051522276u, 4046477658u,
11192917804636u, 864395565u,
11193632704095u, 140762681u,
111941802040304u, 990407433u,
111953771506212u, 4106024923u,
111961287729497u, 2198985327u,
111974052924496u, 2926590471u,
111983084557148u, 1472898694u,
111991009870118u, 559702706u,
112004265214507u, 82077489u,
112013067891003u, 3295678907u,
112022402308151u, 1096697687u,
11203464407878u, 4190838199u,
112044269578403u, 3060919438u,
112052899950405u, 3046872820u,
11206733509243u, 1583801700u,
1120740453902u, 3879773881u,
112081993425202u, 2185339100u,
112091877837196u, 3912423882u,
112103293122640u, 4104318469u,
112111679617763u, 3703603898u,
112128759461u, 2540185277u,
112131152198475u, 2038345882u,
112142503579743u, 1446869792u,
112152019419351u, 4051584612u,
112163178289407u, 3992503830u,
112172879018745u, 2719373510u,
11218700836153u, 1675560450u,
112194121245793u, 2064715719u,
11220343595772u, 1996164093u,
112213130433948u, 405251683u,
112222804817126u, 1607133689u,
11223463852893u, 2864244470u,
112242224044848u, 4071581802u,
112252537107938u, 2246347953u,
112263207234525u, 2028708916u,
112272272418128u, 803575837u,
1122838655481u, 2170452091u,
112293272166407u, 557660441u,
112304019147902u, 3841480082u,
11231298459606u, 2600943364u,
112322440657523u, 255451671u,
112333424361375u, 779434428u,
112343088526123u, 490671625u,
112351322855877u, 3452203069u,
112363057021940u, 2285701422u,
112372014993457u, 2390431709u,
112382002090272u, 1568745354u,
112391783152480u, 823305654u,
112404053862835u, 2200236540u,
112413009412313u, 3184047862u,
112423032187389u, 4159715581u,
112432966902888u, 252986948u,
112441849329144u, 3160134214u,
112453420960112u, 3198900547u,
11246749160960u, 379139040u,
112471208883495u, 1566527339u,
112483006227299u, 4194096960u,
11249556075248u, 497404038u,
112501717327230u, 1496132623u,
112511775955687u, 1719108984u,
112521014328900u, 4189966956u,
112532108574735u, 2584236470u,
11254684087286u, 531310503u,
112554264509527u, 773405691u,
112563088905079u, 3456882941u,
112573105682208u, 3382290593u,
112582289363624u, 3296306400u,
112594168438718u, 467441309u,
11260777173623u, 3241407531u,
112611183994815u, 1132983260u,
112621610606159u, 2540270567u,
112632649684057u, 1397502982u,
11264146657385u, 3318434267u,
112652109315753u, 3348545480u,
112663193669211u, 811750340u,
112671073256162u, 3571673088u,
11268546596661u, 1017047954u,
112693403136990u, 2540585554u,
112701477047647u, 4145867423u,
112712826408201u, 3531646869u,
11272784952939u, 943914610u,
112732717443875u, 3657384638u,
112741806867885u, 1903578924u,
112753985088434u, 1911188923u,
112761764002686u, 3672748083u,
112771832925325u, 241574049u,
11278519948041u, 3181425568u,
112792939747257u, 1634174593u,
112803429894862u, 3529565564u,
112811089679033u, 240953857u,
112822025369941u, 2695166650u,
11283517086873u, 2964595704u,
112843017658263u, 3828377737u,
112852144895011u, 994799311u,
112861184683823u, 4260564140u,
11287308018483u, 4262383425u,
112881374752558u, 3431057723u,
112891572637805u, 383233885u,
112903188015819u, 4051263539u,
11291233319221u, 3794788167u,
112922017406667u, 919677938u,
112934074952232u, 1683612329u,
112944213676186u, 327142514u,
112953032591014u, 4204155962u,
11296206775997u, 2283918569u,
112972395147154u, 3427505379u,
112982211319468u, 4153726847u,
112992217060665u, 350160869u,
113002493667051u, 1648200185u,
113013441709766u, 1387233546u,
11302140980u, 1891558063u,
11303760080239u, 2088061981u,
113041580964938u, 740563169u,
11305422986366u, 330624974u,
113064264507722u, 150928357u,
113072738323042u, 2948665536u,
11308918718096u, 376390582u,
113093966098971u, 717653678u,
113103219466255u, 3799363969u,
113113424344721u, 3187805406u,
11312375347278u, 3490350144u,
113131992212097u, 2263421398u,
113143855037968u, 1928519266u,
113153866327955u, 1129127000u,
113161782515131u, 2746577402u,
113173059200728u, 2108753646u,
113182738070963u, 1336849395u,
113191705302106u, 768287270u,
113201343511943u, 2247006571u,
113211956142255u, 1780259453u,
113223475618043u, 212490675u,
11323622521957u, 917121602u,
113241852992332u, 1267987847u,
113253170016833u, 2549835613u,
113263299763344u, 2864033668u,
113273378768767u, 1236609378u,
113284169365948u, 3738062408u,
113292661022773u, 2006922227u,
113302760592161u, 3828932355u,
113312636387819u, 2616619070u,
113321237256330u, 3449066284u,
113332871755260u, 3729280948u,
113343862686086u, 431292293u,
113353285899651u, 786322314u,
113362531158535u, 724901242u,
113372377363130u, 1415970351u,
113381244759631u, 3263135197u,
11339965248856u, 174024139u,
113402297418515u, 2954777083u,
11341987586766u, 3206261120u,
113424059515114u, 3903854066u,
113431931934525u, 2287507921u,
113441827135136u, 1781944746u,
11345574617451u, 2299034788u,
113462650140034u, 4081586725u,
113472482286699u, 1109175923u,
11348458483596u, 618705848u,
113494059852729u, 1813855658u,
113504190721328u, 1129462471u,
113514089998050u, 3575732749u,
113522375584220u, 1037031473u,
113531623777358u, 3389003793u,
11354546597541u, 352770237u,
113551383747654u, 3122687303u,
113561646071378u, 1164309901u,
11357290870767u, 830691298u,
11358929335420u, 3193251135u,
11359989577914u, 3626554867u,
11360591974737u, 3996958215u,
113613163711272u, 3071568023u,
113621516846461u, 3656006011u,
113632698625268u, 2510865430u,
11364340274176u, 1167681812u,
113653698796465u, 3155218919u,
113664102288238u, 1673474350u,
113673069708839u, 2704165015u,
113681237411891u, 1854985978u,
113693646837503u, 3625406022u,
11370921552000u, 1712976649u,
113713939149151u, 878608872u,
113723406359248u, 1068844551u,
113731834682077u, 4155949943u,
113742437686324u, 3163786257u,
113752645117577u, 1988168803u,
11376747285578u, 1626463554u,
113771235300371u, 1256485167u,
113781914142538u, 4141546431u,
113793838102563u, 582664250u,
113801883344352u, 2083771672u,
113812611657933u, 2139079047u,
113822250573853u, 804336148u,
113833066325351u, 2770847216u,
113844275641370u, 1455750577u,
113853346357270u, 1674051445u,
11386601221482u, 3992583643u,
113871402445097u, 3622527604u,
113882509017299u, 2966108111u,
113892557027816u, 900741486u,
113901790771021u, 2912643797u,
113912631381069u, 4014551783u,
1139290375300u, 300318232u,
113933269968032u, 2679371729u,
113942664752123u, 3517585534u,
113953253901179u, 542270815u,
113961188641600u, 365479232u,
113972210121140u, 760762191u,
113981273768482u, 1216399252u,
113993484324231u, 4287337666u,
1140016322182u, 643179562u,
11401325675502u, 3652676161u,
114023120716054u, 3330259752u,
114031011990087u, 2990167340u,
114041097584090u, 3262252593u,
114051829409951u, 3665087267u,
114061214854475u, 2134299399u,
114073704419305u, 411263051u,
114081625446136u, 549838529u,
114094283196353u, 1342880802u,
114103460621305u, 1967599860u,
114114282843369u, 1275671016u,
114122544665755u, 853593042u,
11413901109753u, 2682611693u,
11414110631633u, 797487791u,
114151472073141u, 850464484u,
11416797089608u, 3286110054u,
11417350397471u, 2775631060u,
11418366448238u, 3842907484u,
114192219863904u, 3623364733u,
114201850985302u, 4009616991u,
11421294963924u, 3693536939u,
114223061255808u, 1615375832u,
114231920066675u, 4113028420u,
114244032223840u, 2318423400u,
114252701956286u, 4145497671u,
114263991532344u, 2536338351u,
114271679099863u, 1728968857u,
11428449740816u, 2686506989u,
11429685242457u, 97590863u,
114303258354115u, 1502282913u,
114311235084019u, 2151665147u,
11432528459289u, 231097464u,
114332477280726u, 3651607391u,
114342091754612u, 1178454681u,
11435980597335u, 1604483865u,
114361842333726u, 4146839064u,
114373213794286u, 2601416506u,
11438754220096u, 3571436033u,
11439488595746u, 1448097974u,
114404004834921u, 238887261u,
114413320337489u, 1416989070u,
114422928916831u, 4093725287u,
11443186020771u, 2367569534u,
114443046087671u, 4090084518u,
114453548184546u, 679517009u,
114461962659444u, 3539886328u,
114474192003933u, 1678423485u,
114483827951761u, 3086277222u,
114492144472852u, 1390394371u,
114502976322029u, 1574517163u,
114513553313841u, 119173722u,
114521702434637u, 1766260771u,
114533629581771u, 1407497759u,
11454895654784u, 751439914u,
114554008409498u, 215917713u,
114561482103833u, 695551833u,
114571288382231u, 2656990891u,
114582581779077u, 1570750352u,
114593710689053u, 1741390464u,
114602666411616u, 3533987737u,
114614289478316u, 3576119563u,
114624118694920u, 108199666u,
114633869794273u, 963183826u,
114642081410737u, 3796810515u,
11465791123882u, 2525792704u,
114661036883117u, 136547246u,
11467875691100u, 2592925324u,
11468614302599u, 3013176417u,
114692689342539u, 427154472u,
11470532957601u, 1228758574u,
114711898117151u, 1181643858u,
114721908591042u, 1464255968u,
11473446980910u, 2984611177u,
1147458509511u, 1046943619u,
114753508927906u, 2001585786u,
114762544767379u, 1525438381u,
11477552181222u, 1959725830u,
11478879448844u, 1348536411u,
114794242243590u, 2861338018u,
114801082052441u, 1034351453u,
11481601175800u, 764077711u,
11482530635011u, 3785343245u,
114832178026726u, 117256687u,
114842378297261u, 457568934u,
1148576438221u, 4104954272u,
11486956793873u, 3783168634u,
114872485968477u, 2381948487u,
114884226929450u, 3148473363u,
114892518273601u, 3569490233u,
11490879369091u, 2180270337u,
114913674375989u, 1387729170u,
11492977997984u, 4270646856u,
11493568650985u, 951677556u,
114944213877384u, 2721005055u,
114951073364549u, 2563403831u,
114961678669911u, 66786703u,
114972273631661u, 1149351924u,
114983651298990u, 1581883443u,
11499246723096u, 1895026827u,
115003810605772u, 3711056516u,
115014058833288u, 2193790614u,
115022080120290u, 3638638708u,
115032915672708u, 2263003308u,
115042361934197u, 4136767460u,
115051976115991u, 3448840877u,
115062019238520u, 225333538u,
11507874340815u, 2976159827u,
115081555273378u, 3797521928u,
115091942347150u, 3262952567u,
11510435997738u, 340403353u,
115112817830907u, 2078619498u,
11512749534111u, 1178073973u,
11513894654712u, 3361226032u,
11514841092198u, 3288261538u,
115151696412169u, 1496966875u,
11516697501571u, 1059158875u,
115173739946319u, 2481012988u,
11518568983526u, 114945840u,
115191559249010u, 2218244008u,
115202841706923u, 1632780103u,
115214020169654u, 2087949619u,
115222438736103u, 24032648u,
11523833416317u, 3787017905u,
115242373238993u, 2575395164u,
115253434544481u, 3228481067u,
115262542976862u, 2971726178u,
115272880371864u, 3642087909u,
115282407477975u, 2239080836u,
115291043714217u, 3894199764u,
115302235879182u, 203853421u,
115312933669448u, 2504940536u,
11532834683330u, 425935223u,
115333560796393u, 3565833278u,
115341668000829u, 3683399154u,
115353414330886u, 1748785729u,
115361023171602u, 580966986u,
115372531038985u, 3227325488u,
115382657385925u, 2124704694u,
11539233442446u, 1107045577u,
115403407293834u, 552770757u,
115413899097693u, 1067532701u,
11542115667924u, 1406028344u,
115431707768231u, 3724015962u,
115442419657149u, 18613994u,
115452532882091u, 3476683808u,
115461560838678u, 811220224u,
11547895961699u, 3762914298u,
115481328752423u, 1844996900u,
115491420427894u, 1848067707u,
115501210281744u, 904215228u,
115514055325594u, 1118521573u,
115522496554183u, 2579259919u,
115533996647489u, 3657647605u,
11554325254059u, 3136157065u,
115553951522674u, 4052925250u,
115563341068436u, 2287683323u,
115571313073005u, 126005630u,
115582505120084u, 1194725057u,
11559853746559u, 3555092974u,
115602689238752u, 49515858u,
115611244776042u, 1069300695u,
1156261073168u, 1010661841u,
115631269521335u, 1902040126u,
11564990632502u, 2378708922u,
115653858321250u, 1400735275u,
115662974699176u, 2771676666u,
11567170995186u, 2877798589u,
11568545726212u, 2225229957u,
115691086473152u, 3454177594u,
115703859483262u, 1499729584u,
115712088002891u, 2883475137u,
115723222194252u, 4144472319u,
115732212229854u, 4146740722u,
11574567988835u, 1051332394u,
115753932046135u, 542648229u,
115763017852446u, 1277887997u,
11577162888005u, 1669710469u,
115781492500905u, 553041029u,
115791434876932u, 533989516u,
115803817492747u, 584127807u,
115814147115982u, 2993670925u,
115824020312558u, 710021255u,
115833509733475u, 3587959456u,
115842088550465u, 1745399498u,
115852952242967u, 1259815443u,
11586869648362u, 1404723176u,
115873947542735u, 1334333531u,
115883873471582u, 229399758u,
1158959634866u, 3239516985u,
115903844250972u, 1275954779u,
115911385684948u, 2243700741u,
115922512155003u, 1685649437u,
11593639306006u, 2524620206u,
11594955360345u, 1646776457u,
11595576786501u, 655707039u,
115962864351838u, 3736264674u,
11597655621239u, 362070173u,
115981200907897u, 2384379464u,
1159915823708u, 206117476u,
116003652870937u, 122927134u,
116011193310960u, 1093099415u,
116023696538026u, 4112584792u,
116031834541277u, 845639252u,
116042069527017u, 547588820u,
116054178147211u, 2827259351u,
116061764455305u, 3312003602u,
11607940846775u, 1054995047u,
116082976960697u, 1934305529u,
116093095615046u, 3354962706u,
116102199137382u, 1005722394u,
116111875867180u, 2064356511u,
116123363633633u, 2688499147u,
116134019734130u, 3096333006u,
116142069509024u, 2906358341u,
116153247463123u, 4191788132u,
116162232866485u, 1456016086u,
116171422674894u, 867282151u,
116181851386407u, 1268304058u,
116191612503136u, 1739843072u,
11620134947567u, 2978775774u,
116212051592101u, 1017127033u,
116221284167756u, 1090844589u,
11623831688783u, 2079216362u,
116242079309682u, 1950585801u,
116251626991196u, 3644714163u,
116263678110059u, 898470030u,
116271117570988u, 2517572125u,
116283916646913u, 3182422972u,
116293630426828u, 969847973u,
116302835126238u, 53541366u,
116313427164640u, 3463937250u,
116323044785046u, 897322257u,
11633103038235u, 3804506837u,
116343443872170u, 4185408854u,
116352557463241u, 4080940424u,
116363669923099u, 2789619871u,
116372048168570u, 2429169982u,
116383174690447u, 2513494106u,
116393099587829u, 2627855577u,
116401213061732u, 3143736628u,
116413482268149u, 1250714337u,
116423553412672u, 2689632914u,
1164331648125u, 3872383625u,
116441565760579u, 36665130u,
116451282106920u, 359361724u,
11646751041229u, 2257179590u,
116472915361862u, 280819225u,
11648954406473u, 4101682199u,
116492907818413u, 4254297769u,
116503493178615u, 3755944354u,
116513539557658u, 3330196096u,
116524043533423u, 1134196225u,
116534177134659u, 127246419u,
116544213770762u, 1978302978u,
116552442615581u, 923049607u,
116561004426206u, 782768297u,
116572702745496u, 1880389457u,
116582410586681u, 1430106871u,
116594103323427u, 3168399477u,
11660201787012u, 3105353527u,
116613716682375u, 3616334719u,
116623413209549u, 656672786u,
11663526032790u, 2895072131u,
116642876965944u, 182894450u,
11665456581318u, 2683752067u,
116661287916294u, 1270745752u,
116673877875910u, 3190666241u,
116683240336907u, 4024807233u,
116694227999465u, 2389301430u,
116701681224377u, 1576191191u,
116713599250276u, 2381111980u,
116723995044500u, 995595530u,
116733495321877u, 3956024585u,
116741611608524u, 3815677453u,
116751520987487u, 3669102590u,
116762062334396u, 1656117707u,
116775457134u, 3234118251u,
116784242065111u, 596879987u,
11679470187419u, 2688566989u,
116803259870297u, 660100446u,
116811042378442u, 2206034096u,
11682442236198u, 2542452448u,
11683493137955u, 392411099u,
116843111186954u, 438250493u,
11685947967568u, 1234595917u,
116864230082284u, 2762976773u,
11687421203727u, 3728409592u,
116882870085764u, 1455086530u,
116892762099647u, 4011882747u,
116901785430706u, 3684427488u,
116911215981925u, 3227517889u,
116923269061963u, 4037515364u,
116931749401388u, 2167451566u,
116943168911474u, 4255057396u,
116952026092260u, 1736192508u,
116964123254745u, 2319366806u,
116973909727042u, 3114708966u,
116981938800693u, 680793595u,
116993933041672u, 616863613u,
117001525265867u, 2808224480u,
117012122290603u, 1211197714u,
117021186177814u, 2395325006u,
117033520488321u, 3979192396u,
117043540779343u, 4192918639u,
117051763872074u, 3402419930u,
117062736030448u, 1120335563u,
117071698949078u, 3993310631u,
117082947659998u, 1461045789u,
117091966048551u, 2228221363u,
11710597941119u, 3498018399u,
117111441110751u, 2229999711u,
11712393987327u, 454500547u,
117131222959566u, 567151340u,
117142496952483u, 1708770195u,
117153774764786u, 1492844524u,
117163308300614u, 805568076u,
117174068812294u, 3404648243u,
11718868414882u, 177406999u,
117191608110313u, 642061169u,
117202093999089u, 222470301u,
117211027515771u, 3131251981u,
117222851936150u, 4272755262u,
117232763002551u, 1881527822u,
117241532845092u, 709643652u,
11725682573592u, 1244104217u,
11726440905170u, 1111321746u,
11727796769556u, 2500467040u,
117283002618826u, 1112998535u,
117291188525643u, 4212674512u,
117301780193104u, 1243644607u,
117313691719535u, 2958853053u,
117322813437721u, 4036584207u,
11733466635014u, 2277292580u,
117344082276003u, 1030800045u,
117351899531424u, 609466946u,
117361750863246u, 379050598u,
117373576413281u, 731493104u,
117382707384133u, 2289193651u,
11739132259176u, 4115195437u,
117401769890695u, 2715470335u,
117413348954692u, 2166575624u,
117421819263183u, 2028531518u,
117432154809766u, 3672399742u,
117441142139448u, 88299682u,
1174576727603u, 4198182186u,
117462304993586u, 1666387627u,
117472488475423u, 3832777692u,
11748284366017u, 3359785538u,
117493469807328u, 2926494787u,
117501914195188u, 1134129972u,
117513829072836u, 2493478921u,
117523738499303u, 3311304980u,
11753726951526u, 911080963u,
11754932916545u, 2235559063u,
117552909742396u, 1765719309u,
11756465269850u, 3803621553u,
117571456588655u, 508290328u,
117581490719640u, 3356513470u,
117592262196163u, 1451774941u,
117602908490783u, 251085588u,
11761830410677u, 3172220325u,
117624039692645u, 1383603170u,
117633897208579u, 1940535730u,
11764151909546u, 2384458112u,
11765};
11766
11767// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
11768bool Test(int offset, int len = 0) {
11769#undef Check
11770#undef IsAlive
11771
11772#define Check(x) do { \
11773 const uint32_t actual = (x), e = expected[index++]; \
11774 bool ok = actual == e; \
11775 if (!ok) { \
11776 cerr << "expected " << hex << e << " but got " << actual << endl; \
11777 ++errors; \
11778 } \
11779 assert(ok); \
11780} while (0)
11781
11782#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
11783
11784 // After the following line is where the uses of "Check" and such will go.
11785 static int index = 0;
11786if (offset == -1) { int alive = 0; { uint64_t h = farmhashxo::Hash64WithSeeds(data, len++, SEED0, SEED1); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64WithSeed(data, len++, SEED); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } { uint64_t h = farmhashxo::Hash64(data, len++); IsAlive(h >> 32); IsAlive((h << 32) >> 32); } len -= 3; return alive > 0; }
11787{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
11788{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
11789{ uint64_t h = farmhashxo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
11790
11791 return true;
11792#undef Check
11793#undef IsAlive
11794}
11795
11796int RunTest() {
11797 Setup();
11798 int i = 0;
11799 cout << "Running farmhashxoTest";
11800 if (!Test(-1)) {
11801 cout << "... Unavailable\n";
11802 return NoteErrors();
11803 }
11804 // Good. The function is attempting to hash, so run the full test.
11805 int errors_prior_to_test = errors;
11806 for ( ; i < kTestSize - 1; i++) {
11807 Test(i * i, i);
11808 }
11809 for ( ; i < kDataSize; i += i / 7) {
11810 Test(0, i);
11811 }
11812 Test(0, kDataSize);
11813 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
11814 return NoteErrors();
11815}
11816
11817#else
11818
11819// After the following line is where the code to print hash codes will go.
11820void Dump(int offset, int len) {
11821{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11822{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11823{ uint64_t h = farmhashxo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11824}
11825
11826#endif
11827
11828#undef SEED
11829#undef SEED1
11830#undef SEED0
11831
11832} // namespace farmhashxoTest
11833
11834#if TESTING
11835
11836static int farmhashxoTestResult = farmhashxoTest::RunTest();
11837
11838#else
11839int main(int argc, char** argv) {
11840 Setup();
11841 cout << "uint32_t expected[] = {\n";
11842 int i = 0;
11843 for ( ; i < kTestSize - 1; i++) {
11844 farmhashxoTest::Dump(i * i, i);
11845 }
11846 for ( ; i < kDataSize; i += i / 7) {
11847 farmhashxoTest::Dump(0, i);
11848 }
11849 farmhashxoTest::Dump(0, kDataSize);
11850 cout << "};\n";
11851}
11852#endif
11853
11854#endif // FARMHASHSELFTEST
11855