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 _WIN32
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__) || defined(__DragonFly__)
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#elif defined(__HAIKU__)
169
170#define _BSD_SOURCE
171#include <bsd/endian.h>
172#undef bswap_32
173#undef bswap_64
174#define bswap_32(x) bswap32(x)
175#define bswap_64(x) bswap64(x)
176
177#else
178
179#undef bswap_32
180#undef bswap_64
181#undef _BYTESWAP_H
182#include <byteswap.h>
183
184#endif
185
186#ifdef WORDS_BIGENDIAN
187#define FARMHASH_BIG_ENDIAN 1
188#endif
189
190#endif
191
192#ifdef FARMHASH_BIG_ENDIAN
193#define uint32_in_expected_order(x) (bswap_32(x))
194#define uint64_in_expected_order(x) (bswap_64(x))
195#else
196#define uint32_in_expected_order(x) (x)
197#define uint64_in_expected_order(x) (x)
198#endif
199
200namespace NAMESPACE_FOR_HASH_FUNCTIONS {
201
202STATIC_INLINE uint64_t Fetch64(const char *p) {
203 uint64_t result;
204 memcpy(&result, p, sizeof(result));
205 return uint64_in_expected_order(result);
206}
207
208STATIC_INLINE uint32_t Fetch32(const char *p) {
209 uint32_t result;
210 memcpy(&result, p, sizeof(result));
211 return uint32_in_expected_order(result);
212}
213
214STATIC_INLINE uint32_t Bswap32(uint32_t val) { return bswap_32(val); }
215STATIC_INLINE uint64_t Bswap64(uint64_t val) { return bswap_64(val); }
216
217// FARMHASH PORTABILITY LAYER: bitwise rot
218
219STATIC_INLINE uint32_t BasicRotate32(uint32_t val, int shift) {
220 // Avoid shifting by 32: doing so yields an undefined result.
221 return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
222}
223
224STATIC_INLINE uint64_t BasicRotate64(uint64_t val, int shift) {
225 // Avoid shifting by 64: doing so yields an undefined result.
226 return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
227}
228
229#if defined(_WIN32) && defined(FARMHASH_ROTR)
230
231STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
232 return sizeof(unsigned long) == sizeof(val) ?
233 _lrotr(val, shift) :
234 BasicRotate32(val, shift);
235}
236
237STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
238 return sizeof(unsigned long) == sizeof(val) ?
239 _lrotr(val, shift) :
240 BasicRotate64(val, shift);
241}
242
243#else
244
245STATIC_INLINE uint32_t Rotate32(uint32_t val, int shift) {
246 return BasicRotate32(val, shift);
247}
248STATIC_INLINE uint64_t Rotate64(uint64_t val, int shift) {
249 return BasicRotate64(val, shift);
250}
251
252#endif
253
254} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
255
256// FARMHASH PORTABILITY LAYER: debug mode or max speed?
257// One may use -DFARMHASH_DEBUG=1 or -DFARMHASH_DEBUG=0 to force the issue.
258
259#if !defined(FARMHASH_DEBUG) && (!defined(NDEBUG) || defined(_DEBUG))
260#define FARMHASH_DEBUG 1
261#endif
262
263#undef debug_mode
264#if FARMHASH_DEBUG
265#define debug_mode 1
266#else
267#define debug_mode 0
268#endif
269
270// PLATFORM-SPECIFIC FUNCTIONS AND MACROS
271
272#undef x86_64
273#if defined (__x86_64) || defined (__x86_64__)
274#define x86_64 1
275#else
276#define x86_64 0
277#endif
278
279#undef x86
280#if defined(__i386__) || defined(__i386) || defined(__X86__)
281#define x86 1
282#else
283#define x86 x86_64
284#endif
285
286#if !defined(is_64bit)
287#define is_64bit (x86_64 || (sizeof(void*) == 8))
288#endif
289
290#undef can_use_ssse3
291#if defined(__SSSE3__) || defined(FARMHASH_ASSUME_SSSE3)
292
293#include <immintrin.h>
294#define can_use_ssse3 1
295// Now we can use _mm_hsub_epi16 and so on.
296
297#else
298#define can_use_ssse3 0
299#endif
300
301#undef can_use_sse41
302#if defined(__SSE4_1__) || defined(FARMHASH_ASSUME_SSE41)
303
304#include <immintrin.h>
305#define can_use_sse41 1
306// Now we can use _mm_insert_epi64 and so on.
307
308#else
309#define can_use_sse41 0
310#endif
311
312#undef can_use_sse42
313#if defined(__SSE4_2__) || defined(FARMHASH_ASSUME_SSE42)
314
315#include <nmmintrin.h>
316#define can_use_sse42 1
317// Now we can use _mm_crc32_u{32,16,8}. And on 64-bit platforms, _mm_crc32_u64.
318
319#else
320#define can_use_sse42 0
321#endif
322
323#undef can_use_aesni
324#if defined(__AES__) || defined(FARMHASH_ASSUME_AESNI)
325
326#include <wmmintrin.h>
327#define can_use_aesni 1
328// Now we can use _mm_aesimc_si128 and so on.
329
330#else
331#define can_use_aesni 0
332#endif
333
334#undef can_use_avx
335#if defined(__AVX__) || defined(FARMHASH_ASSUME_AVX)
336
337#include <immintrin.h>
338#define can_use_avx 1
339
340#else
341#define can_use_avx 0
342#endif
343
344#if can_use_ssse3 || can_use_sse41 || can_use_sse42 || can_use_aesni || can_use_avx
345STATIC_INLINE __m128i Fetch128(const char* s) {
346 return _mm_loadu_si128(reinterpret_cast<const __m128i*>(s));
347}
348#endif
349// Building blocks for hash functions
350
351// std::swap() was in <algorithm> but is in <utility> from C++11 on.
352#if !FARMHASH_CAN_USE_CXX11
353#include <algorithm>
354#endif
355
356#undef PERMUTE3
357#define PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0)
358
359namespace NAMESPACE_FOR_HASH_FUNCTIONS {
360
361// Some primes between 2^63 and 2^64 for various uses.
362static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
363static const uint64_t k1 = 0xb492b66fbe98f273ULL;
364static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
365
366// Magic numbers for 32-bit hashing. Copied from Murmur3.
367static const uint32_t c1 = 0xcc9e2d51;
368static const uint32_t c2 = 0x1b873593;
369
370// A 32-bit to 32-bit integer hash copied from Murmur3.
371STATIC_INLINE uint32_t fmix(uint32_t h)
372{
373 h ^= h >> 16;
374 h *= 0x85ebca6b;
375 h ^= h >> 13;
376 h *= 0xc2b2ae35;
377 h ^= h >> 16;
378 return h;
379}
380
381STATIC_INLINE uint32_t Mur(uint32_t a, uint32_t h) {
382 // Helper from Murmur3 for combining two 32-bit values.
383 a *= c1;
384 a = Rotate32(a, 17);
385 a *= c2;
386 h ^= a;
387 h = Rotate32(h, 19);
388 return h * 5 + 0xe6546b64;
389}
390
391template <typename T> STATIC_INLINE T DebugTweak(T x) {
392 if (debug_mode) {
393 if (sizeof(x) == 4) {
394 x = ~Bswap32(x * c1);
395 } else {
396 x = ~Bswap64(x * k1);
397 }
398 }
399 return x;
400}
401
402template <> uint128_t DebugTweak(uint128_t x) {
403 if (debug_mode) {
404 uint64_t y = DebugTweak(Uint128Low64(x));
405 uint64_t z = DebugTweak(Uint128High64(x));
406 y += z;
407 z += y;
408 x = Uint128(y, z * k1);
409 }
410 return x;
411}
412
413} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
414
415using namespace std;
416using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
417namespace farmhashna {
418#undef Fetch
419#define Fetch Fetch64
420
421#undef Rotate
422#define Rotate Rotate64
423
424#undef Bswap
425#define Bswap Bswap64
426
427STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
428 return val ^ (val >> 47);
429}
430
431STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
432 return Hash128to64(Uint128(u, v));
433}
434
435STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
436 // Murmur-inspired hashing.
437 uint64_t a = (u ^ v) * mul;
438 a ^= (a >> 47);
439 uint64_t b = (v ^ a) * mul;
440 b ^= (b >> 47);
441 b *= mul;
442 return b;
443}
444
445STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
446 if (len >= 8) {
447 uint64_t mul = k2 + len * 2;
448 uint64_t a = Fetch(s) + k2;
449 uint64_t b = Fetch(s + len - 8);
450 uint64_t c = Rotate(b, 37) * mul + a;
451 uint64_t d = (Rotate(a, 25) + b) * mul;
452 return HashLen16(c, d, mul);
453 }
454 if (len >= 4) {
455 uint64_t mul = k2 + len * 2;
456 uint64_t a = Fetch32(s);
457 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
458 }
459 if (len > 0) {
460 uint8_t a = s[0];
461 uint8_t b = s[len >> 1];
462 uint8_t c = s[len - 1];
463 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
464 uint32_t z = len + (static_cast<uint32_t>(c) << 2);
465 return ShiftMix(y * k2 ^ z * k0) * k2;
466 }
467 return k2;
468}
469
470// This probably works well for 16-byte strings as well, but it may be overkill
471// in that case.
472STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
473 uint64_t mul = k2 + len * 2;
474 uint64_t a = Fetch(s) * k1;
475 uint64_t b = Fetch(s + 8);
476 uint64_t c = Fetch(s + len - 8) * mul;
477 uint64_t d = Fetch(s + len - 16) * k2;
478 return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
479 a + Rotate(b + k2, 18) + c, mul);
480}
481
482// Return a 16-byte hash for 48 bytes. Quick and dirty.
483// Callers do best to use "random-looking" values for a and b.
484STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
485 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
486 a += w;
487 b = Rotate(b + a + z, 21);
488 uint64_t c = a;
489 a += x;
490 a += y;
491 b += Rotate(a, 44);
492 return make_pair(a + z, b + c);
493}
494
495// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
496STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
497 const char* s, uint64_t a, uint64_t b) {
498 return WeakHashLen32WithSeeds(Fetch(s),
499 Fetch(s + 8),
500 Fetch(s + 16),
501 Fetch(s + 24),
502 a,
503 b);
504}
505
506// Return an 8-byte hash for 33 to 64 bytes.
507STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
508 uint64_t mul = k2 + len * 2;
509 uint64_t a = Fetch(s) * k2;
510 uint64_t b = Fetch(s + 8);
511 uint64_t c = Fetch(s + len - 8) * mul;
512 uint64_t d = Fetch(s + len - 16) * k2;
513 uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
514 uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
515 uint64_t e = Fetch(s + 16) * mul;
516 uint64_t f = Fetch(s + 24);
517 uint64_t g = (y + Fetch(s + len - 32)) * mul;
518 uint64_t h = (z + Fetch(s + len - 24)) * mul;
519 return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
520 e + Rotate(f + a, 18) + g, mul);
521}
522
523uint64_t Hash64(const char *s, size_t len) {
524 const uint64_t seed = 81;
525 if (len <= 32) {
526 if (len <= 16) {
527 return HashLen0to16(s, len);
528 } else {
529 return HashLen17to32(s, len);
530 }
531 } else if (len <= 64) {
532 return HashLen33to64(s, len);
533 }
534
535 // For strings over 64 bytes we loop. Internal state consists of
536 // 56 bytes: v, w, x, y, and z.
537 uint64_t x = seed;
538 uint64_t y = seed * k1 + 113;
539 uint64_t z = ShiftMix(y * k2 + 113) * k2;
540 pair<uint64_t, uint64_t> v = make_pair(0, 0);
541 pair<uint64_t, uint64_t> w = make_pair(0, 0);
542 x = x * k2 + Fetch(s);
543
544 // Set end so that after the loop we have 1 to 64 bytes left to process.
545 const char* end = s + ((len - 1) / 64) * 64;
546 const char* last64 = end + ((len - 1) & 63) - 63;
547 assert(s + len - 64 == last64);
548 do {
549 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
550 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
551 x ^= w.second;
552 y += v.first + Fetch(s + 40);
553 z = Rotate(z + w.first, 33) * k1;
554 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
555 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
556 std::swap(z, x);
557 s += 64;
558 } while (s != end);
559 uint64_t mul = k1 + ((z & 0xff) << 1);
560 // Make s point to the last 64 bytes of input.
561 s = last64;
562 w.first += ((len - 1) & 63);
563 v.first += w.first;
564 w.first += v.first;
565 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
566 y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
567 x ^= w.second * 9;
568 y += v.first * 9 + Fetch(s + 40);
569 z = Rotate(z + w.first, 33) * mul;
570 v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
571 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
572 std::swap(z, x);
573 return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
574 HashLen16(v.second, w.second, mul) + x,
575 mul);
576}
577
578uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
579
580uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
581 return Hash64WithSeeds(s, len, k2, seed);
582}
583
584uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
585 return HashLen16(Hash64(s, len) - seed0, seed1);
586}
587} // namespace farmhashna
588namespace farmhashuo {
589#undef Fetch
590#define Fetch Fetch64
591
592#undef Rotate
593#define Rotate Rotate64
594
595STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
596 uint64_t a = (x ^ y) * mul;
597 a ^= (a >> 47);
598 uint64_t b = (y ^ a) * mul;
599 return Rotate(b, r) * mul;
600}
601
602uint64_t Hash64WithSeeds(const char *s, size_t len,
603 uint64_t seed0, uint64_t seed1) {
604 if (len <= 64) {
605 return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
606 }
607
608 // For strings over 64 bytes we loop. Internal state consists of
609 // 64 bytes: u, v, w, x, y, and z.
610 uint64_t x = seed0;
611 uint64_t y = seed1 * k2 + 113;
612 uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
613 pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
614 pair<uint64_t, uint64_t> w = make_pair(0, 0);
615 uint64_t u = x - z;
616 x *= k2;
617 uint64_t mul = k2 + (u & 0x82);
618
619 // Set end so that after the loop we have 1 to 64 bytes left to process.
620 const char* end = s + ((len - 1) / 64) * 64;
621 const char* last64 = end + ((len - 1) & 63) - 63;
622 assert(s + len - 64 == last64);
623 do {
624 uint64_t a0 = Fetch(s);
625 uint64_t a1 = Fetch(s + 8);
626 uint64_t a2 = Fetch(s + 16);
627 uint64_t a3 = Fetch(s + 24);
628 uint64_t a4 = Fetch(s + 32);
629 uint64_t a5 = Fetch(s + 40);
630 uint64_t a6 = Fetch(s + 48);
631 uint64_t a7 = Fetch(s + 56);
632 x += a0 + a1;
633 y += a2;
634 z += a3;
635 v.first += a4;
636 v.second += a5 + a1;
637 w.first += a6;
638 w.second += a7;
639
640 x = Rotate(x, 26);
641 x *= 9;
642 y = Rotate(y, 29);
643 z *= mul;
644 v.first = Rotate(v.first, 33);
645 v.second = Rotate(v.second, 30);
646 w.first ^= x;
647 w.first *= 9;
648 z = Rotate(z, 32);
649 z += w.second;
650 w.second += z;
651 z *= 9;
652 std::swap(u, y);
653
654 z += a0 + a6;
655 v.first += a2;
656 v.second += a3;
657 w.first += a4;
658 w.second += a5 + a6;
659 x += a1;
660 y += a7;
661
662 y += v.first;
663 v.first += x - y;
664 v.second += w.first;
665 w.first += v.second;
666 w.second += x - y;
667 x += w.second;
668 w.second = Rotate(w.second, 34);
669 std::swap(u, z);
670 s += 64;
671 } while (s != end);
672 // Make s point to the last 64 bytes of input.
673 s = last64;
674 u *= 9;
675 v.second = Rotate(v.second, 28);
676 v.first = Rotate(v.first, 20);
677 w.first += ((len - 1) & 63);
678 u += y;
679 y += u;
680 x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
681 y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
682 x ^= w.second * 9;
683 y += v.first + Fetch(s + 40);
684 z = Rotate(z + w.first, 33) * mul;
685 v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
686 w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
687 return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
688 H(v.second + y, w.second + z, k2, 30) ^ x,
689 k2,
690 31);
691}
692
693uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
694 return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
695 Hash64WithSeeds(s, len, 0, seed);
696}
697
698uint64_t Hash64(const char *s, size_t len) {
699 return len <= 64 ? farmhashna::Hash64(s, len) :
700 Hash64WithSeeds(s, len, 81, 0);
701}
702} // namespace farmhashuo
703namespace farmhashxo {
704#undef Fetch
705#define Fetch Fetch64
706
707#undef Rotate
708#define Rotate Rotate64
709
710STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
711 uint64_t seed0 = 0, uint64_t seed1 = 0) {
712 uint64_t a = Fetch(s) * k1;
713 uint64_t b = Fetch(s + 8);
714 uint64_t c = Fetch(s + len - 8) * mul;
715 uint64_t d = Fetch(s + len - 16) * k2;
716 uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
717 uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
718 a = farmhashna::ShiftMix((u ^ v) * mul);
719 b = farmhashna::ShiftMix((v ^ a) * mul);
720 return b;
721}
722
723// Return an 8-byte hash for 33 to 64 bytes.
724STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
725 uint64_t mul0 = k2 - 30;
726 uint64_t mul1 = k2 - 30 + 2 * len;
727 uint64_t h0 = H32(s, 32, mul0);
728 uint64_t h1 = H32(s + len - 32, 32, mul1);
729 return ((h1 * mul1) + h0) * mul1;
730}
731
732// Return an 8-byte hash for 65 to 96 bytes.
733STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
734 uint64_t mul0 = k2 - 114;
735 uint64_t mul1 = k2 - 114 + 2 * len;
736 uint64_t h0 = H32(s, 32, mul0);
737 uint64_t h1 = H32(s + 32, 32, mul1);
738 uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
739 return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
740}
741
742uint64_t Hash64(const char *s, size_t len) {
743 if (len <= 32) {
744 if (len <= 16) {
745 return farmhashna::HashLen0to16(s, len);
746 } else {
747 return farmhashna::HashLen17to32(s, len);
748 }
749 } else if (len <= 64) {
750 return HashLen33to64(s, len);
751 } else if (len <= 96) {
752 return HashLen65to96(s, len);
753 } else if (len <= 256) {
754 return farmhashna::Hash64(s, len);
755 } else {
756 return farmhashuo::Hash64(s, len);
757 }
758}
759
760uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
761 return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
762}
763
764uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
765 return farmhashuo::Hash64WithSeed(s, len, seed);
766}
767} // namespace farmhashxo
768namespace farmhashte {
769#if !can_use_sse41 || !x86_64
770
771uint64_t Hash64(const char *s, size_t len) {
772 FARMHASH_DIE_IF_MISCONFIGURED;
773 return s == NULL ? 0 : len;
774}
775
776uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
777 FARMHASH_DIE_IF_MISCONFIGURED;
778 return seed + Hash64(s, len);
779}
780
781uint64_t Hash64WithSeeds(const char *s, size_t len,
782 uint64_t seed0, uint64_t seed1) {
783 FARMHASH_DIE_IF_MISCONFIGURED;
784 return seed0 + seed1 + Hash64(s, len);
785}
786
787#else
788
789#undef Fetch
790#define Fetch Fetch64
791
792#undef Rotate
793#define Rotate Rotate64
794
795#undef Bswap
796#define Bswap Bswap64
797
798// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
799STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
800STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
801STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
802STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
803
804// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
805// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
806STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
807 uint64_t seed0, uint64_t seed1) {
808 const __m128i kShuf =
809 _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
810 const __m128i kMult =
811 _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
812 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
813 uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
814 uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
815 __m128i d0 = _mm_cvtsi64_si128(seed0);
816 __m128i d1 = _mm_cvtsi64_si128(seed1);
817 __m128i d2 = Shuf(kShuf, d0);
818 __m128i d3 = Shuf(kShuf, d1);
819 __m128i d4 = Xor(d0, d1);
820 __m128i d5 = Xor(d1, d2);
821 __m128i d6 = Xor(d2, d4);
822 __m128i d7 = _mm_set1_epi32(seed2 >> 32);
823 __m128i d8 = Mul(kMult, d2);
824 __m128i d9 = _mm_set1_epi32(seed3 >> 32);
825 __m128i d10 = _mm_set1_epi32(seed3);
826 __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
827 const char* end = s + (n & ~static_cast<size_t>(255));
828 do {
829 __m128i z;
830 z = Fetch128(s);
831 d0 = Add(d0, z);
832 d1 = Shuf(kShuf, d1);
833 d2 = Xor(d2, d0);
834 d4 = Xor(d4, z);
835 d4 = Xor(d4, d1);
836 std::swap(d0, d6);
837 z = Fetch128(s + 16);
838 d5 = Add(d5, z);
839 d6 = Shuf(kShuf, d6);
840 d8 = Shuf(kShuf, d8);
841 d7 = Xor(d7, d5);
842 d0 = Xor(d0, z);
843 d0 = Xor(d0, d6);
844 std::swap(d5, d11);
845 z = Fetch128(s + 32);
846 d1 = Add(d1, z);
847 d2 = Shuf(kShuf, d2);
848 d4 = Shuf(kShuf, d4);
849 d5 = Xor(d5, z);
850 d5 = Xor(d5, d2);
851 std::swap(d10, d4);
852 z = Fetch128(s + 48);
853 d6 = Add(d6, z);
854 d7 = Shuf(kShuf, d7);
855 d0 = Shuf(kShuf, d0);
856 d8 = Xor(d8, d6);
857 d1 = Xor(d1, z);
858 d1 = Add(d1, d7);
859 z = Fetch128(s + 64);
860 d2 = Add(d2, z);
861 d5 = Shuf(kShuf, d5);
862 d4 = Add(d4, d2);
863 d6 = Xor(d6, z);
864 d6 = Xor(d6, d11);
865 std::swap(d8, d2);
866 z = Fetch128(s + 80);
867 d7 = Xor(d7, z);
868 d8 = Shuf(kShuf, d8);
869 d1 = Shuf(kShuf, d1);
870 d0 = Add(d0, d7);
871 d2 = Add(d2, z);
872 d2 = Add(d2, d8);
873 std::swap(d1, d7);
874 z = Fetch128(s + 96);
875 d4 = Shuf(kShuf, d4);
876 d6 = Shuf(kShuf, d6);
877 d8 = Mul(kMult, d8);
878 d5 = Xor(d5, d11);
879 d7 = Xor(d7, z);
880 d7 = Add(d7, d4);
881 std::swap(d6, d0);
882 z = Fetch128(s + 112);
883 d8 = Add(d8, z);
884 d0 = Shuf(kShuf, d0);
885 d2 = Shuf(kShuf, d2);
886 d1 = Xor(d1, d8);
887 d10 = Xor(d10, z);
888 d10 = Xor(d10, d0);
889 std::swap(d11, d5);
890 z = Fetch128(s + 128);
891 d4 = Add(d4, z);
892 d5 = Shuf(kShuf, d5);
893 d7 = Shuf(kShuf, d7);
894 d6 = Add(d6, d4);
895 d8 = Xor(d8, z);
896 d8 = Xor(d8, d5);
897 std::swap(d4, d10);
898 z = Fetch128(s + 144);
899 d0 = Add(d0, z);
900 d1 = Shuf(kShuf, d1);
901 d2 = Add(d2, d0);
902 d4 = Xor(d4, z);
903 d4 = Xor(d4, d1);
904 z = Fetch128(s + 160);
905 d5 = Add(d5, z);
906 d6 = Shuf(kShuf, d6);
907 d8 = Shuf(kShuf, d8);
908 d7 = Xor(d7, d5);
909 d0 = Xor(d0, z);
910 d0 = Xor(d0, d6);
911 std::swap(d2, d8);
912 z = Fetch128(s + 176);
913 d1 = Add(d1, z);
914 d2 = Shuf(kShuf, d2);
915 d4 = Shuf(kShuf, d4);
916 d5 = Mul(kMult, d5);
917 d5 = Xor(d5, z);
918 d5 = Xor(d5, d2);
919 std::swap(d7, d1);
920 z = Fetch128(s + 192);
921 d6 = Add(d6, z);
922 d7 = Shuf(kShuf, d7);
923 d0 = Shuf(kShuf, d0);
924 d8 = Add(d8, d6);
925 d1 = Xor(d1, z);
926 d1 = Xor(d1, d7);
927 std::swap(d0, d6);
928 z = Fetch128(s + 208);
929 d2 = Add(d2, z);
930 d5 = Shuf(kShuf, d5);
931 d4 = Xor(d4, d2);
932 d6 = Xor(d6, z);
933 d6 = Xor(d6, d9);
934 std::swap(d5, d11);
935 z = Fetch128(s + 224);
936 d7 = Add(d7, z);
937 d8 = Shuf(kShuf, d8);
938 d1 = Shuf(kShuf, d1);
939 d0 = Xor(d0, d7);
940 d2 = Xor(d2, z);
941 d2 = Xor(d2, d8);
942 std::swap(d10, d4);
943 z = Fetch128(s + 240);
944 d3 = Add(d3, z);
945 d4 = Shuf(kShuf, d4);
946 d6 = Shuf(kShuf, d6);
947 d7 = Mul(kMult, d7);
948 d5 = Add(d5, d3);
949 d7 = Xor(d7, z);
950 d7 = Xor(d7, d4);
951 std::swap(d3, d9);
952 s += 256;
953 } while (s != end);
954 d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
955 if (n % 256 != 0) {
956 d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
957 d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
958 }
959 __m128i t[8];
960 d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
961 d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
962 d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
963 d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
964 d0 = Add(d11, d0);
965 d3 = Xor(d7, d3);
966 d9 = Add(d8, d9);
967 d1 = Add(d10, d1);
968 d4 = Add(d3, d4);
969 d5 = Add(d9, d5);
970 d6 = Xor(d1, d6);
971 d2 = Add(d0, d2);
972 t[0] = d0;
973 t[1] = d3;
974 t[2] = d9;
975 t[3] = d1;
976 t[4] = d4;
977 t[5] = d5;
978 t[6] = d6;
979 t[7] = d2;
980 return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
981}
982
983uint64_t Hash64(const char *s, size_t len) {
984 // Empirically, farmhashxo seems faster until length 512.
985 return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
986}
987
988uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
989 return len >= 512 ? Hash64Long(s, len, k1, seed) :
990 farmhashxo::Hash64WithSeed(s, len, seed);
991}
992
993uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
994 return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
995 farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
996}
997
998#endif
999} // namespace farmhashte
1000namespace farmhashnt {
1001#if !can_use_sse41 || !x86_64
1002
1003uint32_t Hash32(const char *s, size_t len) {
1004 FARMHASH_DIE_IF_MISCONFIGURED;
1005 return s == NULL ? 0 : len;
1006}
1007
1008uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1009 FARMHASH_DIE_IF_MISCONFIGURED;
1010 return seed + Hash32(s, len);
1011}
1012
1013#else
1014
1015uint32_t Hash32(const char *s, size_t len) {
1016 return static_cast<uint32_t>(farmhashte::Hash64(s, len));
1017}
1018
1019uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1020 return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
1021}
1022
1023#endif
1024} // namespace farmhashnt
1025namespace farmhashmk {
1026#undef Fetch
1027#define Fetch Fetch32
1028
1029#undef Rotate
1030#define Rotate Rotate32
1031
1032#undef Bswap
1033#define Bswap Bswap32
1034
1035STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
1036 uint32_t a = Fetch(s - 4 + (len >> 1));
1037 uint32_t b = Fetch(s + 4);
1038 uint32_t c = Fetch(s + len - 8);
1039 uint32_t d = Fetch(s + (len >> 1));
1040 uint32_t e = Fetch(s);
1041 uint32_t f = Fetch(s + len - 4);
1042 uint32_t h = d * c1 + len + seed;
1043 a = Rotate(a, 12) + f;
1044 h = Mur(c, h) + a;
1045 a = Rotate(a, 3) + c;
1046 h = Mur(e, h) + a;
1047 a = Rotate(a + f, 12) + d;
1048 h = Mur(b ^ seed, h) + a;
1049 return fmix(h);
1050}
1051
1052STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
1053 uint32_t b = seed;
1054 uint32_t c = 9;
1055 for (size_t i = 0; i < len; i++) {
1056 signed char v = s[i];
1057 b = b * c1 + v;
1058 c ^= b;
1059 }
1060 return fmix(Mur(b, Mur(len, c)));
1061}
1062
1063STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
1064 uint32_t a = len, b = len * 5, c = 9, d = b + seed;
1065 a += Fetch(s);
1066 b += Fetch(s + len - 4);
1067 c += Fetch(s + ((len >> 1) & 4));
1068 return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
1069}
1070
1071uint32_t Hash32(const char *s, size_t len) {
1072 if (len <= 24) {
1073 return len <= 12 ?
1074 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1075 Hash32Len13to24(s, len);
1076 }
1077
1078 // len > 24
1079 uint32_t h = len, g = c1 * len, f = g;
1080 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1081 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1082 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1083 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1084 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1085 h ^= a0;
1086 h = Rotate(h, 19);
1087 h = h * 5 + 0xe6546b64;
1088 h ^= a2;
1089 h = Rotate(h, 19);
1090 h = h * 5 + 0xe6546b64;
1091 g ^= a1;
1092 g = Rotate(g, 19);
1093 g = g * 5 + 0xe6546b64;
1094 g ^= a3;
1095 g = Rotate(g, 19);
1096 g = g * 5 + 0xe6546b64;
1097 f += a4;
1098 f = Rotate(f, 19) + 113;
1099 size_t iters = (len - 1) / 20;
1100 do {
1101 uint32_t a = Fetch(s);
1102 uint32_t b = Fetch(s + 4);
1103 uint32_t c = Fetch(s + 8);
1104 uint32_t d = Fetch(s + 12);
1105 uint32_t e = Fetch(s + 16);
1106 h += a;
1107 g += b;
1108 f += c;
1109 h = Mur(d, h) + e;
1110 g = Mur(c, g) + a;
1111 f = Mur(b + e * c1, f) + d;
1112 f += g;
1113 g += f;
1114 s += 20;
1115 } while (--iters != 0);
1116 g = Rotate(g, 11) * c1;
1117 g = Rotate(g, 17) * c1;
1118 f = Rotate(f, 11) * c1;
1119 f = Rotate(f, 17) * c1;
1120 h = Rotate(h + g, 19);
1121 h = h * 5 + 0xe6546b64;
1122 h = Rotate(h, 17) * c1;
1123 h = Rotate(h + f, 19);
1124 h = h * 5 + 0xe6546b64;
1125 h = Rotate(h, 17) * c1;
1126 return h;
1127}
1128
1129uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1130 if (len <= 24) {
1131 if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
1132 else if (len >= 5) return Hash32Len5to12(s, len, seed);
1133 else return Hash32Len0to4(s, len, seed);
1134 }
1135 uint32_t h = Hash32Len13to24(s, 24, seed ^ len);
1136 return Mur(Hash32(s + 24, len - 24) + seed, h);
1137}
1138} // namespace farmhashmk
1139namespace farmhashsu {
1140#if !can_use_sse42 || !can_use_aesni
1141
1142uint32_t Hash32(const char *s, size_t len) {
1143 FARMHASH_DIE_IF_MISCONFIGURED;
1144 return s == NULL ? 0 : len;
1145}
1146
1147uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1148 FARMHASH_DIE_IF_MISCONFIGURED;
1149 return seed + Hash32(s, len);
1150}
1151
1152#else
1153
1154#undef Fetch
1155#define Fetch Fetch32
1156
1157#undef Rotate
1158#define Rotate Rotate32
1159
1160#undef Bswap
1161#define Bswap Bswap32
1162
1163// Helpers for data-parallel operations (4x 32-bits).
1164STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1165STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1166STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1167STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1168STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1169STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
1170 return Or(_mm_slli_epi32(x, c),
1171 _mm_srli_epi32(x, 32 - c));
1172}
1173STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
1174STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
1175STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1176 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1177}
1178
1179uint32_t Hash32(const char *s, size_t len) {
1180 const uint32_t seed = 81;
1181 if (len <= 24) {
1182 return len <= 12 ?
1183 (len <= 4 ?
1184 farmhashmk::Hash32Len0to4(s, len) :
1185 farmhashmk::Hash32Len5to12(s, len)) :
1186 farmhashmk::Hash32Len13to24(s, len);
1187 }
1188
1189 if (len < 40) {
1190 uint32_t a = len, b = seed * c2, c = a + b;
1191 a += Fetch(s + len - 4);
1192 b += Fetch(s + len - 20);
1193 c += Fetch(s + len - 16);
1194 uint32_t d = a;
1195 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1196 a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
1197 a += Fetch(s + len - 12);
1198 b += Fetch(s + len - 8);
1199 d += a;
1200 a += d;
1201 b = Mur(b, d) * c2;
1202 a = _mm_crc32_u32(a, b + c);
1203 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1204 }
1205
1206#undef Mulc1
1207#define Mulc1(x) Mul((x), cc1)
1208
1209#undef Mulc2
1210#define Mulc2(x) Mul((x), cc2)
1211
1212#undef Murk
1213#define Murk(a, h) \
1214 Add(k, \
1215 Mul5( \
1216 Rol19( \
1217 Xor( \
1218 Mulc2( \
1219 Rol17( \
1220 Mulc1(a))), \
1221 (h)))))
1222
1223 const __m128i cc1 = _mm_set1_epi32(c1);
1224 const __m128i cc2 = _mm_set1_epi32(c2);
1225 __m128i h = _mm_set1_epi32(seed);
1226 __m128i g = _mm_set1_epi32(c1 * seed);
1227 __m128i f = g;
1228 __m128i k = _mm_set1_epi32(0xe6546b64);
1229 __m128i q;
1230 if (len < 80) {
1231 __m128i a = Fetch128(s);
1232 __m128i b = Fetch128(s + 16);
1233 __m128i c = Fetch128(s + (len - 15) / 2);
1234 __m128i d = Fetch128(s + len - 32);
1235 __m128i e = Fetch128(s + len - 16);
1236 h = Add(h, a);
1237 g = Add(g, b);
1238 q = g;
1239 g = Shuffle0321(g);
1240 f = Add(f, c);
1241 __m128i be = Add(b, Mulc1(e));
1242 h = Add(h, f);
1243 f = Add(f, h);
1244 h = Add(Murk(d, h), e);
1245 k = Xor(k, _mm_shuffle_epi8(g, f));
1246 g = Add(Xor(c, g), a);
1247 f = Add(Xor(be, f), d);
1248 k = Add(k, be);
1249 k = Add(k, _mm_shuffle_epi8(f, h));
1250 f = Add(f, g);
1251 g = Add(g, f);
1252 g = Add(_mm_set1_epi32(len), Mulc1(g));
1253 } else {
1254 // len >= 80
1255 // The following is loosely modelled after farmhashmk::Hash32.
1256 size_t iters = (len - 1) / 80;
1257 len -= iters * 80;
1258
1259#undef Chunk
1260#define Chunk() do { \
1261 __m128i a = Fetch128(s); \
1262 __m128i b = Fetch128(s + 16); \
1263 __m128i c = Fetch128(s + 32); \
1264 __m128i d = Fetch128(s + 48); \
1265 __m128i e = Fetch128(s + 64); \
1266 h = Add(h, a); \
1267 g = Add(g, b); \
1268 g = Shuffle0321(g); \
1269 f = Add(f, c); \
1270 __m128i be = Add(b, Mulc1(e)); \
1271 h = Add(h, f); \
1272 f = Add(f, h); \
1273 h = Add(h, d); \
1274 q = Add(q, e); \
1275 h = Rol17(h); \
1276 h = Mulc1(h); \
1277 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1278 g = Add(Xor(c, g), a); \
1279 f = Add(Xor(be, f), d); \
1280 std::swap(f, q); \
1281 q = _mm_aesimc_si128(q); \
1282 k = Add(k, be); \
1283 k = Add(k, _mm_shuffle_epi8(f, h)); \
1284 f = Add(f, g); \
1285 g = Add(g, f); \
1286 f = Mulc1(f); \
1287} while (0)
1288
1289 q = g;
1290 while (iters-- != 0) {
1291 Chunk();
1292 s += 80;
1293 }
1294
1295 if (len != 0) {
1296 h = Add(h, _mm_set1_epi32(len));
1297 s = s + len - 80;
1298 Chunk();
1299 }
1300 }
1301
1302 g = Shuffle0321(g);
1303 k = Xor(k, g);
1304 k = Xor(k, q);
1305 h = Xor(h, q);
1306 f = Mulc1(f);
1307 k = Mulc2(k);
1308 g = Mulc1(g);
1309 h = Mulc2(h);
1310 k = Add(k, _mm_shuffle_epi8(g, f));
1311 h = Add(h, f);
1312 f = Add(f, h);
1313 g = Add(g, k);
1314 k = Add(k, g);
1315 k = Xor(k, _mm_shuffle_epi8(f, h));
1316 __m128i buf[4];
1317 buf[0] = f;
1318 buf[1] = g;
1319 buf[2] = k;
1320 buf[3] = h;
1321 s = reinterpret_cast<char*>(buf);
1322 uint32_t x = Fetch(s);
1323 uint32_t y = Fetch(s+4);
1324 uint32_t z = Fetch(s+8);
1325 x = _mm_crc32_u32(x, Fetch(s+12));
1326 y = _mm_crc32_u32(y, Fetch(s+16));
1327 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1328 x = _mm_crc32_u32(x, Fetch(s+24));
1329 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1330 uint32_t o = y;
1331 z = _mm_crc32_u32(z, Fetch(s+32));
1332 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1333 y = _mm_crc32_u32(y, Fetch(s+40));
1334 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1335 x = _mm_crc32_u32(x, Fetch(s+48));
1336 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1337 z = _mm_crc32_u32(z, Fetch(s+56));
1338 x = _mm_crc32_u32(x, Fetch(s+60));
1339 return (o - x + y - z) * c1;
1340}
1341
1342#undef Chunk
1343#undef Murk
1344#undef Mulc2
1345#undef Mulc1
1346
1347uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1348 if (len <= 24) {
1349 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1350 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1351 else return farmhashmk::Hash32Len0to4(s, len, seed);
1352 }
1353 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1354 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1355}
1356
1357#endif
1358} // namespace farmhashsu
1359namespace farmhashsa {
1360#if !can_use_sse42
1361
1362uint32_t Hash32(const char *s, size_t len) {
1363 FARMHASH_DIE_IF_MISCONFIGURED;
1364 return s == NULL ? 0 : len;
1365}
1366
1367uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1368 FARMHASH_DIE_IF_MISCONFIGURED;
1369 return seed + Hash32(s, len);
1370}
1371
1372#else
1373
1374#undef Fetch
1375#define Fetch Fetch32
1376
1377#undef Rotate
1378#define Rotate Rotate32
1379
1380#undef Bswap
1381#define Bswap Bswap32
1382
1383// Helpers for data-parallel operations (4x 32-bits).
1384STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1385STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1386STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1387STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1388STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1389STATIC_INLINE __m128i Rotate(__m128i x, int c) {
1390 return Or(_mm_slli_epi32(x, c),
1391 _mm_srli_epi32(x, 32 - c));
1392}
1393STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
1394STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
1395STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1396 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1397}
1398
1399uint32_t Hash32(const char *s, size_t len) {
1400 const uint32_t seed = 81;
1401 if (len <= 24) {
1402 return len <= 12 ?
1403 (len <= 4 ?
1404 farmhashmk::Hash32Len0to4(s, len) :
1405 farmhashmk::Hash32Len5to12(s, len)) :
1406 farmhashmk::Hash32Len13to24(s, len);
1407 }
1408
1409 if (len < 40) {
1410 uint32_t a = len, b = seed * c2, c = a + b;
1411 a += Fetch(s + len - 4);
1412 b += Fetch(s + len - 20);
1413 c += Fetch(s + len - 16);
1414 uint32_t d = a;
1415 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1416 a = Mur(a, Mur(b, Mur(c, d)));
1417 a += Fetch(s + len - 12);
1418 b += Fetch(s + len - 8);
1419 d += a;
1420 a += d;
1421 b = Mur(b, d) * c2;
1422 a = _mm_crc32_u32(a, b + c);
1423 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1424 }
1425
1426#undef Mulc1
1427#define Mulc1(x) Mul((x), cc1)
1428
1429#undef Mulc2
1430#define Mulc2(x) Mul((x), cc2)
1431
1432#undef Murk
1433#define Murk(a, h) \
1434 Add(k, \
1435 Mul5( \
1436 Rot19( \
1437 Xor( \
1438 Mulc2( \
1439 Rot17( \
1440 Mulc1(a))), \
1441 (h)))))
1442
1443 const __m128i cc1 = _mm_set1_epi32(c1);
1444 const __m128i cc2 = _mm_set1_epi32(c2);
1445 __m128i h = _mm_set1_epi32(seed);
1446 __m128i g = _mm_set1_epi32(c1 * seed);
1447 __m128i f = g;
1448 __m128i k = _mm_set1_epi32(0xe6546b64);
1449 if (len < 80) {
1450 __m128i a = Fetch128(s);
1451 __m128i b = Fetch128(s + 16);
1452 __m128i c = Fetch128(s + (len - 15) / 2);
1453 __m128i d = Fetch128(s + len - 32);
1454 __m128i e = Fetch128(s + len - 16);
1455 h = Add(h, a);
1456 g = Add(g, b);
1457 g = Shuffle0321(g);
1458 f = Add(f, c);
1459 __m128i be = Add(b, Mulc1(e));
1460 h = Add(h, f);
1461 f = Add(f, h);
1462 h = Add(Murk(d, h), e);
1463 k = Xor(k, _mm_shuffle_epi8(g, f));
1464 g = Add(Xor(c, g), a);
1465 f = Add(Xor(be, f), d);
1466 k = Add(k, be);
1467 k = Add(k, _mm_shuffle_epi8(f, h));
1468 f = Add(f, g);
1469 g = Add(g, f);
1470 g = Add(_mm_set1_epi32(len), Mulc1(g));
1471 } else {
1472 // len >= 80
1473 // The following is loosely modelled after farmhashmk::Hash32.
1474 size_t iters = (len - 1) / 80;
1475 len -= iters * 80;
1476
1477#undef Chunk
1478#define Chunk() do { \
1479 __m128i a = Fetch128(s); \
1480 __m128i b = Fetch128(s + 16); \
1481 __m128i c = Fetch128(s + 32); \
1482 __m128i d = Fetch128(s + 48); \
1483 __m128i e = Fetch128(s + 64); \
1484 h = Add(h, a); \
1485 g = Add(g, b); \
1486 g = Shuffle0321(g); \
1487 f = Add(f, c); \
1488 __m128i be = Add(b, Mulc1(e)); \
1489 h = Add(h, f); \
1490 f = Add(f, h); \
1491 h = Add(Murk(d, h), e); \
1492 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1493 g = Add(Xor(c, g), a); \
1494 f = Add(Xor(be, f), d); \
1495 k = Add(k, be); \
1496 k = Add(k, _mm_shuffle_epi8(f, h)); \
1497 f = Add(f, g); \
1498 g = Add(g, f); \
1499 f = Mulc1(f); \
1500} while (0)
1501
1502 while (iters-- != 0) {
1503 Chunk();
1504 s += 80;
1505 }
1506
1507 if (len != 0) {
1508 h = Add(h, _mm_set1_epi32(len));
1509 s = s + len - 80;
1510 Chunk();
1511 }
1512 }
1513
1514 g = Shuffle0321(g);
1515 k = Xor(k, g);
1516 f = Mulc1(f);
1517 k = Mulc2(k);
1518 g = Mulc1(g);
1519 h = Mulc2(h);
1520 k = Add(k, _mm_shuffle_epi8(g, f));
1521 h = Add(h, f);
1522 f = Add(f, h);
1523 g = Add(g, k);
1524 k = Add(k, g);
1525 k = Xor(k, _mm_shuffle_epi8(f, h));
1526 __m128i buf[4];
1527 buf[0] = f;
1528 buf[1] = g;
1529 buf[2] = k;
1530 buf[3] = h;
1531 s = reinterpret_cast<char*>(buf);
1532 uint32_t x = Fetch(s);
1533 uint32_t y = Fetch(s+4);
1534 uint32_t z = Fetch(s+8);
1535 x = _mm_crc32_u32(x, Fetch(s+12));
1536 y = _mm_crc32_u32(y, Fetch(s+16));
1537 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1538 x = _mm_crc32_u32(x, Fetch(s+24));
1539 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1540 uint32_t o = y;
1541 z = _mm_crc32_u32(z, Fetch(s+32));
1542 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1543 y = _mm_crc32_u32(y, Fetch(s+40));
1544 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1545 x = _mm_crc32_u32(x, Fetch(s+48));
1546 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1547 z = _mm_crc32_u32(z, Fetch(s+56));
1548 x = _mm_crc32_u32(x, Fetch(s+60));
1549 return (o - x + y - z) * c1;
1550}
1551
1552#undef Chunk
1553#undef Murk
1554#undef Mulc2
1555#undef Mulc1
1556
1557uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1558 if (len <= 24) {
1559 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1560 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1561 else return farmhashmk::Hash32Len0to4(s, len, seed);
1562 }
1563 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1564 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1565}
1566
1567#endif
1568} // namespace farmhashsa
1569namespace farmhashcc {
1570// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
1571// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
1572// a seeded 32-bit hash function similar to CityHash32.
1573
1574#undef Fetch
1575#define Fetch Fetch32
1576
1577#undef Rotate
1578#define Rotate Rotate32
1579
1580#undef Bswap
1581#define Bswap Bswap32
1582
1583STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
1584 uint32_t a = Fetch(s - 4 + (len >> 1));
1585 uint32_t b = Fetch(s + 4);
1586 uint32_t c = Fetch(s + len - 8);
1587 uint32_t d = Fetch(s + (len >> 1));
1588 uint32_t e = Fetch(s);
1589 uint32_t f = Fetch(s + len - 4);
1590 uint32_t h = len;
1591
1592 return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
1593}
1594
1595STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
1596 uint32_t b = 0;
1597 uint32_t c = 9;
1598 for (size_t i = 0; i < len; i++) {
1599 signed char v = s[i];
1600 b = b * c1 + v;
1601 c ^= b;
1602 }
1603 return fmix(Mur(b, Mur(len, c)));
1604}
1605
1606STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
1607 uint32_t a = len, b = len * 5, c = 9, d = b;
1608 a += Fetch(s);
1609 b += Fetch(s + len - 4);
1610 c += Fetch(s + ((len >> 1) & 4));
1611 return fmix(Mur(c, Mur(b, Mur(a, d))));
1612}
1613
1614uint32_t Hash32(const char *s, size_t len) {
1615 if (len <= 24) {
1616 return len <= 12 ?
1617 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1618 Hash32Len13to24(s, len);
1619 }
1620
1621 // len > 24
1622 uint32_t h = len, g = c1 * len, f = g;
1623 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1624 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1625 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1626 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1627 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1628 h ^= a0;
1629 h = Rotate(h, 19);
1630 h = h * 5 + 0xe6546b64;
1631 h ^= a2;
1632 h = Rotate(h, 19);
1633 h = h * 5 + 0xe6546b64;
1634 g ^= a1;
1635 g = Rotate(g, 19);
1636 g = g * 5 + 0xe6546b64;
1637 g ^= a3;
1638 g = Rotate(g, 19);
1639 g = g * 5 + 0xe6546b64;
1640 f += a4;
1641 f = Rotate(f, 19);
1642 f = f * 5 + 0xe6546b64;
1643 size_t iters = (len - 1) / 20;
1644 do {
1645 uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
1646 uint32_t a1 = Fetch(s + 4);
1647 uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
1648 uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
1649 uint32_t a4 = Fetch(s + 16);
1650 h ^= a0;
1651 h = Rotate(h, 18);
1652 h = h * 5 + 0xe6546b64;
1653 f += a1;
1654 f = Rotate(f, 19);
1655 f = f * c1;
1656 g += a2;
1657 g = Rotate(g, 18);
1658 g = g * 5 + 0xe6546b64;
1659 h ^= a3 + a1;
1660 h = Rotate(h, 19);
1661 h = h * 5 + 0xe6546b64;
1662 g ^= a4;
1663 g = Bswap(g) * 5;
1664 h += a4 * 5;
1665 h = Bswap(h);
1666 f += a0;
1667 PERMUTE3(f, h, g);
1668 s += 20;
1669 } while (--iters != 0);
1670 g = Rotate(g, 11) * c1;
1671 g = Rotate(g, 17) * c1;
1672 f = Rotate(f, 11) * c1;
1673 f = Rotate(f, 17) * c1;
1674 h = Rotate(h + g, 19);
1675 h = h * 5 + 0xe6546b64;
1676 h = Rotate(h, 17) * c1;
1677 h = Rotate(h + f, 19);
1678 h = h * 5 + 0xe6546b64;
1679 h = Rotate(h, 17) * c1;
1680 return h;
1681}
1682
1683uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1684 if (len <= 24) {
1685 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1686 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1687 else return farmhashmk::Hash32Len0to4(s, len, seed);
1688 }
1689 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1690 return Mur(Hash32(s + 24, len - 24) + seed, h);
1691}
1692
1693#undef Fetch
1694#define Fetch Fetch64
1695
1696#undef Rotate
1697#define Rotate Rotate64
1698
1699#undef Bswap
1700#define Bswap Bswap64
1701
1702STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
1703 return val ^ (val >> 47);
1704}
1705
1706STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
1707 return Hash128to64(Uint128(u, v));
1708}
1709
1710STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
1711 // Murmur-inspired hashing.
1712 uint64_t a = (u ^ v) * mul;
1713 a ^= (a >> 47);
1714 uint64_t b = (v ^ a) * mul;
1715 b ^= (b >> 47);
1716 b *= mul;
1717 return b;
1718}
1719
1720STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
1721 if (len >= 8) {
1722 uint64_t mul = k2 + len * 2;
1723 uint64_t a = Fetch(s) + k2;
1724 uint64_t b = Fetch(s + len - 8);
1725 uint64_t c = Rotate(b, 37) * mul + a;
1726 uint64_t d = (Rotate(a, 25) + b) * mul;
1727 return HashLen16(c, d, mul);
1728 }
1729 if (len >= 4) {
1730 uint64_t mul = k2 + len * 2;
1731 uint64_t a = Fetch32(s);
1732 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
1733 }
1734 if (len > 0) {
1735 uint8_t a = s[0];
1736 uint8_t b = s[len >> 1];
1737 uint8_t c = s[len - 1];
1738 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
1739 uint32_t z = len + (static_cast<uint32_t>(c) << 2);
1740 return ShiftMix(y * k2 ^ z * k0) * k2;
1741 }
1742 return k2;
1743}
1744
1745// Return a 16-byte hash for 48 bytes. Quick and dirty.
1746// Callers do best to use "random-looking" values for a and b.
1747STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1748 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
1749 a += w;
1750 b = Rotate(b + a + z, 21);
1751 uint64_t c = a;
1752 a += x;
1753 a += y;
1754 b += Rotate(a, 44);
1755 return make_pair(a + z, b + c);
1756}
1757
1758// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
1759STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1760 const char* s, uint64_t a, uint64_t b) {
1761 return WeakHashLen32WithSeeds(Fetch(s),
1762 Fetch(s + 8),
1763 Fetch(s + 16),
1764 Fetch(s + 24),
1765 a,
1766 b);
1767}
1768
1769
1770
1771// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
1772// of any length representable in signed long. Based on City and Murmur.
1773STATIC_INLINE uint128_t CityMurmur(const char *s, size_t len, uint128_t seed) {
1774 uint64_t a = Uint128Low64(seed);
1775 uint64_t b = Uint128High64(seed);
1776 uint64_t c = 0;
1777 uint64_t d = 0;
1778 signed long l = len - 16;
1779 if (l <= 0) { // len <= 16
1780 a = ShiftMix(a * k1) * k1;
1781 c = b * k1 + HashLen0to16(s, len);
1782 d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
1783 } else { // len > 16
1784 c = HashLen16(Fetch(s + len - 8) + k1, a);
1785 d = HashLen16(b + len, c + Fetch(s + len - 16));
1786 a += d;
1787 do {
1788 a ^= ShiftMix(Fetch(s) * k1) * k1;
1789 a *= k1;
1790 b ^= a;
1791 c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
1792 c *= k1;
1793 d ^= c;
1794 s += 16;
1795 l -= 16;
1796 } while (l > 0);
1797 }
1798 a = HashLen16(a, c);
1799 b = HashLen16(d, b);
1800 return Uint128(a ^ b, HashLen16(b, a));
1801}
1802
1803uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
1804 if (len < 128) {
1805 return CityMurmur(s, len, seed);
1806 }
1807
1808 // We expect len >= 128 to be the common case. Keep 56 bytes of state:
1809 // v, w, x, y, and z.
1810 pair<uint64_t, uint64_t> v, w;
1811 uint64_t x = Uint128Low64(seed);
1812 uint64_t y = Uint128High64(seed);
1813 uint64_t z = len * k1;
1814 v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
1815 v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
1816 w.first = Rotate(y + z, 35) * k1 + x;
1817 w.second = Rotate(x + Fetch(s + 88), 53) * k1;
1818
1819 // This is the same inner loop as CityHash64(), manually unrolled.
1820 do {
1821 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1822 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1823 x ^= w.second;
1824 y += v.first + Fetch(s + 40);
1825 z = Rotate(z + w.first, 33) * k1;
1826 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1827 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1828 std::swap(z, x);
1829 s += 64;
1830 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1831 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1832 x ^= w.second;
1833 y += v.first + Fetch(s + 40);
1834 z = Rotate(z + w.first, 33) * k1;
1835 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1836 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1837 std::swap(z, x);
1838 s += 64;
1839 len -= 128;
1840 } while (LIKELY(len >= 128));
1841 x += Rotate(v.first + z, 49) * k0;
1842 y = y * k0 + Rotate(w.second, 37);
1843 z = z * k0 + Rotate(w.first, 27);
1844 w.first *= 9;
1845 v.first *= k0;
1846 // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
1847 for (size_t tail_done = 0; tail_done < len; ) {
1848 tail_done += 32;
1849 y = Rotate(x + y, 42) * k0 + v.second;
1850 w.first += Fetch(s + len - tail_done + 16);
1851 x = x * k0 + w.first;
1852 z += w.second + Fetch(s + len - tail_done);
1853 w.second += v.first;
1854 v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
1855 v.first *= k0;
1856 }
1857 // At this point our 56 bytes of state should contain more than
1858 // enough information for a strong 128-bit hash. We use two
1859 // different 56-byte-to-8-byte hashes to get a 16-byte final result.
1860 x = HashLen16(x, v.first);
1861 y = HashLen16(y + z, w.first);
1862 return Uint128(HashLen16(x + v.second, w.second) + y,
1863 HashLen16(x + w.second, y + v.second));
1864}
1865
1866STATIC_INLINE uint128_t CityHash128(const char *s, size_t len) {
1867 return len >= 16 ?
1868 CityHash128WithSeed(s + 16, len - 16,
1869 Uint128(Fetch(s), Fetch(s + 8) + k0)) :
1870 CityHash128WithSeed(s, len, Uint128(k0, k1));
1871}
1872
1873uint128_t Fingerprint128(const char* s, size_t len) {
1874 return CityHash128(s, len);
1875}
1876} // namespace farmhashcc
1877namespace NAMESPACE_FOR_HASH_FUNCTIONS {
1878
1879// BASIC STRING HASHING
1880
1881// Hash function for a byte array. See also Hash(), below.
1882// May change from time to time, may differ on different platforms, may differ
1883// depending on NDEBUG.
1884uint32_t Hash32(const char* s, size_t len) {
1885 return DebugTweak(
1886 (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
1887 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
1888 can_use_sse42 ? farmhashsa::Hash32(s, len) :
1889 farmhashmk::Hash32(s, len));
1890}
1891
1892// Hash function for a byte array. For convenience, a 32-bit seed is also
1893// hashed into the result.
1894// May change from time to time, may differ on different platforms, may differ
1895// depending on NDEBUG.
1896uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
1897 return DebugTweak(
1898 (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
1899 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
1900 can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
1901 farmhashmk::Hash32WithSeed(s, len, seed));
1902}
1903
1904// Hash function for a byte array. For convenience, a 64-bit seed is also
1905// hashed into the result. See also Hash(), below.
1906// May change from time to time, may differ on different platforms, may differ
1907// depending on NDEBUG.
1908uint64_t Hash64(const char* s, size_t len) {
1909 return DebugTweak(
1910 (can_use_sse42 & x86_64) ?
1911 farmhashte::Hash64(s, len) :
1912 farmhashxo::Hash64(s, len));
1913}
1914
1915// Hash function for a byte array.
1916// May change from time to time, may differ on different platforms, may differ
1917// depending on NDEBUG.
1918size_t Hash(const char* s, size_t len) {
1919 return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
1920}
1921
1922// Hash function for a byte array. For convenience, a 64-bit seed is also
1923// hashed into the result.
1924// May change from time to time, may differ on different platforms, may differ
1925// depending on NDEBUG.
1926uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
1927 return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
1928}
1929
1930// Hash function for a byte array. For convenience, two seeds are also
1931// hashed into the result.
1932// May change from time to time, may differ on different platforms, may differ
1933// depending on NDEBUG.
1934uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
1935 return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
1936}
1937
1938// Hash function for a byte array.
1939// May change from time to time, may differ on different platforms, may differ
1940// depending on NDEBUG.
1941uint128_t Hash128(const char* s, size_t len) {
1942 return DebugTweak(farmhashcc::Fingerprint128(s, len));
1943}
1944
1945// Hash function for a byte array. For convenience, a 128-bit seed is also
1946// hashed into the result.
1947// May change from time to time, may differ on different platforms, may differ
1948// depending on NDEBUG.
1949uint128_t Hash128WithSeed(const char* s, size_t len, uint128_t seed) {
1950 return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
1951}
1952
1953// BASIC NON-STRING HASHING
1954
1955// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
1956
1957// Fingerprint function for a byte array. Most useful in 32-bit binaries.
1958uint32_t Fingerprint32(const char* s, size_t len) {
1959 return farmhashmk::Hash32(s, len);
1960}
1961
1962// Fingerprint function for a byte array.
1963uint64_t Fingerprint64(const char* s, size_t len) {
1964 return farmhashna::Hash64(s, len);
1965}
1966
1967// Fingerprint function for a byte array.
1968uint128_t Fingerprint128(const char* s, size_t len) {
1969 return farmhashcc::Fingerprint128(s, len);
1970}
1971
1972// Older and still available but perhaps not as fast as the above:
1973// farmhashns::Hash32{,WithSeed}()
1974
1975} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
1976
1977#if FARMHASHSELFTEST
1978
1979#ifndef FARMHASH_SELF_TEST_GUARD
1980#define FARMHASH_SELF_TEST_GUARD
1981#include <cstdio>
1982#include <iostream>
1983#include <string.h>
1984
1985using std::cout;
1986using std::cerr;
1987using std::endl;
1988using std::hex;
1989
1990static const uint64_t kSeed0 = 1234567;
1991static const uint64_t kSeed1 = k0;
1992static const int kDataSize = 1 << 20;
1993static const int kTestSize = 300;
1994#define kSeed128 Uint128(kSeed0, kSeed1)
1995
1996static char data[kDataSize];
1997
1998static int completed_self_tests = 0;
1999static int errors = 0;
2000
2001// Initialize data to pseudorandom values.
2002void Setup() {
2003 if (completed_self_tests == 0) {
2004 uint64_t a = 9;
2005 uint64_t b = 777;
2006 for (int i = 0; i < kDataSize; i++) {
2007 a += b;
2008 b += a;
2009 a = (a ^ (a >> 41)) * k0;
2010 b = (b ^ (b >> 41)) * k0 + i;
2011 uint8_t u = b >> 37;
2012 memcpy(data + i, &u, 1); // uint8_t -> char
2013 }
2014 }
2015}
2016
2017int NoteErrors() {
2018#define NUM_SELF_TESTS 9
2019 if (++completed_self_tests == NUM_SELF_TESTS)
2020 std::exit(errors > 0);
2021 return errors;
2022}
2023
2024template <typename T> inline bool IsNonZero(T x) {
2025 return x != 0;
2026}
2027
2028template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
2029 return x != Uint128(0, 0);
2030}
2031
2032#endif // FARMHASH_SELF_TEST_GUARD
2033
2034namespace farmhashccTest {
2035
2036uint32_t CreateSeed(int offset, int salt) {
2037 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
2038 h = h * c1;
2039 h ^= (h >> 17);
2040 h = h * c1;
2041 h ^= (h >> 17);
2042 h = h * c1;
2043 h ^= (h >> 17);
2044 h += static_cast<uint32_t>(offset & 0xffffffff);
2045 h = h * c1;
2046 h ^= (h >> 17);
2047 h = h * c1;
2048 h ^= (h >> 17);
2049 h = h * c1;
2050 h ^= (h >> 17);
2051 return h;
2052}
2053
2054#undef SEED
2055#undef SEED1
2056#undef SEED0
2057#define SEED CreateSeed(offset, -1)
2058#define SEED0 CreateSeed(offset, 0)
2059#define SEED1 CreateSeed(offset, 1)
2060
2061#undef TESTING
2062#define TESTING 1
2063#if TESTING
2064uint32_t expected[] = {
20654223616069u,
20663696677242u,
20671039179260u, 1690343979u, 1018511555u, 2464489001u,
206820368522u, 2663783964u, 175201532u, 1619210592u,
20694081014168u,
20702576519988u,
20713285042206u, 502478099u, 739479538u, 1500332790u,
207213754768u, 3789353455u, 3473868058u, 1909255088u,
20732212771159u,
20741112731063u,
2075826915357u, 2893489933u, 118369799u, 1848668220u,
20761308219822u, 249416982u, 64306364u, 4221800195u,
20771020067935u,
20783955445564u,
2079563346294u, 550236731u, 2339016688u, 1826259714u,
20803872358639u, 2295981050u, 1870005390u, 4015628802u,
20811451961420u,
2082653440099u,
20831292493871u, 164377749u, 1717712483u, 463414587u,
20843924343675u, 1050492084u, 3566618804u, 2046983362u,
208531917516u,
20862957164615u,
2087230718965u, 999595115u, 3534822176u, 2175709186u,
2088965707431u, 441796222u, 2481718051u, 1827777486u,
20892590087362u,
20903879448744u,
20913515079898u, 1601433082u, 982764532u, 254808716u,
20921293372530u, 4205605817u, 947001462u, 1138890052u,
2093176305566u,
20942447367541u,
20952973802542u, 4123621138u, 3083865840u, 1706367795u,
2096792114347u, 2880110657u, 440613768u, 195054868u,
20971359016305u,
20983363804638u,
2099649488537u, 1624045597u, 1441938215u, 3147758996u,
21003199173578u, 2597283203u, 2191333609u, 3763129144u,
21011117290165u,
21021062549743u,
21032565615889u, 1046361554u, 1581968261u, 1058773671u,
21041123053168u, 3807622275u, 1486749916u, 3900816089u,
21052437877004u,
21061894455839u,
21071912520953u, 1914997013u, 561048608u, 1643267444u,
21083671572006u, 194811086u, 1468911468u, 2179206286u,
2109673206794u,
21103486923651u,
21113741426466u, 3292160512u, 697001377u, 1900763774u,
21123726097344u, 629282039u, 3578723715u, 2868028489u,
21133269862919u,
21142303349487u,
21153643953525u, 2307255916u, 849996280u, 732080434u,
2116909961480u, 3542445214u, 2628347095u, 4236856917u,
21171380660650u,
21182631821908u,
21192007289004u, 3509705198u, 3788541675u, 789457322u,
21203090670546u, 638977894u, 3503881773u, 947102987u,
21211525325287u,
21221816697045u,
21232706647405u, 288763142u, 3505438495u, 481308609u,
21242882636782u, 3745162621u, 3503467033u, 428247823u,
2125176408838u,
2126333551502u,
21271001068721u, 1681483651u, 75380831u, 4191469679u,
21283627361839u, 2736617386u, 3120737438u, 1297502456u,
2129864896482u,
213085674920u,
21312886047255u, 4119881331u, 2496990525u, 3442502055u,
21321806582817u, 3186345024u, 4099591287u, 2560171465u,
21333489229104u,
21343065015872u,
21352755089808u, 3098442882u, 378524719u, 2664097023u,
21361771960725u, 2901182183u, 55258521u, 1266621443u,
2137581644891u,
213837790450u,
21391800731704u, 3601350920u, 53428754u, 2759476837u,
21403391093099u, 1496510311u, 2511119507u, 2636877410u,
2141631613207u,
21421573846064u,
2143260484875u, 1088212603u, 2369525206u, 322522428u,
21443191396600u, 2076543340u, 1552496658u, 2739811558u,
21453867875546u,
21462051584261u,
21472126250818u, 901517871u, 3651631165u, 1323139145u,
21481521111765u, 477802997u, 3508559783u, 383954241u,
21493804516756u,
21504250206331u,
21512655954340u, 2484996477u, 1417544845u, 1520282298u,
21522745204366u, 2869345147u, 1872738335u, 2592877343u,
21531619744564u,
21541804962124u,
21553458679890u, 423948620u, 273645618u, 4187865426u,
2156376057175u, 2943431463u, 3581950599u, 1035398331u,
21571088213445u,
2158861988903u,
21591323370244u, 777069428u, 506235917u, 369720851u,
21602789995854u, 230915180u, 1505086948u, 940361236u,
21613727873235u,
21621159167499u,
21631860302871u, 3456858862u, 3923555152u, 2131072714u,
21642910461068u, 3671950363u, 2010742682u, 4088068851u,
21653616470388u,
21662087714788u,
2167221675509u, 1230154072u, 3450704646u, 1463226695u,
21681998357699u, 266026801u, 619568740u, 3560427266u,
21694148162586u,
21703150417316u,
21711356375822u, 2056097622u, 627905802u, 3881675638u,
21722309738053u, 971916703u, 3447805361u, 1673575328u,
2173673084328u,
21743317849401u,
21752836362782u, 2377208890u, 3275350588u, 158350552u,
21762553241779u, 2497264995u, 3262882649u, 3897937187u,
21771598963653u,
21783068514414u,
2179601541505u, 374517071u, 3380795976u, 235752573u,
2180284670003u, 2990192160u, 904937105u, 2306579150u,
21812117362589u,
21821635274830u,
21833355572906u, 170799903u, 1226685528u, 664567688u,
2184413219134u, 878324258u, 4026159448u, 3620649295u,
21851823625377u,
21863175888439u,
21871759344347u, 2640637095u, 3549558u, 2192984935u,
2188978623493u, 804017880u, 3877562323u, 3843116489u,
21891641748342u,
21901853539444u,
21913001178468u, 3443560727u, 2685426077u, 1653064722u,
2192349231508u, 2726789654u, 3136215581u, 768402830u,
2193269384321u,
2194531936536u,
21952592883487u, 1343156334u, 3628619802u, 1477143570u,
21964269458419u, 3285611028u, 959104925u, 2712290710u,
21973480237248u,
2198835796333u,
21992020636251u, 1191914589u, 126521603u, 4288023938u,
22003731699932u, 2136758855u, 985780142u, 193807575u,
22011850544433u,
2202653947619u,
22033929316796u, 381871169u, 950486363u, 1787262279u,
2204360480382u, 1800636585u, 1039258631u, 3682073259u,
22051262819303u,
22061786000319u,
22071570627191u, 893065837u, 301304916u, 1478469809u,
2208623018819u, 2742232545u, 2058913014u, 1706060059u,
22092421125401u,
22101315829592u,
22113208766775u, 1805586156u, 575853086u, 3085025513u,
22124010908260u, 2344058256u, 3814407434u, 1458485673u,
22132474514786u,
22143581895658u,
22152710719679u, 190812706u, 2135454262u, 2620080728u,
22163400757986u, 1669914857u, 1559978393u, 1629811331u,
22173096616493u,
22181391424435u,
22194158376003u, 1015657076u, 794783832u, 479952178u,
22201150290207u, 2497437906u, 231815090u, 755078067u,
22213832053281u,
222263649475u,
22232415822606u, 4105027719u, 1706992318u, 1106598740u,
22243941945667u, 1271300761u, 505882259u, 760186809u,
22252657183368u,
22261925422058u,
22271039773764u, 880219458u, 4275949176u, 1556833823u,
2228925882132u, 4216310340u, 757497522u, 461833914u,
22293884002070u,
22302790957660u,
22312100050089u, 651959176u, 1380301291u, 1289124125u,
2232452314403u, 226156280u, 3306924715u, 1750807758u,
22332290180542u,
22341953760569u,
22352253069096u, 3960924806u, 1786291620u, 60736185u,
22362569018293u, 3870479674u, 2247005661u, 2239850953u,
22374261808536u,
22383282975782u,
2239780945879u, 3349849383u, 1579362556u, 2265045884u,
2240905088740u, 725212379u, 3156479246u, 2501620391u,
22413062836263u,
22424070422690u,
2243996797869u, 4082582315u, 976105756u, 303983602u,
22441862104804u, 3864508254u, 3383979677u, 2835500286u,
22452798364010u,
2246519359476u,
22473447342725u, 194373889u, 3313466630u, 232399983u,
22482841787856u, 1672751454u, 3345183154u, 1805381384u,
22492226129336u,
22502847829057u,
22512350774567u, 2838540121u, 2757948482u, 1017002062u,
22522329150951u, 2171488196u, 3668619047u, 3874977844u,
22533287966998u,
2254262346753u,
22552493054715u, 2298644430u, 2926101182u, 1528457638u,
2256598656233u, 2615845874u, 989110727u, 820441411u,
2257253617372u,
22582201077208u,
22592047569338u, 3114356329u, 3335563734u, 2967673540u,
2260768438341u, 1417708203u, 3873718246u, 1538441843u,
22611279167650u,
22623917966776u,
22632218481734u, 1015935150u, 1957845042u, 1318150213u,
22643146423971u, 4218994877u, 1162470863u, 1519718292u,
22652594658906u,
2266665870414u,
22673430347817u, 3933868731u, 1597041394u, 3138684682u,
22683398212027u, 1064647658u, 1576321132u, 14792918u,
2269224938029u,
22703706456050u,
2271847274786u, 2645698692u, 1743374687u, 2343133224u,
22723066596790u, 2857270120u, 200596308u, 452055528u,
22732319312082u,
22743488655402u,
22754146865894u, 608206438u, 2699777051u, 3687240713u,
2276327957508u, 3664730153u, 568134564u, 2993484554u,
22774159860363u,
22784274533921u,
22791079994063u, 2360220210u, 3609597760u, 3639708902u,
22802836180437u, 1069910270u, 1892427666u, 1874729790u,
22811267712826u,
2282121886940u,
22833572289214u, 2475945610u, 783779452u, 588827737u,
22841531395014u, 2085084212u, 2219189792u, 3981444548u,
22852218885336u,
22861691622694u,
22872053232885u, 1386558530u, 2182946189u, 2365247285u,
22881871081313u, 2935751853u, 38413723u, 543465863u,
2289900691890u,
22902899905665u,
2291575120562u, 93133904u, 457154948u, 2983705792u,
22924232229200u, 2038565963u, 614693984u, 3405328302u,
22934083090010u,
22942088004171u,
2295244031209u, 1861889294u, 2417109253u, 3299562328u,
22964158642443u, 4199064449u, 3161611046u, 885015950u,
22973677904099u,
22982969861785u,
2299772348805u, 1712263832u, 3219357614u, 484271305u,
23003645706114u, 2059620251u, 409557488u, 2278896731u,
2301224475749u,
23023523022952u,
23032057140088u, 449131785u, 1149879244u, 4255363996u,
23043602720135u, 1690010854u, 2503998822u, 2750828466u,
23053340671802u,
23061447583863u,
23072649684943u, 2764747249u, 3046070595u, 3441726138u,
23083840332559u, 3156747501u, 1288666680u, 1472744459u,
23093452391933u,
23101617542784u,
2311217869690u, 3718469527u, 348639731u, 590532355u,
231243789787u, 22606314u, 1621559290u, 2231743261u,
23132234620879u,
2314544748955u,
23153169387920u, 203343594u, 3272552527u, 1078282365u,
2316809576321u, 854207584u, 3625491053u, 1193737267u,
23171628966807u,
23182661421060u,
23192433442061u, 3886639039u, 2149304418u, 303000565u,
23201432830882u, 137378235u, 1135974068u, 318705754u,
23212491227157u,
23222627534472u,
23233520352233u, 2488397682u, 3969194920u, 3843962181u,
23242135981459u, 2611933220u, 799460731u, 2300968851u,
23253412851628u,
23263070914013u,
23273555224260u, 4125937572u, 240359903u, 722496673u,
23282061023600u, 3843919221u, 2759960043u, 1191155322u,
23291504041490u,
23303735253656u,
23311773124736u, 101110011u, 1627699578u, 2645634551u,
2332263603947u, 1388368439u, 677146538u, 1644201982u,
23332625699644u,
23342403862553u,
23352426069017u, 3613511705u, 915141802u, 2981654265u,
23363474818167u, 2611101773u, 627891434u, 762754924u,
23372143021902u,
233851067670u,
23394017746573u, 2269879853u, 3037857950u, 2388899692u,
2340582729171u, 1886116725u, 2281219772u, 264704948u,
23413509984037u,
23424078683368u,
23432172959411u, 1807195632u, 3357092302u, 2253764928u,
23442320369390u, 3076335959u, 2623583210u, 168378015u,
23451435562650u,
23461100977467u,
23473160490319u, 2550328495u, 2396855930u, 1347823908u,
23481617990918u, 3849653099u, 3224111576u, 1681539821u,
23494171542880u,
2350552200045u,
23513562947778u, 1676237880u, 3747732307u, 2453332913u,
2352865530667u, 3566636849u, 3485502777u, 336779723u,
23532535942410u,
23541685000184u,
2355820545711u, 1893670486u, 1273910461u, 1193758569u,
2356970365241u, 381205962u, 3612810852u, 1160577445u,
2357541488143u,
23584005031080u,
23592333965236u, 2419855455u, 3484533538u, 3073937876u,
2360908466956u, 661391539u, 2342122412u, 1467049112u,
23611785800827u,
2362135343033u,
2363139643209u, 2438375667u, 974654058u, 3216478230u,
23643807620420u, 779043363u, 2812846449u, 333254784u,
23651025244024u,
23662242303095u,
23672476683742u, 350018683u, 174652916u, 933097576u,
2368826905896u, 559603581u, 2777181260u, 164915169u,
23694070353203u,
23701459055748u,
2371297303985u, 3103837241u, 3812514233u, 232265137u,
23722032819099u, 1523091376u, 3531238208u, 1403510182u,
23732886832080u,
23742599705941u,
23752789695716u, 68437968u, 3823813791u, 1040994569u,
23763024194990u, 2461740520u, 3735391266u, 2042207153u,
23772461678616u,
23783519231840u,
23791344224923u, 411442756u, 1179779351u, 7661528u,
2380778352196u, 3288808867u, 589356197u, 2627504511u,
23813374744599u,
23823312172905u,
2383357423007u, 3539567796u, 4044452215u, 1445118403u,
23842937983820u, 184089910u, 346201845u, 2427295202u,
23851345448010u,
23862884434843u,
23873085001879u, 2640105409u, 315310640u, 3530289798u,
23883362974764u, 963602652u, 75228477u, 3509381180u,
23894012777756u,
23902380345941u,
23911073137836u, 2083960378u, 1220315185u, 3628720934u,
23923508867818u, 67148343u, 3558085158u, 1753943368u,
2393863309561u,
23942844713625u,
2395441921850u, 854732254u, 816793316u, 2555428747u,
23963440623414u, 1707304366u, 3189874375u, 1623229221u,
23971220335976u,
2398806745430u,
23993909262947u, 1680369031u, 2926179486u, 3410391660u,
24003991630434u, 2876458763u, 1179167079u, 536360759u,
24011592117159u,
24021514343977u,
24031032622306u, 2057494855u, 784938958u, 178402996u,
24041152907972u, 2326185495u, 2939973666u, 4181120253u,
2405552831733u,
2406664251856u,
24071297139539u, 1969357631u, 1474065957u, 3055419017u,
24083395829380u, 3316562752u, 2168409017u, 614624786u,
24093585854336u,
2410668291094u,
24111162889217u, 3773171307u, 2263271126u, 355089668u,
24123195850578u, 3396793277u, 3519870267u, 527857605u,
24133972392320u,
24142224315010u,
24154047225561u, 3271434798u, 3192704713u, 2798505213u,
24163932215896u, 3792924012u, 3796843756u, 453872975u,
24174050552799u,
24181056432676u,
2419928166947u, 121311642u, 930989547u, 2087070683u,
24201288978057u, 1556325239u, 1812435626u, 1682385724u,
24211214364933u,
2422904760776u,
24233957045528u, 3949822847u, 2411065880u, 3716420732u,
24243424837835u, 3833550693u, 1799375326u, 2012368921u,
24252768764136u,
24261786111037u,
24274055479315u, 3751639533u, 2808224623u, 3492656387u,
24281306824780u, 2624000170u, 3134795218u, 1778409297u,
24293900821801u,
2430593336325u,
24312772069220u, 2980873673u, 3574497158u, 3994780459u,
24324246519854u, 3482758570u, 4228015183u, 33101083u,
24331769887734u,
24344158035314u,
24353690638998u, 1119035482u, 4134969651u, 2483207353u,
24363932823321u, 285829887u, 3485140138u, 1304815138u,
2437995608264u,
24383133997465u,
24391195477617u, 2147693728u, 3506673112u, 4234467492u,
24401183174337u, 1395340482u, 769199343u, 193262308u,
24412798920256u,
24423827889422u,
24433399695609u, 3036045724u, 2999477386u, 3567001759u,
24442682864314u, 1414023907u, 3699872975u, 3369870701u,
24452662284872u,
24462179640019u,
24472485080099u, 3234415609u, 3755915606u, 1339453220u,
24481567403399u, 2076272391u, 293946298u, 3861962750u,
24491291949822u,
24502916864995u,
2451132642326u, 2215117062u, 2205863575u, 2488805750u,
2452405632860u, 3248129390u, 2952606864u, 896734759u,
24532047417173u,
24543865951392u,
2455657296855u, 1328547532u, 3966511825u, 3959682388u,
24564171801020u, 2981416957u, 1868896247u, 790081075u,
24573143666398u,
24582950766549u,
24592065854887u, 2737081890u, 995061774u, 1510712611u,
24602865954809u, 565044286u, 1565631102u, 1500654931u,
2461494822108u,
24622803515503u,
24631058154996u, 3506280187u, 856885925u, 4204610546u,
2464800905649u, 1130711562u, 558146282u, 2053400666u,
2465449794061u,
24662643520245u,
24672101248725u, 3123292429u, 3583524041u, 983372394u,
24681587743780u, 672870813u, 444833475u, 100741452u,
2469366232251u,
24701717951248u,
2471524144122u, 1362432726u, 1304947719u, 674306020u,
2472405665887u, 4081931036u, 1580408204u, 2343242778u,
24733901654006u,
24742627173567u,
24753015148205u, 814686701u, 1327920712u, 1346494176u,
24762468632605u, 2259795544u, 2519278184u, 2129281928u,
24772860266380u,
24784001619412u,
24791154910973u, 2841022216u, 1199925485u, 1372200293u,
24802713179055u, 3609776550u, 2896463880u, 1056406892u,
2481177413841u,
248240180172u,
24833274788406u, 660921784u, 1686225028u, 4003382965u,
24842532691887u, 4256809101u, 1186018983u, 667359096u,
24852375266493u,
24862760222015u,
2487745187078u, 312264012u, 396822261u, 2588536966u,
24882026998998u, 1766454365u, 3218807676u, 3915487497u,
24892630550356u,
24904130063378u,
24914231937074u, 752212123u, 3085144349u, 3267186363u,
24924103872100u, 4193207863u, 1306401710u, 3014853131u,
24931067760598u,
24942306188342u,
24952437881506u, 4258185052u, 2506507580u, 130876929u,
24961076894205u, 4106981702u, 2799540844u, 945747327u,
24971436722291u,
24982499772225u,
24992571537041u, 2038830635u, 2066826058u, 2892892912u,
2500524875858u, 3392572161u, 2869992096u, 1308273341u,
2501923668994u,
25021980407857u,
25032275009652u, 240598096u, 2658376530u, 3505603048u,
25041022603789u, 582423424u, 846379327u, 4092636095u,
25054177298326u,
25061004173023u,
25072154027018u, 2993634669u, 1098364089u, 3035642175u,
25081335688126u, 1376393415u, 1252369770u, 3815033328u,
25091999309358u,
25101234054757u,
25111388595255u, 2859334775u, 366532860u, 3453410395u,
25124226967708u, 1321729870u, 2078463405u, 156766592u,
25133157683394u,
25143549293384u,
25153348214547u, 2879648344u, 1144813399u, 2758966254u,
2516647753581u, 813615926u, 2035441590u, 1961053117u,
2517600168686u,
25182192833387u,
25193156481401u, 3627320321u, 383550248u, 81209584u,
25202339331745u, 1284116690u, 1980144976u, 2955724163u,
2521789301728u,
25223842040415u,
25231115881490u, 965249078u, 4098663322u, 1870257033u,
25242923150701u, 4217108433u, 183816559u, 2104089285u,
25252640095343u,
25263173757052u,
2527927847464u, 2383114981u, 4287174363u, 1886129652u,
252870635161u, 1182924521u, 1121440038u, 4246220730u,
25293890583049u,
2530975913757u,
25312436253031u, 1074894869u, 1301280627u, 992471939u,
2532735658128u, 244441856u, 1541612456u, 3457776165u,
25333503534059u,
25341931651133u,
2535349142786u, 3669028584u, 1828812038u, 99128389u,
25361364272849u, 1963678455u, 3971963311u, 2316950886u,
25371308901796u,
25382789591580u,
25391460494965u, 2380227479u, 1577190651u, 1755822080u,
25402911014607u, 859387544u, 13023113u, 2319243370u,
25412522582211u,
25422299110490u,
25433342378874u, 2589323490u, 1884430765u, 3739058655u,
25442419330954u, 355389916u, 273950915u, 3670136553u,
2545410946824u,
25463174041420u,
25472609010298u, 3059091350u, 2300275014u, 725729828u,
25482548380995u, 1738849964u, 1257081412u, 79430455u,
2549810321297u,
25503246190593u,
25511007937684u, 912115394u, 40880059u, 3450073327u,
25524289832174u, 2253485111u, 1065639151u, 2953189309u,
2553124779113u,
2554654299738u,
2555115760833u, 1250932069u, 884995826u, 3998908281u,
25561382882981u, 1134187162u, 3202324501u, 487502928u,
25573032756345u,
25584057517628u,
2559933197381u, 2319223127u, 2044528655u, 2554572663u,
25604049450620u, 1620812836u, 2832905391u, 2273005481u,
25611913090121u,
25621055456023u,
2563510593296u, 3285343192u, 2912822536u, 1645225063u,
2564638418430u, 452701300u, 1025483165u, 1639370512u,
2565167948643u,
25662809842730u,
25672983135664u, 407521332u, 1543756616u, 3949773145u,
25684283462892u, 659962275u, 3878013463u, 1000748756u,
25694053212051u,
25704099239406u,
25713467581965u, 354635541u, 21301844u, 3831212473u,
25723189450571u, 2264401966u, 4096484849u, 1736448515u,
25733976926096u,
25743727194724u,
25752243487039u, 585209095u, 3143046007u, 969558123u,
25763037113502u, 3594170243u, 2835860223u, 3775493975u,
25772787220812u,
25782274252217u,
25792915380701u, 3077533278u, 1252871826u, 1519790952u,
2580205297661u, 2950557658u, 3956882191u, 2724439401u,
25813694608025u,
2582124028038u,
2583216019153u, 1533010676u, 2259986336u, 2014061617u,
25842068617849u, 3078123052u, 2692046098u, 1582812948u,
2585396916232u,
25861470894001u,
25871694309312u, 300268215u, 1553892743u, 671176040u,
25881544988994u, 2793402821u, 4194972569u, 2296476154u,
2589748354332u,
25903491325898u,
25914261053291u, 1104998242u, 797816835u, 243564059u,
25922197717393u, 299029458u, 1675252188u, 3139770041u,
2593583018574u,
25942532106100u,
25952099391658u, 3760526730u, 3422719327u, 3556917689u,
25962374009285u, 2130865894u, 3710563151u, 1437538307u,
25973938030842u,
25982006930694u,
25992151243336u, 1939741287u, 1957068175u, 2135147479u,
2600649553342u, 1713643042u, 4188696599u, 1698739939u,
26013549427584u,
26021016382174u,
2603322644378u, 2476164549u, 2037263020u, 88036019u,
26042548960923u, 539867919u, 2871157727u, 4031659929u,
2605754087252u,
2606972656559u,
26074246379429u, 3877308578u, 2059459630u, 3614934323u,
26081410565271u, 2102980459u, 215395636u, 1083393481u,
26093775523015u,
26102062750105u,
26112475645882u, 3041186774u, 3534315423u, 758607219u,
26121686100614u, 180500983u, 1155581185u, 1476664671u,
26132918661695u,
26143812731350u,
26154003853737u, 4148884881u, 1468469436u, 3278880418u,
26161045838071u, 1049161262u, 360450415u, 3158065524u,
2617814443735u,
26183391401707u,
2619729968410u, 738771593u, 3662738792u, 1672830580u,
26204199496163u, 188487238u, 219098233u, 2141731267u,
26213890250614u,
26222988780375u,
26234026279523u, 3489429375u, 2468433807u, 1178270701u,
26242685094218u, 2716621497u, 3718335529u, 2273344755u,
2625701110882u,
26261925717409u,
26271515176562u, 2325460593u, 3954798930u, 784566105u,
26283769422266u, 1641530321u, 2703876862u, 2907480267u,
26291828076455u,
26301805635221u,
26313883381245u, 1476756210u, 2072514392u, 3658557081u,
26322003610746u, 2556845550u, 729594004u, 3303898266u,
26331968227254u,
2634423204951u,
2635231828688u, 4223697811u, 698619045u, 3636824418u,
26362738779239u, 2333529003u, 2833158642u, 580285428u,
26373038148234u,
26381012378004u,
26391113647298u, 1424593483u, 4053247723u, 1167152941u,
26402677383578u, 3419485379u, 2135673840u, 440478166u,
26411682229112u,
26423226724137u,
26431217439806u, 3828726923u, 3636576271u, 3467643156u,
26442005614908u, 2655346461u, 2345488441u, 1027557096u,
26453594084220u,
26461372306343u,
26472342583762u, 4291342905u, 4094931814u, 3254771759u,
2648821978248u, 2404930117u, 1143937655u, 3156949255u,
26493460606610u,
2650449701786u,
26513474906110u, 1932585294u, 2283357584u, 1808481478u,
26523522851029u, 3040164731u, 1530172182u, 2950426149u,
26531402416557u,
2654756419859u,
26554132576145u, 724994790u, 2852015871u, 2177908339u,
2656899914731u, 139675671u, 1423281870u, 3198458070u,
2657807581308u,
26582021611521u,
26591801452575u, 1425984297u, 2833835949u, 1536827865u,
26603902351840u, 164546042u, 1872840974u, 3986194780u,
2661792156290u,
26623378681896u,
2663941547959u, 3931328334u, 3661060482u, 2386420777u,
26643920146272u, 3458621279u, 3348500844u, 2269586542u,
2665797371473u,
26663188953649u,
266780514771u, 2913333490u, 1246325623u, 3253846094u,
26681723906239u, 1606413555u, 587500718u, 1412413859u,
26692310046829u,
26702113313263u,
26713855635608u, 47271944u, 1112281934u, 3440228404u,
26722633519166u, 425094457u, 307659635u, 67338587u,
26732412987939u,
26742363930989u,
26752853008596u, 2844637339u, 922568813u, 130379293u,
26762825204405u, 2904442145u, 1176875333u, 1511685505u,
2677599177514u,
26781872681372u,
2679682394826u, 1888849790u, 3635304282u, 1761257265u,
26801571292431u, 355247075u, 1177210823u, 1691529530u,
26813629531121u,
26823760474006u,
26831129340625u, 868116266u, 3908237785u, 1942124366u,
26841266630014u, 3214841995u, 334023850u, 1110037019u,
2685369650727u,
26861288666741u,
268770535706u, 20230114u, 4284225520u, 727856157u,
2688293696779u, 1244943770u, 3976592462u, 560421917u,
26894171688499u,
26902438786950u,
26911218144639u, 3809125983u, 1302395746u, 534542359u,
26922121993015u, 2899519374u, 3192177626u, 1761707794u,
26933101683464u,
26941555403906u,
26953225675390u, 1875263768u, 4278894569u, 651707603u,
26962111591484u, 3802716028u, 2900262228u, 1181469202u,
26973254743797u,
26981822684466u,
2699860641829u, 3046128268u, 1284833012u, 1125261608u,
2700461384524u, 2331344566u, 1274400010u, 990498321u,
27013462536298u,
27023796842585u,
27032346607194u, 279495949u, 3951194590u, 3522664971u,
27043169688303u, 726831706u, 1123875117u, 1816166599u,
27053759808754u,
27062918558151u,
27073713203220u, 3369939267u, 466047109u, 384042536u,
2708587271104u, 2191634696u, 2449929095u, 1157932232u,
27092084466674u,
2710841370485u,
27113241372562u, 4277738486u, 2150836793u, 1173569449u,
2712778768930u, 2594706485u, 3065269405u, 3019263663u,
27132660146610u,
27142789946230u,
271577056913u, 728174395u, 3647185904u, 804562358u,
27162697276483u, 881311175u, 1178696435u, 2059173891u,
27172308303791u,
2718221481230u,
271950241451u, 3689414100u, 1969074761u, 2732071529u,
27201900890356u, 840789500u, 2100609300u, 985565597u,
27211220850414u,
27222456636259u,
2723223607678u, 1016310244u, 1937434395u, 85717256u,
2724275058190u, 3712011133u, 171916016u, 2389569096u,
27253679765802u,
27263575358777u,
27273481108261u, 3178286380u, 2489642395u, 2931039055u,
27283086601621u, 3079518902u, 3027718495u, 2506894644u,
27292976869602u,
27302134336365u,
27312420172217u, 918054427u, 661522682u, 1403791357u,
27323587174388u, 2623673551u, 1355661457u, 4159477684u,
27331109013587u,
27343112183488u,
27352217849279u, 3500291996u, 2419603731u, 2929886201u,
27363854470013u, 1358382103u, 1357666555u, 21053566u,
27372716621233u,
27383094836862u,
27393309729704u, 57086558u, 839187419u, 2757944838u,
27403651040558u, 3607536716u, 3691257732u, 2312878285u,
27411202511724u,
2742183479927u,
27432509829803u, 109313218u, 478173887u, 2072044014u,
2744190631406u, 2495604975u, 1010416260u, 3679857586u,
2745726566957u,
2746258500881u,
27471805873908u, 3081447051u, 2352101327u, 534922207u,
27481584552873u, 813470716u, 255914637u, 249169434u,
27493193498057u,
27501038802706u,
27512590158653u, 3147907290u, 663060128u, 1156177857u,
2752634616100u, 312879189u, 1545020368u, 2054634247u,
27533271451914u,
27543438291534u,
27552181454946u, 3864535432u, 2398586877u, 896491075u,
27562810631478u, 2770357487u, 3372930052u, 898070638u,
27572051007323u,
2758392959778u,
275936645539u, 3743556044u, 4134529680u, 4124451188u,
2760566806297u, 2936523982u, 1304761965u, 537399498u,
27611940818842u,
276240862381u,
276336288410u, 3063605629u, 2826611650u, 3961972098u,
27641871578006u, 2392095486u, 1136931591u, 513864488u,
2765173276451u,
27663039055682u,
27673543322032u, 1943592006u, 657217094u, 1751698246u,
27682969618445u, 456616022u, 900309519u, 113892716u,
27691126392103u,
27701235651045u,
27711882073852u, 2136610853u, 2353639710u, 2819956700u,
27723980083530u, 828773559u, 224069850u, 902434120u,
27732802008036u,
277494358995u,
27752777723394u, 2812641403u, 2525832595u, 4157388110u,
27764235563782u, 937800324u, 141690749u, 568062536u,
2777550123849u,
27781330316521u,
27791949488696u, 2296431366u, 1958465262u, 3564751729u,
27803748252207u, 120455129u, 1607318832u, 2525729790u,
27812640987481u,
27822332096657u,
27831775969159u, 1555085077u, 2913525137u, 1347085183u,
27842376253113u, 3194050574u, 1806090610u, 678641356u,
27851499146713u,
2786383849715u,
27873299835823u, 2284860330u, 2614269636u, 3913628844u,
27882761334210u, 1959484587u, 529797021u, 239966995u,
27893102194829u,
27903602307804u,
27911122192627u, 3577510006u, 164486066u, 1680137310u,
27921473396395u, 1467801424u, 903493660u, 1185943071u,
27932798556505u,
27942306744492u,
27953167201310u, 3577947177u, 3067592134u, 2905506289u,
27961210366329u, 204484056u, 2347778932u, 3862374472u,
27973277439508u,
27984187414621u,
27991646699310u, 621385800u, 3934869089u, 3975491588u,
28003580085916u, 1925674500u, 2436305348u, 3983301539u,
28012739439523u,
28023291507446u,
28033395637920u, 3753389171u, 2955202032u, 2654255623u,
28043771089254u, 2140443405u, 2779834738u, 3261942805u,
28053526889244u,
28061842009139u,
28074048484340u, 2106218403u, 2161244271u, 772152700u,
28081158647659u, 3776791619u, 3882186721u, 699525237u,
28092954670460u,
28101007105869u,
28113359152025u, 1146388699u, 1401550303u, 2326582541u,
28124181783540u, 1085644043u, 1942143795u, 1038368308u,
28131526153809u,
28144042547244u,
28151891441000u, 2573991874u, 1281441253u, 3635098284u,
28161980545715u, 825985487u, 3934748116u, 4228386979u,
28171480870944u,
28181042194545u,
28192397771642u, 2248490001u, 3817869868u, 878654626u,
28203785629484u, 1672470870u, 3229367873u, 1894538933u,
28211010692731u,
28221733824268u,
2823656620328u, 3048283803u, 3353340056u, 2324965120u,
28244192585951u, 2284524675u, 3483884368u, 1510168293u,
28251554942691u,
28261309709396u,
28271241133168u, 3162179280u, 4046378054u, 3171681593u,
28281165297136u, 3496703563u, 150437903u, 1948622072u,
28291076332463u,
28302292479143u,
28311464229958u, 3479738093u, 2328067598u, 2334503110u,
2832833324834u, 3981605747u, 3002629155u, 2854644186u,
28332832201336u,
283495796957u,
28353269249397u, 2358313329u, 3411860910u, 4283292480u,
28362802208697u, 1305947955u, 2156803420u, 1991340283u,
2837189678024u,
2838447602599u,
28391055411517u, 1531748363u, 1555852656u, 412402681u,
28403774988152u, 20597551u, 2925024131u, 1423989620u,
28413749428061u,
28421541439448u,
2843112270416u, 1936224776u, 132162941u, 3772011507u,
28443814102518u, 1908807815u, 444154079u, 823765347u,
28453362275567u,
28463419047430u,
28472108287005u, 2315102125u, 658593738u, 3195094029u,
28483721937534u, 3176229204u, 3398835373u, 1271898712u,
28491142546577u,
28503185986817u,
28513562705803u, 2046119567u, 912990621u, 1829977672u,
28523459576979u, 1118045834u, 1369529376u, 3320601076u,
28533954988953u,
28544002467635u,
28553359456351u, 1314849568u, 1766750942u, 2998874853u,
28561181800239u, 707328036u, 3314954697u, 2066721120u,
2857598194215u,
28581124451278u,
28593156679616u, 3742684743u, 2960199690u, 2683497915u,
28602566077529u, 937014607u, 102095219u, 4262922475u,
28613132264275u,
28621262099830u,
2863862722905u, 2717653494u, 3245583534u, 3427209989u,
28643220278124u, 85457091u, 2222333500u, 3513997967u,
28653522324951u,
28662830855552u,
28672215004781u, 3482411840u, 4227160614u, 2030964411u,
28681741393851u, 2643723748u, 942813508u, 403442675u,
28693112048748u,
2870530556423u,
28713817755244u, 3543286628u, 2247276090u, 1532920842u,
28724101962711u, 1446540991u, 3297821473u, 1861255389u,
28731984398u,
28742366525138u,
2875377589481u, 3549193828u, 1427765914u, 506831657u,
2876277278988u, 1447652775u, 3214362239u, 3142198690u,
28772843087541u,
2878468915015u,
2879807895062u, 2198723907u, 4031145069u, 2417156212u,
28804027298697u, 637175947u, 1229254212u, 1773257887u,
28811659444818u,
2882451148891u,
28832099741368u, 735351990u, 2534775713u, 3261804619u,
2884712519954u, 3527962772u, 3758642738u, 4245823575u,
28851281314264u,
28861167866160u,
28871489546151u, 1197354389u, 1043278102u, 2563326586u,
2888371937794u, 2320164817u, 3189512691u, 573685198u,
28894108603513u,
28903758899588u,
28913507030163u, 2947201212u, 2529492585u, 578234375u,
28923362349842u, 3318878925u, 3611203517u, 3059253190u,
28934270755916u,
28944291274625u,
28954237586791u, 4137422245u, 2927218651u, 2444687041u,
2896797128811u, 2043057612u, 396533859u, 2665256178u,
28973346510674u,
28981779586176u,
28993076562062u, 1882746214u, 921095362u, 2026988397u,
2900514514911u, 3886379478u, 4218272420u, 1480386793u,
29013900160816u,
29022292273451u,
29031276138356u, 1125461821u, 1912885715u, 3365266013u,
29041333211627u, 4085009861u, 1390530102u, 3347984752u,
29052721771301u,
29061419492325u,
29074066766256u, 3250852311u, 820111852u, 1382201318u,
29082366036798u, 938032241u, 3100979439u, 487048687u,
29092292851045u,
29103241399180u,
29113912670510u, 2416437067u, 2973194517u, 3507707986u,
29121935099406u, 2533441488u, 104616731u, 2892622820u,
29133801190339u,
29144239188808u,
2915807238241u, 3300121546u, 2249406147u, 4032114017u,
29163713738189u, 3324425575u, 4275607376u, 3663120298u,
29174173658372u,
29183984289690u,
29191827636846u, 3264588778u, 3297165529u, 558623533u,
29202728945672u, 1566297318u, 3447249966u, 481719551u,
29211596842050u,
29221838185946u,
2923265271620u, 1050246315u, 4046655705u, 1844193138u,
29243807563245u, 1075384804u, 1292554949u, 1506525927u,
29252921816148u,
29262051885269u,
29271930534041u, 3872721086u, 1564489377u, 2272482181u,
29282849358683u, 589618304u, 2262072443u, 290363051u,
2929299168363u,
29303867603931u,
29312868688756u, 2545263115u, 1092098533u, 3885725603u,
29322352430409u, 1981595469u, 2047946646u, 1332642839u,
2933793806516u,
2934214858837u,
29351061484659u, 3192394476u, 1115054785u, 3690637234u,
2936996792368u, 2023479706u, 3046498231u, 4205835102u,
29373870714754u,
2938257472875u,
29393549864599u, 2040276129u, 2414778670u, 812235477u,
29402674248196u, 1864096101u, 2257492689u, 1332556794u,
29411079540713u,
2942465530720u,
29432304763972u, 830724724u, 3354588920u, 2510713652u,
29443103749409u, 468835585u, 1707620787u, 3038024846u,
29451000303198u,
29463462270146u,
29472748698899u, 2100348093u, 511537258u, 1237187486u,
2948102049383u, 2268226698u, 3162251739u, 4219404629u,
2949838822407u,
29501481440623u,
29512989224077u, 2676681975u, 3246551821u, 3812079906u,
2952370572963u, 2283154352u, 3084789986u, 1961085583u,
29531955640586u,
29542409348147u,
29552284780581u, 1634818716u, 4018221729u, 2320761377u,
29563566831899u, 1799560520u, 91431959u, 1754113747u,
29571459430477u,
29583613658517u,
2959924489906u, 3406317699u, 866289774u, 3924821603u,
29601265394945u, 1870668109u, 151949856u, 2747006534u,
29613111906201u,
296264039467u,
29632314447545u, 2600195638u, 4095795204u, 4162096026u,
29641026756826u, 2460047982u, 52686887u, 823198739u,
29651518045160u,
29662867527376u,
2967566410761u, 2200433819u, 2114146405u, 2893790965u,
2968881504901u, 974783212u, 490815659u, 937300283u,
29691523735309u,
29702511976468u,
29712634644947u, 355119367u, 1373773092u, 309232995u,
29723088671051u, 787126032u, 3442836843u, 4289194567u,
29732177850062u,
29741174136430u,
29753248982914u, 3129039732u, 1166851580u, 2196451882u,
2976469595580u, 2130837700u, 3783349021u, 3745262548u,
29771236930515u,
29783032131496u,
29791525591437u, 1823628217u, 1939019255u, 1950270463u,
29803659899927u, 3688643445u, 3004399289u, 1155199552u,
2981357547234u,
29822213110526u,
29833122658210u, 2667800490u, 2718690333u, 3512372076u,
29841098611683u, 2657518392u, 4248458835u, 3109874532u,
29851592908438u,
29862864927516u,
29873635248840u, 1251777186u, 3797340158u, 3508496870u,
2988303354834u, 1482394062u, 2087100120u, 1595931912u,
2989608574156u,
2990723367884u,
2991907938402u, 3357047807u, 1619629851u, 3092082995u,
299289030300u, 916336992u, 1861180168u, 3436334155u,
29931375000544u,
29943472936241u,
29951321217853u, 791356402u, 2872410224u, 2326250297u,
29962657644088u, 1748314108u, 4146771421u, 2913114440u,
29972924821844u,
29982101101496u,
29993268017251u, 2109603066u, 690665520u, 1830067573u,
3000951427661u, 2982533150u, 3884512506u, 2358657479u,
30012833210784u,
30023419798214u,
30033785893994u, 2103940206u, 86759766u, 4031230616u,
30043745237192u, 2739453927u, 497038072u, 3303159408u,
30051251537249u,
30061993408196u,
30073185905715u, 2885948408u, 3154277110u, 2444150313u,
30082505582079u, 2120610195u, 3266465773u, 1814611964u,
30093080050407u,
30101079915522u,
30111819346505u, 2529946763u, 892097374u, 3740257161u,
30123618100441u, 1079900094u, 3607172225u, 737863389u,
3013360704560u,
30143341993089u,
30151139047381u, 3132219631u, 1248981859u, 1109338159u,
30162004908615u, 4022302594u, 4166640860u, 2959140950u,
30173949235962u,
30182832278473u,
30192200524012u, 2634933043u, 2495844522u, 2613799818u,
30204034096813u, 683271795u, 1673546817u, 1363163726u,
30211805395136u,
3022511749501u,
30231231032599u, 2305979751u, 345737783u, 3339868854u,
30242931857933u, 2323251738u, 1332068477u, 51846558u,
30253927238177u,
30261387182179u,
30271701238601u, 1419275173u, 2580882268u, 3357874599u,
30281726558907u, 1292901039u, 1371322339u, 1311713044u,
30293526735232u,
30304017884184u,
30313366093428u, 77140994u, 2128996229u, 1357915765u,
30324019691901u, 483989024u, 2390311750u, 2766065288u,
30333938587520u,
30343064810344u,
30351054589198u, 1274997019u, 4040589616u, 1277751144u,
30362274907047u, 4170399945u, 2886368209u, 4168922115u,
30373901237033u,
30383252972311u,
30392205185840u, 3403097556u, 3385493699u, 2809751370u,
3040555319628u, 399539034u, 2998971454u, 1521596214u,
3041178870216u,
30421471733541u,
3043519629198u, 514159209u, 1500582242u, 1928616587u,
30442686427928u, 4133138798u, 1225914083u, 1432713584u,
30453559310915u,
30463925489366u,
30471055613123u, 4126676029u, 2723867653u, 3290604111u,
30481377022957u, 2373608155u, 3615237379u, 594338683u,
30492645257602u,
30502408427260u,
3051917033274u, 750455097u, 625657657u, 121713200u,
30522191273413u, 4043949724u, 3293146785u, 3809297972u,
30533947296919u,
3054115456894u,
30551529576616u, 1459278275u, 2157117997u, 1747859293u,
30564106665903u, 996939232u, 2007976332u, 4274649009u,
30571017725787u,
30584244666096u,
30591219631331u, 3072426253u, 3547691720u, 1620822012u,
30601397717508u, 2031597325u, 3345983430u, 2459068000u,
30613645130467u,
30622308642742u,
3063359955852u, 1348467968u, 1133123059u, 2435919062u,
30642800365907u, 4213217210u, 4056565603u, 2811666556u,
30652318007236u,
30663823652401u,
30673654086429u, 1273260424u, 1591610446u, 943349350u,
30683441227678u, 3779964757u, 233818224u, 3469971032u,
30693764095096u,
30704009204587u,
3071678472092u, 1990559652u, 2583121088u, 2978143652u,
30722496370864u, 2139539656u, 4287972050u, 295832576u,
30733536742861u,
30742257466133u,
30752738052161u, 1988611898u, 2466189642u, 3294419573u,
30762311186273u, 474374532u, 3081964174u, 2515138278u,
3077835731677u,
30781178182694u,
30793352119543u, 2884763225u, 3462399574u, 2900817210u,
30801993698511u, 2868445043u, 2746444849u, 1205258179u,
30812353442946u,
30824079040070u,
30833624133102u, 2907136076u, 2902521697u, 426813211u,
30841418185512u, 3711189488u, 1351506552u, 1934749519u,
308546595543u,
3086401688809u,
30873514602124u, 1396852607u, 1951477943u, 2502249173u,
30883199695820u, 2890250638u, 4205072507u, 1715623846u,
30893266686789u,
30903218688128u,
30911697759742u, 851227671u, 2358709645u, 4174233268u,
3092500583683u, 3805940955u, 736234120u, 2710563712u,
30931949664540u,
30943139414003u,
30954293073253u, 1284406972u, 1785182449u, 1051548274u,
30962994248357u, 2499882522u, 717208669u, 2039517285u,
3097518424929u,
3098143136433u,
30992303774671u, 1272930860u, 2286410920u, 788459311u,
3100273225293u, 2439291703u, 2254505236u, 3446287701u,
31013655156558u,
31021546628787u,
3103340081500u, 3285722006u, 1324810435u, 1053980860u,
31041779472859u, 2700355724u, 686005017u, 3762376315u,
31053963193100u,
31061370881135u,
3107661300087u, 1152753704u, 2349891598u, 3910051187u,
31082109444785u, 1311123870u, 2639837565u, 1896770931u,
31091081414128u,
3110869877586u,
31114284220400u, 63045374u, 235968615u, 184451062u,
31121271099822u, 1319179857u, 3274963209u, 4172272710u,
31133388797445u,
31142965973320u,
31153793110097u, 3327241723u, 2991804005u, 1199544355u,
3116771553759u, 2031749842u, 2596517372u, 1199888213u,
3117858347951u,
31183340178832u,
31192903875412u, 763490382u, 76949161u, 2056544406u,
31201145227689u, 998233136u, 2354530024u, 427713587u,
31213537837347u,
3122604661755u,
3123923986833u, 1023730418u, 798294227u, 432557449u,
3124801802449u, 1861313429u, 3899128441u, 4068407979u,
31252352677083u,
31263783539925u,
312710731973u, 3390767975u, 3949540249u, 1920121661u,
31283248580201u, 641956426u, 2104847395u, 604835744u,
31291491663404u,
31304255204651u,
31311520970746u, 2845653368u, 3247412938u, 3730629005u,
3132855569514u, 3073294700u, 2429691698u, 3818342476u,
31333938869985u,
31342731201328u,
31352335202643u, 778117742u, 13298408u, 228780590u,
31362871715314u, 3253688653u, 4150999702u, 3846220408u,
3137930808u,
31381397128726u,
31391964216488u, 2781092828u, 116285375u, 2271239476u,
31403724347554u, 2931203895u, 3893169206u, 1883912528u,
31412093892660u,
31423658787024u,
31433095016046u, 1094059199u, 3640239610u, 558564267u,
31442102812456u, 464734873u, 925262247u, 1609838036u,
3145588364741u,
31461731409233u,
31471576165139u, 3933979268u, 375316394u, 4247099643u,
31483670508019u, 4080496835u, 2371248533u, 183762693u,
31492078935389u,
31502699810414u,
31511491815683u, 2999180789u, 1831158425u, 1603373553u,
31522006136905u, 3210230591u, 416748595u, 1536971415u,
31533271869367u,
31541266062739u,
31552138414557u, 3337114778u, 1634586826u, 36472629u,
31564482244u, 568009609u, 2721216780u, 4037289545u,
31572235138807u,
31581789351460u,
31594067539527u, 1323062829u, 3864620647u, 4192026301u,
31604278901241u, 1399025382u, 2826652805u, 1363860382u,
31611801770651u,
31621613381526u,
31631165249276u, 4046576622u, 2535596946u, 3260388176u,
31641078898578u, 2259750862u, 643387587u, 237144235u,
31654199571427u,
31663440917581u,
31673067939258u, 2018625455u, 1460528353u, 3138629939u,
31681666223528u, 3841139376u, 2528281125u, 885565193u,
31692609492686u,
31702517257479u,
3171560864620u, 2261471820u, 3491559165u, 1329620416u,
3172622383582u, 1759597655u, 2877873893u, 584692817u,
31731901728399u,
31742599000260u,
31753169771644u, 296332336u, 774719455u, 4175920823u,
31762287316070u, 4115615023u, 1073335619u, 4240292725u,
31771359158837u,
31781960974237u,
31793173724597u, 1619084286u, 2876340752u, 4065675347u,
3180480741335u, 1237329941u, 701055566u, 3729009837u,
31811314736422u,
31824003180069u,
31833118519317u, 3035354420u, 3380357671u, 4020909015u,
3184253958714u, 3545798863u, 3008185002u, 2624719888u,
31853219955575u,
31863060719376u,
3187573101682u, 1580316843u, 2610493412u, 3490983536u,
31883601975611u, 851470366u, 635384901u, 3427048824u,
31891470002757u,
31903592460087u,
31912265226856u, 4124282457u, 2106385486u, 3334305617u,
31924208282753u, 3798749815u, 225396466u, 118791182u,
31932523395972u,
3194194595464u,
31952563824631u, 2521301383u, 4224409406u, 468670274u,
31961761966400u, 1300908277u, 2570709228u, 1847901526u,
31971470099163u,
31982690466752u,
31991472536718u, 2399279735u, 4150607803u, 1775080054u,
32002082537685u, 4080034578u, 1256001880u, 392967725u,
32012055838940u,
32023349115816u,
32031745947263u, 2213925887u, 1836572741u, 2417722792u,
3204636223705u, 2423329294u, 3960951311u, 1543591052u,
32051547914361u,
32062760945653u,
32073519014111u, 313543871u, 4119598884u, 1071003714u,
32082192556597u, 1526995535u, 3929839778u, 536388591u,
32093040873792u,
32103752682932u,
32111640614237u, 2432794021u, 385337403u, 2794410617u,
32122386128075u, 1055206708u, 1422747714u, 3759330929u,
32132533597496u,
321430440955u,
32151482899460u, 3350385050u, 616259409u, 3980103795u,
32161211364140u, 1040071544u, 594746920u, 1645973936u,
32172547331531u,
32181097726368u,
3219700666526u, 2976247482u, 1144906608u, 996506677u,
32201997130756u, 800321417u, 1392942823u, 1601662248u,
32212079778663u,
3222529512908u,
32232925120134u, 4106433085u, 630221833u, 2423086156u,
32241119859778u, 1726827981u, 1870859181u, 2559832707u,
32251792284257u,
32262059356387u,
32273572353364u, 3229407475u, 575621095u, 3221893291u,
32282372428048u, 2020123035u, 961449593u, 2243824063u,
32293803906611u,
32303735348189u,
32312981620804u, 4180681078u, 1555330629u, 230736535u,
32322075526640u, 749652975u, 713664372u, 2152096659u,
32332142067223u,
32343322302242u,
32351421646830u, 2092832615u, 1213735101u, 3192136753u,
32361106723940u, 3455398230u, 2541685524u, 2529956739u,
32373789430647u,
32381950084508u,
32392157395621u, 850457360u, 2758902426u, 2848030169u,
32406506379u, 1162213157u, 2981459221u, 272690871u,
32413059420255u,
32424242691285u,
3243588065598u, 1206949936u, 3968214184u, 566348532u,
3244126142880u, 1480567086u, 2959621988u, 2050218418u,
32452242731195u,
32463833514449u,
32471898070331u, 3687399477u, 3891859374u, 868185955u,
32482335308774u, 3676335246u, 3871121805u, 2189032743u,
32493275728647u,
3250860492892u,
32511590764344u, 4130384758u, 262871548u, 3004764525u,
32522685542071u, 991231482u, 435122019u, 3031116998u,
32532898921700u,
32542917932604u,
32554238665148u, 2459072654u, 3444612545u, 4207731740u,
32561808564313u, 2798532269u, 3944553556u, 3926395409u,
32571633200670u,
32584138335224u,
32592524878605u, 4184292650u, 3563398268u, 4288943552u,
32603802121210u, 957502058u, 2410820887u, 4227117506u,
32614018625153u,
32624284329158u,
3263530216712u, 2978986531u, 863452221u, 1910162118u,
32644088211378u, 4091971261u, 3150811451u, 4200871487u,
32653794038652u,
32663041564310u,
32672045287082u, 887805614u, 2889167251u, 4120352181u,
32681699912580u, 3478922097u, 3211994687u, 3136177842u,
32691500806861u,
32703211881347u,
32712147976385u, 3342722260u, 3359650541u, 4197378460u,
3272781354073u, 1533623029u, 2204677828u, 3228172832u,
32733248592437u,
32743355841359u,
3275560815159u, 1144951236u, 4027015711u, 2882625391u,
3276339363613u, 2354572719u, 1769831876u, 4238589331u,
32771519732871u,
32782185834614u,
32791601096831u, 129709881u, 39655633u, 367604993u,
32801737681770u, 3259114599u, 2767070452u, 872365177u,
32811574125529u,
32823405020189u,
32834181346685u, 1134030380u, 403769171u, 2193351164u,
32841426232618u, 2885309450u, 3033612627u, 924948363u,
3285935514094u,
32863202053329u,
3287912294839u, 1618472324u, 4159158431u, 3744999487u,
3288777064358u, 3974213124u, 1990246048u, 309725290u,
32892449849392u,
32901943692420u,
32912288635750u, 2433793635u, 2168904061u, 683315308u,
32923081493019u, 3477759434u, 3815496269u, 2823504699u,
3293586945121u,
32943088963200u,
32953492287335u, 636875049u, 1111206944u, 2037346120u,
32961282050044u, 1409681512u, 1786128584u, 755810950u,
32972332676758u,
32982178142310u,
3299957827166u, 1014983590u, 1888800725u, 3608595803u,
33003200072714u, 2534008478u, 659336139u, 1281728287u,
33014060560529u,
33022915575125u,
33033521503774u, 2926487340u, 1096297674u, 653489861u,
33042352326980u, 2561136777u, 1224141198u, 1250479629u,
33051297625391u,
33062409997371u,
33071942483722u, 2481835750u, 1394715707u, 1673070941u,
33082456039704u, 3980558014u, 3547934764u, 1882038812u,
33091078160498u,
33102488279087u,
33111848235245u, 1211914722u, 2264928765u, 2807773070u,
3312270145554u, 583747883u, 3826009010u, 2996618216u,
3313425727157u,
3314992726957u,
33153384462280u, 726650661u, 1955043265u, 1923879512u,
33161854693773u, 2987614542u, 2660044993u, 2457260810u,
3317426299370u,
33182671892900u,
33191827308087u, 3083953443u, 1791749638u, 3265087416u,
33202119752201u, 2547122538u, 3990783236u, 1912713468u,
33213688865211u,
33221815780016u,
3323303699291u, 2416763742u, 2690891610u, 1535193548u,
33241107803989u, 1504143133u, 2235270371u, 2545884083u,
33252276278682u,
3326411724404u,
33273416925704u, 2565792091u, 3383911757u, 546058824u,
33283374654444u, 2364630415u, 2693473470u, 2622125691u,
3329261864817u,
333055682470u,
3331857617568u, 141304067u, 1885488541u, 155368182u,
33321281949051u, 3384522408u, 3254816901u, 1959816782u,
33331452224057u,
33342830267691u,
33353709231247u, 58988202u, 4218130458u, 2984061349u,
33361888707848u, 4223605071u, 4241442486u, 375269213u,
33373208327038u,
33382199916493u,
3339550337252u, 2855061437u, 276088636u, 114362204u,
33402321163647u, 2127813633u, 3289403024u, 2686973202u,
33412717376797u,
33423593428039u,
33433648831666u, 890925902u, 3289404818u, 3289516821u,
33444248913260u, 1858916580u, 3303932308u, 1752797086u,
33451628149686u,
33463245893605u,
33471568537311u, 2844194502u, 1593855770u, 2408174109u,
3348124797514u, 2085649512u, 3188565660u, 2264996276u,
33491926696513u,
33503053957740u,
33512238806881u, 2189050973u, 203685243u, 379855590u,
33523920271562u, 1058600179u, 3698061923u, 4255106849u,
3353608401664u,
33541598041932u,
33553318266418u, 2535016555u, 852760884u, 1918098822u,
33562200437599u, 1532285043u, 3425662132u, 3561293706u,
33572231633206u,
33584108785088u,
33593359152801u, 173534780u, 208383607u, 2862988169u,
33602406642243u, 426814583u, 2777335795u, 3322703596u,
3361954190623u,
3362615093090u,
33634179102978u, 2452847930u, 100239619u, 42471741u,
3364818352432u, 2190624654u, 504379960u, 3631619975u,
3365633412456u,
33661018421783u,
3367842645419u, 711808707u, 3424580813u, 2132457941u,
33681158335882u, 3567952480u, 2302183699u, 1145788151u,
33693474264138u,
33703105085243u,
33713115506027u, 2783713015u, 3871785309u, 539583269u,
33721400252405u, 3857849984u, 4231186588u, 1278653799u,
33731760227022u,
3374761044088u,
33753838185417u, 2439542532u, 585283357u, 2055995220u,
3376937117124u, 3831944855u, 1823586038u, 3287917855u,
3377485082427u,
33783209172809u,
33791984570176u, 2818337297u, 2691869057u, 3790476953u,
3380839035557u, 3203129010u, 669981176u, 4121157385u,
33813519870450u,
33823792633352u,
33833017650322u, 1603459507u, 4225677666u, 376555451u,
3384473780127u, 2018786277u, 3299822439u, 1010254499u,
33852383887565u,
33863155009499u,
33873108110655u, 2641738274u, 3684908622u, 1606463047u,
33883311068174u, 52708046u, 754181455u, 1018079176u,
33893915670272u,
33903366999425u,
33911012880204u, 1339439715u, 466437962u, 1402662350u,
33922504046911u, 736323938u, 2037800124u, 1725908589u,
3393716341840u,
33941750123474u,
33953366342464u, 1743666195u, 2975303189u, 3821364027u,
33963253707772u, 3635548377u, 3840413796u, 1955642085u,
33971018315169u,
33981258092848u,
33992095540656u, 1076256607u, 117289557u, 1311658655u,
34002118301000u, 68721550u, 2886814107u, 2712432819u,
34014201862886u,
3402753807148u,
34031940229047u, 731347296u, 1068901393u, 3873155894u,
34042852787666u, 1973464853u, 79735652u, 3966380587u,
34053245740712u,
34062525773438u,
3407734938109u, 3045656416u, 3335746354u, 4099732691u,
34081911896517u, 1697006473u, 1145487066u, 1605663299u,
34093053606724u,
34102386289465u,
34113821211369u, 1006215345u, 1256304829u, 1053001668u,
34121289194958u, 118761054u, 1853688730u, 2803418011u,
3413188650809u,
34143763686458u,
34151006829556u, 2961984133u, 3390525025u, 2061199893u,
3416141792681u, 2439893463u, 2652982650u, 1804942682u,
34171546510005u,
34181246961405u,
34192407577046u, 565772575u, 3751844810u, 2943166103u,
34203750052451u, 3022527280u, 25162928u, 397381043u,
34211818337632u,
34223447363730u,
34233936437150u, 2569420703u, 2215592390u, 2171555672u,
34243665571006u, 4021712412u, 2939158353u, 4057813172u,
34251823237318u,
3426103999245u,
34273251978010u, 3591914940u, 3582495283u, 2519035265u,
34283905726135u, 3180393349u, 2743117123u, 55247368u,
34293325286701u,
3430705195946u,
34311857526853u, 1480518550u, 3809990433u, 1398189338u,
34323126362926u, 3959531492u, 1503658285u, 1977847740u,
34333043964489u,
34342613086143u,
34351518119282u, 4238434900u, 3905746486u, 3064949667u,
34361028122931u, 3309119457u, 4071194920u, 3096098907u,
34374137180520u,
3438494467959u,
34391231408687u, 1691606157u, 1793452569u, 2722196118u,
34403478603952u, 1059665738u, 2282032278u, 3990268388u,
34411719514651u,
34424248311578u,
34433799146721u, 898026304u, 3367808954u, 4162472815u,
3444170495870u, 1308116609u, 3428285344u, 1714716475u,
3445395576794u,
34464153638621u,
34472999745812u, 3483315953u, 304980828u, 595337120u,
34483486516729u, 2331563143u, 2583609459u, 1885928417u,
34493834283777u,
3450979337825u,
3451932057378u, 3124081189u, 1930356777u, 3865887996u,
34524178282217u, 4214219408u, 3669465884u, 1472413856u,
34533356866587u,
34541012769806u,
34553043639963u, 996996396u, 207308216u, 982967331u,
34562991319933u, 318066902u, 721489670u, 1249967713u,
3457749240921u,
3458591392325u,
34592379365192u, 2250868849u, 2163259329u, 143191325u,
34603778285606u, 982149096u, 3536906200u, 2244353244u,
34611443862317u,
34623161549210u,
34632183127464u, 2015409516u, 547003700u, 2032484282u,
3464523677821u, 4275663308u, 3827205526u, 3903778273u,
34652444530525u,
34662543645801u,
34671173958423u, 784740616u, 2878693675u, 3127696736u,
34683832037316u, 3161002398u, 4084166400u, 4213346853u,
3469223390424u,
34704273380883u,
34712130315482u, 3429606032u, 3367732613u, 1912357694u,
3472422632590u, 1266957023u, 3437535648u, 736404240u,
34732281709372u,
3474415859912u,
3475212948797u, 351612650u, 3920561440u, 112963586u,
34762230727543u, 2851076612u, 1990662634u, 2264296857u,
34773131463650u,
34782704034623u,
34793541637839u, 2954232792u, 533986918u, 4158757533u,
348065174248u, 4232639593u, 865906667u, 1948225652u,
3481779656112u,
34823873989249u,
34832372984749u, 2346988193u, 1104345713u, 1165654138u,
34844045762610u, 3588205178u, 461363991u, 1111215752u,
34851389675192u,
34862404325151u,
34872152228101u, 3808973622u, 1901235912u, 3458690696u,
3488314513238u, 2539459143u, 2847998873u, 952026138u,
34892325705328u,
3490407844712u,
34913727960715u, 2996448351u, 2374336760u, 3138756390u,
34922600015243u, 539980418u, 1876285352u, 1670330799u,
34931709360377u,
34942868531654u,
3495494777964u, 2773053597u, 599486162u, 3962209577u,
34961871328846u, 2171933018u, 110279472u, 384074780u,
34974147021936u,
34982333589647u,
34994251778066u, 40493468u, 3099342316u, 4108779767u,
35002812424588u, 954542332u, 2040682331u, 2251152306u,
350145915516u,
3502259525626u,
35031045384743u, 4134656562u, 749389261u, 874399445u,
3504616549904u, 2200447504u, 436024539u, 78972290u,
35053210485762u,
35061907985531u,
35073013721395u, 4214533685u, 4198804243u, 534879265u,
35081517190881u, 3756787754u, 1152563554u, 1718750948u,
3509777737463u,
35101402478860u,
35111824562784u, 1879401449u, 3515818786u, 513165201u,
35121423491227u, 2103067918u, 2291777410u, 1097943000u,
3513};
3514
3515// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
3516bool Test(int offset, int len = 0) {
3517#undef Check
3518#undef IsAlive
3519
3520#define Check(x) do { \
3521 const uint32_t actual = (x), e = expected[index++]; \
3522 bool ok = actual == e; \
3523 if (!ok) { \
3524 cerr << "expected " << hex << e << " but got " << actual << endl; \
3525 ++errors; \
3526 } \
3527 assert(ok); \
3528} while (0)
3529
3530#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
3531
3532 // After the following line is where the uses of "Check" and such will go.
3533 static int index = 0;
3534if (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; }
3535Check(farmhashcc::Hash32WithSeed(data + offset, len, SEED));
3536Check(farmhashcc::Hash32(data + offset, len));
3537{ 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); }
3538{ 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); }
3539
3540 return true;
3541#undef Check
3542#undef IsAlive
3543}
3544
3545int RunTest() {
3546 Setup();
3547 int i = 0;
3548 cout << "Running farmhashccTest";
3549 if (!Test(-1)) {
3550 cout << "... Unavailable\n";
3551 return NoteErrors();
3552 }
3553 // Good. The function is attempting to hash, so run the full test.
3554 int errors_prior_to_test = errors;
3555 for ( ; i < kTestSize - 1; i++) {
3556 Test(i * i, i);
3557 }
3558 for ( ; i < kDataSize; i += i / 7) {
3559 Test(0, i);
3560 }
3561 Test(0, kDataSize);
3562 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
3563 return NoteErrors();
3564}
3565
3566#else
3567
3568// After the following line is where the code to print hash codes will go.
3569void Dump(int offset, int len) {
3570cout << farmhashcc::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
3571cout << farmhashcc::Hash32(data + offset, len) << "u," << endl;
3572{ 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; }
3573{ 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; }
3574}
3575
3576#endif
3577
3578#undef SEED
3579#undef SEED1
3580#undef SEED0
3581
3582} // namespace farmhashccTest
3583
3584#if !TESTING
3585int main(int argc, char** argv) {
3586 Setup();
3587 cout << "uint32_t expected[] = {\n";
3588 int i = 0;
3589 for ( ; i < kTestSize - 1; i++) {
3590 farmhashccTest::Dump(i * i, i);
3591 }
3592 for ( ; i < kDataSize; i += i / 7) {
3593 farmhashccTest::Dump(0, i);
3594 }
3595 farmhashccTest::Dump(0, kDataSize);
3596 cout << "};\n";
3597}
3598#endif
3599#ifndef FARMHASH_SELF_TEST_GUARD
3600#define FARMHASH_SELF_TEST_GUARD
3601#include <cstdio>
3602#include <iostream>
3603#include <string.h>
3604
3605using std::cout;
3606using std::cerr;
3607using std::endl;
3608using std::hex;
3609
3610static const uint64_t kSeed0 = 1234567;
3611static const uint64_t kSeed1 = k0;
3612static const int kDataSize = 1 << 20;
3613static const int kTestSize = 300;
3614#define kSeed128 Uint128(kSeed0, kSeed1)
3615
3616static char data[kDataSize];
3617
3618static int completed_self_tests = 0;
3619static int errors = 0;
3620
3621// Initialize data to pseudorandom values.
3622void Setup() {
3623 if (completed_self_tests == 0) {
3624 uint64_t a = 9;
3625 uint64_t b = 777;
3626 for (int i = 0; i < kDataSize; i++) {
3627 a += b;
3628 b += a;
3629 a = (a ^ (a >> 41)) * k0;
3630 b = (b ^ (b >> 41)) * k0 + i;
3631 uint8_t u = b >> 37;
3632 memcpy(data + i, &u, 1); // uint8_t -> char
3633 }
3634 }
3635}
3636
3637int NoteErrors() {
3638#define NUM_SELF_TESTS 9
3639 if (++completed_self_tests == NUM_SELF_TESTS)
3640 std::exit(errors > 0);
3641 return errors;
3642}
3643
3644template <typename T> inline bool IsNonZero(T x) {
3645 return x != 0;
3646}
3647
3648template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
3649 return x != Uint128(0, 0);
3650}
3651
3652#endif // FARMHASH_SELF_TEST_GUARD
3653
3654namespace farmhashmkTest {
3655
3656uint32_t CreateSeed(int offset, int salt) {
3657 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
3658 h = h * c1;
3659 h ^= (h >> 17);
3660 h = h * c1;
3661 h ^= (h >> 17);
3662 h = h * c1;
3663 h ^= (h >> 17);
3664 h += static_cast<uint32_t>(offset & 0xffffffff);
3665 h = h * c1;
3666 h ^= (h >> 17);
3667 h = h * c1;
3668 h ^= (h >> 17);
3669 h = h * c1;
3670 h ^= (h >> 17);
3671 return h;
3672}
3673
3674#undef SEED
3675#undef SEED1
3676#undef SEED0
3677#define SEED CreateSeed(offset, -1)
3678#define SEED0 CreateSeed(offset, 0)
3679#define SEED1 CreateSeed(offset, 1)
3680
3681#undef TESTING
3682#define TESTING 1
3683#if TESTING
3684uint32_t expected[] = {
36854223616069u,
36863696677242u,
36874081014168u,
36882576519988u,
36892212771159u,
36901112731063u,
36911020067935u,
36923955445564u,
36931451961420u,
3694653440099u,
369531917516u,
36962957164615u,
36972590087362u,
36983879448744u,
3699176305566u,
37002447367541u,
37011359016305u,
37023363804638u,
37031117290165u,
37041062549743u,
37052437877004u,
37061894455839u,
3707673206794u,
37083486923651u,
37093269862919u,
37102303349487u,
37111380660650u,
3712595525107u,
37131525325287u,
37142025609358u,
3715176408838u,
37161592885012u,
3717864896482u,
37182101378090u,
37193489229104u,
37202118965695u,
3721581644891u,
37222718789079u,
3723631613207u,
37244228658372u,
37253867875546u,
37263531368319u,
37273804516756u,
37283317755099u,
37291619744564u,
37302884717286u,
37311088213445u,
37322667691076u,
37333727873235u,
37342330406762u,
37353616470388u,
3736967660719u,
37374148162586u,
3738315219121u,
3739673084328u,
37403047602355u,
37411598963653u,
37421267826661u,
37432117362589u,
37442861192253u,
37451823625377u,
37461380350078u,
37471641748342u,
37481176094482u,
3749269384321u,
37502178982315u,
37513480237248u,
37522660755208u,
37531850544433u,
37543429699438u,
37551262819303u,
3756640556464u,
37572421125401u,
37582188368608u,
37592612932825u,
37601474432581u,
3761173790449u,
37622124882189u,
3763831272654u,
3764622960146u,
37654238751051u,
37663250317967u,
37672120810248u,
37681948231495u,
37691389029321u,
37702200398357u,
37712134232963u,
37722948072329u,
3773617717625u,
3774681164587u,
3775114859387u,
3776430545646u,
377757239089u,
37783163338012u,
37793482496399u,
3780557662576u,
37811102441413u,
37822670159360u,
3783991116729u,
3784846014240u,
37854233741566u,
37861802317242u,
37873129528802u,
37881459456375u,
37891305643039u,
37903258671612u,
37911578285833u,
3792868590079u,
37931631034517u,
37941695432937u,
3795561078856u,
37961004115553u,
37973086090507u,
37983818348650u,
3799731596645u,
3800780926790u,
38012544205955u,
3802158479164u,
38033983514188u,
38042004735250u,
38053436218400u,
3806673684751u,
38071463431419u,
38082880490219u,
38093223748024u,
38102218318859u,
38111474466194u,
38122636437533u,
38132206794961u,
3814140995728u,
38151186394086u,
38161805716888u,
38171640037724u,
38183942729099u,
38191944727013u,
3820918951560u,
3821498666871u,
38223486974657u,
38232967205462u,
38241167253804u,
38251884281041u,
38262866015002u,
38274158319270u,
38282627220079u,
38293733319624u,
38303317092271u,
3831438323662u,
38323195868065u,
38333426606709u,
3834360708338u,
38351905491012u,
3836650004803u,
38371351266252u,
38383133279000u,
38393722811115u,
38402722412434u,
3841918432408u,
38423678271248u,
3843269599647u,
3844621514057u,
38453117077855u,
38461545425390u,
38472597567410u,
38481221437820u,
38493493254589u,
3850102787342u,
3851918861168u,
3852348795089u,
38533439883229u,
38542353641807u,
38552209585469u,
38564035884492u,
38572686995435u,
38581649888022u,
38593852893848u,
38603042700028u,
3861314103172u,
3862726977769u,
38632489830276u,
38642872753660u,
38651316214989u,
38661488801501u,
38671811420390u,
3868639581627u,
38692362837215u,
38703634581834u,
38713648576802u,
38721257314182u,
3873762118371u,
38744268447045u,
3875730167096u,
3876755561509u,
3877882614845u,
38783696972894u,
3879228263661u,
38801478636142u,
38812767751651u,
38821532617116u,
38833838657661u,
38841944359935u,
38851401102137u,
38863772933173u,
38871050098254u,
38881658079354u,
38891846025728u,
38902204244794u,
38912017217424u,
38921275162853u,
38931429816745u,
38942175565479u,
38951716109139u,
38961187506761u,
38972434641075u,
38982725597783u,
38991795687662u,
39001393312782u,
39013511565397u,
3902627885430u,
39034145733164u,
39042519005353u,
3905231414775u,
39061242015635u,
39072760723497u,
39082185540568u,
3909727314436u,
39102358790354u,
39111186393454u,
39124234795645u,
3913350567813u,
3914866773875u,
39153145590392u,
39161158374055u,
39173903123687u,
39181862119793u,
39192204587556u,
39204266276976u,
39214151548555u,
3922915250402u,
39232874695320u,
39242360311410u,
39251099212769u,
39261271542714u,
39273473148363u,
39281637325418u,
39291807795989u,
39302493819794u,
39313800917924u,
39324001205856u,
39332582153621u,
39343365872040u,
39352890146216u,
39362626363824u,
39373133351295u,
39384046827296u,
39393053118771u,
39404113026751u,
3941884356716u,
39423828347401u,
394310608262u,
3944830987972u,
39451841080500u,
39463202717763u,
39473561778749u,
39481906000052u,
39493058284660u,
39501432904514u,
39512567431677u,
39522550162530u,
3953665557986u,
3954936887821u,
39552101205308u,
39564253535847u,
39571662043545u,
39581253611611u,
39592091370094u,
39602635077370u,
39612602176041u,
39623624115809u,
3963748442714u,
39642709749154u,
39651023493343u,
3966860291012u,
39673924715584u,
39681536436740u,
39692551145800u,
39702391782865u,
39711467705048u,
39722583909796u,
39733616666170u,
39741162857372u,
39754228631071u,
39761510132376u,
39772739165009u,
39782656606142u,
39793454996358u,
39803155038853u,
39811022087316u,
3982100044110u,
3983494208296u,
39842746186477u,
39854216782431u,
3986225448834u,
39873728320521u,
3988335282866u,
39893148194874u,
3990953503703u,
39911293353960u,
3992202372387u,
39931326119870u,
39944045123735u,
39953819994846u,
39961629004186u,
39971081099186u,
39983591584153u,
39991670825804u,
40003404257979u,
40013262192301u,
40022572846095u,
40033714992543u,
40044264142572u,
4005529616678u,
40062882154574u,
40073006354178u,
40083865969421u,
40092007174907u,
4010308283107u,
40112629833703u,
40123159124075u,
40131146492131u,
4014494104332u,
4015493149727u,
40161342910585u,
4017521642387u,
40182201695937u,
40192517980959u,
40202426821287u,
4021777374655u,
40222228189792u,
40234027055486u,
4024228976000u,
40253842083468u,
40261723920223u,
40271192126094u,
4028787744493u,
40292740368380u,
40302284153001u,
40312773829458u,
4032442000614u,
4033387830783u,
40342169780670u,
40352253144627u,
40363532502484u,
40371969684059u,
40381165351416u,
40393055056536u,
40403582324253u,
4041231419363u,
4042770979865u,
40433213983597u,
40443690452836u,
4045935794639u,
40463230602762u,
40472841762457u,
4048407598927u,
40491164479891u,
40503721799696u,
4051354738136u,
40521801566618u,
40533206038542u,
40542621379981u,
40551943487262u,
40563534745636u,
40571074424589u,
40581304517521u,
40594133400969u,
40602339317978u,
40612135116860u,
40624180643791u,
40632415309340u,
40641855926417u,
40653418648630u,
40661968113037u,
4067597304222u,
40683668824865u,
40693810008716u,
40703014702569u,
40713151212026u,
4072156057449u,
4073373134533u,
40742068234004u,
4075191580563u,
40763832754488u,
40772924104199u,
40782026044494u,
40794065780435u,
4080122565840u,
40814194985167u,
40822744823717u,
40832494098735u,
40843753793370u,
40851885739217u,
40862488161225u,
40873643797615u,
40882653367310u,
40892494061477u,
4090189968132u,
4091899646597u,
4092392100396u,
40934012318310u,
40943855777086u,
40953566860954u,
40962698574996u,
40972414249905u,
40981330623339u,
40991263222732u,
41001277741760u,
41012194959402u,
41021629656136u,
4103120494320u,
41041072368005u,
41051084245077u,
41064011372748u,
41071366613353u,
41083108643228u,
41093332219532u,
41102114746095u,
41113964007334u,
4112371687128u,
41131084813876u,
4114126459896u,
41154292782331u,
4116321283184u,
4117398168499u,
41183604983506u,
4119560701543u,
41202073961354u,
41214240841868u,
41224151211362u,
41231338986875u,
41244093476832u,
41252269279497u,
41263500846299u,
41272510225147u,
4128598000444u,
41291330391422u,
41301432533385u,
41314171226231u,
4132426821154u,
41332932270996u,
41343378981077u,
41352217871549u,
41361619647984u,
41374051608043u,
41383180237819u,
413912919578u,
41401375401767u,
4141371320427u,
41422986640571u,
41432336669859u,
41443796464715u,
41451892383284u,
4146306814912u,
41472125823211u,
41481863678891u,
41493249703818u,
41503840225752u,
4151281579900u,
4152264680257u,
41534266359110u,
41544182229890u,
41552239659703u,
41563627947372u,
41572373929191u,
4158224082765u,
41594053639058u,
41601862360303u,
41613187739624u,
41623392706679u,
4163948039509u,
4164817505760u,
41651215842393u,
41663462222651u,
4167536021853u,
4168182346832u,
41692731944883u,
41702346674384u,
41712640961678u,
41723446695687u,
41732271722179u,
41741301069656u,
41752803881468u,
41762832614405u,
41771691544398u,
4178698756814u,
41793980620906u,
41803565421410u,
4181754769376u,
41824115923404u,
41833909962218u,
41842747614077u,
41852888289845u,
41861016920862u,
41872790946178u,
41883067070960u,
41893173251481u,
41901572132982u,
4191255048203u,
41922996538818u,
41933405398987u,
4194136106013u,
41953581605228u,
41964277437977u,
41972147300534u,
41983728426265u,
41993483629996u,
42001478452694u,
420120756076u,
42022774992067u,
4203432987927u,
42041516771026u,
42053511588664u,
42062130994978u,
4207509385406u,
4208873090347u,
42092163904107u,
42104192239086u,
42112532489989u,
42121090772651u,
42133910797408u,
42143710882132u,
4215155010959u,
42161369823531u,
42171599664937u,
42184035593587u,
42191212746925u,
4220795822552u,
4221116689518u,
42223674240941u,
42231135576664u,
4224756750261u,
42251027431362u,
4226390555140u,
42272228460216u,
42281506940482u,
42293733857700u,
42303048762971u,
42312511703196u,
4232548609887u,
42331607354252u,
4234659053982u,
4235259884450u,
42361793130460u,
42374083364495u,
42383148555881u,
42391764350138u,
42402436485683u,
42414031563025u,
42423261860724u,
42432475833430u,
42442101726086u,
42453191176464u,
42462646658847u,
42472127042126u,
4248771316100u,
42492115922959u,
42503208515045u,
42512355437783u,
42523621147793u,
42531580163615u,
42543211555675u,
42553299188490u,
4256191613920u,
4257466733956u,
42582939029038u,
42591509152039u,
4260130591314u,
42611892874677u,
42621646908044u,
42633452406523u,
42643998376606u,
42651199243832u,
42662187108812u,
42673189230066u,
42684161151481u,
42693371454980u,
42703681788646u,
4271180842187u,
42723685022399u,
42733058749895u,
42743250165163u,
42752895367943u,
42762627101723u,
4277771755098u,
42781332921024u,
42793638871848u,
4280514215135u,
42813591227378u,
42822300310870u,
42833689533503u,
4284851607114u,
4285114330368u,
42862709027386u,
42871743034877u,
42881013693860u,
4289288169008u,
42903545190686u,
42911052165084u,
42923995862307u,
429396902755u,
42941097819851u,
42952645431442u,
42962184148618u,
42972151206566u,
4298350979797u,
42993467920900u,
4300421116779u,
43011246252u,
43024057835428u,
4303329324407u,
43044104482417u,
4305844624570u,
43063306265806u,
43073787625025u,
43084263241191u,
43093251413927u,
43102921204431u,
43112931915325u,
4312992134330u,
43133986338354u,
43141327895216u,
43151458363596u,
43161480608532u,
4317728594368u,
43183804366693u,
4319794404223u,
43201643240863u,
4321793417255u,
43224167916443u,
43232683488959u,
43243124925324u,
43254184843652u,
43263750971752u,
4327308509829u,
43281054550805u,
43292797511972u,
43304043123412u,
43311587158240u,
43324050518606u,
43333030062190u,
43342589912753u,
4335603440067u,
4336937013191u,
43371071662315u,
43382100661456u,
43392602005741u,
4340435516078u,
43412260470147u,
43421256268350u,
43433612035u,
43443368856141u,
4345151516099u,
43463081868591u,
43473363755681u,
43482049963149u,
43492885320434u,
435084682005u,
43512411758308u,
43522695174275u,
43533099904644u,
43541787308684u,
43551132379308u,
4356564634346u,
4357510236510u,
43582804443681u,
43593931864252u,
43602064427949u,
43611893979229u,
43622916544974u,
43631885887717u,
43642978018250u,
4365494192125u,
43662642662373u,
4367901112508u,
4368636035003u,
43691658643797u,
4370172746975u,
4371517504890u,
43723440019372u,
43734144498044u,
43741854755456u,
43753672653905u,
43764176892856u,
4377382159097u,
4378282871690u,
43793629300472u,
43802500754041u,
43811677659759u,
43821067175061u,
4383161654075u,
43841672575536u,
4385346120493u,
43862730229631u,
4387203466442u,
43881244549529u,
4389199761971u,
43902744895408u,
43913195315331u,
43922124618519u,
43933261045496u,
4394985339699u,
43953385585455u,
43961545740710u,
43973636652160u,
43982167020081u,
43991207897204u,
440028752417u,
44012895834146u,
44023640845375u,
44033750293073u,
4404548997850u,
44054207814196u,
44064183030708u,
44072462810989u,
44083929965401u,
4409};
4410
4411// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
4412bool Test(int offset, int len = 0) {
4413#undef Check
4414#undef IsAlive
4415
4416#define Check(x) do { \
4417 const uint32_t actual = (x), e = expected[index++]; \
4418 bool ok = actual == e; \
4419 if (!ok) { \
4420 cerr << "expected " << hex << e << " but got " << actual << endl; \
4421 ++errors; \
4422 } \
4423 assert(ok); \
4424} while (0)
4425
4426#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
4427
4428 // After the following line is where the uses of "Check" and such will go.
4429 static int index = 0;
4430if (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; }
4431Check(farmhashmk::Hash32WithSeed(data + offset, len, SEED));
4432Check(farmhashmk::Hash32(data + offset, len));
4433
4434 return true;
4435#undef Check
4436#undef IsAlive
4437}
4438
4439int RunTest() {
4440 Setup();
4441 int i = 0;
4442 cout << "Running farmhashmkTest";
4443 if (!Test(-1)) {
4444 cout << "... Unavailable\n";
4445 return NoteErrors();
4446 }
4447 // Good. The function is attempting to hash, so run the full test.
4448 int errors_prior_to_test = errors;
4449 for ( ; i < kTestSize - 1; i++) {
4450 Test(i * i, i);
4451 }
4452 for ( ; i < kDataSize; i += i / 7) {
4453 Test(0, i);
4454 }
4455 Test(0, kDataSize);
4456 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
4457 return NoteErrors();
4458}
4459
4460#else
4461
4462// After the following line is where the code to print hash codes will go.
4463void Dump(int offset, int len) {
4464cout << farmhashmk::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
4465cout << farmhashmk::Hash32(data + offset, len) << "u," << endl;
4466}
4467
4468#endif
4469
4470#undef SEED
4471#undef SEED1
4472#undef SEED0
4473
4474} // namespace farmhashmkTest
4475
4476#if !TESTING
4477int main(int argc, char** argv) {
4478 Setup();
4479 cout << "uint32_t expected[] = {\n";
4480 int i = 0;
4481 for ( ; i < kTestSize - 1; i++) {
4482 farmhashmkTest::Dump(i * i, i);
4483 }
4484 for ( ; i < kDataSize; i += i / 7) {
4485 farmhashmkTest::Dump(0, i);
4486 }
4487 farmhashmkTest::Dump(0, kDataSize);
4488 cout << "};\n";
4489}
4490#endif
4491#ifndef FARMHASH_SELF_TEST_GUARD
4492#define FARMHASH_SELF_TEST_GUARD
4493#include <cstdio>
4494#include <iostream>
4495#include <string.h>
4496
4497using std::cout;
4498using std::cerr;
4499using std::endl;
4500using std::hex;
4501
4502static const uint64_t kSeed0 = 1234567;
4503static const uint64_t kSeed1 = k0;
4504static const int kDataSize = 1 << 20;
4505static const int kTestSize = 300;
4506#define kSeed128 Uint128(kSeed0, kSeed1)
4507
4508static char data[kDataSize];
4509
4510static int completed_self_tests = 0;
4511static int errors = 0;
4512
4513// Initialize data to pseudorandom values.
4514void Setup() {
4515 if (completed_self_tests == 0) {
4516 uint64_t a = 9;
4517 uint64_t b = 777;
4518 for (int i = 0; i < kDataSize; i++) {
4519 a += b;
4520 b += a;
4521 a = (a ^ (a >> 41)) * k0;
4522 b = (b ^ (b >> 41)) * k0 + i;
4523 uint8_t u = b >> 37;
4524 memcpy(data + i, &u, 1); // uint8_t -> char
4525 }
4526 }
4527}
4528
4529int NoteErrors() {
4530#define NUM_SELF_TESTS 9
4531 if (++completed_self_tests == NUM_SELF_TESTS)
4532 std::exit(errors > 0);
4533 return errors;
4534}
4535
4536template <typename T> inline bool IsNonZero(T x) {
4537 return x != 0;
4538}
4539
4540template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
4541 return x != Uint128(0, 0);
4542}
4543
4544#endif // FARMHASH_SELF_TEST_GUARD
4545
4546namespace farmhashnaTest {
4547
4548uint32_t CreateSeed(int offset, int salt) {
4549 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
4550 h = h * c1;
4551 h ^= (h >> 17);
4552 h = h * c1;
4553 h ^= (h >> 17);
4554 h = h * c1;
4555 h ^= (h >> 17);
4556 h += static_cast<uint32_t>(offset & 0xffffffff);
4557 h = h * c1;
4558 h ^= (h >> 17);
4559 h = h * c1;
4560 h ^= (h >> 17);
4561 h = h * c1;
4562 h ^= (h >> 17);
4563 return h;
4564}
4565
4566#undef SEED
4567#undef SEED1
4568#undef SEED0
4569#define SEED CreateSeed(offset, -1)
4570#define SEED0 CreateSeed(offset, 0)
4571#define SEED1 CreateSeed(offset, 1)
4572
4573#undef TESTING
4574#define TESTING 1
4575#if TESTING
4576uint32_t expected[] = {
45771140953930u, 861465670u,
45783277735313u, 2681724312u,
45792598464059u, 797982799u,
4580890626835u, 800175912u,
45812603993599u, 921001710u,
45821410420968u, 2134990486u,
45833283896453u, 1867689945u,
45842914424215u, 2244477846u,
4585255297188u, 2992121793u,
45861110588164u, 4186314283u,
4587161451183u, 3943596029u,
45884019337850u, 452431531u,
4589283198166u, 2741341286u,
45903379021470u, 2557197665u,
4591299850021u, 2532580744u,
4592452473466u, 1706958772u,
45931298374911u, 3099673830u,
45942199864459u, 3696623795u,
4595236935126u, 2976578695u,
45964055299123u, 3281581178u,
45971053458494u, 1882212500u,
45982305012065u, 2169731866u,
45993456121707u, 275903667u,
4600458884671u, 3033004529u,
46013058973506u, 2379411653u,
46021898235244u, 1402319660u,
46032700149065u, 2699376854u,
4604147814787u, 720739346u,
46052433714046u, 4222949502u,
46064220361840u, 1712034059u,
46073425469811u, 3690733394u,
46084148372108u, 1330324210u,
4609594028478u, 2921867846u,
46101635026870u, 192883107u,
4611780716741u, 1728752234u,
46123280331829u, 326029180u,
46133969463346u, 1436364519u,
4614393215742u, 3349570000u,
46153824583307u, 1612122221u,
46162859809759u, 3808705738u,
46171379537552u, 1646032583u,
46182233466664u, 1432476832u,
46194023053163u, 2650381482u,
46202052294713u, 3552092450u,
46211628777059u, 1499109081u,
46223476440786u, 3829307897u,
46232960536756u, 1554038301u,
46241145519619u, 3190844552u,
46252902102606u, 3600725550u,
4626237495366u, 540224401u,
462765721842u, 489963606u,
46281448662590u, 397635823u,
46291596489240u, 1562872448u,
46301790705123u, 2128624475u,
4631180854224u, 2604346966u,
46321435705557u, 1262831810u,
4633155445229u, 1672724608u,
46341669465176u, 1341975128u,
4635663607706u, 2077310004u,
46363610042449u, 1911523866u,
46371043692997u, 1454396064u,
46382563776023u, 294527927u,
46391099072299u, 1389770549u,
4640703505868u, 678706990u,
46412952353448u, 2026137563u,
46423603803785u, 629449419u,
46431933894405u, 3043213226u,
4644226132789u, 2489287368u,
46451552847036u, 645684964u,
46463828089804u, 3632594520u,
4647187883449u, 230403464u,
46483151491850u, 3272648435u,
46493729087873u, 1303930448u,
46502002861219u, 165370827u,
4651916494250u, 1230085527u,
46523103338579u, 3064290191u,
46533807265751u, 3628174014u,
4654231181488u, 851743255u,
46552295806711u, 1781190011u,
46562988893883u, 1554380634u,
46571142264800u, 3667013118u,
46581968445277u, 315203929u,
46592638023604u, 2290487377u,
4660732137533u, 1909203251u,
4661440398219u, 1891630171u,
46621380301172u, 1498556724u,
46634072067757u, 4165088768u,
46644204318635u, 441430649u,
46653931792696u, 197618179u,
4666956300927u, 914413116u,
46673010839769u, 2837339569u,
46682148126371u, 1913303225u,
46693074915312u, 3117299654u,
46704139181436u, 2993479124u,
46713178848746u, 1357272220u,
46721438494951u, 507436733u,
4673667183474u, 2084369203u,
46743854939912u, 1413396341u,
4675126024219u, 146044391u,
46761016656857u, 3022024459u,
46773254014218u, 429095991u,
4678165589978u, 1578546616u,
4679985653208u, 1718653828u,
4680623071693u, 366414107u,
4681249776086u, 1207522198u,
46823047342438u, 2991127487u,
46833120876698u, 1684583131u,
468446987739u, 1157614300u,
4685863214540u, 1087193030u,
4686199124911u, 520792961u,
46873614377032u, 586863115u,
46883331828431u, 1013201099u,
46891716848157u, 4033596884u,
46901164298657u, 4140791139u,
46911146169032u, 1434258493u,
46923824360466u, 3242407770u,
46933725511003u, 232064808u,
4694872586426u, 762243036u,
46952736953692u, 816692935u,
4696512845449u, 3748861010u,
46972266795890u, 3781899767u,
46984290630595u, 517646945u,
469922638523u, 648000590u,
4700959214578u, 558910384u,
47011283799121u, 3047062993u,
47021024246061u, 4027776454u,
47033544509313u, 622325861u,
4704834785312u, 382936554u,
4705411505255u, 1973395102u,
47061825135056u, 2725923798u,
4707580988377u, 2826990641u,
47083474970689u, 1029055034u,
4709812546227u, 2506885666u,
47102584372201u, 1758123094u,
4711589567754u, 325737734u,
4712345313518u, 2022370576u,
47133886113119u, 3338548567u,
4714257578986u, 3698087965u,
47151776047957u, 1771384107u,
47163604937815u, 3198590202u,
47172305332220u, 191910725u,
47184232136669u, 427759438u,
47194244322689u, 542201663u,
47203315355162u, 2135941665u,
4721556609672u, 45845311u,
47221175961330u, 3948351189u,
472323075771u, 3252374102u,
47241634635545u, 4151937410u,
4725713127376u, 1467786451u,
4726663013031u, 3444053918u,
47272638154051u, 810082938u,
47283077742128u, 1062268187u,
47292115441882u, 4081398201u,
47303735739145u, 2794294783u,
47312335576331u, 2560479831u,
47321379288194u, 4225182569u,
47332442302747u, 3948961926u,
47343958366652u, 3067277639u,
47353667516477u, 1709989541u,
47361516711748u, 2339636583u,
47374188504038u, 59581167u,
47382725013602u, 3639843023u,
47392658147000u, 2643979752u,
47403758739543u, 4189944477u,
47412470483982u, 877580602u,
47422995362413u, 118817200u,
47433252925478u, 2062343506u,
47443981838403u, 3762572073u,
47451231633714u, 4168280671u,
47462931588131u, 3284356565u,
47471129162571u, 732225574u,
47484173605289u, 1407328702u,
47491677744031u, 3532596884u,
47503232041815u, 1652884780u,
47512256541290u, 3459463480u,
47523740979556u, 259034107u,
47532227121257u, 1426140634u,
47543606709555u, 3424793077u,
4755315836068u, 3200749877u,
47561386256573u, 24035717u,
47572982018998u, 1811050648u,
4758234531934u, 1115203611u,
47591598686658u, 3146815575u,
47601603559457u, 323296368u,
47612632963283u, 1778459926u,
4762739944537u, 579625482u,
47633486330348u, 492621815u,
47641231665285u, 2457048126u,
47653903349120u, 389846205u,
47663355404249u, 3275550588u,
47671052645068u, 862072556u,
47682834153464u, 1481069623u,
47692657392572u, 4279236653u,
47701688445808u, 701920051u,
47713740748788u, 3388062747u,
47721873358321u, 2152785640u,
4773883382081u, 1005815394u,
47741020177209u, 734239551u,
47752371453141u, 100326520u,
47763488500412u, 1279682138u,
47772610427744u, 49703572u,
47783026361211u, 605900428u,
4779302392721u, 2509302188u,
47801416453607u, 2815915291u,
47811862819968u, 519710058u,
47822450888314u, 4017598378u,
4783937074653u, 3035635454u,
47841590230729u, 3268013438u,
47852710029305u, 12886044u,
47863711259084u, 2627383582u,
47873895772404u, 648534979u,
4788260307902u, 855990313u,
47893669691805u, 263366740u,
47902938543471u, 414331688u,
47913080542944u, 3405007814u,
47923565059103u, 1190977418u,
4793390836981u, 1606450012u,
47942649808239u, 2514169310u,
47952747519432u, 4129538640u,
47961721522849u, 492099164u,
4797792990594u, 3625507637u,
47982271095827u, 2993032712u,
47992302363854u, 4013112951u,
48001111617969u, 2183845740u,
4801795918276u, 1116991810u,
48023110898804u, 3963062126u,
48032737064702u, 462795667u,
4804937372240u, 1343017609u,
48051091041189u, 2790555455u,
4806277024217u, 25485284u,
48071166522068u, 1623631848u,
4808241727183u, 2836158787u,
48093112996740u, 573836428u,
48102721658101u, 1937681565u,
48114175169209u, 3190765433u,
48121970000788u, 1668258120u,
4813114616703u, 954762543u,
4814199237753u, 4094644498u,
48152522281978u, 732086117u,
48161756889687u, 2936126607u,
48172437031370u, 4103143808u,
48183883389541u, 3171090854u,
48192483004780u, 1927385370u,
48202360538162u, 2740855009u,
48214241185118u, 1492209542u,
48221672737098u, 2148675559u,
48231789864670u, 2434313103u,
48242319172611u, 2760941207u,
48252636210123u, 1338083267u,
48261128080590u, 822806371u,
48271199583556u, 314727461u,
48281335160250u, 2084630531u,
48291156261526u, 316766066u,
4830112090465u, 3129033323u,
48312746885618u, 636616055u,
48322582210744u, 1721064910u,
48333468394263u, 470463518u,
48342076016059u, 408721884u,
48352121041886u, 378460278u,
48361915948002u, 357324860u,
48372301682622u, 2691859523u,
48381869756364u, 2429314418u,
48392193146527u, 1185564327u,
48402614088922u, 1975527044u,
4841919067651u, 2855948894u,
48423662539576u, 1943802836u,
48433529473373u, 1490330107u,
4844366036094u, 3384241033u,
48454276268604u, 448403661u,
48464271796078u, 1910401882u,
48473077107698u, 299427366u,
48482035665349u, 3201262636u,
48493738454258u, 2554452696u,
48503588997135u, 3363895827u,
48511267505995u, 1852004679u,
48522237827073u, 2803250686u,
48533468044908u, 2143572850u,
48541728158656u, 1022551180u,
48551996680960u, 839529273u,
48562400647871u, 2201096054u,
48573606433628u, 2597259793u,
48583544595875u, 3909443124u,
4859819278607u, 3447346709u,
4860806136613u, 2711436388u,
48613656063205u, 837475154u,
4862694525336u, 4070212073u,
48634011303412u, 1068395209u,
4864438095290u, 484603494u,
48652673730227u, 737767009u,
4866642310823u, 3914002299u,
4867308425103u, 268427550u,
48681334387085u, 4069797497u,
48694280783219u, 2914011058u,
48704243643405u, 2849988118u,
48712504230175u, 1817156623u,
48722804200483u, 3406991497u,
48732948254999u, 2102063419u,
48741071272117u, 514889942u,
4875571972433u, 1246595599u,
48761735616066u, 1539151988u,
48771230831543u, 277987182u,
48784269526481u, 991511607u,
487995237878u, 2005032160u,
48801291113144u, 626619670u,
48813560835907u, 164940926u,
48821433635018u, 116647396u,
48833039097112u, 2868163232u,
48841141645918u, 1764165478u,
4885881378302u, 2159170082u,
48862953647681u, 1011320066u,
4887184856151u, 1723308975u,
4888336034862u, 2017579106u,
48891476681709u, 147523618u,
48903896252223u, 2264728166u,
4891944743644u, 1694443528u,
48922690700128u, 1947321519u,
4893735478508u, 4058183171u,
4894260177668u, 505662155u,
48952391691262u, 1920739747u,
48963216960415u, 1898176786u,
48973722741628u, 1511077569u,
4898449636564u, 983350414u,
48992580237367u, 2055059789u,
49001103819072u, 2089123665u,
49013873755579u, 2718467458u,
49023124338704u, 3204250304u,
49032475035432u, 1120017626u,
49043873758287u, 1982999824u,
49052950794582u, 780634378u,
49062842141483u, 4029205195u,
49071656892865u, 3330993377u,
490880890710u, 1953796601u,
49093873078673u, 136118734u,
49102317676604u, 4199091610u,
49111864448181u, 3063437608u,
49121699452298u, 1403506686u,
49131513069466u, 2348491299u,
49144273657745u, 4055855649u,
49151805475756u, 2562064338u,
4916973124563u, 4197091358u,
4917172861513u, 2858726767u,
49184271866024u, 3071338162u,
49193590386266u, 2328277259u,
49201096050703u, 1189614342u,
4921459509140u, 771592405u,
4922817999971u, 3740825152u,
4923520400189u, 1941874618u,
4924185232757u, 4032960199u,
49253928245258u, 3527721294u,
49261301118856u, 752188080u,
49273512945009u, 308584855u,
49282105373972u, 752872278u,
49293823368815u, 3760952096u,
49304250142168u, 2565680167u,
49313646354146u, 1259957455u,
49321085857127u, 3471066607u,
493338924274u, 3770488806u,
49341083869477u, 3312508103u,
493571956383u, 3738784936u,
49363099963860u, 1255084262u,
49374286969992u, 3621849251u,
49381190908967u, 1831557743u,
49392363435042u, 54945052u,
49404059585566u, 4023974274u,
49411788578453u, 3442180039u,
49422534883189u, 2432427547u,
49433909757989u, 731996369u,
49444168347425u, 1356028512u,
49452741583197u, 1280920000u,
4946312887059u, 3259015297u,
49473946278527u, 4135481831u,
49481281043691u, 1121403845u,
49493312292477u, 1819941269u,
49501741932545u, 3293015483u,
49512127558730u, 713121337u,
49522635469238u, 486003418u,
49534015067527u, 2976737859u,
49542108187161u, 927011680u,
49551970188338u, 4177613234u,
49561799789551u, 2118505126u,
49574134691985u, 1958963937u,
49581929210029u, 2555835851u,
49592768832862u, 910892050u,
49602567532373u, 4075249328u,
496186689814u, 3726640307u,
49621392137718u, 1240000030u,
49634104757832u, 3026358429u,
4964313797689u, 1435798509u,
49653101500919u, 1241665335u,
49663573008472u, 3615577014u,
49673767659003u, 3134294021u,
49684063565523u, 2296824134u,
49691541946015u, 3087190425u,
49702693152531u, 2199672572u,
49712123763822u, 1034244398u,
4972857839960u, 2515339233u,
49732228007483u, 1628096047u,
49742116502287u, 2502657424u,
49752809830736u, 460237542u,
4976450205998u, 3646921704u,
49773818199357u, 1808504491u,
49781950698961u, 2069753399u,
49793657033172u, 3734547671u,
49804067859590u, 3292597295u,
49811106466069u, 356742959u,
49822469567432u, 3495418823u,
4983183440071u, 3248055817u,
49843662626864u, 1750561299u,
49853926138664u, 4088592524u,
4986567122118u, 3810297651u,
4987992181339u, 3384018814u,
49883272124369u, 3177596743u,
4989320086295u, 2316548367u,
4990100741310u, 451656820u,
49914086604273u, 3759628395u,
49922553391092u, 1745659881u,
49933650357479u, 2390172694u,
4994330172533u, 767377322u,
4995526742034u, 4102497288u,
49962088767754u, 164402616u,
49972482632320u, 2352347393u,
49981873658044u, 3861555476u,
49992751052984u, 1767810825u,
500020037241u, 545143220u,
50012594532522u, 472304191u,
50023441135892u, 3323383489u,
5003258785117u, 2977745165u,
50042781737565u, 2963590112u,
50052756998822u, 207428029u,
50062581558559u, 3824717027u,
50071258619503u, 3472047571u,
50082648427775u, 2360400900u,
50092393763818u, 2332399088u,
50103932701729u, 884421165u,
50111396468647u, 1377764574u,
50124061795938u, 1559119087u,
50133343596838u, 3604258095u,
50141435134775u, 1099809675u,
5015908163739u, 1418405656u,
5016368446627u, 3741651161u,
50173374512975u, 3542220540u,
50183244772570u, 200009340u,
50193198975081u, 2521038253u,
50204081637863u, 337070226u,
50213235259030u, 3897262827u,
5022736956644u, 641040550u,
5023644850146u, 1306761320u,
50244219448634u, 193750500u,
50253293278106u, 1383997679u,
50261242645122u, 4109252858u,
5027450747727u, 3716617561u,
5028362725793u, 2252520167u,
50293377483696u, 1788337208u,
50308130777u, 3226734120u,
5031759239140u, 1012411364u,
50321658628529u, 2911512007u,
50331002580201u, 1681898320u,
50343039016929u, 4294520281u,
5035367022558u, 3071359622u,
50363205848570u, 152989999u,
50373839042136u, 2357687350u,
50384273132307u, 3898950547u,
50391176841812u, 1314157485u,
504075443951u, 1027027239u,
50411858986613u, 2040551642u,
504236574105u, 2603059541u,
50433456147251u, 2137668425u,
50444077477194u, 3565689036u,
5045491832241u, 363703593u,
50462579177168u, 3589545214u,
5047265993036u, 1864569342u,
50484149035573u, 3189253455u,
50491072259310u, 3153745937u,
5050923017956u, 490608221u,
5051855846773u, 845706553u,
50521018226240u, 1604548872u,
50533833372385u, 3287246572u,
50542757959551u, 2452872151u,
50551553870564u, 1713154780u,
50562649450292u, 500120236u,
505784251717u, 661869670u,
50581444911517u, 2489716881u,
50592810524030u, 1561519055u,
50603884088359u, 2509890699u,
50614247155916u, 1005636939u,
50623224066062u, 2774151984u,
50632035978240u, 2514910366u,
50641478837908u, 3144450144u,
50652107011431u, 96459446u,
50663587732908u, 2389230590u,
50673287635953u, 250533792u,
50681235983679u, 4237425634u,
50693704645833u, 3882376657u,
50702976369049u, 1187061987u,
5071276949224u, 4100839753u,
50721698347543u, 1629662314u,
50731556151829u, 3784939568u,
5074427484362u, 4246879223u,
50753155311770u, 4285163791u,
50761693376813u, 124492786u,
50771858777639u, 3476334357u,
50781941442701u, 1121980173u,
50793485932087u, 820852908u,
5080358032121u, 2511026735u,
50811873607283u, 2556067450u,
50822248275536u, 1528632094u,
50831535473864u, 556796152u,
50841499201704u, 1472623890u,
50851526518503u, 3692729434u,
50861476438092u, 2913077464u,
5087335109599u, 2167614601u,
50884121131078u, 3158127917u,
50893051522276u, 4046477658u,
50902857717851u, 1863977403u,
50911341023343u, 692059110u,
50921802040304u, 990407433u,
50933285847572u, 319814144u,
5094561105582u, 1540183799u,
50954052924496u, 2926590471u,
50962244539806u, 439121871u,
50973317903224u, 3178387550u,
50984265214507u, 82077489u,
50991978918971u, 4279668976u,
5100128732476u, 2853224222u,
5101464407878u, 4190838199u,
5102997819001u, 3250520802u,
51032330081301u, 4095846095u,
5104733509243u, 1583801700u,
5105722314527u, 3552883023u,
51061403784280u, 432327540u,
51071877837196u, 3912423882u,
5108505219998u, 696031431u,
5109908238873u, 4189387259u,
51108759461u, 2540185277u,
51113385159748u, 381355877u,
51122519951681u, 1679786240u,
51132019419351u, 4051584612u,
51141933923923u, 3768201861u,
51151670133081u, 3454981037u,
5116700836153u, 1675560450u,
5117371560700u, 338262316u,
5118847351840u, 2222395828u,
51193130433948u, 405251683u,
51203037574880u, 184098830u,
5121453340528u, 1385561439u,
51222224044848u, 4071581802u,
51231431235296u, 5570097u,
5124570114376u, 2287305551u,
51252272418128u, 803575837u,
51263943113491u, 414959787u,
5127708083137u, 2452657767u,
51284019147902u, 3841480082u,
51293791794715u, 2965956183u,
51302763690963u, 2350937598u,
51313424361375u, 779434428u,
51321274947212u, 686105485u,
51333426668051u, 3692865672u,
51343057021940u, 2285701422u,
5135349809124u, 1379278508u,
51363623750518u, 215970497u,
51371783152480u, 823305654u,
5138216118434u, 1787189830u,
51393692048450u, 2272612521u,
51403032187389u, 4159715581u,
51411388133148u, 1611772864u,
51422544383526u, 552925303u,
51433420960112u, 3198900547u,
51443503230228u, 2603352423u,
51452318375898u, 4064071435u,
51463006227299u, 4194096960u,
51471283392422u, 1510460996u,
5148174272138u, 3671038966u,
51491775955687u, 1719108984u,
51501763892006u, 1385029063u,
51514083790740u, 406757708u,
5152684087286u, 531310503u,
51533329923157u, 3492083607u,
51541059031410u, 3037314475u,
51553105682208u, 3382290593u,
51562292208503u, 426380557u,
515797373678u, 3842309471u,
5158777173623u, 3241407531u,
5159303065016u, 1477104583u,
51604234905200u, 2512514774u,
51612649684057u, 1397502982u,
51621802596032u, 3973022223u,
51632543566442u, 3139578968u,
51643193669211u, 811750340u,
51654013496209u, 567361887u,
51664169410406u, 3622282782u,
51673403136990u, 2540585554u,
5168895210040u, 3862229802u,
51691145435213u, 4146963980u,
5170784952939u, 943914610u,
5171573034522u, 464420660u,
51722356867109u, 3054347639u,
51733985088434u, 1911188923u,
5174583391304u, 176468511u,
51752990150068u, 2338031599u,
5176519948041u, 3181425568u,
5177496106033u, 4110294665u,
51782736756930u, 1196757691u,
51791089679033u, 240953857u,
51803399092928u, 4040779538u,
51812843673626u, 240495962u,
51823017658263u, 3828377737u,
51834243717901u, 2448373688u,
51842759616657u, 2246245780u,
5185308018483u, 4262383425u,
51862731780771u, 328023017u,
51872884443148u, 841480070u,
51883188015819u, 4051263539u,
51892298178908u, 2944209234u,
51901372958390u, 4164532914u,
51914074952232u, 1683612329u,
51922155036654u, 1872815858u,
51932041174279u, 2368092311u,
5194206775997u, 2283918569u,
5195645945606u, 115406202u,
51964206471368u, 3923500892u,
51972217060665u, 350160869u,
5198706531239u, 2824302286u,
5199509981657u, 1469342315u,
5200140980u, 1891558063u,
5201164887091u, 3094962711u,
52023437115622u, 13327420u,
5203422986366u, 330624974u,
52043630863408u, 2425505046u,
5205824008515u, 3543885677u,
5206918718096u, 376390582u,
52073224043675u, 3724791476u,
52081837192976u, 2968738516u,
52093424344721u, 3187805406u,
52101550978788u, 1743089918u,
52114251270061u, 645016762u,
52123855037968u, 1928519266u,
52131373803416u, 2289007286u,
52141889218686u, 1610271373u,
52153059200728u, 2108753646u,
5216582042641u, 812347242u,
52173188172418u, 191994904u,
52181343511943u, 2247006571u,
5219463291708u, 2697254095u,
52201534175504u, 1106275740u,
5221622521957u, 917121602u,
52224095777215u, 3955972648u,
52233852234638u, 2845309942u,
52243299763344u, 2864033668u,
52252554947496u, 799569078u,
52262551629074u, 1102873346u,
52272661022773u, 2006922227u,
52282900438444u, 1448194126u,
52291321567432u, 1983773590u,
52301237256330u, 3449066284u,
52311691553115u, 3274671549u,
52324271625619u, 2741371614u,
52333285899651u, 786322314u,
52341586632825u, 564385522u,
52352530557509u, 2974240289u,
52361244759631u, 3263135197u,
52373592389776u, 3570296884u,
52382749873561u, 521432811u,
5239987586766u, 3206261120u,
52401327840078u, 4078716491u,
52411753812954u, 976892272u,
52421827135136u, 1781944746u,
52431328622957u, 1015377974u,
52443439601008u, 2209584557u,
52452482286699u, 1109175923u,
5246874877499u, 2036083451u,
5247483570344u, 1091877599u,
52484190721328u, 1129462471u,
5249640035849u, 1867372700u,
5250920761165u, 3273688770u,
52511623777358u, 3389003793u,
52523241132743u, 2734783008u,
5253696674661u, 2502161880u,
52541646071378u, 1164309901u,
5255350411888u, 1978005963u,
52562253937037u, 7371540u,
5257989577914u, 3626554867u,
52583214796883u, 531343826u,
5259398899695u, 1145247203u,
52601516846461u, 3656006011u,
5261529303412u, 3318455811u,
52623062828129u, 1696355359u,
52633698796465u, 3155218919u,
52641457595996u, 3191404246u,
52651395609912u, 2917345728u,
52661237411891u, 1854985978u,
52671091884675u, 3504488111u,
52683109924189u, 1628881950u,
52693939149151u, 878608872u,
5270778235395u, 1052990614u,
5271903730231u, 2069566979u,
52722437686324u, 3163786257u,
52732257884264u, 2123173186u,
5274939764916u, 2933010098u,
52751235300371u, 1256485167u,
52761950274665u, 2180372319u,
52772648400302u, 122035049u,
52781883344352u, 2083771672u,
52793712110541u, 321199441u,
52801896357377u, 508560958u,
52813066325351u, 2770847216u,
52823177982504u, 296902736u,
52831486926688u, 456842861u,
5284601221482u, 3992583643u,
52852794121515u, 1533934172u,
52861706465470u, 4281971893u,
52872557027816u, 900741486u,
5288227175484u, 550595824u,
5289690918144u, 2825943628u,
529090375300u, 300318232u,
52911985329734u, 1440763373u,
52923670603707u, 2533900859u,
52933253901179u, 542270815u,
52943677388841u, 307706478u,
52952570910669u, 3320103693u,
52961273768482u, 1216399252u,
52971652924805u, 1043647584u,
52981120323676u, 639941430u,
5299325675502u, 3652676161u,
53004241680335u, 1545838362u,
53011991398008u, 4100211814u,
53021097584090u, 3262252593u,
53032254324292u, 1765019121u,
53044060211241u, 2315856188u,
53053704419305u, 411263051u,
5306238929055u, 3540688404u,
53073094544537u, 3250435765u,
53083460621305u, 1967599860u,
53092016157366u, 847389916u,
53101659615591u, 4020453639u,
5311901109753u, 2682611693u,
53121661364280u, 177155177u,
53133210561911u, 3802058181u,
5314797089608u, 3286110054u,
53152110358240u, 1353279028u,
53162479975820u, 471725410u,
53172219863904u, 3623364733u,
53183167128228u, 1052188336u,
53193656587111u, 721788662u,
53203061255808u, 1615375832u,
5321924941453u, 2547780700u,
53223328169224u, 1310964134u,
53232701956286u, 4145497671u,
53241421461094u, 1221397398u,
53251589183618u, 1492533854u,
5326449740816u, 2686506989u,
53273035198924u, 1682886232u,
53282529760244u, 3342031659u,
53291235084019u, 2151665147u,
53302315686577u, 3282027660u,
53311140138691u, 2754346599u,
53322091754612u, 1178454681u,
53334226896579u, 2942520471u,
53342122168506u, 3751680858u,
53353213794286u, 2601416506u,
53364142747914u, 3951404257u,
53374243249649u, 748595836u,
53384004834921u, 238887261u,
53391927321047u, 2217148444u,
5340205977665u, 1885975275u,
5341186020771u, 2367569534u,
53422941662631u, 2608559272u,
53433342096731u, 741809437u,
53441962659444u, 3539886328u,
53453036596491u, 2282550094u,
53462366462727u, 2748286642u,
53472144472852u, 1390394371u,
53481257385924u, 2205425874u,
53492119055686u, 46865323u,
53503597555910u, 3188438773u,
53512372320753u, 3641116924u,
53523116286108u, 2680722658u,
53533371014971u, 2058751609u,
53542966943726u, 2345078707u,
53552330535244u, 4013841927u,
53561169588594u, 857915866u,
53571875260989u, 3175831309u,
53583193475664u, 1955181430u,
5359923161569u, 4068653043u,
5360776445899u, 954196929u,
536161509556u, 4248237857u,
53623808667664u, 581227317u,
53632893240187u, 4159497403u,
53644212264930u, 3973886195u,
53652077539039u, 851579036u,
53662957587591u, 772351886u,
53671173659554u, 946748363u,
53682794103714u, 2094375930u,
53694234750213u, 3671645488u,
53702614250782u, 2620465358u,
53713122317317u, 2365436865u,
53723393973390u, 523513960u,
53733645735309u, 2766686992u,
53742023960931u, 2312244996u,
53751875932218u, 3253711056u,
53763622416881u, 3274929205u,
5377612094988u, 1555465129u,
53782114270406u, 3553762793u,
53791832633644u, 1087551556u,
53803306195841u, 1702313921u,
53813675066046u, 1735998785u,
53821690923980u, 1482649756u,
53831171351291u, 2043136409u,
53841962596992u, 461214626u,
53853278253346u, 1392428048u,
53863744621107u, 1028502697u,
53873991171462u, 1014064003u,
53883642345425u, 3186995039u,
53896114625u, 3359104346u,
5390414856965u, 2814387514u,
53913583605071u, 2497896367u,
53921024572712u, 1927582962u,
53932892797583u, 845302635u,
5394328548052u, 1523379748u,
53953392622118u, 1347167673u,
53961012316581u, 37767602u,
53972647726017u, 1070326065u,
53982075035198u, 4202817168u,
53992502924707u, 2612406822u,
54002187115553u, 1180137213u,
5401701024148u, 1481965992u,
54023223787553u, 2083541843u,
5403203230202u, 3876887380u,
54041334816273u, 2870251538u,
54052186205850u, 3985213979u,
5406333533378u, 806507642u,
54071010064531u, 713520765u,
54083084131515u, 2637421459u,
54091703168933u, 1517562266u,
54104089081247u, 3231042924u,
54113079916123u, 3154574447u,
54122253948262u, 1725190035u,
54132452539325u, 1343734533u,
5414213706059u, 2519409656u,
5415108055211u, 2916327746u,
5416587001593u, 1917607088u,
54174202913084u, 926304016u,
5418469255411u, 4042080256u,
54193498936874u, 246692543u,
5420495780578u, 438717281u,
54212259272650u, 4011324645u,
54222836854664u, 2317249321u,
5423946828752u, 1280403658u,
54241905648354u, 2034241661u,
5425774652981u, 1285694082u,
54262200307766u, 2158671727u,
54271135162148u, 232040752u,
5428397012087u, 1717527689u,
54291720414106u, 918797022u,
54302580119304u, 3568069742u,
54312904461070u, 3893453420u,
5432973817938u, 667499332u,
54333785870412u, 2088861715u,
54341565179401u, 600903026u,
5435591806775u, 3512242245u,
5436997964515u, 2339605347u,
54371134342772u, 3234226304u,
54384084179455u, 302315791u,
54392445626811u, 2590372496u,
5440345572299u, 2274770442u,
54413600587867u, 3706939009u,
54421430507980u, 2656330434u,
54431079209397u, 2122849632u,
54441423705223u, 3826321888u,
54453683385276u, 1057038163u,
54461242840526u, 3987000643u,
54472398253089u, 1538190921u,
54481295898647u, 3570196893u,
54493065138774u, 3111336863u,
54502524949549u, 4203895425u,
54513025864372u, 968800353u,
54521023721001u, 3763083325u,
5453526350786u, 635552097u,
54542308118370u, 2166472723u,
54552196937373u, 2643841788u,
54563040011470u, 4010301879u,
54572782379560u, 3474682856u,
54584201389782u, 4223278891u,
54591457302296u, 2251842132u,
54601090062008u, 3188219189u,
5461292733931u, 1424229089u,
54621590782640u, 1365212370u,
54633975957073u, 3982969588u,
54642927147928u, 1048291071u,
54652766680094u, 884908196u,
546635237839u, 2221180633u,
54672490333812u, 4098360768u,
54684029081103u, 3490831871u,
54692392516272u, 3455379186u,
54703948800722u, 335456628u,
54712105117968u, 4181629008u,
54721044201772u, 3335754111u,
5473540133451u, 3313113759u,
54743786107905u, 2627207327u,
54753540337875u, 3473113388u,
54763430536378u, 2514123129u,
54772124531276u, 3872633376u,
54783272957388u, 3501994650u,
54792418881542u, 487365389u,
54803877672368u, 1512866656u,
54813486531087u, 2102955203u,
54821136054817u, 3004241477u,
54831549075351u, 1302002008u,
54843936430045u, 2258587644u,
54854109233936u, 3679809321u,
54863467083076u, 2484463221u,
54871594979755u, 529218470u,
54883527024461u, 1147434678u,
5489106799023u, 1823161970u,
54901704656738u, 1675883700u,
54913308746763u, 1875093248u,
54921352868568u, 1898561846u,
54932508994984u, 3177750780u,
54944217929592u, 400784472u,
549580090315u, 3564414786u,
54963841585648u, 3379293868u,
5497160353261u, 2413172925u,
54982378499279u, 673436726u,
54991505702418u, 1330977363u,
55001853298225u, 3201741245u,
55012135714208u, 4069554166u,
55023715612384u, 3692488887u,
55033680311316u, 4274382900u,
5504914186796u, 2264886523u,
55053869634032u, 1254199592u,
55061131020455u, 194781179u,
5507429923922u, 2763792336u,
55082052895198u, 3997373194u,
55093440090658u, 2165746386u,
55101575500242u, 3463310191u,
55112064974716u, 3779513671u,
55123106421434u, 880320527u,
55133281914119u, 286569042u,
55143909096631u, 122359727u,
55151429837716u, 252230074u,
55164111461225u, 762273136u,
551793658514u, 2766407143u,
55183623657004u, 3869801679u,
55193925695921u, 2390397316u,
55202499025338u, 2741806539u,
55212507199021u, 1659221866u,
5522361292116u, 4048761557u,
55233797133396u, 1517903247u,
55243121647246u, 3884308578u,
55251697201500u, 1558800262u,
55264150812360u, 3161302278u,
55272610217849u, 641564641u,
5528183814518u, 2075245419u,
5529611996508u, 2223461433u,
5530329123979u, 121860586u,
5531860985829u, 1137889144u,
55324018949439u, 2904348960u,
5533947795261u, 1992594155u,
55344255427501u, 2281583851u,
55352892637604u, 1478186924u,
55363050771207u, 2767035539u,
5537373510582u, 1963520320u,
55383763848370u, 3756817798u,
5539627269409u, 1806905031u,
55401814444610u, 3646665053u,
55411822693920u, 278515794u,
5542584050483u, 4142579188u,
55432149745808u, 3193071606u,
55441179706341u, 2693495182u,
55453259749808u, 644172091u,
5546880509048u, 3340630542u,
55473365160815u, 2384445068u,
55483053081915u, 2840648309u,
55491986990122u, 1084703471u,
55502370410550u, 1627743573u,
55512244943480u, 4057483496u,
55522611595995u, 2470013639u,
55534024732359u, 3987190386u,
5554873421687u, 2447660175u,
55553226583022u, 767655877u,
55562528024413u, 1962070688u,
55571233635843u, 2163464207u,
5558659054446u, 854207134u,
5559258410943u, 4197831420u,
55602515400215u, 3100476924u,
55611961549594u, 2219491151u,
55623997658851u, 163850514u,
5563470325051u, 2598261204u,
55643052145580u, 59836528u,
55651376188597u, 966733415u,
5566850667549u, 3622479237u,
55671083731990u, 1525777459u,
55684005126532u, 1428155540u,
55692781907007u, 943739431u,
55701493961005u, 2839096988u,
55712000057832u, 1941829603u,
55721901484772u, 939810041u,
55733377407371u, 3090115837u,
55743310840540u, 2068409688u,
55753261383939u, 2212130277u,
55762594774045u, 2912652418u,
55774179816101u, 3534504531u,
55783349254805u, 2796552902u,
55791385421283u, 4259908631u,
55803714780837u, 3070073945u,
55813372846298u, 3835884044u,
55823047965714u, 3009018735u,
5583744091167u, 1861124263u,
55842764936304u, 1338171648u,
55854222019554u, 1395200692u,
55861371426007u, 3338031581u,
55872525665319u, 4196233786u,
55882332743921u, 1474702008u,
55892274266301u, 4255175517u,
55902290169528u, 1793910997u,
55912188254024u, 354202001u,
55923864458796u, 4280290498u,
55931554419340u, 1733094688u,
55942010552302u, 1561807039u,
5595664313606u, 2548990879u,
55961084699349u, 3233936866u,
5597973895284u, 2386881969u,
55981831995860u, 2961465052u,
55991428704144u, 3269904970u,
5600231648253u, 2602483763u,
56014125013173u, 3319187387u,
56023347011944u, 1892898231u,
56034019114049u, 868879116u,
56044085937045u, 2378411019u,
56051072588531u, 3547435717u,
56062208070766u, 1069899078u,
56073142980597u, 2337088907u,
56081593338562u, 919414554u,
5609688077849u, 3625708135u,
56101472447348u, 1947711896u,
56113953006207u, 877438080u,
5612845995820u, 3150361443u,
56133053496713u, 2484577841u,
5614224271045u, 2914958001u,
56152682612949u, 806655563u,
56162436224507u, 1907729235u,
56172920583824u, 1251814062u,
56182070814520u, 4034325578u,
5619497847539u, 2714317144u,
5620385182008u, 640855184u,
56211327075087u, 1062468773u,
56221757405994u, 1374270191u,
56234263183176u, 3041193150u,
56241037871524u, 3633173991u,
56254231821821u, 2830131945u,
56263505072908u, 2830570613u,
56274195208715u, 575398021u,
56283992840257u, 3691788221u,
56291949847968u, 2999344380u,
56303183782163u, 3723754342u,
5631759716128u, 3284107364u,
56321714496583u, 15918244u,
5633820509475u, 2553936299u,
56342201876606u, 4237151697u,
56352605688266u, 3253705097u,
56361008333207u, 712158730u,
56371722280252u, 1933868287u,
56384152736859u, 2097020806u,
5639584426382u, 2836501956u,
56402522777566u, 1996172430u,
56412122199776u, 1069285218u,
56421474209360u, 690831894u,
5643107482532u, 3695525410u,
5644670591796u, 768977505u,
56452412057331u, 3647886687u,
56463110327607u, 1072658422u,
5647379861934u, 1557579480u,
56484124127129u, 2271365865u,
56493880613089u, 739218494u,
5650547346027u, 388559045u,
56513147335977u, 176230425u,
56523094853730u, 2554321205u,
56531495176194u, 4093461535u,
56543521297827u, 4108148413u,
56551913727929u, 1177947623u,
56561911655402u, 1053371241u,
56573265708874u, 1266515850u,
56581045540427u, 3194420196u,
56593717104621u, 1144474110u,
56601464392345u, 52070157u,
56614144237690u, 3350490823u,
56624166253320u, 2747410691u,
5663};
5664
5665// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
5666bool Test(int offset, int len = 0) {
5667#undef Check
5668#undef IsAlive
5669
5670#define Check(x) do { \
5671 const uint32_t actual = (x), e = expected[index++]; \
5672 bool ok = actual == e; \
5673 if (!ok) { \
5674 cerr << "expected " << hex << e << " but got " << actual << endl; \
5675 ++errors; \
5676 } \
5677 assert(ok); \
5678} while (0)
5679
5680#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
5681
5682 // After the following line is where the uses of "Check" and such will go.
5683 static int index = 0;
5684if (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; }
5685{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
5686{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
5687{ uint64_t h = farmhashna::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
5688
5689 return true;
5690#undef Check
5691#undef IsAlive
5692}
5693
5694int RunTest() {
5695 Setup();
5696 int i = 0;
5697 cout << "Running farmhashnaTest";
5698 if (!Test(-1)) {
5699 cout << "... Unavailable\n";
5700 return NoteErrors();
5701 }
5702 // Good. The function is attempting to hash, so run the full test.
5703 int errors_prior_to_test = errors;
5704 for ( ; i < kTestSize - 1; i++) {
5705 Test(i * i, i);
5706 }
5707 for ( ; i < kDataSize; i += i / 7) {
5708 Test(0, i);
5709 }
5710 Test(0, kDataSize);
5711 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
5712 return NoteErrors();
5713}
5714
5715#else
5716
5717// After the following line is where the code to print hash codes will go.
5718void Dump(int offset, int len) {
5719{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5720{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5721{ uint64_t h = farmhashna::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5722}
5723
5724#endif
5725
5726#undef SEED
5727#undef SEED1
5728#undef SEED0
5729
5730} // namespace farmhashnaTest
5731
5732#if !TESTING
5733int main(int argc, char** argv) {
5734 Setup();
5735 cout << "uint32_t expected[] = {\n";
5736 int i = 0;
5737 for ( ; i < kTestSize - 1; i++) {
5738 farmhashnaTest::Dump(i * i, i);
5739 }
5740 for ( ; i < kDataSize; i += i / 7) {
5741 farmhashnaTest::Dump(0, i);
5742 }
5743 farmhashnaTest::Dump(0, kDataSize);
5744 cout << "};\n";
5745}
5746#endif
5747#ifndef FARMHASH_SELF_TEST_GUARD
5748#define FARMHASH_SELF_TEST_GUARD
5749#include <cstdio>
5750#include <iostream>
5751#include <string.h>
5752
5753using std::cout;
5754using std::cerr;
5755using std::endl;
5756using std::hex;
5757
5758static const uint64_t kSeed0 = 1234567;
5759static const uint64_t kSeed1 = k0;
5760static const int kDataSize = 1 << 20;
5761static const int kTestSize = 300;
5762#define kSeed128 Uint128(kSeed0, kSeed1)
5763
5764static char data[kDataSize];
5765
5766static int completed_self_tests = 0;
5767static int errors = 0;
5768
5769// Initialize data to pseudorandom values.
5770void Setup() {
5771 if (completed_self_tests == 0) {
5772 uint64_t a = 9;
5773 uint64_t b = 777;
5774 for (int i = 0; i < kDataSize; i++) {
5775 a += b;
5776 b += a;
5777 a = (a ^ (a >> 41)) * k0;
5778 b = (b ^ (b >> 41)) * k0 + i;
5779 uint8_t u = b >> 37;
5780 memcpy(data + i, &u, 1); // uint8_t -> char
5781 }
5782 }
5783}
5784
5785int NoteErrors() {
5786#define NUM_SELF_TESTS 9
5787 if (++completed_self_tests == NUM_SELF_TESTS)
5788 std::exit(errors > 0);
5789 return errors;
5790}
5791
5792template <typename T> inline bool IsNonZero(T x) {
5793 return x != 0;
5794}
5795
5796template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
5797 return x != Uint128(0, 0);
5798}
5799
5800#endif // FARMHASH_SELF_TEST_GUARD
5801
5802namespace farmhashntTest {
5803
5804uint32_t CreateSeed(int offset, int salt) {
5805 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
5806 h = h * c1;
5807 h ^= (h >> 17);
5808 h = h * c1;
5809 h ^= (h >> 17);
5810 h = h * c1;
5811 h ^= (h >> 17);
5812 h += static_cast<uint32_t>(offset & 0xffffffff);
5813 h = h * c1;
5814 h ^= (h >> 17);
5815 h = h * c1;
5816 h ^= (h >> 17);
5817 h = h * c1;
5818 h ^= (h >> 17);
5819 return h;
5820}
5821
5822#undef SEED
5823#undef SEED1
5824#undef SEED0
5825#define SEED CreateSeed(offset, -1)
5826#define SEED0 CreateSeed(offset, 0)
5827#define SEED1 CreateSeed(offset, 1)
5828
5829#undef TESTING
5830#define TESTING 1
5831#if TESTING
5832uint32_t expected[] = {
58332681724312u,
5834797982799u,
5835921001710u,
58362134990486u,
58372244477846u,
58382992121793u,
58393943596029u,
5840452431531u,
58412557197665u,
58422532580744u,
58433099673830u,
58443696623795u,
58453281581178u,
58461882212500u,
5847275903667u,
58483033004529u,
58491402319660u,
58502699376854u,
58514222949502u,
58521712034059u,
58531330324210u,
58542921867846u,
58551728752234u,
5856326029180u,
58573349570000u,
58581612122221u,
58591646032583u,
58601432476832u,
58613552092450u,
58621499109081u,
58631554038301u,
58643190844552u,
5865540224401u,
5866489963606u,
58671562872448u,
58682128624475u,
58691262831810u,
58701672724608u,
58712077310004u,
58721911523866u,
5873294527927u,
58741389770549u,
58752026137563u,
5876629449419u,
58772489287368u,
5878645684964u,
5879230403464u,
58803272648435u,
5881165370827u,
58821230085527u,
58833628174014u,
5884851743255u,
58851554380634u,
58863667013118u,
58872290487377u,
58881909203251u,
58891498556724u,
58904165088768u,
5891197618179u,
5892914413116u,
58931913303225u,
58943117299654u,
58951357272220u,
5896507436733u,
58971413396341u,
5898146044391u,
5899429095991u,
59003056862311u,
5901366414107u,
59022293458109u,
59031684583131u,
59041170404994u,
5905520792961u,
59061577421232u,
59074033596884u,
59084229339322u,
59093242407770u,
59102649785113u,
5911816692935u,
59123555213933u,
5913517646945u,
59142180594090u,
59153047062993u,
59162391606125u,
5917382936554u,
5918788479970u,
59192826990641u,
59203167748333u,
59211758123094u,
5922389974094u,
59233338548567u,
59242583576230u,
59253198590202u,
59264155628142u,
5927542201663u,
59282856634168u,
59293948351189u,
59304194218315u,
59311467786451u,
59322743592929u,
59331062268187u,
59343810665822u,
59352560479831u,
5936997658837u,
59373067277639u,
59381211737169u,
593959581167u,
59401389679610u,
59414189944477u,
5942100876854u,
59432062343506u,
59443088828656u,
59453284356565u,
59463130054947u,
59473532596884u,
59483887208531u,
5949259034107u,
59503233195759u,
59513200749877u,
5952760633989u,
59531115203611u,
59541516407838u,
59551778459926u,
59562146672889u,
59572457048126u,
59582217471853u,
5959862072556u,
59603745267835u,
5961701920051u,
5962581695350u,
59631410111809u,
59643326135446u,
59652187968410u,
59664267859263u,
5967479241367u,
59682868987960u,
5969704325635u,
59701418509533u,
5971735688735u,
59723283299459u,
5973813690332u,
59741439630796u,
59753195309868u,
59761616408198u,
59773254795114u,
59782799925823u,
59793929484338u,
59801798536177u,
59814205965408u,
59821499475160u,
59834247675634u,
59843779953975u,
5985785893184u,
59862778575413u,
59871160134629u,
5988823113169u,
59894116162021u,
59904167766971u,
59912487440590u,
59924004655503u,
59934044418876u,
59941462554406u,
59952011102035u,
59964265993528u,
5997576405853u,
59984038839101u,
59992425317635u,
60001401013391u,
60013062418115u,
60023167030094u,
60032602636307u,
60044264167741u,
60054017058800u,
60061029665228u,
60074036354071u,
60082670703363u,
6009688472265u,
60101054670286u,
6011338058159u,
60121539305024u,
6013146827036u,
60144060134777u,
60152502815838u,
60161603444633u,
60172448966429u,
60183891353218u,
60191082330589u,
6020201837927u,
60212848283092u,
6022883849006u,
60231982110346u,
6024541496720u,
6025133643215u,
60263847827123u,
60274015671361u,
60282849988118u,
60293452457457u,
60302102063419u,
60313281002516u,
60321539151988u,
60331147951686u,
60342005032160u,
60352415262714u,
6036116647396u,
60371029284767u,
60382159170082u,
60391919171906u,
60402017579106u,
60412473524405u,
60421694443528u,
60433671562289u,
6044505662155u,
60451019936943u,
60461511077569u,
6047773792826u,
60482089123665u,
6049484732447u,
60501120017626u,
60512809286837u,
60524029205195u,
60531097806406u,
6054136118734u,
60554017075736u,
60561403506686u,
60571516736273u,
60582562064338u,
60592984955003u,
60603071338162u,
60611923531348u,
6062771592405u,
60632586632018u,
60644032960199u,
60652687561076u,
6066308584855u,
60671692079268u,
60682565680167u,
60693674576684u,
60703770488806u,
607169201295u,
60721255084262u,
60733593730713u,
607454945052u,
60751939595371u,
60762432427547u,
60772295501078u,
60781280920000u,
607982177963u,
60801121403845u,
60812889101923u,
6082713121337u,
60831747052377u,
6084927011680u,
60854142246789u,
60861958963937u,
60871636932722u,
60884075249328u,
60892025886508u,
60903026358429u,
60911845587644u,
60923615577014u,
60931363253259u,
60943087190425u,
6095341851980u,
60962515339233u,
60971276595523u,
6098460237542u,
60994198897105u,
61002069753399u,
61014278599955u,
6102356742959u,
61033735275001u,
61041750561299u,
6105668829411u,
61063384018814u,
61074233785523u,
6108451656820u,
6109107312677u,
61102390172694u,
61111216645846u,
6112164402616u,
61131689811113u,
61141767810825u,
61151397772514u,
61163323383489u,
61172986430557u,
6118207428029u,
61192260498180u,
61202360400900u,
61211263709570u,
61221377764574u,
61234252610345u,
61241099809675u,
61252776960536u,
61263542220540u,
61273752806924u,
6128337070226u,
61293267551635u,
61301306761320u,
61312220373824u,
61324109252858u,
6133896322512u,
61341788337208u,
61351336556841u,
61362911512007u,
61373712582785u,
61383071359622u,
61392561488770u,
61403898950547u,
6141536047554u,
61422040551642u,
61433528794619u,
61443565689036u,
61451197100813u,
61461864569342u,
61473329594980u,
6148490608221u,
61491174785921u,
61503287246572u,
61512163330264u,
6152500120236u,
61532520062970u,
61541561519055u,
61554042710240u,
61562774151984u,
61573160666939u,
615896459446u,
61591878067032u,
61604237425634u,
61612952135524u,
61624100839753u,
61631265237690u,
61644246879223u,
6165834830418u,
61663476334357u,
61674277111759u,
61682511026735u,
61693065234219u,
6170556796152u,
6171198182691u,
61722913077464u,
61731535115487u,
61744046477658u,
6175140762681u,
6176990407433u,
61772198985327u,
61782926590471u,
6179559702706u,
618082077489u,
61811096697687u,
61824190838199u,
61833046872820u,
61841583801700u,
61852185339100u,
61863912423882u,
61873703603898u,
61882540185277u,
61891446869792u,
61904051584612u,
61912719373510u,
61921675560450u,
61931996164093u,
6194405251683u,
61952864244470u,
61964071581802u,
61972028708916u,
6198803575837u,
6199557660441u,
62003841480082u,
6201255451671u,
6202779434428u,
62033452203069u,
62042285701422u,
62051568745354u,
6206823305654u,
62073184047862u,
62084159715581u,
62093160134214u,
62103198900547u,
62111566527339u,
62124194096960u,
62131496132623u,
62141719108984u,
62152584236470u,
6216531310503u,
62173456882941u,
62183382290593u,
6219467441309u,
62203241407531u,
62212540270567u,
62221397502982u,
62233348545480u,
6224811750340u,
62251017047954u,
62262540585554u,
62273531646869u,
6228943914610u,
62291903578924u,
62301911188923u,
6231241574049u,
62323181425568u,
62333529565564u,
6234240953857u,
62352964595704u,
62363828377737u,
62374260564140u,
62384262383425u,
6239383233885u,
62404051263539u,
6241919677938u,
62421683612329u,
62434204155962u,
62442283918569u,
62454153726847u,
6246350160869u,
62471387233546u,
62481891558063u,
6249740563169u,
6250330624974u,
62512948665536u,
6252376390582u,
62533799363969u,
62543187805406u,
62552263421398u,
62561928519266u,
62572746577402u,
62582108753646u,
6259768287270u,
62602247006571u,
6261212490675u,
6262917121602u,
62632549835613u,
62642864033668u,
62653738062408u,
62662006922227u,
62672616619070u,
62683449066284u,
6269431292293u,
6270786322314u,
62711415970351u,
62723263135197u,
62732954777083u,
62743206261120u,
62752287507921u,
62761781944746u,
62774081586725u,
62781109175923u,
62791813855658u,
62801129462471u,
62811037031473u,
62823389003793u,
62833122687303u,
62841164309901u,
62853193251135u,
62863626554867u,
62873071568023u,
62883656006011u,
62891167681812u,
62903155218919u,
62912704165015u,
62921854985978u,
62931712976649u,
6294878608872u,
62954155949943u,
62963163786257u,
62971626463554u,
62981256485167u,
6299582664250u,
63002083771672u,
6301804336148u,
63022770847216u,
63031674051445u,
63043992583643u,
63052966108111u,
6306900741486u,
63074014551783u,
6308300318232u,
63093517585534u,
6310542270815u,
6311760762191u,
63121216399252u,
6313643179562u,
63143652676161u,
63152990167340u,
63163262252593u,
63172134299399u,
6318411263051u,
63191342880802u,
63201967599860u,
6321853593042u,
63222682611693u,
6323850464484u,
63243286110054u,
63253842907484u,
63263623364733u,
63273693536939u,
63281615375832u,
63292318423400u,
63304145497671u,
63311728968857u,
63322686506989u,
63331502282913u,
63342151665147u,
63353651607391u,
63361178454681u,
63374146839064u,
63382601416506u,
63391448097974u,
6340238887261u,
63414093725287u,
63422367569534u,
6343679517009u,
63443539886328u,
63453086277222u,
63461390394371u,
6347119173722u,
63481766260771u,
6349751439914u,
6350215917713u,
63512656990891u,
63521570750352u,
63533533987737u,
63543576119563u,
6355963183826u,
63563796810515u,
6357136547246u,
63582592925324u,
6359427154472u,
63601228758574u,
63611464255968u,
63622984611177u,
63632001585786u,
63641525438381u,
63651348536411u,
63662861338018u,
6367764077711u,
63683785343245u,
6369457568934u,
63704104954272u,
63712381948487u,
63723148473363u,
63732180270337u,
63741387729170u,
6375951677556u,
63762721005055u,
637766786703u,
63781149351924u,
63791895026827u,
63803711056516u,
63813638638708u,
63822263003308u,
63833448840877u,
6384225333538u,
63853797521928u,
63863262952567u,
63872078619498u,
63881178073973u,
63893288261538u,
63901496966875u,
63912481012988u,
6392114945840u,
63931632780103u,
63942087949619u,
63953787017905u,
63962575395164u,
63972971726178u,
63983642087909u,
63993894199764u,
6400203853421u,
6401425935223u,
64023565833278u,
64031748785729u,
6404580966986u,
64052124704694u,
64061107045577u,
64071067532701u,
64081406028344u,
640918613994u,
64103476683808u,
64113762914298u,
64121844996900u,
6413904215228u,
64141118521573u,
64153657647605u,
64163136157065u,
64172287683323u,
6418126005630u,
64193555092974u,
642049515858u,
64211010661841u,
64221902040126u,
64231400735275u,
64242771676666u,
64252225229957u,
64263454177594u,
64272883475137u,
64284144472319u,
64291051332394u,
6430542648229u,
64311669710469u,
6432553041029u,
6433584127807u,
64342993670925u,
64353587959456u,
64361745399498u,
64371404723176u,
64381334333531u,
64393239516985u,
64401275954779u,
6441367320647u,
64423684418197u,
64434030809053u,
6444484559105u,
64454255931645u,
64464271715616u,
64473171911678u,
6448928543347u,
64492159512867u,
6450313902234u,
6451647086234u,
6452577214736u,
64531130129573u,
6454995791646u,
64551645086060u,
64564122335794u,
64571064648931u,
64582752145076u,
64593312498873u,
64604238535494u,
64611471227427u,
6462633688562u,
64631959779970u,
6464766642813u,
64651380896111u,
64663647601207u,
64671733961041u,
6468521947915u,
6469189164145u,
6470486382294u,
64713770038872u,
64723235740744u,
64731912506671u,
64742276864677u,
64751588060152u,
64762504457929u,
64771471020554u,
64783623212998u,
64793026631806u,
64802342164722u,
64811674890530u,
64823011542850u,
64833549160092u,
64844290680005u,
64853943068002u,
64862273781461u,
64872127663659u,
64881646681121u,
6489447810651u,
64902366308558u,
6491970504950u,
64922008155560u,
64932695940969u,
64943444688454u,
64951739318893u,
64962683090634u,
64972774816580u,
6498437560100u,
6499512012738u,
65003305170944u,
6501665292744u,
65023580039116u,
65031579404983u,
65043397891494u,
6505710590371u,
65062514565805u,
65073624609754u,
65083516075816u,
65091314000850u,
65101935166880u,
65113257747610u,
65123776931214u,
65133183054185u,
6514675129307u,
65153333261712u,
65161154611403u,
65172759854023u,
65181963228038u,
6519505138315u,
65201803966773u,
65214032705384u,
6522798395739u,
65233473799845u,
6524476400898u,
6525602972493u,
65263289878097u,
65272520311409u,
65283214794876u,
6529748160407u,
65301326769504u,
6531902775872u,
65321372805534u,
65331213925114u,
65343009384989u,
65353781981134u,
65362835608783u,
65372716786748u,
65381669490957u,
65391089334066u,
6540250756920u,
65414041016629u,
65422495807367u,
65432008251381u,
6544106212622u,
65451927268995u,
65462251978818u,
65473788056262u,
65483678660147u,
65492656772270u,
65501997584981u,
65512668998785u,
65522954162084u,
6553845687881u,
6554776018378u,
65552066910012u,
6556918315064u,
6557};
6558
6559// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
6560bool Test(int offset, int len = 0) {
6561#undef Check
6562#undef IsAlive
6563
6564#define Check(x) do { \
6565 const uint32_t actual = (x), e = expected[index++]; \
6566 bool ok = actual == e; \
6567 if (!ok) { \
6568 cerr << "expected " << hex << e << " but got " << actual << endl; \
6569 ++errors; \
6570 } \
6571 assert(ok); \
6572} while (0)
6573
6574#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
6575
6576 // After the following line is where the uses of "Check" and such will go.
6577 static int index = 0;
6578if (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; }
6579Check(farmhashnt::Hash32WithSeed(data + offset, len, SEED));
6580Check(farmhashnt::Hash32(data + offset, len));
6581
6582 return true;
6583#undef Check
6584#undef IsAlive
6585}
6586
6587int RunTest() {
6588 Setup();
6589 int i = 0;
6590 cout << "Running farmhashntTest";
6591 if (!Test(-1)) {
6592 cout << "... Unavailable\n";
6593 return NoteErrors();
6594 }
6595 // Good. The function is attempting to hash, so run the full test.
6596 int errors_prior_to_test = errors;
6597 for ( ; i < kTestSize - 1; i++) {
6598 Test(i * i, i);
6599 }
6600 for ( ; i < kDataSize; i += i / 7) {
6601 Test(0, i);
6602 }
6603 Test(0, kDataSize);
6604 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
6605 return NoteErrors();
6606}
6607
6608#else
6609
6610// After the following line is where the code to print hash codes will go.
6611void Dump(int offset, int len) {
6612cout << farmhashnt::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
6613cout << farmhashnt::Hash32(data + offset, len) << "u," << endl;
6614}
6615
6616#endif
6617
6618#undef SEED
6619#undef SEED1
6620#undef SEED0
6621
6622} // namespace farmhashntTest
6623
6624#if !TESTING
6625int main(int argc, char** argv) {
6626 Setup();
6627 cout << "uint32_t expected[] = {\n";
6628 int i = 0;
6629 for ( ; i < kTestSize - 1; i++) {
6630 farmhashntTest::Dump(i * i, i);
6631 }
6632 for ( ; i < kDataSize; i += i / 7) {
6633 farmhashntTest::Dump(0, i);
6634 }
6635 farmhashntTest::Dump(0, kDataSize);
6636 cout << "};\n";
6637}
6638#endif
6639#ifndef FARMHASH_SELF_TEST_GUARD
6640#define FARMHASH_SELF_TEST_GUARD
6641#include <cstdio>
6642#include <iostream>
6643#include <string.h>
6644
6645using std::cout;
6646using std::cerr;
6647using std::endl;
6648using std::hex;
6649
6650static const uint64_t kSeed0 = 1234567;
6651static const uint64_t kSeed1 = k0;
6652static const int kDataSize = 1 << 20;
6653static const int kTestSize = 300;
6654#define kSeed128 Uint128(kSeed0, kSeed1)
6655
6656static char data[kDataSize];
6657
6658static int completed_self_tests = 0;
6659static int errors = 0;
6660
6661// Initialize data to pseudorandom values.
6662void Setup() {
6663 if (completed_self_tests == 0) {
6664 uint64_t a = 9;
6665 uint64_t b = 777;
6666 for (int i = 0; i < kDataSize; i++) {
6667 a += b;
6668 b += a;
6669 a = (a ^ (a >> 41)) * k0;
6670 b = (b ^ (b >> 41)) * k0 + i;
6671 uint8_t u = b >> 37;
6672 memcpy(data + i, &u, 1); // uint8_t -> char
6673 }
6674 }
6675}
6676
6677int NoteErrors() {
6678#define NUM_SELF_TESTS 9
6679 if (++completed_self_tests == NUM_SELF_TESTS)
6680 std::exit(errors > 0);
6681 return errors;
6682}
6683
6684template <typename T> inline bool IsNonZero(T x) {
6685 return x != 0;
6686}
6687
6688template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
6689 return x != Uint128(0, 0);
6690}
6691
6692#endif // FARMHASH_SELF_TEST_GUARD
6693
6694namespace farmhashsaTest {
6695
6696uint32_t CreateSeed(int offset, int salt) {
6697 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
6698 h = h * c1;
6699 h ^= (h >> 17);
6700 h = h * c1;
6701 h ^= (h >> 17);
6702 h = h * c1;
6703 h ^= (h >> 17);
6704 h += static_cast<uint32_t>(offset & 0xffffffff);
6705 h = h * c1;
6706 h ^= (h >> 17);
6707 h = h * c1;
6708 h ^= (h >> 17);
6709 h = h * c1;
6710 h ^= (h >> 17);
6711 return h;
6712}
6713
6714#undef SEED
6715#undef SEED1
6716#undef SEED0
6717#define SEED CreateSeed(offset, -1)
6718#define SEED0 CreateSeed(offset, 0)
6719#define SEED1 CreateSeed(offset, 1)
6720
6721#undef TESTING
6722#define TESTING 1
6723#if TESTING
6724uint32_t expected[] = {
67254223616069u,
67263696677242u,
67274081014168u,
67282576519988u,
67292212771159u,
67301112731063u,
67311020067935u,
67323955445564u,
67331451961420u,
6734653440099u,
673531917516u,
67362957164615u,
67372590087362u,
67383879448744u,
6739176305566u,
67402447367541u,
67411359016305u,
67423363804638u,
67431117290165u,
67441062549743u,
67452437877004u,
67461894455839u,
6747673206794u,
67483486923651u,
67493269862919u,
67502303349487u,
67511380660650u,
6752595525107u,
67531525325287u,
67542025609358u,
6755176408838u,
67561592885012u,
6757864896482u,
67582101378090u,
67593489229104u,
67602118965695u,
6761581644891u,
67622718789079u,
6763631613207u,
67644228658372u,
67653867875546u,
67663531368319u,
67673804516756u,
67683317755099u,
67691619744564u,
67702884717286u,
67711088213445u,
67722667691076u,
67733727873235u,
67742330406762u,
6775858590707u,
6776123802208u,
67774150036245u,
6778182283099u,
67791478882570u,
67803282617403u,
6781819171187u,
67821172627392u,
67834254302102u,
67842957028020u,
6785437030323u,
67862452147680u,
67872868246750u,
67883530169402u,
67893154852132u,
6790215019192u,
6791357580983u,
67921354454461u,
67931108813287u,
67942324008118u,
67952315997713u,
67964181601562u,
67971360882441u,
679892423273u,
67993048866755u,
68003369188505u,
68013664371439u,
68022920710428u,
68031027891570u,
68042653166430u,
68053461888315u,
68061475780447u,
6807292769636u,
68081737473313u,
68094064110516u,
68104170160075u,
6811762850927u,
68123630603695u,
68132803307356u,
6814844987665u,
6815460980967u,
68163005635467u,
68172802568977u,
6818588668033u,
68192148940781u,
68203239099984u,
68211266953698u,
68223197808789u,
68233519942533u,
68242511995334u,
68252553810188u,
6826871667697u,
68271358675720u,
68281499319171u,
68292044931270u,
68301210355103u,
6831807152540u,
68323262320756u,
68332810214575u,
68341813386141u,
68354089465863u,
6836903928165u,
68371388899322u,
68383209183659u,
6839834536144u,
68402733354550u,
68412742289921u,
68423689042563u,
68432655593281u,
68444169686303u,
6845415985561u,
6846138892376u,
6847516115393u,
684865683883u,
68494162865100u,
6850889944635u,
6851313566528u,
68523346420907u,
68531504303591u,
68542256809275u,
6855742243229u,
6856779775302u,
68573140940172u,
68582312556111u,
68592304095772u,
68601151741606u,
68612194712422u,
68621714084652u,
68633272736835u,
68641311540658u,
6865191179665u,
68663996605106u,
68671657345233u,
68684205442903u,
68691553339212u,
68702351843044u,
68711647502006u,
68722525516233u,
6873292202846u,
68741498646290u,
68751429323381u,
6876974274898u,
68773759331561u,
68782881238887u,
6879826787221u,
68801069622448u,
6881221991032u,
68821462969082u,
68832799661508u,
6884364022781u,
68852594244377u,
6886797773898u,
68874097839290u,
68881529150125u,
68892456805570u,
6890541503425u,
68913936326142u,
68923112719954u,
6893775223581u,
68943074018423u,
68953198488875u,
68961772191849u,
68972456535211u,
68983154686028u,
68991520862019u,
69004005829426u,
69011306433767u,
69021943028506u,
69032246000782u,
69041057766454u,
69053761996982u,
69063441075333u,
6907898641979u,
69083450209088u,
69093941329307u,
69103289922449u,
69113085075827u,
69121814193220u,
6913690422997u,
69142627846676u,
69152653520704u,
69163739145533u,
69173996776010u,
69182287072592u,
69191346671698u,
69203082629900u,
69212298811274u,
69223639722036u,
69231729419228u,
69241836765953u,
69253708118742u,
6926213436u,
6927950223749u,
69283734247682u,
69292924575678u,
69301382024841u,
69312431637732u,
69323448846682u,
69331341301397u,
69344206956590u,
69351730650902u,
69362581075456u,
69371542359141u,
6938707222542u,
69392925350541u,
69403846303536u,
69413579103295u,
69423932175763u,
69431339615732u,
6944848825750u,
69451070170828u,
69461964973818u,
6947577060344u,
6948607721296u,
69494031023048u,
6950406883794u,
69513991905552u,
69521198544082u,
6953872468460u,
69541044847096u,
69553159976313u,
69563020028266u,
69572108700400u,
69583373767922u,
6959264431841u,
69602817097007u,
69613700061048u,
69621733731531u,
69633459415893u,
696480378591u,
69651479875104u,
696619735612u,
69671382658977u,
69683416562245u,
69691959852842u,
69702384002344u,
6971124683828u,
69723725782174u,
69732300301222u,
6974393852269u,
69751302492002u,
69763623776492u,
69773787086417u,
69781730024749u,
69791710531361u,
6980443700716u,
69811461987482u,
6982671998131u,
69833018380746u,
69842592292305u,
69853390799372u,
69863945101155u,
69873743494852u,
69883716045582u,
6989996005166u,
6990320698449u,
69913420221765u,
69921518157951u,
69932555810666u,
69943381929684u,
69952019638523u,
69963088262796u,
69972072178906u,
69983433649364u,
6999203906916u,
700034663784u,
7001290301305u,
70021188021504u,
70033754681145u,
70043920313139u,
70052840496520u,
70061656802962u,
70072288475489u,
70083399185138u,
70091296000826u,
70102362384746u,
7011309633360u,
70122719851778u,
7013776035930u,
70143200733043u,
7015365690832u,
70163326378243u,
70171500331457u,
70181625708592u,
70194230903462u,
7020715344888u,
70213363777768u,
70222243620288u,
70232890765789u,
7024553154234u,
70254044100108u,
70264056887320u,
70271185656496u,
70283671476744u,
70291064586897u,
70301154949698u,
70313493481974u,
70321294573722u,
70331869224012u,
70342530084956u,
7035995321553u,
7036833419249u,
7037563815282u,
7038250258043u,
70392970801822u,
7040441007535u,
704142246961u,
70422820426655u,
70432878882436u,
70442363245780u,
70452138489282u,
70462972360481u,
70472312619393u,
70483598664848u,
70493071556076u,
7050776990325u,
70513220427357u,
70522257939577u,
70533817305903u,
70541502979698u,
70553159755934u,
70563955997276u,
70572423850008u,
70581959927572u,
70591219782288u,
70604119776679u,
70611124253854u,
70623678052422u,
70632620644947u,
70641262408666u,
70653480072280u,
70662627137665u,
7067807538749u,
70683276646337u,
7069518510128u,
70701137828655u,
70711498449110u,
70723031692317u,
70731125635969u,
70741130096111u,
7075780007336u,
70763111856399u,
70771014917264u,
7078780877352u,
70792909458336u,
70804235949214u,
70812423879289u,
7082275888892u,
70833891926795u,
70843538163953u,
708554815161u,
7086162228302u,
7087258154068u,
70883554455591u,
70891801469029u,
70902801563220u,
7091726560058u,
70922450221940u,
70933677582978u,
7094440993800u,
7095424762443u,
70962624525253u,
70972587715329u,
70982292264424u,
70991074856749u,
71003294752007u,
71013164112672u,
71022399146799u,
71031920182465u,
71043858835361u,
7105193755240u,
71063333610311u,
71071757504059u,
71082576027039u,
71092775253365u,
71102939191561u,
71111046147275u,
7112235149906u,
71134262218222u,
71142900542726u,
71152260154702u,
71161019551635u,
71171194720570u,
71183519118691u,
71193039483153u,
712084918216u,
71213053381097u,
71222572396843u,
71233849763371u,
71242782686780u,
71253710049554u,
71263403430713u,
71272346080784u,
71282496307442u,
71291597281872u,
7130696018239u,
7131704625714u,
7132623026921u,
71333182413559u,
71343794540330u,
7135305497722u,
71361592680199u,
71372377854072u,
71383060601746u,
71393953057908u,
71403941551588u,
71411033716182u,
71422765716854u,
71431309699058u,
71443519400181u,
71453073370877u,
7146115583008u,
71474032909296u,
71482944563574u,
71493762753718u,
7150192842727u,
71511711348701u,
71523086147235u,
71531658229443u,
71541479783872u,
71553839977157u,
7156225619117u,
71571349684817u,
71581964813173u,
7159565753187u,
71602530252046u,
7161840014353u,
71621645183704u,
71633668429078u,
71643438418557u,
7165639704059u,
7166360837811u,
71672531807958u,
71681572353913u,
71692116037299u,
71701948437512u,
7171744553393u,
71722380697034u,
71733775234105u,
71743816065157u,
7175301868653u,
71762960939561u,
71773306528247u,
71782389296549u,
7179805918610u,
71801759358265u,
71811760876328u,
71822827601706u,
71832944594708u,
71843313666458u,
71852022601495u,
7186730938791u,
7187193539397u,
71882026103244u,
7189802928398u,
71902630934308u,
7191782805818u,
71923499326016u,
7193293509489u,
71943646131514u,
71953182478647u,
7196854800333u,
71972284531628u,
7198438528022u,
71992339298129u,
72001692289216u,
72012427728723u,
720246501288u,
7203350652353u,
72041355971222u,
7205889682372u,
7206944799254u,
72072763906061u,
72082807550612u,
72092683762637u,
7210100870317u,
72112449357318u,
72122638348436u,
72134206088869u,
72141788948473u,
72153537588549u,
72162782490204u,
7217134406470u,
72182409190528u,
72192362439849u,
72201861661528u,
72212101513194u,
72221424834765u,
72233581765745u,
72243185999525u,
72252057487100u,
72262303941176u,
72273639628788u,
72281180265315u,
7229230437935u,
72302108319366u,
72311131685143u,
72321055685292u,
72331509007009u,
72341258485140u,
7235560525005u,
72363598799040u,
72373835680585u,
72381851859628u,
7239332858996u,
7240641769248u,
72414252450037u,
7242865386707u,
7243720719117u,
72443133612164u,
72453833045874u,
72463492515435u,
72472465970289u,
72484234420011u,
7249573859916u,
7250252532886u,
7251870392318u,
72524051320920u,
7253894929092u,
72543748361688u,
7255699355960u,
72561885212350u,
72571609756949u,
7258461896870u,
72591337065461u,
72601775211059u,
72611786193749u,
72622815154643u,
72632128729882u,
7264969639529u,
72653960427545u,
7266859416958u,
72672739758802u,
72682698032197u,
72692813292418u,
72701985467524u,
7271396604317u,
72724122172759u,
72731201259789u,
72744282051702u,
72753270018895u,
7276961215209u,
7277961075860u,
72784211926998u,
72794088374597u,
7280577510509u,
72813058349487u,
72824025377754u,
72832815478438u,
7284471023164u,
72853947959608u,
72864161486934u,
72872299888461u,
72881103571511u,
72892450153872u,
72901839939275u,
7291108299608u,
7292858086440u,
72931030152945u,
72943895328530u,
72953009080718u,
72963690840454u,
72973847025277u,
7298152331362u,
7299161365689u,
7300831319961u,
73012166017294u,
73023945322722u,
73034059970216u,
73041420824131u,
73052770648308u,
73061567250186u,
73072181067149u,
73081939743488u,
73093080158120u,
73103435218248u,
73112495237495u,
73123814085102u,
73133180983013u,
73143199054292u,
73152204745908u,
73161140337267u,
73172213569784u,
73181941879842u,
73192105562605u,
73203618835614u,
73212247103645u,
73222492473487u,
7323856414299u,
7324166022030u,
73254080104712u,
73263218935344u,
73273284220561u,
73284261581452u,
73291206944836u,
73303496705432u,
73312215996876u,
73323154627465u,
73333384005496u,
7334742170556u,
73351333047620u,
7336802680366u,
7337156833431u,
73382682100354u,
73392493654830u,
7340584848366u,
73411691693131u,
73422169934170u,
7343779968026u,
73442099545800u,
73451423039695u,
73464292110968u,
73474266576788u,
7348149142597u,
7349748501873u,
73503865014822u,
73511913588198u,
7352130285614u,
73533500768879u,
7354915458923u,
73553071792750u,
73561339986633u,
73574143929149u,
73584048379479u,
7359725193827u,
73601375113643u,
73612425277412u,
73624144659274u,
7363465714768u,
7364226991589u,
73652212127704u,
73663936145258u,
73672891024846u,
73683816000225u,
7369979331165u,
73701749907536u,
737153847318u,
73721462525833u,
73732961425455u,
7374368859113u,
73753572721452u,
7376453048644u,
73771628629918u,
73783497673923u,
73793619079585u,
7380139870565u,
73811518176798u,
73823933074281u,
73831878623729u,
73842074035641u,
73853016759257u,
73861313053591u,
73872557706970u,
73882348296582u,
7389962370022u,
73902337285014u,
73911618936717u,
73921915877085u,
73932743743122u,
73943250783882u,
73951346652536u,
7396143311109u,
73972443788461u,
73981048248964u,
73992806619339u,
74003263266976u,
74011668146349u,
74023397428868u,
74033276188862u,
74041774196343u,
74051993847813u,
74062771079610u,
7407476672419u,
74082119050359u,
74092918326659u,
74102245402721u,
74112692910474u,
74122374383269u,
7413342400227u,
74142961437795u,
74153899230368u,
7416337787132u,
74173664444935u,
74181269451153u,
74192971526729u,
74201486511182u,
7421791070133u,
74222570319890u,
74233482497490u,
74242134230518u,
74254273391202u,
74261825511330u,
74273947753714u,
74281389755724u,
74293995075516u,
74302081052615u,
74313626343470u,
74324213603435u,
74332137917278u,
74342898987303u,
74353059215715u,
74363383237881u,
74373003674434u,
7438409174425u,
74391911915604u,
74402087728055u,
74412942005882u,
74423386522440u,
7443714936074u,
7444261924004u,
74453268784033u,
74461141188757u,
74472413217552u,
74481515163433u,
7449};
7450
7451// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
7452bool Test(int offset, int len = 0) {
7453#undef Check
7454#undef IsAlive
7455
7456#define Check(x) do { \
7457 const uint32_t actual = (x), e = expected[index++]; \
7458 bool ok = actual == e; \
7459 if (!ok) { \
7460 cerr << "expected " << hex << e << " but got " << actual << endl; \
7461 ++errors; \
7462 } \
7463 assert(ok); \
7464} while (0)
7465
7466#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
7467
7468 // After the following line is where the uses of "Check" and such will go.
7469 static int index = 0;
7470if (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; }
7471Check(farmhashsa::Hash32WithSeed(data + offset, len, SEED));
7472Check(farmhashsa::Hash32(data + offset, len));
7473
7474 return true;
7475#undef Check
7476#undef IsAlive
7477}
7478
7479int RunTest() {
7480 Setup();
7481 int i = 0;
7482 cout << "Running farmhashsaTest";
7483 if (!Test(-1)) {
7484 cout << "... Unavailable\n";
7485 return NoteErrors();
7486 }
7487 // Good. The function is attempting to hash, so run the full test.
7488 int errors_prior_to_test = errors;
7489 for ( ; i < kTestSize - 1; i++) {
7490 Test(i * i, i);
7491 }
7492 for ( ; i < kDataSize; i += i / 7) {
7493 Test(0, i);
7494 }
7495 Test(0, kDataSize);
7496 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
7497 return NoteErrors();
7498}
7499
7500#else
7501
7502// After the following line is where the code to print hash codes will go.
7503void Dump(int offset, int len) {
7504cout << farmhashsa::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
7505cout << farmhashsa::Hash32(data + offset, len) << "u," << endl;
7506}
7507
7508#endif
7509
7510#undef SEED
7511#undef SEED1
7512#undef SEED0
7513
7514} // namespace farmhashsaTest
7515
7516#if !TESTING
7517int main(int argc, char** argv) {
7518 Setup();
7519 cout << "uint32_t expected[] = {\n";
7520 int i = 0;
7521 for ( ; i < kTestSize - 1; i++) {
7522 farmhashsaTest::Dump(i * i, i);
7523 }
7524 for ( ; i < kDataSize; i += i / 7) {
7525 farmhashsaTest::Dump(0, i);
7526 }
7527 farmhashsaTest::Dump(0, kDataSize);
7528 cout << "};\n";
7529}
7530#endif
7531#ifndef FARMHASH_SELF_TEST_GUARD
7532#define FARMHASH_SELF_TEST_GUARD
7533#include <cstdio>
7534#include <iostream>
7535#include <string.h>
7536
7537using std::cout;
7538using std::cerr;
7539using std::endl;
7540using std::hex;
7541
7542static const uint64_t kSeed0 = 1234567;
7543static const uint64_t kSeed1 = k0;
7544static const int kDataSize = 1 << 20;
7545static const int kTestSize = 300;
7546#define kSeed128 Uint128(kSeed0, kSeed1)
7547
7548static char data[kDataSize];
7549
7550static int completed_self_tests = 0;
7551static int errors = 0;
7552
7553// Initialize data to pseudorandom values.
7554void Setup() {
7555 if (completed_self_tests == 0) {
7556 uint64_t a = 9;
7557 uint64_t b = 777;
7558 for (int i = 0; i < kDataSize; i++) {
7559 a += b;
7560 b += a;
7561 a = (a ^ (a >> 41)) * k0;
7562 b = (b ^ (b >> 41)) * k0 + i;
7563 uint8_t u = b >> 37;
7564 memcpy(data + i, &u, 1); // uint8_t -> char
7565 }
7566 }
7567}
7568
7569int NoteErrors() {
7570#define NUM_SELF_TESTS 9
7571 if (++completed_self_tests == NUM_SELF_TESTS)
7572 std::exit(errors > 0);
7573 return errors;
7574}
7575
7576template <typename T> inline bool IsNonZero(T x) {
7577 return x != 0;
7578}
7579
7580template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
7581 return x != Uint128(0, 0);
7582}
7583
7584#endif // FARMHASH_SELF_TEST_GUARD
7585
7586namespace farmhashsuTest {
7587
7588uint32_t CreateSeed(int offset, int salt) {
7589 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
7590 h = h * c1;
7591 h ^= (h >> 17);
7592 h = h * c1;
7593 h ^= (h >> 17);
7594 h = h * c1;
7595 h ^= (h >> 17);
7596 h += static_cast<uint32_t>(offset & 0xffffffff);
7597 h = h * c1;
7598 h ^= (h >> 17);
7599 h = h * c1;
7600 h ^= (h >> 17);
7601 h = h * c1;
7602 h ^= (h >> 17);
7603 return h;
7604}
7605
7606#undef SEED
7607#undef SEED1
7608#undef SEED0
7609#define SEED CreateSeed(offset, -1)
7610#define SEED0 CreateSeed(offset, 0)
7611#define SEED1 CreateSeed(offset, 1)
7612
7613#undef TESTING
7614#define TESTING 1
7615#if TESTING
7616uint32_t expected[] = {
76174223616069u,
76183696677242u,
76194081014168u,
76202576519988u,
76212212771159u,
76221112731063u,
76231020067935u,
76243955445564u,
76251451961420u,
7626653440099u,
762731917516u,
76282957164615u,
76292590087362u,
76303879448744u,
7631176305566u,
76322447367541u,
76331359016305u,
76343363804638u,
76351117290165u,
76361062549743u,
76372437877004u,
76381894455839u,
7639673206794u,
76403486923651u,
76413269862919u,
76422303349487u,
76431380660650u,
7644595525107u,
76451525325287u,
76462025609358u,
7647176408838u,
76481592885012u,
7649864896482u,
76502101378090u,
76513489229104u,
76522118965695u,
7653581644891u,
76542718789079u,
7655631613207u,
76564228658372u,
76573867875546u,
76583531368319u,
76593804516756u,
76603317755099u,
76611619744564u,
76622884717286u,
76631088213445u,
76642667691076u,
76653727873235u,
76662330406762u,
7667858590707u,
7668457744844u,
76694150036245u,
76702000404290u,
76711478882570u,
7672901678172u,
7673819171187u,
7674195942998u,
76754254302102u,
76763967266927u,
7677437030323u,
76784018009204u,
76792868246750u,
76803540087514u,
76813154852132u,
76823319116625u,
7683357580983u,
76843177665294u,
76851108813287u,
76861253366798u,
76872315997713u,
7688510718750u,
76891360882441u,
76902770216279u,
76913048866755u,
76923406961221u,
76933664371439u,
76941151145514u,
76951027891570u,
76962699067992u,
76973461888315u,
7698198061905u,
7699292769636u,
77001106771795u,
77014064110516u,
77023258279756u,
7703762850927u,
77041818699721u,
77052803307356u,
77063919169404u,
7707460980967u,
77083125535078u,
77092802568977u,
77103582546426u,
77112148940781u,
77123963274378u,
77131266953698u,
7714204185123u,
77151100034381u,
77163009193601u,
77174200651967u,
7718274889605u,
77192700589508u,
7720952511689u,
77213765324859u,
77223465498478u,
77234014967037u,
77242070988082u,
77252972423530u,
77263068638223u,
77274156773651u,
7728489509804u,
77291323863238u,
77303731914806u,
77312846098469u,
77322728930632u,
7733346814072u,
7734848146907u,
7735551160669u,
77364165126521u,
77372039095001u,
77384179859388u,
77392434936359u,
77402764414551u,
7741238491210u,
7742732483969u,
77433366512764u,
7744478307468u,
77454124179572u,
77464142733597u,
77471953448206u,
77484199329278u,
7749865077060u,
77502627662116u,
77512802499360u,
77523141206831u,
77531959218197u,
7754911371451u,
7755125987200u,
77562821366175u,
77572530992747u,
77582409206225u,
7759117991880u,
77602133402461u,
7761895510531u,
7762428719601u,
77633036014536u,
77641223783733u,
7765733793540u,
7766970650405u,
7767547701766u,
7768570764615u,
77693224485368u,
77703192714940u,
7771319942831u,
77723940200341u,
7773362056204u,
77742832368105u,
77751853281226u,
77763296434636u,
77773752508307u,
7778604292768u,
77792231940616u,
77801204094681u,
7781866194005u,
77822405201650u,
77832466384396u,
7784380829379u,
7785230033818u,
77862783417588u,
77874249886729u,
7788829569301u,
77892988322580u,
77902299983554u,
779174748560u,
7792737514425u,
77933153050211u,
7794652642663u,
77951270205115u,
7796227197032u,
77972773091790u,
7798325849216u,
779949998791u,
78004043203010u,
78013662748068u,
78021709364383u,
78031179105165u,
78041478504366u,
78052980456610u,
78061167476429u,
78071590390732u,
78081306256496u,
7809292008135u,
7810374690995u,
78111809200819u,
78121680595904u,
7813646040226u,
78141742445560u,
78152435776844u,
78163703683804u,
7817478742495u,
7818814967947u,
78192698190177u,
78201003617993u,
78211436118705u,
7822217056304u,
78231412287094u,
78242738417466u,
78252933279339u,
78263461877733u,
78271203141205u,
78282119492857u,
78291134895723u,
78301560001021u,
78313786320122u,
78323748116258u,
78333486219595u,
7834702138030u,
78351062984182u,
7836232789133u,
78371566523968u,
78383885443778u,
78391820171888u,
78403655858585u,
78412316903005u,
78422678779620u,
7843395625433u,
78441609107564u,
78453108726411u,
78462937837224u,
78473911907151u,
7848557272509u,
78493893435978u,
78501542613576u,
78511079886893u,
78522624566322u,
78531413700616u,
78542796974006u,
78551922556114u,
7856562820464u,
78572845409784u,
785854180312u,
78591898782464u,
78603681814953u,
78612417064617u,
78621815464483u,
7863911626132u,
78642964575550u,
78651852696128u,
78662319647785u,
78671998904590u,
7868619992689u,
78693073207513u,
78701238163512u,
78713199435982u,
7872828667254u,
78733561155502u,
78743943095163u,
78751045711849u,
78762238679131u,
78772114975398u,
7878713808403u,
78793871787494u,
78802572031161u,
78812360934075u,
78822337781107u,
7883262596504u,
7884693836699u,
78852129369850u,
78863543189427u,
7887962205222u,
78883685581020u,
7889692974477u,
7890725182211u,
7891646123906u,
78922368836544u,
78932505872733u,
78941999977610u,
78951639885802u,
78961475058032u,
7897207023609u,
78982773581234u,
78993524857793u,
79003433371102u,
79013243027613u,
79021787668353u,
7903985757946u,
79043896012929u,
7905702356957u,
79063559331129u,
7907884084870u,
79084009998120u,
7909648888720u,
79101403349048u,
79111624342778u,
79121766674171u,
79132518582204u,
79143251243146u,
7915792751003u,
79161377201813u,
79173629686054u,
79181583734324u,
79193647107626u,
79204258564381u,
79211469878609u,
79221940598241u,
79232755003690u,
79241907120418u,
7925109916701u,
7926775347954u,
79272090960874u,
7928611281803u,
79293470490146u,
79303301663253u,
79311835412158u,
79321803066146u,
7933591872433u,
7934550703713u,
79351495089683u,
7936826492808u,
7937817200035u,
79384177474571u,
7939688070143u,
7940971427632u,
79411442499481u,
79423568640348u,
79432789993738u,
794485808128u,
79452058346726u,
7946394058570u,
79473466511434u,
7948318905230u,
79494149248030u,
7950415308316u,
7951165997598u,
79521219639412u,
79531648022659u,
79542857432523u,
79551422508004u,
7956468095522u,
7957296968649u,
7958430250611u,
79591775562314u,
79602976361671u,
79611040036362u,
79621372510167u,
7963292746272u,
79643408238954u,
7965626061886u,
79661317637569u,
79671237775792u,
79681218490455u,
79692224234499u,
7970590942419u,
7971713995643u,
79723541889330u,
79734140218960u,
79743529791107u,
7975354462673u,
7976842607274u,
7977365048533u,
79782638303414u,
79793560458014u,
798031621379u,
79814210854794u,
79821273118792u,
79832572743762u,
79843513175801u,
7985402066986u,
7986602524471u,
7987565029192u,
7988180576438u,
79891288605959u,
79902896244423u,
79911420543484u,
79921329862227u,
79931791567324u,
79944248690247u,
799512917038u,
79963483481310u,
79972082050731u,
79981611921143u,
79992443766548u,
80002216338811u,
80012528006095u,
80022984009021u,
8003674210884u,
80042857608106u,
80052155534809u,
80061023105067u,
80072968955846u,
80083303624302u,
80092502112850u,
8010245749006u,
80113175229091u,
80123342796184u,
80133613785362u,
80141614168851u,
80152582149283u,
8016895403488u,
8017416205023u,
80183792242000u,
8019529397534u,
8020299415203u,
80214284673348u,
80222096851282u,
80231864524731u,
80242012577738u,
80253426363316u,
80261387308508u,
80271143610148u,
80282027467219u,
80293772856163u,
80303453862623u,
80312661437174u,
80322047145955u,
80332533381447u,
80342059534115u,
8035439426587u,
80361537543414u,
80372384289877u,
80383174229055u,
80392658017753u,
80402293148474u,
80412359450158u,
80423930242475u,
80431510302397u,
80443354288821u,
8045920095603u,
80462415746928u,
80472729472638u,
80482261143371u,
8049848667611u,
8050919157153u,
80513322393117u,
80524103299943u,
8053413569608u,
805468911216u,
80553334990170u,
80561228068652u,
80571570056373u,
80581905477543u,
80592622302276u,
80602935063895u,
80613224810004u,
80624211768578u,
8063828688131u,
80643556122839u,
80651930935348u,
80662605825202u,
80671540993970u,
80683209115883u,
8069122847500u,
8070665638794u,
8071506571051u,
80722691795295u,
80733996966556u,
8074714660621u,
80753662432239u,
8076470651837u,
80771807432621u,
80783755290953u,
8079359878860u,
80802793081615u,
80814065031431u,
8082904653062u,
80832317800777u,
8084568501094u,
80853492871707u,
80862738806116u,
80872883859610u,
80883242080257u,
8089364246691u,
80903601786516u,
80913159362524u,
80921578272201u,
80931283574375u,
80942912186103u,
80952256279032u,
80961540671086u,
80972356088973u,
80982892277779u,
80993441449267u,
81002225005503u,
81013846428419u,
81022014549218u,
81032290734767u,
81042126684614u,
81054235463487u,
81063811556204u,
8107174739661u,
8108767525888u,
810947684458u,
81104211168099u,
8111889063422u,
8112469864411u,
8113767407110u,
8114413337343u,
81151618456644u,
81162814499820u,
81172401124192u,
8118632089437u,
81191234980238u,
81201288585402u,
81213153169944u,
81222917822069u,
81231843320264u,
81243794359132u,
81253074573530u,
8126258629454u,
81273813357060u,
81283806887248u,
81291665524736u,
81303324533324u,
81313005091922u,
8132793108368u,
81331529669805u,
81342332660395u,
81352217730223u,
81362634687611u,
8137442806463u,
81381968135266u,
8139454523002u,
81403177866230u,
81412808960136u,
81424259114138u,
81434103264843u,
81443103714075u,
81452462967542u,
81461466891491u,
8147477973764u,
8148834565647u,
8149741089037u,
8150218837573u,
81511710536528u,
81522469088212u,
81531229072375u,
81542828341u,
8155176923431u,
8156985763350u,
81574095477420u,
81581984145538u,
81591870791084u,
8160674956677u,
81611978138947u,
81621296493993u,
81631818183554u,
81643443333721u,
81652124949983u,
81662549590262u,
81672700850794u,
81682662736367u,
8169739638109u,
81704061447096u,
81712960078422u,
81722453781158u,
8173929570940u,
81743200328383u,
81752406328791u,
81761419180666u,
81772152455739u,
81782805741044u,
81793305999074u,
81803183816361u,
81812303165050u,
81824922104u,
818363096005u,
8184936656347u,
81853104453886u,
81861088673880u,
81871113407526u,
81881457890086u,
8189453478383u,
81901107686695u,
81913626027824u,
81921159687359u,
81932248467888u,
81942004578380u,
81953274954621u,
81961787958646u,
81972628726704u,
81981138419798u,
81993735442315u,
8200692385301u,
8201313807213u,
82022329068673u,
820359375364u,
82043261084359u,
82052088644507u,
82062471153194u,
8207788336435u,
82084024527246u,
8209141504460u,
82102307553888u,
82111930559950u,
821248975711u,
82132745693338u,
8214230161982u,
82153429230862u,
82161335968626u,
8217609591304u,
821857435073u,
82194279281136u,
82203152151665u,
82213984484924u,
82223459883943u,
8223397478330u,
82241738762229u,
82253033590066u,
82263611539498u,
82271363463523u,
82283319364965u,
82292671169141u,
82303819548561u,
82311691193757u,
82322423834608u,
82332820147055u,
82341378120632u,
82351240565187u,
82363180720050u,
8237680831086u,
82383309658414u,
82391986166490u,
8240762099827u,
8241510883662u,
82422047373648u,
82433606742294u,
82443894965352u,
82452342078853u,
82461091255717u,
8247776594727u,
82483217317445u,
82491574468485u,
82503844504016u,
82512819598918u,
82521037401010u,
82532550943503u,
82543867184001u,
82551687911772u,
8256165313836u,
82571679575281u,
82582418947263u,
82592038774952u,
82603913543652u,
82613209155736u,
8262149905221u,
82633859604717u,
8264713919631u,
82654069810796u,
82661882959164u,
82671019939034u,
82682379867302u,
82693666323035u,
82701157389013u,
82712422300650u,
82723366777340u,
82732526452062u,
82741313747885u,
82751039617868u,
82761620553692u,
82772032976978u,
8278578789528u,
82791592846839u,
82802270630604u,
8281897850577u,
82821603294178u,
82833105664807u,
82841442670138u,
82851728019360u,
828679313861u,
82871683031101u,
82881913067024u,
82894070719870u,
8290708986470u,
82912586453359u,
82923993348863u,
82933358251279u,
82943003552537u,
8295750174793u,
8296836888956u,
82974190747426u,
82984251291318u,
82994145164938u,
83001366883260u,
83011912910955u,
8302510192669u,
83031851315039u,
83043574241274u,
83053220062924u,
83062821142039u,
83071317082195u,
83082274293302u,
83091839219569u,
8310126586168u,
83113989293643u,
83122680178207u,
8313347056948u,
8314799681430u,
83152864517481u,
83163180404853u,
8317213140045u,
83181956305184u,
83191474675286u,
83203085723423u,
83212841859626u,
8322308421914u,
83233670309263u,
83241765052231u,
8325245459238u,
8326113434331u,
83274079521092u,
83282115235526u,
83292943408816u,
83301055476938u,
83311506442339u,
83322291296392u,
83333267864332u,
83341282145528u,
83353700108015u,
83361932843667u,
83372677701670u,
83386041177u,
83393889648557u,
83401461025478u,
8341};
8342
8343// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
8344bool Test(int offset, int len = 0) {
8345#undef Check
8346#undef IsAlive
8347
8348#define Check(x) do { \
8349 const uint32_t actual = (x), e = expected[index++]; \
8350 bool ok = actual == e; \
8351 if (!ok) { \
8352 cerr << "expected " << hex << e << " but got " << actual << endl; \
8353 ++errors; \
8354 } \
8355 assert(ok); \
8356} while (0)
8357
8358#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
8359
8360 // After the following line is where the uses of "Check" and such will go.
8361 static int index = 0;
8362if (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; }
8363Check(farmhashsu::Hash32WithSeed(data + offset, len, SEED));
8364Check(farmhashsu::Hash32(data + offset, len));
8365
8366 return true;
8367#undef Check
8368#undef IsAlive
8369}
8370
8371int RunTest() {
8372 Setup();
8373 int i = 0;
8374 cout << "Running farmhashsuTest";
8375 if (!Test(-1)) {
8376 cout << "... Unavailable\n";
8377 return NoteErrors();
8378 }
8379 // Good. The function is attempting to hash, so run the full test.
8380 int errors_prior_to_test = errors;
8381 for ( ; i < kTestSize - 1; i++) {
8382 Test(i * i, i);
8383 }
8384 for ( ; i < kDataSize; i += i / 7) {
8385 Test(0, i);
8386 }
8387 Test(0, kDataSize);
8388 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
8389 return NoteErrors();
8390}
8391
8392#else
8393
8394// After the following line is where the code to print hash codes will go.
8395void Dump(int offset, int len) {
8396cout << farmhashsu::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
8397cout << farmhashsu::Hash32(data + offset, len) << "u," << endl;
8398}
8399
8400#endif
8401
8402#undef SEED
8403#undef SEED1
8404#undef SEED0
8405
8406} // namespace farmhashsuTest
8407
8408#if !TESTING
8409int main(int argc, char** argv) {
8410 Setup();
8411 cout << "uint32_t expected[] = {\n";
8412 int i = 0;
8413 for ( ; i < kTestSize - 1; i++) {
8414 farmhashsuTest::Dump(i * i, i);
8415 }
8416 for ( ; i < kDataSize; i += i / 7) {
8417 farmhashsuTest::Dump(0, i);
8418 }
8419 farmhashsuTest::Dump(0, kDataSize);
8420 cout << "};\n";
8421}
8422#endif
8423#ifndef FARMHASH_SELF_TEST_GUARD
8424#define FARMHASH_SELF_TEST_GUARD
8425#include <cstdio>
8426#include <iostream>
8427#include <string.h>
8428
8429using std::cout;
8430using std::cerr;
8431using std::endl;
8432using std::hex;
8433
8434static const uint64_t kSeed0 = 1234567;
8435static const uint64_t kSeed1 = k0;
8436static const int kDataSize = 1 << 20;
8437static const int kTestSize = 300;
8438#define kSeed128 Uint128(kSeed0, kSeed1)
8439
8440static char data[kDataSize];
8441
8442static int completed_self_tests = 0;
8443static int errors = 0;
8444
8445// Initialize data to pseudorandom values.
8446void Setup() {
8447 if (completed_self_tests == 0) {
8448 uint64_t a = 9;
8449 uint64_t b = 777;
8450 for (int i = 0; i < kDataSize; i++) {
8451 a += b;
8452 b += a;
8453 a = (a ^ (a >> 41)) * k0;
8454 b = (b ^ (b >> 41)) * k0 + i;
8455 uint8_t u = b >> 37;
8456 memcpy(data + i, &u, 1); // uint8_t -> char
8457 }
8458 }
8459}
8460
8461int NoteErrors() {
8462#define NUM_SELF_TESTS 9
8463 if (++completed_self_tests == NUM_SELF_TESTS)
8464 std::exit(errors > 0);
8465 return errors;
8466}
8467
8468template <typename T> inline bool IsNonZero(T x) {
8469 return x != 0;
8470}
8471
8472template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
8473 return x != Uint128(0, 0);
8474}
8475
8476#endif // FARMHASH_SELF_TEST_GUARD
8477
8478namespace farmhashteTest {
8479
8480uint32_t CreateSeed(int offset, int salt) {
8481 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
8482 h = h * c1;
8483 h ^= (h >> 17);
8484 h = h * c1;
8485 h ^= (h >> 17);
8486 h = h * c1;
8487 h ^= (h >> 17);
8488 h += static_cast<uint32_t>(offset & 0xffffffff);
8489 h = h * c1;
8490 h ^= (h >> 17);
8491 h = h * c1;
8492 h ^= (h >> 17);
8493 h = h * c1;
8494 h ^= (h >> 17);
8495 return h;
8496}
8497
8498#undef SEED
8499#undef SEED1
8500#undef SEED0
8501#define SEED CreateSeed(offset, -1)
8502#define SEED0 CreateSeed(offset, 0)
8503#define SEED1 CreateSeed(offset, 1)
8504
8505#undef TESTING
8506#define TESTING 1
8507#if TESTING
8508uint32_t expected[] = {
85091140953930u, 861465670u,
85103277735313u, 2681724312u,
85112598464059u, 797982799u,
8512890626835u, 800175912u,
85132603993599u, 921001710u,
85141410420968u, 2134990486u,
85153283896453u, 1867689945u,
85162914424215u, 2244477846u,
8517255297188u, 2992121793u,
85181110588164u, 4186314283u,
8519161451183u, 3943596029u,
85204019337850u, 452431531u,
8521283198166u, 2741341286u,
85223379021470u, 2557197665u,
8523299850021u, 2532580744u,
8524452473466u, 1706958772u,
85251298374911u, 3099673830u,
85262199864459u, 3696623795u,
8527236935126u, 2976578695u,
85284055299123u, 3281581178u,
85291053458494u, 1882212500u,
85302305012065u, 2169731866u,
85313456121707u, 275903667u,
8532458884671u, 3033004529u,
85333058973506u, 2379411653u,
85341898235244u, 1402319660u,
85352700149065u, 2699376854u,
8536147814787u, 720739346u,
85372433714046u, 4222949502u,
85384220361840u, 1712034059u,
85393425469811u, 3690733394u,
85404148372108u, 1330324210u,
8541594028478u, 2921867846u,
85421635026870u, 192883107u,
8543780716741u, 1728752234u,
85443280331829u, 326029180u,
85453969463346u, 1436364519u,
8546393215742u, 3349570000u,
85473824583307u, 1612122221u,
85482859809759u, 3808705738u,
85491379537552u, 1646032583u,
85502233466664u, 1432476832u,
85514023053163u, 2650381482u,
85522052294713u, 3552092450u,
85531628777059u, 1499109081u,
85543476440786u, 3829307897u,
85552960536756u, 1554038301u,
85561145519619u, 3190844552u,
85572902102606u, 3600725550u,
8558237495366u, 540224401u,
855965721842u, 489963606u,
85601448662590u, 397635823u,
85611596489240u, 1562872448u,
85621790705123u, 2128624475u,
8563180854224u, 2604346966u,
85641435705557u, 1262831810u,
8565155445229u, 1672724608u,
85661669465176u, 1341975128u,
8567663607706u, 2077310004u,
85683610042449u, 1911523866u,
85691043692997u, 1454396064u,
85702563776023u, 294527927u,
85711099072299u, 1389770549u,
8572703505868u, 678706990u,
85732952353448u, 2026137563u,
85743603803785u, 629449419u,
85751933894405u, 3043213226u,
8576226132789u, 2489287368u,
85771552847036u, 645684964u,
85783828089804u, 3632594520u,
8579187883449u, 230403464u,
85803151491850u, 3272648435u,
85813729087873u, 1303930448u,
85822002861219u, 165370827u,
8583916494250u, 1230085527u,
85843103338579u, 3064290191u,
85853807265751u, 3628174014u,
8586231181488u, 851743255u,
85872295806711u, 1781190011u,
85882988893883u, 1554380634u,
85891142264800u, 3667013118u,
85901968445277u, 315203929u,
85912638023604u, 2290487377u,
8592732137533u, 1909203251u,
8593440398219u, 1891630171u,
85941380301172u, 1498556724u,
85954072067757u, 4165088768u,
85964204318635u, 441430649u,
85973931792696u, 197618179u,
8598956300927u, 914413116u,
85993010839769u, 2837339569u,
86002148126371u, 1913303225u,
86013074915312u, 3117299654u,
86024139181436u, 2993479124u,
86033178848746u, 1357272220u,
86041438494951u, 507436733u,
8605667183474u, 2084369203u,
86063854939912u, 1413396341u,
8607126024219u, 146044391u,
86081016656857u, 3022024459u,
86093254014218u, 429095991u,
8610990500595u, 3056862311u,
8611985653208u, 1718653828u,
8612623071693u, 366414107u,
86131771289760u, 2293458109u,
86143047342438u, 2991127487u,
86153120876698u, 1684583131u,
86163638043310u, 1170404994u,
8617863214540u, 1087193030u,
8618199124911u, 520792961u,
86193169775996u, 1577421232u,
86203331828431u, 1013201099u,
86211716848157u, 4033596884u,
86221770708857u, 4229339322u,
86231146169032u, 1434258493u,
86243824360466u, 3242407770u,
86251926419493u, 2649785113u,
8626872586426u, 762243036u,
86272736953692u, 816692935u,
86281571283333u, 3555213933u,
86292266795890u, 3781899767u,
86304290630595u, 517646945u,
86313006163611u, 2180594090u,
8632959214578u, 558910384u,
86331283799121u, 3047062993u,
86343830962609u, 2391606125u,
86353544509313u, 622325861u,
8636834785312u, 382936554u,
86371421463872u, 788479970u,
86381825135056u, 2725923798u,
8639580988377u, 2826990641u,
8640247825043u, 3167748333u,
8641812546227u, 2506885666u,
86422584372201u, 1758123094u,
86431891789696u, 389974094u,
8644345313518u, 2022370576u,
86453886113119u, 3338548567u,
86461083486947u, 2583576230u,
86471776047957u, 1771384107u,
86483604937815u, 3198590202u,
86493027522813u, 4155628142u,
86504232136669u, 427759438u,
86514244322689u, 542201663u,
86521549591985u, 2856634168u,
8653556609672u, 45845311u,
86541175961330u, 3948351189u,
86554165739882u, 4194218315u,
86561634635545u, 4151937410u,
8657713127376u, 1467786451u,
86581327394015u, 2743592929u,
86592638154051u, 810082938u,
86603077742128u, 1062268187u,
86614084325664u, 3810665822u,
86623735739145u, 2794294783u,
86632335576331u, 2560479831u,
8664690240711u, 997658837u,
86652442302747u, 3948961926u,
86663958366652u, 3067277639u,
86672059157774u, 1211737169u,
86681516711748u, 2339636583u,
86694188504038u, 59581167u,
86702767897792u, 1389679610u,
86712658147000u, 2643979752u,
86723758739543u, 4189944477u,
86731454470782u, 100876854u,
86742995362413u, 118817200u,
86753252925478u, 2062343506u,
86762804483644u, 3088828656u,
86771231633714u, 4168280671u,
86782931588131u, 3284356565u,
86791255909792u, 3130054947u,
86804173605289u, 1407328702u,
86811677744031u, 3532596884u,
86823162657845u, 3887208531u,
86832256541290u, 3459463480u,
86843740979556u, 259034107u,
8685392987633u, 3233195759u,
86863606709555u, 3424793077u,
8687315836068u, 3200749877u,
86884065431359u, 760633989u,
86892982018998u, 1811050648u,
8690234531934u, 1115203611u,
86913897494162u, 1516407838u,
86921603559457u, 323296368u,
86932632963283u, 1778459926u,
86942879836826u, 2146672889u,
86953486330348u, 492621815u,
86961231665285u, 2457048126u,
86973438440082u, 2217471853u,
86983355404249u, 3275550588u,
86991052645068u, 862072556u,
87004110617119u, 3745267835u,
87012657392572u, 4279236653u,
87021688445808u, 701920051u,
8703956734128u, 581695350u,
87043157862788u, 2585726058u,
87051192588249u, 1410111809u,
87061651193125u, 3326135446u,
87071073280453u, 97376972u,
87082513844237u, 2187968410u,
87093976859649u, 4267859263u,
87103429034542u, 564493077u,
87113000537321u, 479241367u,
87123845637831u, 2868987960u,
871351544337u, 1029173765u,
8714393624922u, 704325635u,
87152357610553u, 1418509533u,
87162007814586u, 3866658271u,
87173082385053u, 735688735u,
8718916110004u, 3283299459u,
87191051684175u, 1083796807u,
87204074716319u, 813690332u,
8721144264390u, 1439630796u,
87221508556987u, 675582689u,
87233748881891u, 3195309868u,
8724362884708u, 1616408198u,
872543233176u, 837301135u,
8726881504822u, 3254795114u,
87271385506591u, 2799925823u,
87281469874582u, 3464841997u,
8729497175391u, 3929484338u,
87303975771289u, 1798536177u,
87312926265846u, 1374242438u,
87323675707838u, 4205965408u,
87333153165629u, 1499475160u,
8734187287713u, 548490821u,
87353255259608u, 4247675634u,
87361940181471u, 3779953975u,
8737687167150u, 2319566715u,
87381742785722u, 785893184u,
87392296977392u, 2778575413u,
87401794720651u, 48131484u,
87414084891412u, 1160134629u,
87423737623280u, 823113169u,
87433423207646u, 3803213486u,
8744710625654u, 4116162021u,
87453693420287u, 4167766971u,
87461666602807u, 295320990u,
87473513255468u, 2487440590u,
8748234080704u, 4004655503u,
87492971762528u, 1479656873u,
87504090178629u, 4044418876u,
8751391947536u, 1462554406u,
87523909295855u, 1239580330u,
87531515601363u, 2011102035u,
87541442068334u, 4265993528u,
87551191921695u, 2291355695u,
87564257172787u, 576405853u,
8757314332944u, 4038839101u,
875855559918u, 2378985842u,
8759711098718u, 2425317635u,
87601644327317u, 1401013391u,
87614193760037u, 2958260436u,
87623167371443u, 3062418115u,
87633800755475u, 3167030094u,
87643489648204u, 1405430357u,
8765526177822u, 2602636307u,
8766915406019u, 4264167741u,
87671484090483u, 3070944737u,
8768254529415u, 4017058800u,
87691702710265u, 1029665228u,
87702000382906u, 3185573940u,
87711381258384u, 4036354071u,
87722900841028u, 2670703363u,
87732921748807u, 2899069938u,
87744130543625u, 688472265u,
87754186808827u, 1054670286u,
87761132985391u, 2840525968u,
87774175776103u, 338058159u,
87781735964501u, 1539305024u,
87793497121710u, 1568260669u,
87802227290760u, 146827036u,
87813977176001u, 4060134777u,
8782857488494u, 250055052u,
87834284109679u, 2502815838u,
87842592281721u, 1603444633u,
87851390562014u, 1556658131u,
8786616327404u, 2448966429u,
87873051191726u, 3891353218u,
87881213304082u, 762328245u,
87892239052397u, 1082330589u,
87902455957292u, 201837927u,
8791405397452u, 3079886794u,
87922583939798u, 2848283092u,
87933750724631u, 883849006u,
87943204198988u, 3341327098u,
87951855234968u, 1982110346u,
87961485529487u, 541496720u,
87974117290321u, 3607433551u,
87982168864636u, 133643215u,
87991055817409u, 3847827123u,
88002960769387u, 4046101649u,
88011176127003u, 4015671361u,
88024243643405u, 2849988118u,
8803517111221u, 1796672358u,
88042045051700u, 3452457457u,
88052948254999u, 2102063419u,
88061556410577u, 1536380876u,
88073776661467u, 3281002516u,
88081735616066u, 1539151988u,
88091087795162u, 3332431596u,
8810685631442u, 1147951686u,
881195237878u, 2005032160u,
88124012206915u, 4224354805u,
88133204999386u, 2415262714u,
88141433635018u, 116647396u,
881583167836u, 2881562655u,
88162729416454u, 1029284767u,
8817881378302u, 2159170082u,
8818555057366u, 1169104445u,
88193963877000u, 1919171906u,
8820336034862u, 2017579106u,
88214059340529u, 3020819343u,
8822865146997u, 2473524405u,
8823944743644u, 1694443528u,
88241804513294u, 2904752429u,
8825617975720u, 3671562289u,
8826260177668u, 505662155u,
88271885941445u, 2504509403u,
88282260041112u, 1019936943u,
88293722741628u, 1511077569u,
88303100701179u, 1379422864u,
88311535670711u, 773792826u,
88321103819072u, 2089123665u,
88331157547425u, 329152940u,
88344142587430u, 484732447u,
88352475035432u, 1120017626u,
8836412145504u, 965125959u,
8837324924679u, 2809286837u,
88382842141483u, 4029205195u,
88392974306813u, 515627448u,
88403791551981u, 1097806406u,
88413873078673u, 136118734u,
88421872130856u, 3632422367u,
88433574135531u, 4017075736u,
88441699452298u, 1403506686u,
8845344414660u, 1189129691u,
88463487080616u, 1516736273u,
88471805475756u, 2562064338u,
8848163335594u, 2732147834u,
88494077452507u, 2984955003u,
88504271866024u, 3071338162u,
88512347111903u, 873829983u,
88521948409509u, 1923531348u,
8853459509140u, 771592405u,
88541750124750u, 2334938333u,
8855213811117u, 2586632018u,
8856185232757u, 4032960199u,
88572447383637u, 284777551u,
88581654276320u, 2687561076u,
88593512945009u, 308584855u,
88601861027147u, 4102279334u,
88613203802620u, 1692079268u,
88624250142168u, 2565680167u,
88631507046104u, 841195925u,
8864520565830u, 3674576684u,
886538924274u, 3770488806u,
88662414430882u, 3978473838u,
88673703994407u, 69201295u,
88683099963860u, 1255084262u,
8869690971838u, 3539996781u,
88703696902571u, 3593730713u,
88712363435042u, 54945052u,
88721785765213u, 184911581u,
88731586241476u, 1939595371u,
88742534883189u, 2432427547u,
88752374171993u, 2039128933u,
88762955715987u, 2295501078u,
88772741583197u, 1280920000u,
8878686818699u, 1238742497u,
88793843660102u, 82177963u,
88801281043691u, 1121403845u,
88811697846708u, 284852964u,
8882278661677u, 2889101923u,
88832127558730u, 713121337u,
8884872502474u, 511142139u,
88851261140657u, 1747052377u,
88862108187161u, 927011680u,
8887955328267u, 3821994995u,
88882707230761u, 4142246789u,
88894134691985u, 1958963937u,
88902498463509u, 1977988705u,
88911419293714u, 1636932722u,
88922567532373u, 4075249328u,
8893240575705u, 1956681213u,
88942598802768u, 2025886508u,
88954104757832u, 3026358429u,
88963242615202u, 4026813725u,
8897255108733u, 1845587644u,
88983573008472u, 3615577014u,
88991222733548u, 1205557630u,
8900917608574u, 1363253259u,
89011541946015u, 3087190425u,
89021138008081u, 1444019663u,
8903109793386u, 341851980u,
8904857839960u, 2515339233u,
8905156283211u, 1906768669u,
89063886713057u, 1276595523u,
89072809830736u, 460237542u,
89083420452099u, 142985419u,
8909205970448u, 4198897105u,
89101950698961u, 2069753399u,
89111142216925u, 1113051162u,
89121033680610u, 4278599955u,
89131106466069u, 356742959u,
8914531521052u, 3494863964u,
8915225629455u, 3735275001u,
89163662626864u, 1750561299u,
89171012864651u, 2101846429u,
89181074553219u, 668829411u,
8919992181339u, 3384018814u,
89203330664522u, 860966321u,
89211885071395u, 4233785523u,
8922100741310u, 451656820u,
89232148187612u, 1063001151u,
8924360256231u, 107312677u,
89253650357479u, 2390172694u,
892622452685u, 237319043u,
89273600462351u, 1216645846u,
89282088767754u, 164402616u,
89292418980170u, 926137824u,
893094638678u, 1689811113u,
89312751052984u, 1767810825u,
8932271289013u, 3896132233u,
8933103797041u, 1397772514u,
89343441135892u, 3323383489u,
89352491268371u, 1662561885u,
89361612872497u, 2986430557u,
89372756998822u, 207428029u,
8938937973965u, 2791656726u,
89391949717207u, 2260498180u,
89402648427775u, 2360400900u,
89412080496169u, 486358863u,
89421582022990u, 1263709570u,
89431396468647u, 1377764574u,
8944363008508u, 1293502429u,
8945224580012u, 4252610345u,
89461435134775u, 1099809675u,
8947533671980u, 1533438766u,
89481820532305u, 2776960536u,
89493374512975u, 3542220540u,
8950822810075u, 3716663290u,
89511157398049u, 3752806924u,
89524081637863u, 337070226u,
89533866585976u, 359270190u,
89542110942730u, 3267551635u,
8955644850146u, 1306761320u,
8956746972907u, 934259457u,
89572341378668u, 2220373824u,
89581242645122u, 4109252858u,
89591625266099u, 1173698481u,
8960383517064u, 896322512u,
89613377483696u, 1788337208u,
8962455496839u, 3194373887u,
89631837689083u, 1336556841u,
89641658628529u, 2911512007u,
89653838343487u, 2757664765u,
89661537187340u, 3712582785u,
8967367022558u, 3071359622u,
89683926147070u, 35432879u,
89693093195926u, 2561488770u,
89704273132307u, 3898950547u,
89712838251049u, 2103926083u,
89722549435227u, 536047554u,
89731858986613u, 2040551642u,
89741147412575u, 1972369852u,
89754166184983u, 3528794619u,
89764077477194u, 3565689036u,
8977808048238u, 3826350461u,
89781359641525u, 1197100813u,
8979265993036u, 1864569342u,
8980725164342u, 2264788336u,
89811831223342u, 3329594980u,
8982923017956u, 490608221u,
89833818634478u, 258154469u,
89841441714797u, 1174785921u,
89853833372385u, 3287246572u,
89861677395563u, 3569218731u,
8987868981704u, 2163330264u,
89882649450292u, 500120236u,
8989465161780u, 746438382u,
89901145009669u, 2520062970u,
89912810524030u, 1561519055u,
89921479878006u, 3864969305u,
89932686075657u, 4042710240u,
89943224066062u, 2774151984u,
89952226179547u, 1643626042u,
89962328730865u, 3160666939u,
89972107011431u, 96459446u,
89983920328742u, 3336407558u,
8999829404209u, 1878067032u,
90001235983679u, 4237425634u,
9001466519055u, 3870676863u,
9002934312076u, 2952135524u,
9003276949224u, 4100839753u,
9004424001484u, 1955120893u,
90054015478120u, 1265237690u,
9006427484362u, 4246879223u,
90073452969617u, 1724363362u,
90081553513184u, 834830418u,
90091858777639u, 3476334357u,
90104144030366u, 2450047160u,
90112950762705u, 4277111759u,
9012358032121u, 2511026735u,
9013167923105u, 2059208280u,
9014251949572u, 3065234219u,
90151535473864u, 556796152u,
90161513237478u, 3150857516u,
90171103404394u, 198182691u,
90181476438092u, 2913077464u,
9019207119516u, 3963810232u,
90202954651680u, 1535115487u,
90213051522276u, 4046477658u,
9022917804636u, 864395565u,
9023632704095u, 140762681u,
90241802040304u, 990407433u,
90253771506212u, 4106024923u,
90261287729497u, 2198985327u,
90274052924496u, 2926590471u,
90283084557148u, 1472898694u,
90291009870118u, 559702706u,
90304265214507u, 82077489u,
90313067891003u, 3295678907u,
90322402308151u, 1096697687u,
9033464407878u, 4190838199u,
90344269578403u, 3060919438u,
90352899950405u, 3046872820u,
9036733509243u, 1583801700u,
903740453902u, 3879773881u,
90381993425202u, 2185339100u,
90391877837196u, 3912423882u,
90403293122640u, 4104318469u,
90411679617763u, 3703603898u,
90428759461u, 2540185277u,
90431152198475u, 2038345882u,
90442503579743u, 1446869792u,
90452019419351u, 4051584612u,
90463178289407u, 3992503830u,
90472879018745u, 2719373510u,
9048700836153u, 1675560450u,
90494121245793u, 2064715719u,
9050343595772u, 1996164093u,
90513130433948u, 405251683u,
90522804817126u, 1607133689u,
9053463852893u, 2864244470u,
90542224044848u, 4071581802u,
90552537107938u, 2246347953u,
90563207234525u, 2028708916u,
90572272418128u, 803575837u,
905838655481u, 2170452091u,
90593272166407u, 557660441u,
90604019147902u, 3841480082u,
9061298459606u, 2600943364u,
90622440657523u, 255451671u,
90633424361375u, 779434428u,
90643088526123u, 490671625u,
90651322855877u, 3452203069u,
90663057021940u, 2285701422u,
90672014993457u, 2390431709u,
90682002090272u, 1568745354u,
90691783152480u, 823305654u,
90704053862835u, 2200236540u,
90713009412313u, 3184047862u,
90723032187389u, 4159715581u,
90732966902888u, 252986948u,
90741849329144u, 3160134214u,
90753420960112u, 3198900547u,
9076749160960u, 379139040u,
90771208883495u, 1566527339u,
90783006227299u, 4194096960u,
9079556075248u, 497404038u,
90801717327230u, 1496132623u,
90811775955687u, 1719108984u,
90821014328900u, 4189966956u,
90832108574735u, 2584236470u,
9084684087286u, 531310503u,
90854264509527u, 773405691u,
90863088905079u, 3456882941u,
90873105682208u, 3382290593u,
90882289363624u, 3296306400u,
90894168438718u, 467441309u,
9090777173623u, 3241407531u,
90911183994815u, 1132983260u,
90921610606159u, 2540270567u,
90932649684057u, 1397502982u,
9094146657385u, 3318434267u,
90952109315753u, 3348545480u,
90963193669211u, 811750340u,
90971073256162u, 3571673088u,
9098546596661u, 1017047954u,
90993403136990u, 2540585554u,
91001477047647u, 4145867423u,
91012826408201u, 3531646869u,
9102784952939u, 943914610u,
91032717443875u, 3657384638u,
91041806867885u, 1903578924u,
91053985088434u, 1911188923u,
91061764002686u, 3672748083u,
91071832925325u, 241574049u,
9108519948041u, 3181425568u,
91092939747257u, 1634174593u,
91103429894862u, 3529565564u,
91111089679033u, 240953857u,
91122025369941u, 2695166650u,
9113517086873u, 2964595704u,
91143017658263u, 3828377737u,
91152144895011u, 994799311u,
91161184683823u, 4260564140u,
9117308018483u, 4262383425u,
91181374752558u, 3431057723u,
91191572637805u, 383233885u,
91203188015819u, 4051263539u,
9121233319221u, 3794788167u,
91222017406667u, 919677938u,
91234074952232u, 1683612329u,
91244213676186u, 327142514u,
91253032591014u, 4204155962u,
9126206775997u, 2283918569u,
91272395147154u, 3427505379u,
91282211319468u, 4153726847u,
91292217060665u, 350160869u,
91302493667051u, 1648200185u,
91313441709766u, 1387233546u,
9132140980u, 1891558063u,
9133760080239u, 2088061981u,
91341580964938u, 740563169u,
9135422986366u, 330624974u,
91364264507722u, 150928357u,
91372738323042u, 2948665536u,
9138918718096u, 376390582u,
91393966098971u, 717653678u,
91403219466255u, 3799363969u,
91413424344721u, 3187805406u,
9142375347278u, 3490350144u,
91431992212097u, 2263421398u,
91443855037968u, 1928519266u,
91453866327955u, 1129127000u,
91461782515131u, 2746577402u,
91473059200728u, 2108753646u,
91482738070963u, 1336849395u,
91491705302106u, 768287270u,
91501343511943u, 2247006571u,
91511956142255u, 1780259453u,
91523475618043u, 212490675u,
9153622521957u, 917121602u,
91541852992332u, 1267987847u,
91553170016833u, 2549835613u,
91563299763344u, 2864033668u,
91573378768767u, 1236609378u,
91584169365948u, 3738062408u,
91592661022773u, 2006922227u,
91602760592161u, 3828932355u,
91612636387819u, 2616619070u,
91621237256330u, 3449066284u,
91632871755260u, 3729280948u,
91643862686086u, 431292293u,
91653285899651u, 786322314u,
91662531158535u, 724901242u,
91672377363130u, 1415970351u,
91681244759631u, 3263135197u,
9169965248856u, 174024139u,
91702297418515u, 2954777083u,
9171987586766u, 3206261120u,
91724059515114u, 3903854066u,
91731931934525u, 2287507921u,
91741827135136u, 1781944746u,
9175574617451u, 2299034788u,
91762650140034u, 4081586725u,
91772482286699u, 1109175923u,
9178458483596u, 618705848u,
91794059852729u, 1813855658u,
91804190721328u, 1129462471u,
91814089998050u, 3575732749u,
91822375584220u, 1037031473u,
91831623777358u, 3389003793u,
9184546597541u, 352770237u,
91851383747654u, 3122687303u,
91861646071378u, 1164309901u,
9187290870767u, 830691298u,
9188929335420u, 3193251135u,
9189989577914u, 3626554867u,
9190591974737u, 3996958215u,
91913163711272u, 3071568023u,
91921516846461u, 3656006011u,
91932698625268u, 2510865430u,
9194340274176u, 1167681812u,
91953698796465u, 3155218919u,
91964102288238u, 1673474350u,
91973069708839u, 2704165015u,
91981237411891u, 1854985978u,
91993646837503u, 3625406022u,
9200921552000u, 1712976649u,
92013939149151u, 878608872u,
92023406359248u, 1068844551u,
92031834682077u, 4155949943u,
92042437686324u, 3163786257u,
92052645117577u, 1988168803u,
9206747285578u, 1626463554u,
92071235300371u, 1256485167u,
92081914142538u, 4141546431u,
92093838102563u, 582664250u,
92101883344352u, 2083771672u,
92112611657933u, 2139079047u,
92122250573853u, 804336148u,
92133066325351u, 2770847216u,
92144275641370u, 1455750577u,
92153346357270u, 1674051445u,
9216601221482u, 3992583643u,
92171402445097u, 3622527604u,
92182509017299u, 2966108111u,
92192557027816u, 900741486u,
92201790771021u, 2912643797u,
92212631381069u, 4014551783u,
922290375300u, 300318232u,
92233269968032u, 2679371729u,
92242664752123u, 3517585534u,
92253253901179u, 542270815u,
92261188641600u, 365479232u,
92272210121140u, 760762191u,
92281273768482u, 1216399252u,
92293484324231u, 4287337666u,
923016322182u, 643179562u,
9231325675502u, 3652676161u,
92323120716054u, 3330259752u,
92331011990087u, 2990167340u,
92341097584090u, 3262252593u,
92351829409951u, 3665087267u,
92361214854475u, 2134299399u,
92373704419305u, 411263051u,
92381625446136u, 549838529u,
92394283196353u, 1342880802u,
92403460621305u, 1967599860u,
92414282843369u, 1275671016u,
92422544665755u, 853593042u,
9243901109753u, 2682611693u,
9244110631633u, 797487791u,
92451472073141u, 850464484u,
9246797089608u, 3286110054u,
9247350397471u, 2775631060u,
9248366448238u, 3842907484u,
92492219863904u, 3623364733u,
92501850985302u, 4009616991u,
9251294963924u, 3693536939u,
92523061255808u, 1615375832u,
92531920066675u, 4113028420u,
92544032223840u, 2318423400u,
92552701956286u, 4145497671u,
92563991532344u, 2536338351u,
92571679099863u, 1728968857u,
9258449740816u, 2686506989u,
9259685242457u, 97590863u,
92603258354115u, 1502282913u,
92611235084019u, 2151665147u,
9262528459289u, 231097464u,
92632477280726u, 3651607391u,
92642091754612u, 1178454681u,
9265980597335u, 1604483865u,
92661842333726u, 4146839064u,
92673213794286u, 2601416506u,
9268754220096u, 3571436033u,
9269488595746u, 1448097974u,
92704004834921u, 238887261u,
92713320337489u, 1416989070u,
92722928916831u, 4093725287u,
9273186020771u, 2367569534u,
92743046087671u, 4090084518u,
92753548184546u, 679517009u,
92761962659444u, 3539886328u,
92774192003933u, 1678423485u,
92783827951761u, 3086277222u,
92792144472852u, 1390394371u,
92802976322029u, 1574517163u,
92813553313841u, 119173722u,
92821702434637u, 1766260771u,
92833629581771u, 1407497759u,
9284895654784u, 751439914u,
92854008409498u, 215917713u,
92861482103833u, 695551833u,
92871288382231u, 2656990891u,
92882581779077u, 1570750352u,
92893710689053u, 1741390464u,
92902666411616u, 3533987737u,
92914289478316u, 3576119563u,
92924118694920u, 108199666u,
92933869794273u, 963183826u,
92942081410737u, 3796810515u,
9295791123882u, 2525792704u,
92961036883117u, 136547246u,
9297875691100u, 2592925324u,
9298614302599u, 3013176417u,
92992689342539u, 427154472u,
9300532957601u, 1228758574u,
93011898117151u, 1181643858u,
93021908591042u, 1464255968u,
9303446980910u, 2984611177u,
930458509511u, 1046943619u,
93053508927906u, 2001585786u,
93062544767379u, 1525438381u,
9307552181222u, 1959725830u,
9308879448844u, 1348536411u,
93094242243590u, 2861338018u,
93101082052441u, 1034351453u,
9311601175800u, 764077711u,
9312530635011u, 3785343245u,
93132178026726u, 117256687u,
93142378297261u, 457568934u,
931576438221u, 4104954272u,
9316956793873u, 3783168634u,
93172485968477u, 2381948487u,
93184226929450u, 3148473363u,
93192518273601u, 3569490233u,
9320879369091u, 2180270337u,
93213674375989u, 1387729170u,
9322977997984u, 4270646856u,
9323568650985u, 951677556u,
93244213877384u, 2721005055u,
93251073364549u, 2563403831u,
93261678669911u, 66786703u,
93272273631661u, 1149351924u,
93283651298990u, 1581883443u,
9329246723096u, 1895026827u,
93303810605772u, 3711056516u,
93314058833288u, 2193790614u,
93322080120290u, 3638638708u,
93332915672708u, 2263003308u,
93342361934197u, 4136767460u,
93351976115991u, 3448840877u,
93362019238520u, 225333538u,
9337874340815u, 2976159827u,
93381555273378u, 3797521928u,
93391942347150u, 3262952567u,
9340435997738u, 340403353u,
93412817830907u, 2078619498u,
9342749534111u, 1178073973u,
9343894654712u, 3361226032u,
9344841092198u, 3288261538u,
93451696412169u, 1496966875u,
9346697501571u, 1059158875u,
93473739946319u, 2481012988u,
9348568983526u, 114945840u,
93491559249010u, 2218244008u,
93502841706923u, 1632780103u,
93514020169654u, 2087949619u,
93522438736103u, 24032648u,
9353833416317u, 3787017905u,
93542373238993u, 2575395164u,
93553434544481u, 3228481067u,
93562542976862u, 2971726178u,
93572880371864u, 3642087909u,
93582407477975u, 2239080836u,
93591043714217u, 3894199764u,
93602235879182u, 203853421u,
93612933669448u, 2504940536u,
9362834683330u, 425935223u,
93633560796393u, 3565833278u,
93641668000829u, 3683399154u,
93653414330886u, 1748785729u,
93661023171602u, 580966986u,
93672531038985u, 3227325488u,
93682657385925u, 2124704694u,
9369233442446u, 1107045577u,
93703407293834u, 552770757u,
93713899097693u, 1067532701u,
9372115667924u, 1406028344u,
93731707768231u, 3724015962u,
93742419657149u, 18613994u,
93752532882091u, 3476683808u,
93761560838678u, 811220224u,
9377895961699u, 3762914298u,
93781328752423u, 1844996900u,
93791420427894u, 1848067707u,
93801210281744u, 904215228u,
93814055325594u, 1118521573u,
93822496554183u, 2579259919u,
93833996647489u, 3657647605u,
9384325254059u, 3136157065u,
93853951522674u, 4052925250u,
93863341068436u, 2287683323u,
93871313073005u, 126005630u,
93882505120084u, 1194725057u,
9389853746559u, 3555092974u,
93902689238752u, 49515858u,
93911244776042u, 1069300695u,
939261073168u, 1010661841u,
93931269521335u, 1902040126u,
9394990632502u, 2378708922u,
93953858321250u, 1400735275u,
93962974699176u, 2771676666u,
9397170995186u, 2877798589u,
9398545726212u, 2225229957u,
93991086473152u, 3454177594u,
94003859483262u, 1499729584u,
94012088002891u, 2883475137u,
94023222194252u, 4144472319u,
94032212229854u, 4146740722u,
9404567988835u, 1051332394u,
94053932046135u, 542648229u,
94063017852446u, 1277887997u,
9407162888005u, 1669710469u,
94081492500905u, 553041029u,
94091434876932u, 533989516u,
94103817492747u, 584127807u,
94114147115982u, 2993670925u,
94124020312558u, 710021255u,
94133509733475u, 3587959456u,
94142088550465u, 1745399498u,
94152952242967u, 1259815443u,
9416869648362u, 1404723176u,
94173947542735u, 1334333531u,
94183873471582u, 229399758u,
941959634866u, 3239516985u,
94203844250972u, 1275954779u,
9421492891666u, 1029533080u,
94221552951157u, 367320647u,
9423699480890u, 3684418197u,
94243707014310u, 471105777u,
94251824587258u, 4030809053u,
94263489914436u, 484559105u,
94271235750398u, 1428453396u,
94284230459084u, 4255931645u,
94291848597055u, 4271715616u,
9430331780381u, 482425775u,
94312435323270u, 3171911678u,
94323507210587u, 928543347u,
94334197807526u, 3680046204u,
94342766042024u, 2159512867u,
9435179373257u, 313902234u,
94364024837592u, 294795361u,
94371622282562u, 647086234u,
94382825039429u, 577214736u,
94394043412446u, 2426981244u,
94401277736097u, 1130129573u,
94412601395338u, 995791646u,
944236668922u, 3344746679u,
94431521532225u, 1645086060u,
94442622763015u, 4122335794u,
94452936887705u, 494465807u,
94462580840343u, 1064648931u,
94471247887787u, 2752145076u,
94481277612417u, 1249660507u,
94492288678613u, 3312498873u,
94502459273912u, 4238535494u,
94513117488020u, 2571979978u,
94522680188909u, 1471227427u,
94531616494033u, 633688562u,
94542268653416u, 3268237290u,
94553021962815u, 1959779970u,
94563321382074u, 766642813u,
9457204429780u, 1323319858u,
94583676032891u, 1380896111u,
94594030639049u, 3647601207u,
94601830028502u, 2830263774u,
94611375962216u, 1733961041u,
9462939765180u, 521947915u,
94633903267364u, 497472767u,
94641619700946u, 189164145u,
94653115593885u, 486382294u,
94661262445920u, 4062496162u,
94672464795849u, 3770038872u,
94684032121374u, 3235740744u,
94693757765258u, 1777199847u,
94702167243108u, 1912506671u,
94714180515317u, 2276864677u,
9472536034089u, 2384915026u,
9473162938278u, 1588060152u,
94744018349945u, 2504457929u,
9475841450426u, 2790120722u,
94762719983588u, 1471020554u,
94771390856732u, 3623212998u,
94782506944218u, 1035080801u,
9479348812127u, 3026631806u,
9480746483541u, 2342164722u,
9481122104390u, 4074122771u,
94823986865419u, 1674890530u,
94833693306023u, 3011542850u,
94841294951725u, 899303190u,
94853577146915u, 3549160092u,
94861241677652u, 4290680005u,
94873193053279u, 2029187390u,
94883298063095u, 3943068002u,
94893946220635u, 2273781461u,
9490889053698u, 1376304022u,
94911486839612u, 2127663659u,
9492344127443u, 1646681121u,
94932780117810u, 2142045764u,
94942694572773u, 447810651u,
94952185527146u, 2366308558u,
9496290335413u, 584901173u,
94972012370276u, 970504950u,
94983258236042u, 2008155560u,
94993945579565u, 614796295u,
950024452072u, 2695940969u,
95013983727134u, 3444688454u,
95021327044473u, 3545633451u,
95031875293322u, 1739318893u,
95041707527799u, 2683090634u,
95052848082386u, 2814622471u,
95064111401777u, 2774816580u,
95073849839194u, 437560100u,
95082238350150u, 2462124836u,
9509665017710u, 512012738u,
95102945294779u, 3305170944u,
9511819477765u, 59419271u,
9512155125658u, 665292744u,
9513444722813u, 3580039116u,
95142355675635u, 663735032u,
95153247800169u, 1579404983u,
95161985115003u, 3397891494u,
9517358696453u, 1474896279u,
9518516388613u, 710590371u,
95193490497111u, 2514565805u,
95202386143445u, 477509654u,
9521412854590u, 3624609754u,
95223214388668u, 3516075816u,
95232731288520u, 1369482895u,
95244033204378u, 1314000850u,
9525829769325u, 1935166880u,
95261608191643u, 2607067237u,
9527423820371u, 3257747610u,
95281355298041u, 3776931214u,
95294105054901u, 2107080812u,
95301911521879u, 3183054185u,
95313910177801u, 675129307u,
95321209358971u, 4205727791u,
95331435726287u, 3333261712u,
95341400982708u, 1154611403u,
95351663501483u, 2837596667u,
95363164734053u, 2759854023u,
95374012043629u, 1963228038u,
95383981675284u, 2677557877u,
9539520119591u, 505138315u,
9540897271356u, 1803966773u,
95411016663294u, 616691903u,
95422254742522u, 4032705384u,
95432468470796u, 798395739u,
95443025169002u, 3570037122u,
95451461093710u, 3473799845u,
95463702624858u, 476400898u,
95471043039728u, 2304070437u,
9548181576948u, 602972493u,
95493996616030u, 3289878097u,
95502068516226u, 3922247304u,
95511299968266u, 2520311409u,
95521968824721u, 3214794876u,
95531581813122u, 2668800905u,
95543297613974u, 748160407u,
95551145536484u, 1326769504u,
95562973323521u, 3775262814u,
95573218653169u, 902775872u,
95583498603433u, 1372805534u,
9559704686363u, 3626542352u,
95602271580579u, 1213925114u,
956146329775u, 3009384989u,
95621330254048u, 1194824134u,
9563514204310u, 3781981134u,
9564442526164u, 2835608783u,
95653460471867u, 510634034u,
9566546406434u, 2716786748u,
95672840500021u, 1669490957u,
95682536189149u, 3251421224u,
95691358736072u, 1089334066u,
95703260749330u, 250756920u,
95712974806681u, 1513718866u,
957282635635u, 4041016629u,
95733391765744u, 2495807367u,
95743962674316u, 2822889695u,
9575753413337u, 2008251381u,
95763123390177u, 106212622u,
9577490570565u, 1684884205u,
9578793892547u, 1927268995u,
95792344148164u, 2251978818u,
9580437424236u, 2774023200u,
95812674940754u, 3788056262u,
95822597882666u, 3678660147u,
95833797434193u, 3838215866u,
9584279687080u, 2656772270u,
95852190204787u, 1997584981u,
95863384401882u, 3160208845u,
95873629379425u, 2668998785u,
95881050036757u, 2954162084u,
9589917091826u, 1744374041u,
95901454282570u, 845687881u,
95912997173625u, 776018378u,
95921137560602u, 1938378389u,
95931748082354u, 2066910012u,
95942677675207u, 918315064u,
9595};
9596
9597// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
9598bool Test(int offset, int len = 0) {
9599#undef Check
9600#undef IsAlive
9601
9602#define Check(x) do { \
9603 const uint32_t actual = (x), e = expected[index++]; \
9604 bool ok = actual == e; \
9605 if (!ok) { \
9606 cerr << "expected " << hex << e << " but got " << actual << endl; \
9607 ++errors; \
9608 } \
9609 assert(ok); \
9610} while (0)
9611
9612#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
9613
9614 // After the following line is where the uses of "Check" and such will go.
9615 static int index = 0;
9616if (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; }
9617{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
9618{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
9619{ uint64_t h = farmhashte::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
9620
9621 return true;
9622#undef Check
9623#undef IsAlive
9624}
9625
9626int RunTest() {
9627 Setup();
9628 int i = 0;
9629 cout << "Running farmhashteTest";
9630 if (!Test(-1)) {
9631 cout << "... Unavailable\n";
9632 return NoteErrors();
9633 }
9634 // Good. The function is attempting to hash, so run the full test.
9635 int errors_prior_to_test = errors;
9636 for ( ; i < kTestSize - 1; i++) {
9637 Test(i * i, i);
9638 }
9639 for ( ; i < kDataSize; i += i / 7) {
9640 Test(0, i);
9641 }
9642 Test(0, kDataSize);
9643 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
9644 return NoteErrors();
9645}
9646
9647#else
9648
9649// After the following line is where the code to print hash codes will go.
9650void Dump(int offset, int len) {
9651{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9652{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9653{ uint64_t h = farmhashte::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9654}
9655
9656#endif
9657
9658#undef SEED
9659#undef SEED1
9660#undef SEED0
9661
9662} // namespace farmhashteTest
9663
9664#if !TESTING
9665int main(int argc, char** argv) {
9666 Setup();
9667 cout << "uint32_t expected[] = {\n";
9668 int i = 0;
9669 for ( ; i < kTestSize - 1; i++) {
9670 farmhashteTest::Dump(i * i, i);
9671 }
9672 for ( ; i < kDataSize; i += i / 7) {
9673 farmhashteTest::Dump(0, i);
9674 }
9675 farmhashteTest::Dump(0, kDataSize);
9676 cout << "};\n";
9677}
9678#endif
9679#ifndef FARMHASH_SELF_TEST_GUARD
9680#define FARMHASH_SELF_TEST_GUARD
9681#include <cstdio>
9682#include <iostream>
9683#include <string.h>
9684
9685using std::cout;
9686using std::cerr;
9687using std::endl;
9688using std::hex;
9689
9690static const uint64_t kSeed0 = 1234567;
9691static const uint64_t kSeed1 = k0;
9692static const int kDataSize = 1 << 20;
9693static const int kTestSize = 300;
9694#define kSeed128 Uint128(kSeed0, kSeed1)
9695
9696static char data[kDataSize];
9697
9698static int completed_self_tests = 0;
9699static int errors = 0;
9700
9701// Initialize data to pseudorandom values.
9702void Setup() {
9703 if (completed_self_tests == 0) {
9704 uint64_t a = 9;
9705 uint64_t b = 777;
9706 for (int i = 0; i < kDataSize; i++) {
9707 a += b;
9708 b += a;
9709 a = (a ^ (a >> 41)) * k0;
9710 b = (b ^ (b >> 41)) * k0 + i;
9711 uint8_t u = b >> 37;
9712 memcpy(data + i, &u, 1); // uint8_t -> char
9713 }
9714 }
9715}
9716
9717int NoteErrors() {
9718#define NUM_SELF_TESTS 9
9719 if (++completed_self_tests == NUM_SELF_TESTS)
9720 std::exit(errors > 0);
9721 return errors;
9722}
9723
9724template <typename T> inline bool IsNonZero(T x) {
9725 return x != 0;
9726}
9727
9728template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
9729 return x != Uint128(0, 0);
9730}
9731
9732#endif // FARMHASH_SELF_TEST_GUARD
9733
9734namespace farmhashuoTest {
9735
9736uint32_t CreateSeed(int offset, int salt) {
9737 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
9738 h = h * c1;
9739 h ^= (h >> 17);
9740 h = h * c1;
9741 h ^= (h >> 17);
9742 h = h * c1;
9743 h ^= (h >> 17);
9744 h += static_cast<uint32_t>(offset & 0xffffffff);
9745 h = h * c1;
9746 h ^= (h >> 17);
9747 h = h * c1;
9748 h ^= (h >> 17);
9749 h = h * c1;
9750 h ^= (h >> 17);
9751 return h;
9752}
9753
9754#undef SEED
9755#undef SEED1
9756#undef SEED0
9757#define SEED CreateSeed(offset, -1)
9758#define SEED0 CreateSeed(offset, 0)
9759#define SEED1 CreateSeed(offset, 1)
9760
9761#undef TESTING
9762#define TESTING 1
9763#if TESTING
9764uint32_t expected[] = {
97653277735313u, 2681724312u,
97662598464059u, 797982799u,
97672603993599u, 921001710u,
97681410420968u, 2134990486u,
97692914424215u, 2244477846u,
9770255297188u, 2992121793u,
9771161451183u, 3943596029u,
97724019337850u, 452431531u,
97733379021470u, 2557197665u,
9774299850021u, 2532580744u,
97751298374911u, 3099673830u,
97762199864459u, 3696623795u,
97774055299123u, 3281581178u,
97781053458494u, 1882212500u,
97793456121707u, 275903667u,
9780458884671u, 3033004529u,
97811898235244u, 1402319660u,
97822700149065u, 2699376854u,
97832433714046u, 4222949502u,
97844220361840u, 1712034059u,
97854148372108u, 1330324210u,
9786594028478u, 2921867846u,
9787780716741u, 1728752234u,
97883280331829u, 326029180u,
9789393215742u, 3349570000u,
97903824583307u, 1612122221u,
97911379537552u, 1646032583u,
97922233466664u, 1432476832u,
97932052294713u, 3552092450u,
97941628777059u, 1499109081u,
97952960536756u, 1554038301u,
97961145519619u, 3190844552u,
9797237495366u, 540224401u,
979865721842u, 489963606u,
97991596489240u, 1562872448u,
98001790705123u, 2128624475u,
98011435705557u, 1262831810u,
9802155445229u, 1672724608u,
9803663607706u, 2077310004u,
98043610042449u, 1911523866u,
98052563776023u, 294527927u,
98061099072299u, 1389770549u,
98072952353448u, 2026137563u,
98083603803785u, 629449419u,
9809226132789u, 2489287368u,
98101552847036u, 645684964u,
9811187883449u, 230403464u,
98123151491850u, 3272648435u,
98132002861219u, 165370827u,
9814916494250u, 1230085527u,
98153807265751u, 3628174014u,
9816231181488u, 851743255u,
98172988893883u, 1554380634u,
98181142264800u, 3667013118u,
98192638023604u, 2290487377u,
9820732137533u, 1909203251u,
98211380301172u, 1498556724u,
98224072067757u, 4165088768u,
98233931792696u, 197618179u,
9824956300927u, 914413116u,
98252148126371u, 1913303225u,
98263074915312u, 3117299654u,
98273178848746u, 1357272220u,
98281438494951u, 507436733u,
98293854939912u, 1413396341u,
9830126024219u, 146044391u,
98313254014218u, 429095991u,
9832165589978u, 1578546616u,
9833623071693u, 366414107u,
9834249776086u, 1207522198u,
98353120876698u, 1684583131u,
983646987739u, 1157614300u,
9837199124911u, 520792961u,
98383614377032u, 586863115u,
98391716848157u, 4033596884u,
98401164298657u, 4140791139u,
98413824360466u, 3242407770u,
98423725511003u, 232064808u,
98432736953692u, 816692935u,
9844512845449u, 3748861010u,
98454290630595u, 517646945u,
984622638523u, 648000590u,
98471283799121u, 3047062993u,
98481024246061u, 4027776454u,
9849834785312u, 382936554u,
9850411505255u, 1973395102u,
9851580988377u, 2826990641u,
98523474970689u, 1029055034u,
98532584372201u, 1758123094u,
9854589567754u, 325737734u,
98553886113119u, 3338548567u,
9856257578986u, 3698087965u,
98573604937815u, 3198590202u,
98582305332220u, 191910725u,
98594244322689u, 542201663u,
98603315355162u, 2135941665u,
98611175961330u, 3948351189u,
986223075771u, 3252374102u,
9863713127376u, 1467786451u,
9864663013031u, 3444053918u,
98653077742128u, 1062268187u,
98662115441882u, 4081398201u,
98672335576331u, 2560479831u,
98681379288194u, 4225182569u,
98693958366652u, 3067277639u,
98703667516477u, 1709989541u,
98714188504038u, 59581167u,
98722725013602u, 3639843023u,
98733758739543u, 4189944477u,
98742470483982u, 877580602u,
98753252925478u, 2062343506u,
98763981838403u, 3762572073u,
98772931588131u, 3284356565u,
98781129162571u, 732225574u,
98791677744031u, 3532596884u,
98803232041815u, 1652884780u,
98813740979556u, 259034107u,
98822227121257u, 1426140634u,
9883315836068u, 3200749877u,
98841386256573u, 24035717u,
9885234531934u, 1115203611u,
98861598686658u, 3146815575u,
98872632963283u, 1778459926u,
9888739944537u, 579625482u,
98891231665285u, 2457048126u,
98903903349120u, 389846205u,
98911052645068u, 862072556u,
98922834153464u, 1481069623u,
98931688445808u, 701920051u,
98943740748788u, 3388062747u,
98951192588249u, 1410111809u,
98962633463887u, 4050419847u,
98972513844237u, 2187968410u,
98982951683019u, 3015806005u,
98993000537321u, 479241367u,
9900252167538u, 1231057113u,
9901393624922u, 704325635u,
99021467197045u, 2066433573u,
99033082385053u, 735688735u,
9904956434529u, 4028590195u,
99054074716319u, 813690332u,
99062124740535u, 804073145u,
99073748881891u, 3195309868u,
9908841856605u, 2585865274u,
9909881504822u, 3254795114u,
99101241815736u, 970796142u,
9911497175391u, 3929484338u,
99124264993211u, 1835322201u,
99133675707838u, 4205965408u,
9914300298607u, 3858319990u,
99153255259608u, 4247675634u,
99161095823272u, 1197245408u,
99171742785722u, 785893184u,
99181702965674u, 850401405u,
99194084891412u, 1160134629u,
99202555998391u, 1972759056u,
9921710625654u, 4116162021u,
99223352753742u, 85121177u,
99233513255468u, 2487440590u,
99242480032715u, 2287747045u,
99254090178629u, 4044418876u,
99261703944517u, 486290428u,
99271515601363u, 2011102035u,
9928573985957u, 3536053779u,
99294257172787u, 576405853u,
99301523550693u, 1014952061u,
9931711098718u, 2425317635u,
99323460807169u, 3688987163u,
99333167371443u, 3062418115u,
99343330028292u, 1713171303u,
9935526177822u, 2602636307u,
99361245357025u, 3346699703u,
9937254529415u, 4017058800u,
99381829738451u, 2164236533u,
99391381258384u, 4036354071u,
99401749181924u, 4118435443u,
99414130543625u, 688472265u,
99422731071299u, 2547657502u,
99434175776103u, 338058159u,
99443729582129u, 4181845558u,
99452227290760u, 146827036u,
99462459178427u, 1025353883u,
99474284109679u, 2502815838u,
9948825124804u, 2533140036u,
9949616327404u, 2448966429u,
9950413992636u, 2334782461u,
99512239052397u, 1082330589u,
99523381164715u, 199381437u,
99532583939798u, 2848283092u,
99542300168091u, 2156336315u,
99551855234968u, 1982110346u,
99562482046810u, 3158163887u,
99572168864636u, 133643215u,
99583904021624u, 3646514568u,
99591176127003u, 4015671361u,
9960100525019u, 3534706803u,
99612045051700u, 3452457457u,
99621492267772u, 2308393828u,
99633776661467u, 3281002516u,
99644246334524u, 743955039u,
9965685631442u, 1147951686u,
99662040912376u, 2911148054u,
99673204999386u, 2415262714u,
9968313209105u, 777065474u,
99692729416454u, 1029284767u,
99701632078298u, 1817552554u,
99713963877000u, 1919171906u,
99723843219958u, 3073580867u,
9973865146997u, 2473524405u,
99742593817617u, 3643076308u,
9975617975720u, 3671562289u,
9976121812599u, 2902367378u,
99772260041112u, 1019936943u,
9978320945955u, 2337845588u,
99791535670711u, 773792826u,
99803152195900u, 4090794518u,
99814142587430u, 484732447u,
9982419191319u, 3377973345u,
9983324924679u, 2809286837u,
99841562277603u, 1378362199u,
99853791551981u, 1097806406u,
99861386297408u, 2304900033u,
99873574135531u, 4017075736u,
99881161238398u, 1358056883u,
99893487080616u, 1516736273u,
9990851615042u, 2927899494u,
99914077452507u, 2984955003u,
99923907754394u, 3578173844u,
99931948409509u, 1923531348u,
99943578472493u, 3710074193u,
9995213811117u, 2586632018u,
99961922589216u, 274958014u,
99971654276320u, 2687561076u,
99982569061755u, 3122046057u,
99993203802620u, 1692079268u,
10000477806878u, 140587742u,
10001520565830u, 3674576684u,
1000291246882u, 1010215946u,
100033703994407u, 69201295u,
10004776213083u, 3677771507u,
100053696902571u, 3593730713u,
100062907901228u, 3239753796u,
100071586241476u, 1939595371u,
100082268396558u, 3468719670u,
100092955715987u, 2295501078u,
100102775848696u, 1358532390u,
100113843660102u, 82177963u,
100124094477877u, 191727221u,
10013278661677u, 2889101923u,
100141352525614u, 2844977667u,
100151261140657u, 1747052377u,
100162334120653u, 645125282u,
100172707230761u, 4142246789u,
100181068639717u, 2288162940u,
100191419293714u, 1636932722u,
100203252686293u, 318543902u,
100212598802768u, 2025886508u,
100222250788464u, 2711763065u,
10023255108733u, 1845587644u,
100243719270134u, 3940707863u,
10025917608574u, 1363253259u,
10026788659330u, 673256220u,
10027109793386u, 341851980u,
100282698465479u, 3011229884u,
100293886713057u, 1276595523u,
100302439962760u, 2700515456u,
10031205970448u, 4198897105u,
10032875511891u, 371715572u,
100331033680610u, 4278599955u,
100343120038721u, 1256300069u,
10035225629455u, 3735275001u,
100363961944123u, 1769389163u,
100371074553219u, 668829411u,
100381098679359u, 2573697509u,
100391885071395u, 4233785523u,
100402513878053u, 2030193788u,
10041360256231u, 107312677u,
10042310517502u, 2618936366u,
100433600462351u, 1216645846u,
100442970730323u, 4278812598u,
1004594638678u, 1689811113u,
100464125738800u, 3103759730u,
10047103797041u, 1397772514u,
100481669653333u, 572567964u,
100491612872497u, 2986430557u,
10050214990655u, 3117607990u,
100511949717207u, 2260498180u,
100521493936866u, 3554860960u,
100531582022990u, 1263709570u,
100541244120487u, 3416600761u,
10055224580012u, 4252610345u,
10056286306391u, 814956796u,
100571820532305u, 2776960536u,
100583082703465u, 1659265982u,
100591157398049u, 3752806924u,
100603508246460u, 2902716664u,
100612110942730u, 3267551635u,
10062902835431u, 405228165u,
100632341378668u, 2220373824u,
100643303626294u, 1175118221u,
10065383517064u, 896322512u,
100661697257567u, 2202820683u,
100671837689083u, 1336556841u,
10068914535232u, 3634083711u,
100691537187340u, 3712582785u,
100701088201893u, 3270984620u,
100713093195926u, 2561488770u,
100721962968100u, 236189500u,
100732549435227u, 536047554u,
10074422609195u, 2958815818u,
100754166184983u, 3528794619u,
100761042329086u, 3914176886u,
100771359641525u, 1197100813u,
100781269739674u, 3301844628u,
100791831223342u, 3329594980u,
100802433669782u, 494908536u,
100811441714797u, 1174785921u,
100821933050423u, 958901065u,
10083868981704u, 2163330264u,
100843243110680u, 1443133429u,
100851145009669u, 2520062970u,
100863851564853u, 2664619323u,
100872686075657u, 4042710240u,
100882125408249u, 4165697916u,
100892328730865u, 3160666939u,
10090588683409u, 2126275847u,
10091829404209u, 1878067032u,
100922567792910u, 897670516u,
10093934312076u, 2952135524u,
10094504832490u, 3312698056u,
100954015478120u, 1265237690u,
100963376133707u, 967674402u,
100971553513184u, 834830418u,
100982396504772u, 3278582098u,
100992950762705u, 4277111759u,
101004159211303u, 1290097509u,
10101251949572u, 3065234219u,
101021832020534u, 312136369u,
101031103404394u, 198182691u,
101041369599600u, 3906710870u,
101052954651680u, 1535115487u,
101062389327507u, 1813520230u,
10107632704095u, 140762681u,
101083123202913u, 3336005523u,
101091287729497u, 2198985327u,
101102470730783u, 3821758006u,
101111009870118u, 559702706u,
101124274686257u, 3187546567u,
101132402308151u, 1096697687u,
10114678932329u, 3716363135u,
101152899950405u, 3046872820u,
101163754655641u, 2021741414u,
101171993425202u, 2185339100u,
101182838253700u, 3099212100u,
101191679617763u, 3703603898u,
101201135665833u, 3559875668u,
101212503579743u, 1446869792u,
10122879818611u, 3788305533u,
101232879018745u, 2719373510u,
101243606051203u, 2166567748u,
10125343595772u, 1996164093u,
101261577656121u, 475248376u,
10127463852893u, 2864244470u,
101281332049663u, 3326459767u,
101293207234525u, 2028708916u,
10130938916154u, 3115246264u,
101313272166407u, 557660441u,
101321265684026u, 245033807u,
101332440657523u, 255451671u,
101343811885130u, 1399880284u,
101351322855877u, 3452203069u,
101361324994449u, 3796404024u,
101372002090272u, 1568745354u,
101383700047753u, 31799506u,
101393009412313u, 3184047862u,
10140728680761u, 3848624873u,
101411849329144u, 3160134214u,
101421272923193u, 1474278816u,
101431208883495u, 1566527339u,
101444136466541u, 630825649u,
101451717327230u, 1496132623u,
101462449386742u, 128106940u,
101472108574735u, 2584236470u,
101482872246579u, 397338552u,
101493088905079u, 3456882941u,
101501715915153u, 2940716269u,
101514168438718u, 467441309u,
10152872996731u, 3206901319u,
101531610606159u, 2540270567u,
101541301658081u, 2379410194u,
101552109315753u, 3348545480u,
101562041927873u, 2644077493u,
10157546596661u, 1017047954u,
101582596792972u, 2783958892u,
101592826408201u, 3531646869u,
101602219352672u, 4217451852u,
101611806867885u, 1903578924u,
101622076465705u, 2373061493u,
101631832925325u, 241574049u,
101641509517110u, 3703614272u,
101653429894862u, 3529565564u,
101664010000614u, 2256197939u,
10167517086873u, 2964595704u,
101683501035294u, 4079457298u,
101691184683823u, 4260564140u,
101702339268412u, 3871564102u,
101711572637805u, 383233885u,
101723351411126u, 3419328182u,
101732017406667u, 919677938u,
1017429804156u, 46276077u,
101753032591014u, 4204155962u,
101761172319502u, 969309871u,
101772211319468u, 4153726847u,
101783094193193u, 4240669441u,
101793441709766u, 1387233546u,
101804048882438u, 1217896566u,
101811580964938u, 740563169u,
101823691850348u, 3176426539u,
101832738323042u, 2948665536u,
101841474029445u, 3513354882u,
101853219466255u, 3799363969u,
101863961796122u, 1055550923u,
101871992212097u, 2263421398u,
101884289759174u, 2516844140u,
101891782515131u, 2746577402u,
10190721928440u, 3529570984u,
101911705302106u, 768287270u,
101923474902815u, 4000011125u,
101933475618043u, 212490675u,
10194549130471u, 2970128275u,
101953170016833u, 2549835613u,
101963691104824u, 2694324482u,
101974169365948u, 3738062408u,
10198602930397u, 2148954730u,
101992636387819u, 2616619070u,
10200301617872u, 374657036u,
102013862686086u, 431292293u,
102024225245165u, 1358580562u,
102032377363130u, 1415970351u,
102043885060756u, 1438379807u,
102052297418515u, 2954777083u,
102063970368221u, 1229801760u,
102071931934525u, 2287507921u,
102081713471510u, 2145608111u,
102092650140034u, 4081586725u,
102104196863572u, 1896558394u,
102114059852729u, 1813855658u,
102122618400836u, 1396056469u,
102132375584220u, 1037031473u,
10214249284003u, 2450077637u,
102151383747654u, 3122687303u,
102162664431743u, 3855028730u,
10217929335420u, 3193251135u,
10218137313762u, 1850894384u,
102193163711272u, 3071568023u,
10220418541677u, 3621223039u,
10221340274176u, 1167681812u,
102224106647531u, 4022465625u,
102233069708839u, 2704165015u,
102242332023349u, 641449034u,
10225921552000u, 1712976649u,
102261876484273u, 2343049860u,
102271834682077u, 4155949943u,
102282061821157u, 4240649383u,
10229747285578u, 1626463554u,
10230165503115u, 359629739u,
102313838102563u, 582664250u,
102323878924635u, 4117237498u,
102332250573853u, 804336148u,
10234331393443u, 4242530387u,
102353346357270u, 1674051445u,
102363348019777u, 1722242971u,
102372509017299u, 2966108111u,
102384189102509u, 3323592310u,
102392631381069u, 4014551783u,
102404250787412u, 3448394212u,
102412664752123u, 3517585534u,
102423605365141u, 1669471183u,
102432210121140u, 760762191u,
10244249697459u, 3416920106u,
1024516322182u, 643179562u,
102461564226597u, 2134630675u,
102471011990087u, 2990167340u,
102482349550842u, 1642428946u,
102491214854475u, 2134299399u,
102502704221532u, 2104175211u,
102514283196353u, 1342880802u,
10252198529755u, 2004468390u,
102532544665755u, 853593042u,
102542090611294u, 2970943872u,
102551472073141u, 850464484u,
102561407609278u, 3062461105u,
10257366448238u, 3842907484u,
10258488797416u, 1432670231u,
10259294963924u, 3693536939u,
102603390549825u, 1583234720u,
102614032223840u, 2318423400u,
102622965642867u, 930822729u,
102631679099863u, 1728968857u,
10264900822335u, 702309817u,
102653258354115u, 1502282913u,
102662811888503u, 3924947660u,
102672477280726u, 3651607391u,
102683788310204u, 1300369123u,
102691842333726u, 4146839064u,
102702468893861u, 4091095953u,
10271488595746u, 1448097974u,
102721159634090u, 1738834113u,
102732928916831u, 4093725287u,
10274530850094u, 291657799u,
102753548184546u, 679517009u,
10276399175380u, 2658337143u,
102773827951761u, 3086277222u,
102782067718397u, 3632376023u,
102793553313841u, 119173722u,
102801702434637u, 1766260771u,
10281895654784u, 751439914u,
102824008409498u, 215917713u,
102831288382231u, 2656990891u,
102842581779077u, 1570750352u,
102852666411616u, 3533987737u,
102864289478316u, 3576119563u,
102873869794273u, 963183826u,
102882081410737u, 3796810515u,
102891036883117u, 136547246u,
10290875691100u, 2592925324u,
102912689342539u, 427154472u,
10292532957601u, 1228758574u,
102931908591042u, 1464255968u,
10294446980910u, 2984611177u,
102953508927906u, 2001585786u,
102962544767379u, 1525438381u,
10297879448844u, 1348536411u,
102984242243590u, 2861338018u,
10299601175800u, 764077711u,
10300530635011u, 3785343245u,
103012378297261u, 457568934u,
1030276438221u, 4104954272u,
103032485968477u, 2381948487u,
103044226929450u, 3148473363u,
10305879369091u, 2180270337u,
103063674375989u, 1387729170u,
10307568650985u, 951677556u,
103084213877384u, 2721005055u,
103091678669911u, 66786703u,
103102273631661u, 1149351924u,
10311246723096u, 1895026827u,
103123810605772u, 3711056516u,
103132080120290u, 3638638708u,
103142915672708u, 2263003308u,
103151976115991u, 3448840877u,
103162019238520u, 225333538u,
103171555273378u, 3797521928u,
103181942347150u, 3262952567u,
103192817830907u, 2078619498u,
10320749534111u, 1178073973u,
10321841092198u, 3288261538u,
103221696412169u, 1496966875u,
103233739946319u, 2481012988u,
10324568983526u, 114945840u,
103252841706923u, 1632780103u,
103264020169654u, 2087949619u,
10327833416317u, 3787017905u,
103282373238993u, 2575395164u,
103292542976862u, 2971726178u,
103302880371864u, 3642087909u,
103311043714217u, 3894199764u,
103322235879182u, 203853421u,
10333834683330u, 425935223u,
103343560796393u, 3565833278u,
103353414330886u, 1748785729u,
103361023171602u, 580966986u,
103372657385925u, 2124704694u,
10338233442446u, 1107045577u,
103393899097693u, 1067532701u,
10340115667924u, 1406028344u,
103412419657149u, 18613994u,
103422532882091u, 3476683808u,
10343895961699u, 3762914298u,
103441328752423u, 1844996900u,
103451210281744u, 904215228u,
103464055325594u, 1118521573u,
103473996647489u, 3657647605u,
10348325254059u, 3136157065u,
103493341068436u, 2287683323u,
103501313073005u, 126005630u,
10351853746559u, 3555092974u,
103522689238752u, 49515858u,
1035361073168u, 1010661841u,
103541269521335u, 1902040126u,
103553858321250u, 1400735275u,
103562974699176u, 2771676666u,
10357545726212u, 2225229957u,
103581086473152u, 3454177594u,
103592088002891u, 2883475137u,
103603222194252u, 4144472319u,
10361567988835u, 1051332394u,
103623932046135u, 542648229u,
10363162888005u, 1669710469u,
103641492500905u, 553041029u,
103653817492747u, 584127807u,
103664147115982u, 2993670925u,
103673509733475u, 3587959456u,
103682088550465u, 1745399498u,
10369869648362u, 1404723176u,
103703947542735u, 1334333531u,
1037159634866u, 3239516985u,
103723844250972u, 1275954779u,
103732512155003u, 1685649437u,
10374639306006u, 2524620206u,
10375576786501u, 655707039u,
103762864351838u, 3736264674u,
103771200907897u, 2384379464u,
1037815823708u, 206117476u,
103791193310960u, 1093099415u,
103803696538026u, 4112584792u,
103812069527017u, 547588820u,
103824178147211u, 2827259351u,
10383940846775u, 1054995047u,
103842976960697u, 1934305529u,
103852199137382u, 1005722394u,
103861875867180u, 2064356511u,
103874019734130u, 3096333006u,
103882069509024u, 2906358341u,
103892232866485u, 1456016086u,
103901422674894u, 867282151u,
103911612503136u, 1739843072u,
10392134947567u, 2978775774u,
103931284167756u, 1090844589u,
10394831688783u, 2079216362u,
103951626991196u, 3644714163u,
103963678110059u, 898470030u,
103973916646913u, 3182422972u,
103983630426828u, 969847973u,
103993427164640u, 3463937250u,
104003044785046u, 897322257u,
104013443872170u, 4185408854u,
104022557463241u, 4080940424u,
104032048168570u, 2429169982u,
104043174690447u, 2513494106u,
104051213061732u, 3143736628u,
104063482268149u, 1250714337u,
1040731648125u, 3872383625u,
104081565760579u, 36665130u,
10409751041229u, 2257179590u,
104102915361862u, 280819225u,
104112907818413u, 4254297769u,
104123493178615u, 3755944354u,
104134043533423u, 1134196225u,
104144177134659u, 127246419u,
104152442615581u, 923049607u,
104161004426206u, 782768297u,
104172410586681u, 1430106871u,
104184103323427u, 3168399477u,
104193716682375u, 3616334719u,
104203413209549u, 656672786u,
104212876965944u, 182894450u,
10422456581318u, 2683752067u,
104233877875910u, 3190666241u,
104243240336907u, 4024807233u,
104251681224377u, 1576191191u,
104263599250276u, 2381111980u,
104273495321877u, 3956024585u,
104281611608524u, 3815677453u,
104292062334396u, 1656117707u,
104305457134u, 3234118251u,
10431470187419u, 2688566989u,
104323259870297u, 660100446u,
10433442236198u, 2542452448u,
10434493137955u, 392411099u,
10435947967568u, 1234595917u,
104364230082284u, 2762976773u,
104372870085764u, 1455086530u,
104382762099647u, 4011882747u,
104391215981925u, 3227517889u,
104403269061963u, 4037515364u,
104413168911474u, 4255057396u,
104422026092260u, 1736192508u,
104433909727042u, 3114708966u,
104441938800693u, 680793595u,
104451525265867u, 2808224480u,
104462122290603u, 1211197714u,
104473520488321u, 3979192396u,
104483540779343u, 4192918639u,
104492736030448u, 1120335563u,
104501698949078u, 3993310631u,
104511966048551u, 2228221363u,
10452597941119u, 3498018399u,
10453393987327u, 454500547u,
104541222959566u, 567151340u,
104553774764786u, 1492844524u,
104563308300614u, 805568076u,
10457868414882u, 177406999u,
104581608110313u, 642061169u,
104591027515771u, 3131251981u,
104602851936150u, 4272755262u,
104611532845092u, 709643652u,
10462682573592u, 1244104217u,
10463796769556u, 2500467040u,
104643002618826u, 1112998535u,
104651780193104u, 1243644607u,
104663691719535u, 2958853053u,
10467466635014u, 2277292580u,
104684082276003u, 1030800045u,
104691750863246u, 379050598u,
104703576413281u, 731493104u,
10471132259176u, 4115195437u,
104721769890695u, 2715470335u,
104731819263183u, 2028531518u,
104742154809766u, 3672399742u,
1047576727603u, 4198182186u,
104762304993586u, 1666387627u,
10477284366017u, 3359785538u,
104783469807328u, 2926494787u,
104793829072836u, 2493478921u,
104803738499303u, 3311304980u,
10481932916545u, 2235559063u,
104822909742396u, 1765719309u,
104831456588655u, 508290328u,
104841490719640u, 3356513470u,
104852908490783u, 251085588u,
10486830410677u, 3172220325u,
104873897208579u, 1940535730u,
10488151909546u, 2384458112u,
10489};
10490
10491// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
10492bool Test(int offset, int len = 0) {
10493#undef Check
10494#undef IsAlive
10495
10496#define Check(x) do { \
10497 const uint32_t actual = (x), e = expected[index++]; \
10498 bool ok = actual == e; \
10499 if (!ok) { \
10500 cerr << "expected " << hex << e << " but got " << actual << endl; \
10501 ++errors; \
10502 } \
10503 assert(ok); \
10504} while (0)
10505
10506#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
10507
10508 // After the following line is where the uses of "Check" and such will go.
10509 static int index = 0;
10510if (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; }
10511{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
10512{ uint64_t h = farmhashuo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
10513
10514 return true;
10515#undef Check
10516#undef IsAlive
10517}
10518
10519int RunTest() {
10520 Setup();
10521 int i = 0;
10522 cout << "Running farmhashuoTest";
10523 if (!Test(-1)) {
10524 cout << "... Unavailable\n";
10525 return NoteErrors();
10526 }
10527 // Good. The function is attempting to hash, so run the full test.
10528 int errors_prior_to_test = errors;
10529 for ( ; i < kTestSize - 1; i++) {
10530 Test(i * i, i);
10531 }
10532 for ( ; i < kDataSize; i += i / 7) {
10533 Test(0, i);
10534 }
10535 Test(0, kDataSize);
10536 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
10537 return NoteErrors();
10538}
10539
10540#else
10541
10542// After the following line is where the code to print hash codes will go.
10543void Dump(int offset, int len) {
10544{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10545{ uint64_t h = farmhashuo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10546}
10547
10548#endif
10549
10550#undef SEED
10551#undef SEED1
10552#undef SEED0
10553
10554} // namespace farmhashuoTest
10555
10556#if !TESTING
10557int main(int argc, char** argv) {
10558 Setup();
10559 cout << "uint32_t expected[] = {\n";
10560 int i = 0;
10561 for ( ; i < kTestSize - 1; i++) {
10562 farmhashuoTest::Dump(i * i, i);
10563 }
10564 for ( ; i < kDataSize; i += i / 7) {
10565 farmhashuoTest::Dump(0, i);
10566 }
10567 farmhashuoTest::Dump(0, kDataSize);
10568 cout << "};\n";
10569}
10570#endif
10571#ifndef FARMHASH_SELF_TEST_GUARD
10572#define FARMHASH_SELF_TEST_GUARD
10573#include <cstdio>
10574#include <iostream>
10575#include <string.h>
10576
10577using std::cout;
10578using std::cerr;
10579using std::endl;
10580using std::hex;
10581
10582static const uint64_t kSeed0 = 1234567;
10583static const uint64_t kSeed1 = k0;
10584static const int kDataSize = 1 << 20;
10585static const int kTestSize = 300;
10586#define kSeed128 Uint128(kSeed0, kSeed1)
10587
10588static char data[kDataSize];
10589
10590static int completed_self_tests = 0;
10591static int errors = 0;
10592
10593// Initialize data to pseudorandom values.
10594void Setup() {
10595 if (completed_self_tests == 0) {
10596 uint64_t a = 9;
10597 uint64_t b = 777;
10598 for (int i = 0; i < kDataSize; i++) {
10599 a += b;
10600 b += a;
10601 a = (a ^ (a >> 41)) * k0;
10602 b = (b ^ (b >> 41)) * k0 + i;
10603 uint8_t u = b >> 37;
10604 memcpy(data + i, &u, 1); // uint8_t -> char
10605 }
10606 }
10607}
10608
10609int NoteErrors() {
10610#define NUM_SELF_TESTS 9
10611 if (++completed_self_tests == NUM_SELF_TESTS)
10612 std::exit(errors > 0);
10613 return errors;
10614}
10615
10616template <typename T> inline bool IsNonZero(T x) {
10617 return x != 0;
10618}
10619
10620template <> inline bool IsNonZero<uint128_t>(uint128_t x) {
10621 return x != Uint128(0, 0);
10622}
10623
10624#endif // FARMHASH_SELF_TEST_GUARD
10625
10626namespace farmhashxoTest {
10627
10628uint32_t CreateSeed(int offset, int salt) {
10629 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
10630 h = h * c1;
10631 h ^= (h >> 17);
10632 h = h * c1;
10633 h ^= (h >> 17);
10634 h = h * c1;
10635 h ^= (h >> 17);
10636 h += static_cast<uint32_t>(offset & 0xffffffff);
10637 h = h * c1;
10638 h ^= (h >> 17);
10639 h = h * c1;
10640 h ^= (h >> 17);
10641 h = h * c1;
10642 h ^= (h >> 17);
10643 return h;
10644}
10645
10646#undef SEED
10647#undef SEED1
10648#undef SEED0
10649#define SEED CreateSeed(offset, -1)
10650#define SEED0 CreateSeed(offset, 0)
10651#define SEED1 CreateSeed(offset, 1)
10652
10653#undef TESTING
10654#define TESTING 1
10655#if TESTING
10656uint32_t expected[] = {
106571140953930u, 861465670u,
106583277735313u, 2681724312u,
106592598464059u, 797982799u,
10660890626835u, 800175912u,
106612603993599u, 921001710u,
106621410420968u, 2134990486u,
106633283896453u, 1867689945u,
106642914424215u, 2244477846u,
10665255297188u, 2992121793u,
106661110588164u, 4186314283u,
10667161451183u, 3943596029u,
106684019337850u, 452431531u,
10669283198166u, 2741341286u,
106703379021470u, 2557197665u,
10671299850021u, 2532580744u,
10672452473466u, 1706958772u,
106731298374911u, 3099673830u,
106742199864459u, 3696623795u,
10675236935126u, 2976578695u,
106764055299123u, 3281581178u,
106771053458494u, 1882212500u,
106782305012065u, 2169731866u,
106793456121707u, 275903667u,
10680458884671u, 3033004529u,
106813058973506u, 2379411653u,
106821898235244u, 1402319660u,
106832700149065u, 2699376854u,
10684147814787u, 720739346u,
106852433714046u, 4222949502u,
106864220361840u, 1712034059u,
106873425469811u, 3690733394u,
106884148372108u, 1330324210u,
10689594028478u, 2921867846u,
106901635026870u, 192883107u,
10691780716741u, 1728752234u,
106923280331829u, 326029180u,
106933969463346u, 1436364519u,
10694393215742u, 3349570000u,
106953824583307u, 1612122221u,
106962859809759u, 3808705738u,
106971379537552u, 1646032583u,
106982233466664u, 1432476832u,
106994023053163u, 2650381482u,
107002052294713u, 3552092450u,
107011628777059u, 1499109081u,
107023476440786u, 3829307897u,
107032960536756u, 1554038301u,
107041145519619u, 3190844552u,
107052902102606u, 3600725550u,
10706237495366u, 540224401u,
1070765721842u, 489963606u,
107081448662590u, 397635823u,
107091596489240u, 1562872448u,
107101790705123u, 2128624475u,
10711180854224u, 2604346966u,
107121435705557u, 1262831810u,
10713155445229u, 1672724608u,
107141669465176u, 1341975128u,
10715663607706u, 2077310004u,
107163610042449u, 1911523866u,
107171043692997u, 1454396064u,
107182563776023u, 294527927u,
107191099072299u, 1389770549u,
10720703505868u, 678706990u,
107212952353448u, 2026137563u,
107223603803785u, 629449419u,
107231933894405u, 3043213226u,
10724226132789u, 2489287368u,
107251552847036u, 645684964u,
107263828089804u, 3632594520u,
10727187883449u, 230403464u,
107283151491850u, 3272648435u,
107293729087873u, 1303930448u,
107302002861219u, 165370827u,
10731916494250u, 1230085527u,
107323103338579u, 3064290191u,
107333807265751u, 3628174014u,
10734231181488u, 851743255u,
107352295806711u, 1781190011u,
107362988893883u, 1554380634u,
107371142264800u, 3667013118u,
107381968445277u, 315203929u,
107392638023604u, 2290487377u,
10740732137533u, 1909203251u,
10741440398219u, 1891630171u,
107421380301172u, 1498556724u,
107434072067757u, 4165088768u,
107444204318635u, 441430649u,
107453931792696u, 197618179u,
10746956300927u, 914413116u,
107473010839769u, 2837339569u,
107482148126371u, 1913303225u,
107493074915312u, 3117299654u,
107504139181436u, 2993479124u,
107513178848746u, 1357272220u,
107521438494951u, 507436733u,
10753667183474u, 2084369203u,
107543854939912u, 1413396341u,
10755126024219u, 146044391u,
107561016656857u, 3022024459u,
107573254014218u, 429095991u,
10758990500595u, 3056862311u,
10759985653208u, 1718653828u,
10760623071693u, 366414107u,
107611771289760u, 2293458109u,
107623047342438u, 2991127487u,
107633120876698u, 1684583131u,
107643638043310u, 1170404994u,
10765863214540u, 1087193030u,
10766199124911u, 520792961u,
107673169775996u, 1577421232u,
107683331828431u, 1013201099u,
107691716848157u, 4033596884u,
107701770708857u, 4229339322u,
107711146169032u, 1434258493u,
107723824360466u, 3242407770u,
107731926419493u, 2649785113u,
10774872586426u, 762243036u,
107752736953692u, 816692935u,
107761571283333u, 3555213933u,
107772266795890u, 3781899767u,
107784290630595u, 517646945u,
107793006163611u, 2180594090u,
10780959214578u, 558910384u,
107811283799121u, 3047062993u,
107823830962609u, 2391606125u,
107833544509313u, 622325861u,
10784834785312u, 382936554u,
107851421463872u, 788479970u,
107861825135056u, 2725923798u,
10787580988377u, 2826990641u,
10788247825043u, 3167748333u,
10789812546227u, 2506885666u,
107902584372201u, 1758123094u,
107911891789696u, 389974094u,
10792345313518u, 2022370576u,
107933886113119u, 3338548567u,
107941083486947u, 2583576230u,
107951776047957u, 1771384107u,
107963604937815u, 3198590202u,
107973027522813u, 4155628142u,
107984232136669u, 427759438u,
107994244322689u, 542201663u,
108001549591985u, 2856634168u,
10801556609672u, 45845311u,
108021175961330u, 3948351189u,
108034165739882u, 4194218315u,
108041634635545u, 4151937410u,
10805713127376u, 1467786451u,
108061327394015u, 2743592929u,
108072638154051u, 810082938u,
108083077742128u, 1062268187u,
108094084325664u, 3810665822u,
108103735739145u, 2794294783u,
108112335576331u, 2560479831u,
10812690240711u, 997658837u,
108132442302747u, 3948961926u,
108143958366652u, 3067277639u,
108152059157774u, 1211737169u,
108161516711748u, 2339636583u,
108174188504038u, 59581167u,
108182767897792u, 1389679610u,
108192658147000u, 2643979752u,
108203758739543u, 4189944477u,
108211454470782u, 100876854u,
108222995362413u, 118817200u,
108233252925478u, 2062343506u,
108242804483644u, 3088828656u,
108251231633714u, 4168280671u,
108262931588131u, 3284356565u,
108271255909792u, 3130054947u,
108284173605289u, 1407328702u,
108291677744031u, 3532596884u,
108303162657845u, 3887208531u,
108312256541290u, 3459463480u,
108323740979556u, 259034107u,
10833392987633u, 3233195759u,
108343606709555u, 3424793077u,
10835315836068u, 3200749877u,
108364065431359u, 760633989u,
108372982018998u, 1811050648u,
10838234531934u, 1115203611u,
108393897494162u, 1516407838u,
108401603559457u, 323296368u,
108412632963283u, 1778459926u,
108422879836826u, 2146672889u,
108433486330348u, 492621815u,
108441231665285u, 2457048126u,
108453438440082u, 2217471853u,
108463355404249u, 3275550588u,
108471052645068u, 862072556u,
108484110617119u, 3745267835u,
108492657392572u, 4279236653u,
108501688445808u, 701920051u,
10851956734128u, 581695350u,
108523157862788u, 2585726058u,
108531192588249u, 1410111809u,
108541651193125u, 3326135446u,
108551073280453u, 97376972u,
108562513844237u, 2187968410u,
108573976859649u, 4267859263u,
108583429034542u, 564493077u,
108593000537321u, 479241367u,
108603845637831u, 2868987960u,
1086151544337u, 1029173765u,
10862393624922u, 704325635u,
108632357610553u, 1418509533u,
108642007814586u, 3866658271u,
108653082385053u, 735688735u,
10866916110004u, 3283299459u,
108671051684175u, 1083796807u,
108684074716319u, 813690332u,
10869144264390u, 1439630796u,
108701508556987u, 675582689u,
108713748881891u, 3195309868u,
10872362884708u, 1616408198u,
1087343233176u, 837301135u,
10874881504822u, 3254795114u,
108751385506591u, 2799925823u,
108761469874582u, 3464841997u,
10877497175391u, 3929484338u,
108783975771289u, 1798536177u,
108792926265846u, 1374242438u,
108803675707838u, 4205965408u,
108813153165629u, 1499475160u,
10882187287713u, 548490821u,
108833255259608u, 4247675634u,
108841940181471u, 3779953975u,
10885687167150u, 2319566715u,
108861742785722u, 785893184u,
108872296977392u, 2778575413u,
108881794720651u, 48131484u,
108894084891412u, 1160134629u,
108903737623280u, 823113169u,
108913423207646u, 3803213486u,
10892710625654u, 4116162021u,
108933693420287u, 4167766971u,
108941666602807u, 295320990u,
108953513255468u, 2487440590u,
10896234080704u, 4004655503u,
108972971762528u, 1479656873u,
108984090178629u, 4044418876u,
10899391947536u, 1462554406u,
109003909295855u, 1239580330u,
109011515601363u, 2011102035u,
109021442068334u, 4265993528u,
109031191921695u, 2291355695u,
109044257172787u, 576405853u,
10905314332944u, 4038839101u,
1090655559918u, 2378985842u,
10907711098718u, 2425317635u,
109081644327317u, 1401013391u,
109094193760037u, 2958260436u,
109103167371443u, 3062418115u,
109113800755475u, 3167030094u,
109123489648204u, 1405430357u,
10913526177822u, 2602636307u,
10914915406019u, 4264167741u,
109151484090483u, 3070944737u,
10916254529415u, 4017058800u,
109171702710265u, 1029665228u,
109182000382906u, 3185573940u,
109191381258384u, 4036354071u,
109202900841028u, 2670703363u,
109212921748807u, 2899069938u,
109224130543625u, 688472265u,
109234186808827u, 1054670286u,
109241132985391u, 2840525968u,
109254175776103u, 338058159u,
109261735964501u, 1539305024u,
109273497121710u, 1568260669u,
109282227290760u, 146827036u,
109293977176001u, 4060134777u,
10930857488494u, 250055052u,
109314284109679u, 2502815838u,
109322592281721u, 1603444633u,
109331390562014u, 1556658131u,
10934616327404u, 2448966429u,
109353051191726u, 3891353218u,
109361213304082u, 762328245u,
109372239052397u, 1082330589u,
109382455957292u, 201837927u,
10939405397452u, 3079886794u,
109402583939798u, 2848283092u,
109413750724631u, 883849006u,
109423204198988u, 3341327098u,
109431855234968u, 1982110346u,
109441485529487u, 541496720u,
109454117290321u, 3607433551u,
109462168864636u, 133643215u,
109471055817409u, 3847827123u,
109482960769387u, 4046101649u,
109491176127003u, 4015671361u,
109504243643405u, 2849988118u,
10951517111221u, 1796672358u,
109522045051700u, 3452457457u,
109532948254999u, 2102063419u,
109541556410577u, 1536380876u,
109553776661467u, 3281002516u,
109561735616066u, 1539151988u,
109571087795162u, 3332431596u,
10958685631442u, 1147951686u,
1095995237878u, 2005032160u,
109604012206915u, 4224354805u,
109613204999386u, 2415262714u,
109621433635018u, 116647396u,
1096383167836u, 2881562655u,
109642729416454u, 1029284767u,
10965881378302u, 2159170082u,
10966555057366u, 1169104445u,
109673963877000u, 1919171906u,
10968336034862u, 2017579106u,
109694059340529u, 3020819343u,
10970865146997u, 2473524405u,
10971944743644u, 1694443528u,
109721804513294u, 2904752429u,
10973617975720u, 3671562289u,
10974260177668u, 505662155u,
109751885941445u, 2504509403u,
109762260041112u, 1019936943u,
109773722741628u, 1511077569u,
109783100701179u, 1379422864u,
109791535670711u, 773792826u,
109801103819072u, 2089123665u,
109811157547425u, 329152940u,
109824142587430u, 484732447u,
109832475035432u, 1120017626u,
10984412145504u, 965125959u,
10985324924679u, 2809286837u,
109862842141483u, 4029205195u,
109872974306813u, 515627448u,
109883791551981u, 1097806406u,
109893873078673u, 136118734u,
109901872130856u, 3632422367u,
109913574135531u, 4017075736u,
109921699452298u, 1403506686u,
10993344414660u, 1189129691u,
109943487080616u, 1516736273u,
109951805475756u, 2562064338u,
10996163335594u, 2732147834u,
109974077452507u, 2984955003u,
109984271866024u, 3071338162u,
109992347111903u, 873829983u,
110001948409509u, 1923531348u,
11001459509140u, 771592405u,
110021750124750u, 2334938333u,
11003213811117u, 2586632018u,
11004185232757u, 4032960199u,
110052447383637u, 284777551u,
110061654276320u, 2687561076u,
110073512945009u, 308584855u,
110081861027147u, 4102279334u,
110093203802620u, 1692079268u,
110104250142168u, 2565680167u,
110111507046104u, 841195925u,
11012520565830u, 3674576684u,
1101338924274u, 3770488806u,
110142414430882u, 3978473838u,
110153703994407u, 69201295u,
110163099963860u, 1255084262u,
11017690971838u, 3539996781u,
110183696902571u, 3593730713u,
110192363435042u, 54945052u,
110201785765213u, 184911581u,
110211586241476u, 1939595371u,
110222534883189u, 2432427547u,
110232374171993u, 2039128933u,
110242955715987u, 2295501078u,
110252741583197u, 1280920000u,
11026686818699u, 1238742497u,
110273843660102u, 82177963u,
110281281043691u, 1121403845u,
110291697846708u, 284852964u,
11030278661677u, 2889101923u,
110312127558730u, 713121337u,
11032872502474u, 511142139u,
110331261140657u, 1747052377u,
110342108187161u, 927011680u,
11035955328267u, 3821994995u,
110362707230761u, 4142246789u,
110374134691985u, 1958963937u,
110382498463509u, 1977988705u,
110391419293714u, 1636932722u,
110402567532373u, 4075249328u,
11041240575705u, 1956681213u,
110422598802768u, 2025886508u,
110434104757832u, 3026358429u,
110443242615202u, 4026813725u,
11045255108733u, 1845587644u,
110463573008472u, 3615577014u,
110471222733548u, 1205557630u,
11048917608574u, 1363253259u,
110491541946015u, 3087190425u,
110501138008081u, 1444019663u,
11051109793386u, 341851980u,
11052857839960u, 2515339233u,
11053156283211u, 1906768669u,
110543886713057u, 1276595523u,
110552809830736u, 460237542u,
110563420452099u, 142985419u,
11057205970448u, 4198897105u,
110581950698961u, 2069753399u,
110591142216925u, 1113051162u,
110601033680610u, 4278599955u,
110611106466069u, 356742959u,
11062531521052u, 3494863964u,
11063225629455u, 3735275001u,
110643662626864u, 1750561299u,
110651012864651u, 2101846429u,
110661074553219u, 668829411u,
11067992181339u, 3384018814u,
110683330664522u, 860966321u,
110691885071395u, 4233785523u,
11070100741310u, 451656820u,
110712148187612u, 1063001151u,
11072360256231u, 107312677u,
110733650357479u, 2390172694u,
1107422452685u, 237319043u,
110753600462351u, 1216645846u,
110762088767754u, 164402616u,
110772418980170u, 926137824u,
1107894638678u, 1689811113u,
110792751052984u, 1767810825u,
11080271289013u, 3896132233u,
11081103797041u, 1397772514u,
110823441135892u, 3323383489u,
110832491268371u, 1662561885u,
110841612872497u, 2986430557u,
110852756998822u, 207428029u,
11086937973965u, 2791656726u,
110871949717207u, 2260498180u,
110882648427775u, 2360400900u,
110892080496169u, 486358863u,
110901582022990u, 1263709570u,
110911396468647u, 1377764574u,
11092363008508u, 1293502429u,
11093224580012u, 4252610345u,
110941435134775u, 1099809675u,
11095533671980u, 1533438766u,
110961820532305u, 2776960536u,
110973374512975u, 3542220540u,
11098822810075u, 3716663290u,
110991157398049u, 3752806924u,
111004081637863u, 337070226u,
111013866585976u, 359270190u,
111022110942730u, 3267551635u,
11103644850146u, 1306761320u,
11104746972907u, 934259457u,
111052341378668u, 2220373824u,
111061242645122u, 4109252858u,
111071625266099u, 1173698481u,
11108383517064u, 896322512u,
111093377483696u, 1788337208u,
11110455496839u, 3194373887u,
111111837689083u, 1336556841u,
111121658628529u, 2911512007u,
111133838343487u, 2757664765u,
111141537187340u, 3712582785u,
11115367022558u, 3071359622u,
111163926147070u, 35432879u,
111173093195926u, 2561488770u,
111184273132307u, 3898950547u,
111192838251049u, 2103926083u,
111202549435227u, 536047554u,
111211858986613u, 2040551642u,
111221147412575u, 1972369852u,
111234166184983u, 3528794619u,
111244077477194u, 3565689036u,
11125808048238u, 3826350461u,
111261359641525u, 1197100813u,
11127265993036u, 1864569342u,
11128725164342u, 2264788336u,
111291831223342u, 3329594980u,
11130923017956u, 490608221u,
111313818634478u, 258154469u,
111321441714797u, 1174785921u,
111333833372385u, 3287246572u,
111341677395563u, 3569218731u,
11135868981704u, 2163330264u,
111362649450292u, 500120236u,
11137465161780u, 746438382u,
111381145009669u, 2520062970u,
111392810524030u, 1561519055u,
111401479878006u, 3864969305u,
111412686075657u, 4042710240u,
111423224066062u, 2774151984u,
111432226179547u, 1643626042u,
111442328730865u, 3160666939u,
111452107011431u, 96459446u,
111463920328742u, 3336407558u,
11147829404209u, 1878067032u,
111481235983679u, 4237425634u,
11149466519055u, 3870676863u,
11150934312076u, 2952135524u,
11151276949224u, 4100839753u,
11152424001484u, 1955120893u,
111534015478120u, 1265237690u,
11154427484362u, 4246879223u,
111553452969617u, 1724363362u,
111561553513184u, 834830418u,
111571858777639u, 3476334357u,
111584144030366u, 2450047160u,
111592950762705u, 4277111759u,
11160358032121u, 2511026735u,
11161167923105u, 2059208280u,
11162251949572u, 3065234219u,
111631535473864u, 556796152u,
111641513237478u, 3150857516u,
111651103404394u, 198182691u,
111661476438092u, 2913077464u,
11167207119516u, 3963810232u,
111682954651680u, 1535115487u,
111693051522276u, 4046477658u,
11170917804636u, 864395565u,
11171632704095u, 140762681u,
111721802040304u, 990407433u,
111733771506212u, 4106024923u,
111741287729497u, 2198985327u,
111754052924496u, 2926590471u,
111763084557148u, 1472898694u,
111771009870118u, 559702706u,
111784265214507u, 82077489u,
111793067891003u, 3295678907u,
111802402308151u, 1096697687u,
11181464407878u, 4190838199u,
111824269578403u, 3060919438u,
111832899950405u, 3046872820u,
11184733509243u, 1583801700u,
1118540453902u, 3879773881u,
111861993425202u, 2185339100u,
111871877837196u, 3912423882u,
111883293122640u, 4104318469u,
111891679617763u, 3703603898u,
111908759461u, 2540185277u,
111911152198475u, 2038345882u,
111922503579743u, 1446869792u,
111932019419351u, 4051584612u,
111943178289407u, 3992503830u,
111952879018745u, 2719373510u,
11196700836153u, 1675560450u,
111974121245793u, 2064715719u,
11198343595772u, 1996164093u,
111993130433948u, 405251683u,
112002804817126u, 1607133689u,
11201463852893u, 2864244470u,
112022224044848u, 4071581802u,
112032537107938u, 2246347953u,
112043207234525u, 2028708916u,
112052272418128u, 803575837u,
1120638655481u, 2170452091u,
112073272166407u, 557660441u,
112084019147902u, 3841480082u,
11209298459606u, 2600943364u,
112102440657523u, 255451671u,
112113424361375u, 779434428u,
112123088526123u, 490671625u,
112131322855877u, 3452203069u,
112143057021940u, 2285701422u,
112152014993457u, 2390431709u,
112162002090272u, 1568745354u,
112171783152480u, 823305654u,
112184053862835u, 2200236540u,
112193009412313u, 3184047862u,
112203032187389u, 4159715581u,
112212966902888u, 252986948u,
112221849329144u, 3160134214u,
112233420960112u, 3198900547u,
11224749160960u, 379139040u,
112251208883495u, 1566527339u,
112263006227299u, 4194096960u,
11227556075248u, 497404038u,
112281717327230u, 1496132623u,
112291775955687u, 1719108984u,
112301014328900u, 4189966956u,
112312108574735u, 2584236470u,
11232684087286u, 531310503u,
112334264509527u, 773405691u,
112343088905079u, 3456882941u,
112353105682208u, 3382290593u,
112362289363624u, 3296306400u,
112374168438718u, 467441309u,
11238777173623u, 3241407531u,
112391183994815u, 1132983260u,
112401610606159u, 2540270567u,
112412649684057u, 1397502982u,
11242146657385u, 3318434267u,
112432109315753u, 3348545480u,
112443193669211u, 811750340u,
112451073256162u, 3571673088u,
11246546596661u, 1017047954u,
112473403136990u, 2540585554u,
112481477047647u, 4145867423u,
112492826408201u, 3531646869u,
11250784952939u, 943914610u,
112512717443875u, 3657384638u,
112521806867885u, 1903578924u,
112533985088434u, 1911188923u,
112541764002686u, 3672748083u,
112551832925325u, 241574049u,
11256519948041u, 3181425568u,
112572939747257u, 1634174593u,
112583429894862u, 3529565564u,
112591089679033u, 240953857u,
112602025369941u, 2695166650u,
11261517086873u, 2964595704u,
112623017658263u, 3828377737u,
112632144895011u, 994799311u,
112641184683823u, 4260564140u,
11265308018483u, 4262383425u,
112661374752558u, 3431057723u,
112671572637805u, 383233885u,
112683188015819u, 4051263539u,
11269233319221u, 3794788167u,
112702017406667u, 919677938u,
112714074952232u, 1683612329u,
112724213676186u, 327142514u,
112733032591014u, 4204155962u,
11274206775997u, 2283918569u,
112752395147154u, 3427505379u,
112762211319468u, 4153726847u,
112772217060665u, 350160869u,
112782493667051u, 1648200185u,
112793441709766u, 1387233546u,
11280140980u, 1891558063u,
11281760080239u, 2088061981u,
112821580964938u, 740563169u,
11283422986366u, 330624974u,
112844264507722u, 150928357u,
112852738323042u, 2948665536u,
11286918718096u, 376390582u,
112873966098971u, 717653678u,
112883219466255u, 3799363969u,
112893424344721u, 3187805406u,
11290375347278u, 3490350144u,
112911992212097u, 2263421398u,
112923855037968u, 1928519266u,
112933866327955u, 1129127000u,
112941782515131u, 2746577402u,
112953059200728u, 2108753646u,
112962738070963u, 1336849395u,
112971705302106u, 768287270u,
112981343511943u, 2247006571u,
112991956142255u, 1780259453u,
113003475618043u, 212490675u,
11301622521957u, 917121602u,
113021852992332u, 1267987847u,
113033170016833u, 2549835613u,
113043299763344u, 2864033668u,
113053378768767u, 1236609378u,
113064169365948u, 3738062408u,
113072661022773u, 2006922227u,
113082760592161u, 3828932355u,
113092636387819u, 2616619070u,
113101237256330u, 3449066284u,
113112871755260u, 3729280948u,
113123862686086u, 431292293u,
113133285899651u, 786322314u,
113142531158535u, 724901242u,
113152377363130u, 1415970351u,
113161244759631u, 3263135197u,
11317965248856u, 174024139u,
113182297418515u, 2954777083u,
11319987586766u, 3206261120u,
113204059515114u, 3903854066u,
113211931934525u, 2287507921u,
113221827135136u, 1781944746u,
11323574617451u, 2299034788u,
113242650140034u, 4081586725u,
113252482286699u, 1109175923u,
11326458483596u, 618705848u,
113274059852729u, 1813855658u,
113284190721328u, 1129462471u,
113294089998050u, 3575732749u,
113302375584220u, 1037031473u,
113311623777358u, 3389003793u,
11332546597541u, 352770237u,
113331383747654u, 3122687303u,
113341646071378u, 1164309901u,
11335290870767u, 830691298u,
11336929335420u, 3193251135u,
11337989577914u, 3626554867u,
11338591974737u, 3996958215u,
113393163711272u, 3071568023u,
113401516846461u, 3656006011u,
113412698625268u, 2510865430u,
11342340274176u, 1167681812u,
113433698796465u, 3155218919u,
113444102288238u, 1673474350u,
113453069708839u, 2704165015u,
113461237411891u, 1854985978u,
113473646837503u, 3625406022u,
11348921552000u, 1712976649u,
113493939149151u, 878608872u,
113503406359248u, 1068844551u,
113511834682077u, 4155949943u,
113522437686324u, 3163786257u,
113532645117577u, 1988168803u,
11354747285578u, 1626463554u,
113551235300371u, 1256485167u,
113561914142538u, 4141546431u,
113573838102563u, 582664250u,
113581883344352u, 2083771672u,
113592611657933u, 2139079047u,
113602250573853u, 804336148u,
113613066325351u, 2770847216u,
113624275641370u, 1455750577u,
113633346357270u, 1674051445u,
11364601221482u, 3992583643u,
113651402445097u, 3622527604u,
113662509017299u, 2966108111u,
113672557027816u, 900741486u,
113681790771021u, 2912643797u,
113692631381069u, 4014551783u,
1137090375300u, 300318232u,
113713269968032u, 2679371729u,
113722664752123u, 3517585534u,
113733253901179u, 542270815u,
113741188641600u, 365479232u,
113752210121140u, 760762191u,
113761273768482u, 1216399252u,
113773484324231u, 4287337666u,
1137816322182u, 643179562u,
11379325675502u, 3652676161u,
113803120716054u, 3330259752u,
113811011990087u, 2990167340u,
113821097584090u, 3262252593u,
113831829409951u, 3665087267u,
113841214854475u, 2134299399u,
113853704419305u, 411263051u,
113861625446136u, 549838529u,
113874283196353u, 1342880802u,
113883460621305u, 1967599860u,
113894282843369u, 1275671016u,
113902544665755u, 853593042u,
11391901109753u, 2682611693u,
11392110631633u, 797487791u,
113931472073141u, 850464484u,
11394797089608u, 3286110054u,
11395350397471u, 2775631060u,
11396366448238u, 3842907484u,
113972219863904u, 3623364733u,
113981850985302u, 4009616991u,
11399294963924u, 3693536939u,
114003061255808u, 1615375832u,
114011920066675u, 4113028420u,
114024032223840u, 2318423400u,
114032701956286u, 4145497671u,
114043991532344u, 2536338351u,
114051679099863u, 1728968857u,
11406449740816u, 2686506989u,
11407685242457u, 97590863u,
114083258354115u, 1502282913u,
114091235084019u, 2151665147u,
11410528459289u, 231097464u,
114112477280726u, 3651607391u,
114122091754612u, 1178454681u,
11413980597335u, 1604483865u,
114141842333726u, 4146839064u,
114153213794286u, 2601416506u,
11416754220096u, 3571436033u,
11417488595746u, 1448097974u,
114184004834921u, 238887261u,
114193320337489u, 1416989070u,
114202928916831u, 4093725287u,
11421186020771u, 2367569534u,
114223046087671u, 4090084518u,
114233548184546u, 679517009u,
114241962659444u, 3539886328u,
114254192003933u, 1678423485u,
114263827951761u, 3086277222u,
114272144472852u, 1390394371u,
114282976322029u, 1574517163u,
114293553313841u, 119173722u,
114301702434637u, 1766260771u,
114313629581771u, 1407497759u,
11432895654784u, 751439914u,
114334008409498u, 215917713u,
114341482103833u, 695551833u,
114351288382231u, 2656990891u,
114362581779077u, 1570750352u,
114373710689053u, 1741390464u,
114382666411616u, 3533987737u,
114394289478316u, 3576119563u,
114404118694920u, 108199666u,
114413869794273u, 963183826u,
114422081410737u, 3796810515u,
11443791123882u, 2525792704u,
114441036883117u, 136547246u,
11445875691100u, 2592925324u,
11446614302599u, 3013176417u,
114472689342539u, 427154472u,
11448532957601u, 1228758574u,
114491898117151u, 1181643858u,
114501908591042u, 1464255968u,
11451446980910u, 2984611177u,
1145258509511u, 1046943619u,
114533508927906u, 2001585786u,
114542544767379u, 1525438381u,
11455552181222u, 1959725830u,
11456879448844u, 1348536411u,
114574242243590u, 2861338018u,
114581082052441u, 1034351453u,
11459601175800u, 764077711u,
11460530635011u, 3785343245u,
114612178026726u, 117256687u,
114622378297261u, 457568934u,
1146376438221u, 4104954272u,
11464956793873u, 3783168634u,
114652485968477u, 2381948487u,
114664226929450u, 3148473363u,
114672518273601u, 3569490233u,
11468879369091u, 2180270337u,
114693674375989u, 1387729170u,
11470977997984u, 4270646856u,
11471568650985u, 951677556u,
114724213877384u, 2721005055u,
114731073364549u, 2563403831u,
114741678669911u, 66786703u,
114752273631661u, 1149351924u,
114763651298990u, 1581883443u,
11477246723096u, 1895026827u,
114783810605772u, 3711056516u,
114794058833288u, 2193790614u,
114802080120290u, 3638638708u,
114812915672708u, 2263003308u,
114822361934197u, 4136767460u,
114831976115991u, 3448840877u,
114842019238520u, 225333538u,
11485874340815u, 2976159827u,
114861555273378u, 3797521928u,
114871942347150u, 3262952567u,
11488435997738u, 340403353u,
114892817830907u, 2078619498u,
11490749534111u, 1178073973u,
11491894654712u, 3361226032u,
11492841092198u, 3288261538u,
114931696412169u, 1496966875u,
11494697501571u, 1059158875u,
114953739946319u, 2481012988u,
11496568983526u, 114945840u,
114971559249010u, 2218244008u,
114982841706923u, 1632780103u,
114994020169654u, 2087949619u,
115002438736103u, 24032648u,
11501833416317u, 3787017905u,
115022373238993u, 2575395164u,
115033434544481u, 3228481067u,
115042542976862u, 2971726178u,
115052880371864u, 3642087909u,
115062407477975u, 2239080836u,
115071043714217u, 3894199764u,
115082235879182u, 203853421u,
115092933669448u, 2504940536u,
11510834683330u, 425935223u,
115113560796393u, 3565833278u,
115121668000829u, 3683399154u,
115133414330886u, 1748785729u,
115141023171602u, 580966986u,
115152531038985u, 3227325488u,
115162657385925u, 2124704694u,
11517233442446u, 1107045577u,
115183407293834u, 552770757u,
115193899097693u, 1067532701u,
11520115667924u, 1406028344u,
115211707768231u, 3724015962u,
115222419657149u, 18613994u,
115232532882091u, 3476683808u,
115241560838678u, 811220224u,
11525895961699u, 3762914298u,
115261328752423u, 1844996900u,
115271420427894u, 1848067707u,
115281210281744u, 904215228u,
115294055325594u, 1118521573u,
115302496554183u, 2579259919u,
115313996647489u, 3657647605u,
11532325254059u, 3136157065u,
115333951522674u, 4052925250u,
115343341068436u, 2287683323u,
115351313073005u, 126005630u,
115362505120084u, 1194725057u,
11537853746559u, 3555092974u,
115382689238752u, 49515858u,
115391244776042u, 1069300695u,
1154061073168u, 1010661841u,
115411269521335u, 1902040126u,
11542990632502u, 2378708922u,
115433858321250u, 1400735275u,
115442974699176u, 2771676666u,
11545170995186u, 2877798589u,
11546545726212u, 2225229957u,
115471086473152u, 3454177594u,
115483859483262u, 1499729584u,
115492088002891u, 2883475137u,
115503222194252u, 4144472319u,
115512212229854u, 4146740722u,
11552567988835u, 1051332394u,
115533932046135u, 542648229u,
115543017852446u, 1277887997u,
11555162888005u, 1669710469u,
115561492500905u, 553041029u,
115571434876932u, 533989516u,
115583817492747u, 584127807u,
115594147115982u, 2993670925u,
115604020312558u, 710021255u,
115613509733475u, 3587959456u,
115622088550465u, 1745399498u,
115632952242967u, 1259815443u,
11564869648362u, 1404723176u,
115653947542735u, 1334333531u,
115663873471582u, 229399758u,
1156759634866u, 3239516985u,
115683844250972u, 1275954779u,
115691385684948u, 2243700741u,
115702512155003u, 1685649437u,
11571639306006u, 2524620206u,
11572955360345u, 1646776457u,
11573576786501u, 655707039u,
115742864351838u, 3736264674u,
11575655621239u, 362070173u,
115761200907897u, 2384379464u,
1157715823708u, 206117476u,
115783652870937u, 122927134u,
115791193310960u, 1093099415u,
115803696538026u, 4112584792u,
115811834541277u, 845639252u,
115822069527017u, 547588820u,
115834178147211u, 2827259351u,
115841764455305u, 3312003602u,
11585940846775u, 1054995047u,
115862976960697u, 1934305529u,
115873095615046u, 3354962706u,
115882199137382u, 1005722394u,
115891875867180u, 2064356511u,
115903363633633u, 2688499147u,
115914019734130u, 3096333006u,
115922069509024u, 2906358341u,
115933247463123u, 4191788132u,
115942232866485u, 1456016086u,
115951422674894u, 867282151u,
115961851386407u, 1268304058u,
115971612503136u, 1739843072u,
11598134947567u, 2978775774u,
115992051592101u, 1017127033u,
116001284167756u, 1090844589u,
11601831688783u, 2079216362u,
116022079309682u, 1950585801u,
116031626991196u, 3644714163u,
116043678110059u, 898470030u,
116051117570988u, 2517572125u,
116063916646913u, 3182422972u,
116073630426828u, 969847973u,
116082835126238u, 53541366u,
116093427164640u, 3463937250u,
116103044785046u, 897322257u,
11611103038235u, 3804506837u,
116123443872170u, 4185408854u,
116132557463241u, 4080940424u,
116143669923099u, 2789619871u,
116152048168570u, 2429169982u,
116163174690447u, 2513494106u,
116173099587829u, 2627855577u,
116181213061732u, 3143736628u,
116193482268149u, 1250714337u,
116203553412672u, 2689632914u,
1162131648125u, 3872383625u,
116221565760579u, 36665130u,
116231282106920u, 359361724u,
11624751041229u, 2257179590u,
116252915361862u, 280819225u,
11626954406473u, 4101682199u,
116272907818413u, 4254297769u,
116283493178615u, 3755944354u,
116293539557658u, 3330196096u,
116304043533423u, 1134196225u,
116314177134659u, 127246419u,
116324213770762u, 1978302978u,
116332442615581u, 923049607u,
116341004426206u, 782768297u,
116352702745496u, 1880389457u,
116362410586681u, 1430106871u,
116374103323427u, 3168399477u,
11638201787012u, 3105353527u,
116393716682375u, 3616334719u,
116403413209549u, 656672786u,
11641526032790u, 2895072131u,
116422876965944u, 182894450u,
11643456581318u, 2683752067u,
116441287916294u, 1270745752u,
116453877875910u, 3190666241u,
116463240336907u, 4024807233u,
116474227999465u, 2389301430u,
116481681224377u, 1576191191u,
116493599250276u, 2381111980u,
116503995044500u, 995595530u,
116513495321877u, 3956024585u,
116521611608524u, 3815677453u,
116531520987487u, 3669102590u,
116542062334396u, 1656117707u,
116555457134u, 3234118251u,
116564242065111u, 596879987u,
11657470187419u, 2688566989u,
116583259870297u, 660100446u,
116591042378442u, 2206034096u,
11660442236198u, 2542452448u,
11661493137955u, 392411099u,
116623111186954u, 438250493u,
11663947967568u, 1234595917u,
116644230082284u, 2762976773u,
11665421203727u, 3728409592u,
116662870085764u, 1455086530u,
116672762099647u, 4011882747u,
116681785430706u, 3684427488u,
116691215981925u, 3227517889u,
116703269061963u, 4037515364u,
116711749401388u, 2167451566u,
116723168911474u, 4255057396u,
116732026092260u, 1736192508u,
116744123254745u, 2319366806u,
116753909727042u, 3114708966u,
116761938800693u, 680793595u,
116773933041672u, 616863613u,
116781525265867u, 2808224480u,
116792122290603u, 1211197714u,
116801186177814u, 2395325006u,
116813520488321u, 3979192396u,
116823540779343u, 4192918639u,
116831763872074u, 3402419930u,
116842736030448u, 1120335563u,
116851698949078u, 3993310631u,
116862947659998u, 1461045789u,
116871966048551u, 2228221363u,
11688597941119u, 3498018399u,
116891441110751u, 2229999711u,
11690393987327u, 454500547u,
116911222959566u, 567151340u,
116922496952483u, 1708770195u,
116933774764786u, 1492844524u,
116943308300614u, 805568076u,
116954068812294u, 3404648243u,
11696868414882u, 177406999u,
116971608110313u, 642061169u,
116982093999089u, 222470301u,
116991027515771u, 3131251981u,
117002851936150u, 4272755262u,
117012763002551u, 1881527822u,
117021532845092u, 709643652u,
11703682573592u, 1244104217u,
11704440905170u, 1111321746u,
11705796769556u, 2500467040u,
117063002618826u, 1112998535u,
117071188525643u, 4212674512u,
117081780193104u, 1243644607u,
117093691719535u, 2958853053u,
117102813437721u, 4036584207u,
11711466635014u, 2277292580u,
117124082276003u, 1030800045u,
117131899531424u, 609466946u,
117141750863246u, 379050598u,
117153576413281u, 731493104u,
117162707384133u, 2289193651u,
11717132259176u, 4115195437u,
117181769890695u, 2715470335u,
117193348954692u, 2166575624u,
117201819263183u, 2028531518u,
117212154809766u, 3672399742u,
117221142139448u, 88299682u,
1172376727603u, 4198182186u,
117242304993586u, 1666387627u,
117252488475423u, 3832777692u,
11726284366017u, 3359785538u,
117273469807328u, 2926494787u,
117281914195188u, 1134129972u,
117293829072836u, 2493478921u,
117303738499303u, 3311304980u,
11731726951526u, 911080963u,
11732932916545u, 2235559063u,
117332909742396u, 1765719309u,
11734465269850u, 3803621553u,
117351456588655u, 508290328u,
117361490719640u, 3356513470u,
117372262196163u, 1451774941u,
117382908490783u, 251085588u,
11739830410677u, 3172220325u,
117404039692645u, 1383603170u,
117413897208579u, 1940535730u,
11742151909546u, 2384458112u,
11743};
11744
11745// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
11746bool Test(int offset, int len = 0) {
11747#undef Check
11748#undef IsAlive
11749
11750#define Check(x) do { \
11751 const uint32_t actual = (x), e = expected[index++]; \
11752 bool ok = actual == e; \
11753 if (!ok) { \
11754 cerr << "expected " << hex << e << " but got " << actual << endl; \
11755 ++errors; \
11756 } \
11757 assert(ok); \
11758} while (0)
11759
11760#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
11761
11762 // After the following line is where the uses of "Check" and such will go.
11763 static int index = 0;
11764if (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; }
11765{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
11766{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
11767{ uint64_t h = farmhashxo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
11768
11769 return true;
11770#undef Check
11771#undef IsAlive
11772}
11773
11774int RunTest() {
11775 Setup();
11776 int i = 0;
11777 cout << "Running farmhashxoTest";
11778 if (!Test(-1)) {
11779 cout << "... Unavailable\n";
11780 return NoteErrors();
11781 }
11782 // Good. The function is attempting to hash, so run the full test.
11783 int errors_prior_to_test = errors;
11784 for ( ; i < kTestSize - 1; i++) {
11785 Test(i * i, i);
11786 }
11787 for ( ; i < kDataSize; i += i / 7) {
11788 Test(0, i);
11789 }
11790 Test(0, kDataSize);
11791 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
11792 return NoteErrors();
11793}
11794
11795#else
11796
11797// After the following line is where the code to print hash codes will go.
11798void Dump(int offset, int len) {
11799{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11800{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11801{ uint64_t h = farmhashxo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11802}
11803
11804#endif
11805
11806#undef SEED
11807#undef SEED1
11808#undef SEED0
11809
11810} // namespace farmhashxoTest
11811
11812#if !TESTING
11813int main(int argc, char** argv) {
11814 Setup();
11815 cout << "uint32_t expected[] = {\n";
11816 int i = 0;
11817 for ( ; i < kTestSize - 1; i++) {
11818 farmhashxoTest::Dump(i * i, i);
11819 }
11820 for ( ; i < kDataSize; i += i / 7) {
11821 farmhashxoTest::Dump(0, i);
11822 }
11823 farmhashxoTest::Dump(0, kDataSize);
11824 cout << "};\n";
11825}
11826#endif
11827
11828int main() {
11829 farmhashccTest::RunTest();
11830 farmhashmkTest::RunTest();
11831 farmhashnaTest::RunTest();
11832 farmhashntTest::RunTest();
11833 farmhashsaTest::RunTest();
11834 farmhashsuTest::RunTest();
11835 farmhashteTest::RunTest();
11836 farmhashuoTest::RunTest();
11837 farmhashxoTest::RunTest();
11838 __builtin_unreachable();
11839}
11840
11841#endif // FARMHASHSELFTEST
11842