microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
compb

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/externals/farmhash/src/farmhash.cc

11844lines · modecode

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 x = ~Bswap32(x * c1);
394 }
395 return x;
396}
397
398template <> uint64_t DebugTweak(uint64_t x) {
399 if (debug_mode) {
400 x = ~Bswap64(x * k1);
401 }
402 return x;
403}
404
405template <> NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t DebugTweak(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
406 if (debug_mode) {
407 uint64_t y = DebugTweak(Uint128Low64(x));
408 uint64_t z = DebugTweak(Uint128High64(x));
409 y += z;
410 z += y;
411 x = Uint128(y, z * k1);
412 }
413 return x;
414}
415
416} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
417
418using namespace std;
419using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
420namespace farmhashna {
421#undef Fetch
422#define Fetch Fetch64
423
424#undef Rotate
425#define Rotate Rotate64
426
427#undef Bswap
428#define Bswap Bswap64
429
430STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
431 return val ^ (val >> 47);
432}
433
434STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
435 return Hash128to64(Uint128(u, v));
436}
437
438STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
439 // Murmur-inspired hashing.
440 uint64_t a = (u ^ v) * mul;
441 a ^= (a >> 47);
442 uint64_t b = (v ^ a) * mul;
443 b ^= (b >> 47);
444 b *= mul;
445 return b;
446}
447
448STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
449 if (len >= 8) {
450 uint64_t mul = k2 + len * 2;
451 uint64_t a = Fetch(s) + k2;
452 uint64_t b = Fetch(s + len - 8);
453 uint64_t c = Rotate(b, 37) * mul + a;
454 uint64_t d = (Rotate(a, 25) + b) * mul;
455 return HashLen16(c, d, mul);
456 }
457 if (len >= 4) {
458 uint64_t mul = k2 + len * 2;
459 uint64_t a = Fetch32(s);
460 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
461 }
462 if (len > 0) {
463 uint8_t a = s[0];
464 uint8_t b = s[len >> 1];
465 uint8_t c = s[len - 1];
466 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
467 uint32_t z = static_cast<uint32_t>(len + (static_cast<uint32_t>(c) << 2));
468 return ShiftMix(y * k2 ^ z * k0) * k2;
469 }
470 return k2;
471}
472
473// This probably works well for 16-byte strings as well, but it may be overkill
474// in that case.
475STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
476 uint64_t mul = k2 + len * 2;
477 uint64_t a = Fetch(s) * k1;
478 uint64_t b = Fetch(s + 8);
479 uint64_t c = Fetch(s + len - 8) * mul;
480 uint64_t d = Fetch(s + len - 16) * k2;
481 return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
482 a + Rotate(b + k2, 18) + c, mul);
483}
484
485// Return a 16-byte hash for 48 bytes. Quick and dirty.
486// Callers do best to use "random-looking" values for a and b.
487STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
488 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
489 a += w;
490 b = Rotate(b + a + z, 21);
491 uint64_t c = a;
492 a += x;
493 a += y;
494 b += Rotate(a, 44);
495 return make_pair(a + z, b + c);
496}
497
498// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
499STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
500 const char* s, uint64_t a, uint64_t b) {
501 return WeakHashLen32WithSeeds(Fetch(s),
502 Fetch(s + 8),
503 Fetch(s + 16),
504 Fetch(s + 24),
505 a,
506 b);
507}
508
509// Return an 8-byte hash for 33 to 64 bytes.
510STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
511 uint64_t mul = k2 + len * 2;
512 uint64_t a = Fetch(s) * k2;
513 uint64_t b = Fetch(s + 8);
514 uint64_t c = Fetch(s + len - 8) * mul;
515 uint64_t d = Fetch(s + len - 16) * k2;
516 uint64_t y = Rotate(a + b, 43) + Rotate(c, 30) + d;
517 uint64_t z = HashLen16(y, a + Rotate(b + k2, 18) + c, mul);
518 uint64_t e = Fetch(s + 16) * mul;
519 uint64_t f = Fetch(s + 24);
520 uint64_t g = (y + Fetch(s + len - 32)) * mul;
521 uint64_t h = (z + Fetch(s + len - 24)) * mul;
522 return HashLen16(Rotate(e + f, 43) + Rotate(g, 30) + h,
523 e + Rotate(f + a, 18) + g, mul);
524}
525
526uint64_t Hash64(const char *s, size_t len) {
527 const uint64_t seed = 81;
528 if (len <= 32) {
529 if (len <= 16) {
530 return HashLen0to16(s, len);
531 } else {
532 return HashLen17to32(s, len);
533 }
534 } else if (len <= 64) {
535 return HashLen33to64(s, len);
536 }
537
538 // For strings over 64 bytes we loop. Internal state consists of
539 // 56 bytes: v, w, x, y, and z.
540 uint64_t x = seed;
541 uint64_t y = seed * k1 + 113;
542 uint64_t z = ShiftMix(y * k2 + 113) * k2;
543 pair<uint64_t, uint64_t> v = make_pair(0, 0);
544 pair<uint64_t, uint64_t> w = make_pair(0, 0);
545 x = x * k2 + Fetch(s);
546
547 // Set end so that after the loop we have 1 to 64 bytes left to process.
548 const char* end = s + ((len - 1) / 64) * 64;
549 const char* last64 = end + ((len - 1) & 63) - 63;
550 assert(s + len - 64 == last64);
551 do {
552 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
553 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
554 x ^= w.second;
555 y += v.first + Fetch(s + 40);
556 z = Rotate(z + w.first, 33) * k1;
557 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
558 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
559 std::swap(z, x);
560 s += 64;
561 } while (s != end);
562 uint64_t mul = k1 + ((z & 0xff) << 1);
563 // Make s point to the last 64 bytes of input.
564 s = last64;
565 w.first += ((len - 1) & 63);
566 v.first += w.first;
567 w.first += v.first;
568 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * mul;
569 y = Rotate(y + v.second + Fetch(s + 48), 42) * mul;
570 x ^= w.second * 9;
571 y += v.first * 9 + Fetch(s + 40);
572 z = Rotate(z + w.first, 33) * mul;
573 v = WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
574 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
575 std::swap(z, x);
576 return HashLen16(HashLen16(v.first, w.first, mul) + ShiftMix(y) * k0 + z,
577 HashLen16(v.second, w.second, mul) + x,
578 mul);
579}
580
581uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1);
582
583uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
584 return Hash64WithSeeds(s, len, k2, seed);
585}
586
587uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
588 return HashLen16(Hash64(s, len) - seed0, seed1);
589}
590} // namespace farmhashna
591namespace farmhashuo {
592#undef Fetch
593#define Fetch Fetch64
594
595#undef Rotate
596#define Rotate Rotate64
597
598STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r) {
599 uint64_t a = (x ^ y) * mul;
600 a ^= (a >> 47);
601 uint64_t b = (y ^ a) * mul;
602 return Rotate(b, r) * mul;
603}
604
605uint64_t Hash64WithSeeds(const char *s, size_t len,
606 uint64_t seed0, uint64_t seed1) {
607 if (len <= 64) {
608 return farmhashna::Hash64WithSeeds(s, len, seed0, seed1);
609 }
610
611 // For strings over 64 bytes we loop. Internal state consists of
612 // 64 bytes: u, v, w, x, y, and z.
613 uint64_t x = seed0;
614 uint64_t y = seed1 * k2 + 113;
615 uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
616 pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
617 pair<uint64_t, uint64_t> w = make_pair(0, 0);
618 uint64_t u = x - z;
619 x *= k2;
620 uint64_t mul = k2 + (u & 0x82);
621
622 // Set end so that after the loop we have 1 to 64 bytes left to process.
623 const char* end = s + ((len - 1) / 64) * 64;
624 const char* last64 = end + ((len - 1) & 63) - 63;
625 assert(s + len - 64 == last64);
626 do {
627 uint64_t a0 = Fetch(s);
628 uint64_t a1 = Fetch(s + 8);
629 uint64_t a2 = Fetch(s + 16);
630 uint64_t a3 = Fetch(s + 24);
631 uint64_t a4 = Fetch(s + 32);
632 uint64_t a5 = Fetch(s + 40);
633 uint64_t a6 = Fetch(s + 48);
634 uint64_t a7 = Fetch(s + 56);
635 x += a0 + a1;
636 y += a2;
637 z += a3;
638 v.first += a4;
639 v.second += a5 + a1;
640 w.first += a6;
641 w.second += a7;
642
643 x = Rotate(x, 26);
644 x *= 9;
645 y = Rotate(y, 29);
646 z *= mul;
647 v.first = Rotate(v.first, 33);
648 v.second = Rotate(v.second, 30);
649 w.first ^= x;
650 w.first *= 9;
651 z = Rotate(z, 32);
652 z += w.second;
653 w.second += z;
654 z *= 9;
655 std::swap(u, y);
656
657 z += a0 + a6;
658 v.first += a2;
659 v.second += a3;
660 w.first += a4;
661 w.second += a5 + a6;
662 x += a1;
663 y += a7;
664
665 y += v.first;
666 v.first += x - y;
667 v.second += w.first;
668 w.first += v.second;
669 w.second += x - y;
670 x += w.second;
671 w.second = Rotate(w.second, 34);
672 std::swap(u, z);
673 s += 64;
674 } while (s != end);
675 // Make s point to the last 64 bytes of input.
676 s = last64;
677 u *= 9;
678 v.second = Rotate(v.second, 28);
679 v.first = Rotate(v.first, 20);
680 w.first += ((len - 1) & 63);
681 u += y;
682 y += u;
683 x = Rotate(y - x + v.first + Fetch(s + 8), 37) * mul;
684 y = Rotate(y ^ v.second ^ Fetch(s + 48), 42) * mul;
685 x ^= w.second * 9;
686 y += v.first + Fetch(s + 40);
687 z = Rotate(z + w.first, 33) * mul;
688 v = farmhashna::WeakHashLen32WithSeeds(s, v.second * mul, x + w.first);
689 w = farmhashna::WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
690 return H(farmhashna::HashLen16(v.first + x, w.first ^ y, mul) + z - u,
691 H(v.second + y, w.second + z, k2, 30) ^ x,
692 k2,
693 31);
694}
695
696uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
697 return len <= 64 ? farmhashna::Hash64WithSeed(s, len, seed) :
698 Hash64WithSeeds(s, len, 0, seed);
699}
700
701uint64_t Hash64(const char *s, size_t len) {
702 return len <= 64 ? farmhashna::Hash64(s, len) :
703 Hash64WithSeeds(s, len, 81, 0);
704}
705} // namespace farmhashuo
706namespace farmhashxo {
707#undef Fetch
708#define Fetch Fetch64
709
710#undef Rotate
711#define Rotate Rotate64
712
713STATIC_INLINE uint64_t H32(const char *s, size_t len, uint64_t mul,
714 uint64_t seed0 = 0, uint64_t seed1 = 0) {
715 uint64_t a = Fetch(s) * k1;
716 uint64_t b = Fetch(s + 8);
717 uint64_t c = Fetch(s + len - 8) * mul;
718 uint64_t d = Fetch(s + len - 16) * k2;
719 uint64_t u = Rotate(a + b, 43) + Rotate(c, 30) + d + seed0;
720 uint64_t v = a + Rotate(b + k2, 18) + c + seed1;
721 a = farmhashna::ShiftMix((u ^ v) * mul);
722 b = farmhashna::ShiftMix((v ^ a) * mul);
723 return b;
724}
725
726// Return an 8-byte hash for 33 to 64 bytes.
727STATIC_INLINE uint64_t HashLen33to64(const char *s, size_t len) {
728 uint64_t mul0 = k2 - 30;
729 uint64_t mul1 = k2 - 30 + 2 * len;
730 uint64_t h0 = H32(s, 32, mul0);
731 uint64_t h1 = H32(s + len - 32, 32, mul1);
732 return ((h1 * mul1) + h0) * mul1;
733}
734
735// Return an 8-byte hash for 65 to 96 bytes.
736STATIC_INLINE uint64_t HashLen65to96(const char *s, size_t len) {
737 uint64_t mul0 = k2 - 114;
738 uint64_t mul1 = k2 - 114 + 2 * len;
739 uint64_t h0 = H32(s, 32, mul0);
740 uint64_t h1 = H32(s + 32, 32, mul1);
741 uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1);
742 return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1;
743}
744
745uint64_t Hash64(const char *s, size_t len) {
746 if (len <= 32) {
747 if (len <= 16) {
748 return farmhashna::HashLen0to16(s, len);
749 } else {
750 return farmhashna::HashLen17to32(s, len);
751 }
752 } else if (len <= 64) {
753 return HashLen33to64(s, len);
754 } else if (len <= 96) {
755 return HashLen65to96(s, len);
756 } else if (len <= 256) {
757 return farmhashna::Hash64(s, len);
758 } else {
759 return farmhashuo::Hash64(s, len);
760 }
761}
762
763uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
764 return farmhashuo::Hash64WithSeeds(s, len, seed0, seed1);
765}
766
767uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
768 return farmhashuo::Hash64WithSeed(s, len, seed);
769}
770} // namespace farmhashxo
771namespace farmhashte {
772#if !can_use_sse41 || !x86_64
773
774uint64_t Hash64(const char *s, size_t len) {
775 FARMHASH_DIE_IF_MISCONFIGURED;
776 return s == NULL ? 0 : len;
777}
778
779uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
780 FARMHASH_DIE_IF_MISCONFIGURED;
781 return seed + Hash64(s, len);
782}
783
784uint64_t Hash64WithSeeds(const char *s, size_t len,
785 uint64_t seed0, uint64_t seed1) {
786 FARMHASH_DIE_IF_MISCONFIGURED;
787 return seed0 + seed1 + Hash64(s, len);
788}
789
790#else
791
792#undef Fetch
793#define Fetch Fetch64
794
795#undef Rotate
796#define Rotate Rotate64
797
798#undef Bswap
799#define Bswap Bswap64
800
801// Helpers for data-parallel operations (1x 128 bits or 2x 64 or 4x 32).
802STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi64(x, y); }
803STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
804STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
805STATIC_INLINE __m128i Shuf(__m128i x, __m128i y) { return _mm_shuffle_epi8(y, x); }
806
807// Requires n >= 256. Requires SSE4.1. Should be slightly faster if the
808// compiler uses AVX instructions (e.g., use the -mavx flag with GCC).
809STATIC_INLINE uint64_t Hash64Long(const char* s, size_t n,
810 uint64_t seed0, uint64_t seed1) {
811 const __m128i kShuf =
812 _mm_set_epi8(4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1);
813 const __m128i kMult =
814 _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03,
815 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51);
816 uint64_t seed2 = (seed0 + 113) * (seed1 + 9);
817 uint64_t seed3 = (Rotate(seed0, 23) + 27) * (Rotate(seed1, 30) + 111);
818 __m128i d0 = _mm_cvtsi64_si128(seed0);
819 __m128i d1 = _mm_cvtsi64_si128(seed1);
820 __m128i d2 = Shuf(kShuf, d0);
821 __m128i d3 = Shuf(kShuf, d1);
822 __m128i d4 = Xor(d0, d1);
823 __m128i d5 = Xor(d1, d2);
824 __m128i d6 = Xor(d2, d4);
825 __m128i d7 = _mm_set1_epi32(seed2 >> 32);
826 __m128i d8 = Mul(kMult, d2);
827 __m128i d9 = _mm_set1_epi32(seed3 >> 32);
828 __m128i d10 = _mm_set1_epi32(seed3);
829 __m128i d11 = Add(d2, _mm_set1_epi32(seed2));
830 const char* end = s + (n & ~static_cast<size_t>(255));
831 do {
832 __m128i z;
833 z = Fetch128(s);
834 d0 = Add(d0, z);
835 d1 = Shuf(kShuf, d1);
836 d2 = Xor(d2, d0);
837 d4 = Xor(d4, z);
838 d4 = Xor(d4, d1);
839 std::swap(d0, d6);
840 z = Fetch128(s + 16);
841 d5 = Add(d5, z);
842 d6 = Shuf(kShuf, d6);
843 d8 = Shuf(kShuf, d8);
844 d7 = Xor(d7, d5);
845 d0 = Xor(d0, z);
846 d0 = Xor(d0, d6);
847 std::swap(d5, d11);
848 z = Fetch128(s + 32);
849 d1 = Add(d1, z);
850 d2 = Shuf(kShuf, d2);
851 d4 = Shuf(kShuf, d4);
852 d5 = Xor(d5, z);
853 d5 = Xor(d5, d2);
854 std::swap(d10, d4);
855 z = Fetch128(s + 48);
856 d6 = Add(d6, z);
857 d7 = Shuf(kShuf, d7);
858 d0 = Shuf(kShuf, d0);
859 d8 = Xor(d8, d6);
860 d1 = Xor(d1, z);
861 d1 = Add(d1, d7);
862 z = Fetch128(s + 64);
863 d2 = Add(d2, z);
864 d5 = Shuf(kShuf, d5);
865 d4 = Add(d4, d2);
866 d6 = Xor(d6, z);
867 d6 = Xor(d6, d11);
868 std::swap(d8, d2);
869 z = Fetch128(s + 80);
870 d7 = Xor(d7, z);
871 d8 = Shuf(kShuf, d8);
872 d1 = Shuf(kShuf, d1);
873 d0 = Add(d0, d7);
874 d2 = Add(d2, z);
875 d2 = Add(d2, d8);
876 std::swap(d1, d7);
877 z = Fetch128(s + 96);
878 d4 = Shuf(kShuf, d4);
879 d6 = Shuf(kShuf, d6);
880 d8 = Mul(kMult, d8);
881 d5 = Xor(d5, d11);
882 d7 = Xor(d7, z);
883 d7 = Add(d7, d4);
884 std::swap(d6, d0);
885 z = Fetch128(s + 112);
886 d8 = Add(d8, z);
887 d0 = Shuf(kShuf, d0);
888 d2 = Shuf(kShuf, d2);
889 d1 = Xor(d1, d8);
890 d10 = Xor(d10, z);
891 d10 = Xor(d10, d0);
892 std::swap(d11, d5);
893 z = Fetch128(s + 128);
894 d4 = Add(d4, z);
895 d5 = Shuf(kShuf, d5);
896 d7 = Shuf(kShuf, d7);
897 d6 = Add(d6, d4);
898 d8 = Xor(d8, z);
899 d8 = Xor(d8, d5);
900 std::swap(d4, d10);
901 z = Fetch128(s + 144);
902 d0 = Add(d0, z);
903 d1 = Shuf(kShuf, d1);
904 d2 = Add(d2, d0);
905 d4 = Xor(d4, z);
906 d4 = Xor(d4, d1);
907 z = Fetch128(s + 160);
908 d5 = Add(d5, z);
909 d6 = Shuf(kShuf, d6);
910 d8 = Shuf(kShuf, d8);
911 d7 = Xor(d7, d5);
912 d0 = Xor(d0, z);
913 d0 = Xor(d0, d6);
914 std::swap(d2, d8);
915 z = Fetch128(s + 176);
916 d1 = Add(d1, z);
917 d2 = Shuf(kShuf, d2);
918 d4 = Shuf(kShuf, d4);
919 d5 = Mul(kMult, d5);
920 d5 = Xor(d5, z);
921 d5 = Xor(d5, d2);
922 std::swap(d7, d1);
923 z = Fetch128(s + 192);
924 d6 = Add(d6, z);
925 d7 = Shuf(kShuf, d7);
926 d0 = Shuf(kShuf, d0);
927 d8 = Add(d8, d6);
928 d1 = Xor(d1, z);
929 d1 = Xor(d1, d7);
930 std::swap(d0, d6);
931 z = Fetch128(s + 208);
932 d2 = Add(d2, z);
933 d5 = Shuf(kShuf, d5);
934 d4 = Xor(d4, d2);
935 d6 = Xor(d6, z);
936 d6 = Xor(d6, d9);
937 std::swap(d5, d11);
938 z = Fetch128(s + 224);
939 d7 = Add(d7, z);
940 d8 = Shuf(kShuf, d8);
941 d1 = Shuf(kShuf, d1);
942 d0 = Xor(d0, d7);
943 d2 = Xor(d2, z);
944 d2 = Xor(d2, d8);
945 std::swap(d10, d4);
946 z = Fetch128(s + 240);
947 d3 = Add(d3, z);
948 d4 = Shuf(kShuf, d4);
949 d6 = Shuf(kShuf, d6);
950 d7 = Mul(kMult, d7);
951 d5 = Add(d5, d3);
952 d7 = Xor(d7, z);
953 d7 = Xor(d7, d4);
954 std::swap(d3, d9);
955 s += 256;
956 } while (s != end);
957 d6 = Add(Mul(kMult, d6), _mm_cvtsi64_si128(n));
958 if (n % 256 != 0) {
959 d7 = Add(_mm_shuffle_epi32(d8, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0)), d7);
960 d8 = Add(Mul(kMult, d8), _mm_cvtsi64_si128(farmhashxo::Hash64(s, n % 256)));
961 }
962 __m128i t[8];
963 d0 = Mul(kMult, Shuf(kShuf, Mul(kMult, d0)));
964 d3 = Mul(kMult, Shuf(kShuf, Mul(kMult, d3)));
965 d9 = Mul(kMult, Shuf(kShuf, Mul(kMult, d9)));
966 d1 = Mul(kMult, Shuf(kShuf, Mul(kMult, d1)));
967 d0 = Add(d11, d0);
968 d3 = Xor(d7, d3);
969 d9 = Add(d8, d9);
970 d1 = Add(d10, d1);
971 d4 = Add(d3, d4);
972 d5 = Add(d9, d5);
973 d6 = Xor(d1, d6);
974 d2 = Add(d0, d2);
975 t[0] = d0;
976 t[1] = d3;
977 t[2] = d9;
978 t[3] = d1;
979 t[4] = d4;
980 t[5] = d5;
981 t[6] = d6;
982 t[7] = d2;
983 return farmhashxo::Hash64(reinterpret_cast<const char*>(t), sizeof(t));
984}
985
986uint64_t Hash64(const char *s, size_t len) {
987 // Empirically, farmhashxo seems faster until length 512.
988 return len >= 512 ? Hash64Long(s, len, k2, k1) : farmhashxo::Hash64(s, len);
989}
990
991uint64_t Hash64WithSeed(const char *s, size_t len, uint64_t seed) {
992 return len >= 512 ? Hash64Long(s, len, k1, seed) :
993 farmhashxo::Hash64WithSeed(s, len, seed);
994}
995
996uint64_t Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1) {
997 return len >= 512 ? Hash64Long(s, len, seed0, seed1) :
998 farmhashxo::Hash64WithSeeds(s, len, seed0, seed1);
999}
1000
1001#endif
1002} // namespace farmhashte
1003namespace farmhashnt {
1004#if !can_use_sse41 || !x86_64
1005
1006uint32_t Hash32(const char *s, size_t len) {
1007 FARMHASH_DIE_IF_MISCONFIGURED;
1008 return s == NULL ? 0 : static_cast<uint32_t>(len);
1009}
1010
1011uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1012 FARMHASH_DIE_IF_MISCONFIGURED;
1013 return seed + Hash32(s, len);
1014}
1015
1016#else
1017
1018uint32_t Hash32(const char *s, size_t len) {
1019 return static_cast<uint32_t>(farmhashte::Hash64(s, len));
1020}
1021
1022uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1023 return static_cast<uint32_t>(farmhashte::Hash64WithSeed(s, len, seed));
1024}
1025
1026#endif
1027} // namespace farmhashnt
1028namespace farmhashmk {
1029#undef Fetch
1030#define Fetch Fetch32
1031
1032#undef Rotate
1033#define Rotate Rotate32
1034
1035#undef Bswap
1036#define Bswap Bswap32
1037
1038STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len, uint32_t seed = 0) {
1039 uint32_t a = Fetch(s - 4 + (len >> 1));
1040 uint32_t b = Fetch(s + 4);
1041 uint32_t c = Fetch(s + len - 8);
1042 uint32_t d = Fetch(s + (len >> 1));
1043 uint32_t e = Fetch(s);
1044 uint32_t f = Fetch(s + len - 4);
1045 uint32_t h = static_cast<uint32_t>(d * c1 + len + seed);
1046 a = Rotate(a, 12) + f;
1047 h = Mur(c, h) + a;
1048 a = Rotate(a, 3) + c;
1049 h = Mur(e, h) + a;
1050 a = Rotate(a + f, 12) + d;
1051 h = Mur(b ^ seed, h) + a;
1052 return fmix(h);
1053}
1054
1055STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len, uint32_t seed = 0) {
1056 uint32_t b = seed;
1057 uint32_t c = 9;
1058 for (size_t i = 0; i < len; i++) {
1059 signed char v = s[i];
1060 b = b * c1 + v;
1061 c ^= b;
1062 }
1063 return fmix(Mur(b, Mur(static_cast<uint32_t>(len), c)));
1064}
1065
1066STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len, uint32_t seed = 0) {
1067 uint32_t a = static_cast<uint32_t>(len), b = static_cast<uint32_t>(len * 5), c = 9, d = b + seed;
1068 a += Fetch(s);
1069 b += Fetch(s + len - 4);
1070 c += Fetch(s + ((len >> 1) & 4));
1071 return fmix(seed ^ Mur(c, Mur(b, Mur(a, d))));
1072}
1073
1074uint32_t Hash32(const char *s, size_t len) {
1075 if (len <= 24) {
1076 return len <= 12 ?
1077 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1078 Hash32Len13to24(s, len);
1079 }
1080
1081 // len > 24
1082 uint32_t h = static_cast<uint32_t>(len), g = static_cast<uint32_t>(c1 * len), f = g;
1083 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1084 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1085 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1086 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1087 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1088 h ^= a0;
1089 h = Rotate(h, 19);
1090 h = h * 5 + 0xe6546b64;
1091 h ^= a2;
1092 h = Rotate(h, 19);
1093 h = h * 5 + 0xe6546b64;
1094 g ^= a1;
1095 g = Rotate(g, 19);
1096 g = g * 5 + 0xe6546b64;
1097 g ^= a3;
1098 g = Rotate(g, 19);
1099 g = g * 5 + 0xe6546b64;
1100 f += a4;
1101 f = Rotate(f, 19) + 113;
1102 size_t iters = (len - 1) / 20;
1103 do {
1104 uint32_t a = Fetch(s);
1105 uint32_t b = Fetch(s + 4);
1106 uint32_t c = Fetch(s + 8);
1107 uint32_t d = Fetch(s + 12);
1108 uint32_t e = Fetch(s + 16);
1109 h += a;
1110 g += b;
1111 f += c;
1112 h = Mur(d, h) + e;
1113 g = Mur(c, g) + a;
1114 f = Mur(b + e * c1, f) + d;
1115 f += g;
1116 g += f;
1117 s += 20;
1118 } while (--iters != 0);
1119 g = Rotate(g, 11) * c1;
1120 g = Rotate(g, 17) * c1;
1121 f = Rotate(f, 11) * c1;
1122 f = Rotate(f, 17) * c1;
1123 h = Rotate(h + g, 19);
1124 h = h * 5 + 0xe6546b64;
1125 h = Rotate(h, 17) * c1;
1126 h = Rotate(h + f, 19);
1127 h = h * 5 + 0xe6546b64;
1128 h = Rotate(h, 17) * c1;
1129 return h;
1130}
1131
1132uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1133 if (len <= 24) {
1134 if (len >= 13) return Hash32Len13to24(s, len, seed * c1);
1135 else if (len >= 5) return Hash32Len5to12(s, len, seed);
1136 else return Hash32Len0to4(s, len, seed);
1137 }
1138 uint32_t h = Hash32Len13to24(s, 24, seed ^ static_cast<uint32_t>(len));
1139 return Mur(Hash32(s + 24, len - 24) + seed, h);
1140}
1141} // namespace farmhashmk
1142namespace farmhashsu {
1143#if !can_use_sse42 || !can_use_aesni
1144
1145uint32_t Hash32(const char *s, size_t len) {
1146 FARMHASH_DIE_IF_MISCONFIGURED;
1147 return s == NULL ? 0 : static_cast<uint32_t>(len);
1148}
1149
1150uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1151 FARMHASH_DIE_IF_MISCONFIGURED;
1152 return seed + Hash32(s, len);
1153}
1154
1155#else
1156
1157#undef Fetch
1158#define Fetch Fetch32
1159
1160#undef Rotate
1161#define Rotate Rotate32
1162
1163#undef Bswap
1164#define Bswap Bswap32
1165
1166// Helpers for data-parallel operations (4x 32-bits).
1167STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1168STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1169STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1170STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1171STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1172STATIC_INLINE __m128i RotateLeft(__m128i x, int c) {
1173 return Or(_mm_slli_epi32(x, c),
1174 _mm_srli_epi32(x, 32 - c));
1175}
1176STATIC_INLINE __m128i Rol17(__m128i x) { return RotateLeft(x, 17); }
1177STATIC_INLINE __m128i Rol19(__m128i x) { return RotateLeft(x, 19); }
1178STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1179 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1180}
1181
1182uint32_t Hash32(const char *s, size_t len) {
1183 const uint32_t seed = 81;
1184 if (len <= 24) {
1185 return len <= 12 ?
1186 (len <= 4 ?
1187 farmhashmk::Hash32Len0to4(s, len) :
1188 farmhashmk::Hash32Len5to12(s, len)) :
1189 farmhashmk::Hash32Len13to24(s, len);
1190 }
1191
1192 if (len < 40) {
1193 uint32_t a = len, b = seed * c2, c = a + b;
1194 a += Fetch(s + len - 4);
1195 b += Fetch(s + len - 20);
1196 c += Fetch(s + len - 16);
1197 uint32_t d = a;
1198 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1199 a = Mur(a, Mur(b, _mm_crc32_u32(c, d)));
1200 a += Fetch(s + len - 12);
1201 b += Fetch(s + len - 8);
1202 d += a;
1203 a += d;
1204 b = Mur(b, d) * c2;
1205 a = _mm_crc32_u32(a, b + c);
1206 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1207 }
1208
1209#undef Mulc1
1210#define Mulc1(x) Mul((x), cc1)
1211
1212#undef Mulc2
1213#define Mulc2(x) Mul((x), cc2)
1214
1215#undef Murk
1216#define Murk(a, h) \
1217 Add(k, \
1218 Mul5( \
1219 Rol19( \
1220 Xor( \
1221 Mulc2( \
1222 Rol17( \
1223 Mulc1(a))), \
1224 (h)))))
1225
1226 const __m128i cc1 = _mm_set1_epi32(c1);
1227 const __m128i cc2 = _mm_set1_epi32(c2);
1228 __m128i h = _mm_set1_epi32(seed);
1229 __m128i g = _mm_set1_epi32(c1 * seed);
1230 __m128i f = g;
1231 __m128i k = _mm_set1_epi32(0xe6546b64);
1232 __m128i q;
1233 if (len < 80) {
1234 __m128i a = Fetch128(s);
1235 __m128i b = Fetch128(s + 16);
1236 __m128i c = Fetch128(s + (len - 15) / 2);
1237 __m128i d = Fetch128(s + len - 32);
1238 __m128i e = Fetch128(s + len - 16);
1239 h = Add(h, a);
1240 g = Add(g, b);
1241 q = g;
1242 g = Shuffle0321(g);
1243 f = Add(f, c);
1244 __m128i be = Add(b, Mulc1(e));
1245 h = Add(h, f);
1246 f = Add(f, h);
1247 h = Add(Murk(d, h), e);
1248 k = Xor(k, _mm_shuffle_epi8(g, f));
1249 g = Add(Xor(c, g), a);
1250 f = Add(Xor(be, f), d);
1251 k = Add(k, be);
1252 k = Add(k, _mm_shuffle_epi8(f, h));
1253 f = Add(f, g);
1254 g = Add(g, f);
1255 g = Add(_mm_set1_epi32(len), Mulc1(g));
1256 } else {
1257 // len >= 80
1258 // The following is loosely modelled after farmhashmk::Hash32.
1259 size_t iters = (len - 1) / 80;
1260 len -= iters * 80;
1261
1262#undef Chunk
1263#define Chunk() do { \
1264 __m128i a = Fetch128(s); \
1265 __m128i b = Fetch128(s + 16); \
1266 __m128i c = Fetch128(s + 32); \
1267 __m128i d = Fetch128(s + 48); \
1268 __m128i e = Fetch128(s + 64); \
1269 h = Add(h, a); \
1270 g = Add(g, b); \
1271 g = Shuffle0321(g); \
1272 f = Add(f, c); \
1273 __m128i be = Add(b, Mulc1(e)); \
1274 h = Add(h, f); \
1275 f = Add(f, h); \
1276 h = Add(h, d); \
1277 q = Add(q, e); \
1278 h = Rol17(h); \
1279 h = Mulc1(h); \
1280 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1281 g = Add(Xor(c, g), a); \
1282 f = Add(Xor(be, f), d); \
1283 std::swap(f, q); \
1284 q = _mm_aesimc_si128(q); \
1285 k = Add(k, be); \
1286 k = Add(k, _mm_shuffle_epi8(f, h)); \
1287 f = Add(f, g); \
1288 g = Add(g, f); \
1289 f = Mulc1(f); \
1290} while (0)
1291
1292 q = g;
1293 while (iters-- != 0) {
1294 Chunk();
1295 s += 80;
1296 }
1297
1298 if (len != 0) {
1299 h = Add(h, _mm_set1_epi32(len));
1300 s = s + len - 80;
1301 Chunk();
1302 }
1303 }
1304
1305 g = Shuffle0321(g);
1306 k = Xor(k, g);
1307 k = Xor(k, q);
1308 h = Xor(h, q);
1309 f = Mulc1(f);
1310 k = Mulc2(k);
1311 g = Mulc1(g);
1312 h = Mulc2(h);
1313 k = Add(k, _mm_shuffle_epi8(g, f));
1314 h = Add(h, f);
1315 f = Add(f, h);
1316 g = Add(g, k);
1317 k = Add(k, g);
1318 k = Xor(k, _mm_shuffle_epi8(f, h));
1319 __m128i buf[4];
1320 buf[0] = f;
1321 buf[1] = g;
1322 buf[2] = k;
1323 buf[3] = h;
1324 s = reinterpret_cast<char*>(buf);
1325 uint32_t x = Fetch(s);
1326 uint32_t y = Fetch(s+4);
1327 uint32_t z = Fetch(s+8);
1328 x = _mm_crc32_u32(x, Fetch(s+12));
1329 y = _mm_crc32_u32(y, Fetch(s+16));
1330 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1331 x = _mm_crc32_u32(x, Fetch(s+24));
1332 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1333 uint32_t o = y;
1334 z = _mm_crc32_u32(z, Fetch(s+32));
1335 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1336 y = _mm_crc32_u32(y, Fetch(s+40));
1337 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1338 x = _mm_crc32_u32(x, Fetch(s+48));
1339 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1340 z = _mm_crc32_u32(z, Fetch(s+56));
1341 x = _mm_crc32_u32(x, Fetch(s+60));
1342 return (o - x + y - z) * c1;
1343}
1344
1345#undef Chunk
1346#undef Murk
1347#undef Mulc2
1348#undef Mulc1
1349
1350uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1351 if (len <= 24) {
1352 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1353 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1354 else return farmhashmk::Hash32Len0to4(s, len, seed);
1355 }
1356 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1357 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1358}
1359
1360#endif
1361} // namespace farmhashsu
1362namespace farmhashsa {
1363#if !can_use_sse42
1364
1365uint32_t Hash32(const char *s, size_t len) {
1366 FARMHASH_DIE_IF_MISCONFIGURED;
1367 return s == NULL ? 0 : static_cast<uint32_t>(len);
1368}
1369
1370uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1371 FARMHASH_DIE_IF_MISCONFIGURED;
1372 return seed + Hash32(s, len);
1373}
1374
1375#else
1376
1377#undef Fetch
1378#define Fetch Fetch32
1379
1380#undef Rotate
1381#define Rotate Rotate32
1382
1383#undef Bswap
1384#define Bswap Bswap32
1385
1386// Helpers for data-parallel operations (4x 32-bits).
1387STATIC_INLINE __m128i Add(__m128i x, __m128i y) { return _mm_add_epi32(x, y); }
1388STATIC_INLINE __m128i Xor(__m128i x, __m128i y) { return _mm_xor_si128(x, y); }
1389STATIC_INLINE __m128i Or(__m128i x, __m128i y) { return _mm_or_si128(x, y); }
1390STATIC_INLINE __m128i Mul(__m128i x, __m128i y) { return _mm_mullo_epi32(x, y); }
1391STATIC_INLINE __m128i Mul5(__m128i x) { return Add(x, _mm_slli_epi32(x, 2)); }
1392STATIC_INLINE __m128i Rotate(__m128i x, int c) {
1393 return Or(_mm_slli_epi32(x, c),
1394 _mm_srli_epi32(x, 32 - c));
1395}
1396STATIC_INLINE __m128i Rot17(__m128i x) { return Rotate(x, 17); }
1397STATIC_INLINE __m128i Rot19(__m128i x) { return Rotate(x, 19); }
1398STATIC_INLINE __m128i Shuffle0321(__m128i x) {
1399 return _mm_shuffle_epi32(x, (0 << 6) + (3 << 4) + (2 << 2) + (1 << 0));
1400}
1401
1402uint32_t Hash32(const char *s, size_t len) {
1403 const uint32_t seed = 81;
1404 if (len <= 24) {
1405 return len <= 12 ?
1406 (len <= 4 ?
1407 farmhashmk::Hash32Len0to4(s, len) :
1408 farmhashmk::Hash32Len5to12(s, len)) :
1409 farmhashmk::Hash32Len13to24(s, len);
1410 }
1411
1412 if (len < 40) {
1413 uint32_t a = len, b = seed * c2, c = a + b;
1414 a += Fetch(s + len - 4);
1415 b += Fetch(s + len - 20);
1416 c += Fetch(s + len - 16);
1417 uint32_t d = a;
1418 a = NAMESPACE_FOR_HASH_FUNCTIONS::Rotate32(a, 21);
1419 a = Mur(a, Mur(b, Mur(c, d)));
1420 a += Fetch(s + len - 12);
1421 b += Fetch(s + len - 8);
1422 d += a;
1423 a += d;
1424 b = Mur(b, d) * c2;
1425 a = _mm_crc32_u32(a, b + c);
1426 return farmhashmk::Hash32Len13to24(s, (len + 1) / 2, a) + b;
1427 }
1428
1429#undef Mulc1
1430#define Mulc1(x) Mul((x), cc1)
1431
1432#undef Mulc2
1433#define Mulc2(x) Mul((x), cc2)
1434
1435#undef Murk
1436#define Murk(a, h) \
1437 Add(k, \
1438 Mul5( \
1439 Rot19( \
1440 Xor( \
1441 Mulc2( \
1442 Rot17( \
1443 Mulc1(a))), \
1444 (h)))))
1445
1446 const __m128i cc1 = _mm_set1_epi32(c1);
1447 const __m128i cc2 = _mm_set1_epi32(c2);
1448 __m128i h = _mm_set1_epi32(seed);
1449 __m128i g = _mm_set1_epi32(c1 * seed);
1450 __m128i f = g;
1451 __m128i k = _mm_set1_epi32(0xe6546b64);
1452 if (len < 80) {
1453 __m128i a = Fetch128(s);
1454 __m128i b = Fetch128(s + 16);
1455 __m128i c = Fetch128(s + (len - 15) / 2);
1456 __m128i d = Fetch128(s + len - 32);
1457 __m128i e = Fetch128(s + len - 16);
1458 h = Add(h, a);
1459 g = Add(g, b);
1460 g = Shuffle0321(g);
1461 f = Add(f, c);
1462 __m128i be = Add(b, Mulc1(e));
1463 h = Add(h, f);
1464 f = Add(f, h);
1465 h = Add(Murk(d, h), e);
1466 k = Xor(k, _mm_shuffle_epi8(g, f));
1467 g = Add(Xor(c, g), a);
1468 f = Add(Xor(be, f), d);
1469 k = Add(k, be);
1470 k = Add(k, _mm_shuffle_epi8(f, h));
1471 f = Add(f, g);
1472 g = Add(g, f);
1473 g = Add(_mm_set1_epi32(len), Mulc1(g));
1474 } else {
1475 // len >= 80
1476 // The following is loosely modelled after farmhashmk::Hash32.
1477 size_t iters = (len - 1) / 80;
1478 len -= iters * 80;
1479
1480#undef Chunk
1481#define Chunk() do { \
1482 __m128i a = Fetch128(s); \
1483 __m128i b = Fetch128(s + 16); \
1484 __m128i c = Fetch128(s + 32); \
1485 __m128i d = Fetch128(s + 48); \
1486 __m128i e = Fetch128(s + 64); \
1487 h = Add(h, a); \
1488 g = Add(g, b); \
1489 g = Shuffle0321(g); \
1490 f = Add(f, c); \
1491 __m128i be = Add(b, Mulc1(e)); \
1492 h = Add(h, f); \
1493 f = Add(f, h); \
1494 h = Add(Murk(d, h), e); \
1495 k = Xor(k, _mm_shuffle_epi8(g, f)); \
1496 g = Add(Xor(c, g), a); \
1497 f = Add(Xor(be, f), d); \
1498 k = Add(k, be); \
1499 k = Add(k, _mm_shuffle_epi8(f, h)); \
1500 f = Add(f, g); \
1501 g = Add(g, f); \
1502 f = Mulc1(f); \
1503} while (0)
1504
1505 while (iters-- != 0) {
1506 Chunk();
1507 s += 80;
1508 }
1509
1510 if (len != 0) {
1511 h = Add(h, _mm_set1_epi32(len));
1512 s = s + len - 80;
1513 Chunk();
1514 }
1515 }
1516
1517 g = Shuffle0321(g);
1518 k = Xor(k, g);
1519 f = Mulc1(f);
1520 k = Mulc2(k);
1521 g = Mulc1(g);
1522 h = Mulc2(h);
1523 k = Add(k, _mm_shuffle_epi8(g, f));
1524 h = Add(h, f);
1525 f = Add(f, h);
1526 g = Add(g, k);
1527 k = Add(k, g);
1528 k = Xor(k, _mm_shuffle_epi8(f, h));
1529 __m128i buf[4];
1530 buf[0] = f;
1531 buf[1] = g;
1532 buf[2] = k;
1533 buf[3] = h;
1534 s = reinterpret_cast<char*>(buf);
1535 uint32_t x = Fetch(s);
1536 uint32_t y = Fetch(s+4);
1537 uint32_t z = Fetch(s+8);
1538 x = _mm_crc32_u32(x, Fetch(s+12));
1539 y = _mm_crc32_u32(y, Fetch(s+16));
1540 z = _mm_crc32_u32(z * c1, Fetch(s+20));
1541 x = _mm_crc32_u32(x, Fetch(s+24));
1542 y = _mm_crc32_u32(y * c1, Fetch(s+28));
1543 uint32_t o = y;
1544 z = _mm_crc32_u32(z, Fetch(s+32));
1545 x = _mm_crc32_u32(x * c1, Fetch(s+36));
1546 y = _mm_crc32_u32(y, Fetch(s+40));
1547 z = _mm_crc32_u32(z * c1, Fetch(s+44));
1548 x = _mm_crc32_u32(x, Fetch(s+48));
1549 y = _mm_crc32_u32(y * c1, Fetch(s+52));
1550 z = _mm_crc32_u32(z, Fetch(s+56));
1551 x = _mm_crc32_u32(x, Fetch(s+60));
1552 return (o - x + y - z) * c1;
1553}
1554
1555#undef Chunk
1556#undef Murk
1557#undef Mulc2
1558#undef Mulc1
1559
1560uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1561 if (len <= 24) {
1562 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1563 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1564 else return farmhashmk::Hash32Len0to4(s, len, seed);
1565 }
1566 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ len);
1567 return _mm_crc32_u32(Hash32(s + 24, len - 24) + seed, h);
1568}
1569
1570#endif
1571} // namespace farmhashsa
1572namespace farmhashcc {
1573// This file provides a 32-bit hash equivalent to CityHash32 (v1.1.1)
1574// and a 128-bit hash equivalent to CityHash128 (v1.1.1). It also provides
1575// a seeded 32-bit hash function similar to CityHash32.
1576
1577#undef Fetch
1578#define Fetch Fetch32
1579
1580#undef Rotate
1581#define Rotate Rotate32
1582
1583#undef Bswap
1584#define Bswap Bswap32
1585
1586STATIC_INLINE uint32_t Hash32Len13to24(const char *s, size_t len) {
1587 uint32_t a = Fetch(s - 4 + (len >> 1));
1588 uint32_t b = Fetch(s + 4);
1589 uint32_t c = Fetch(s + len - 8);
1590 uint32_t d = Fetch(s + (len >> 1));
1591 uint32_t e = Fetch(s);
1592 uint32_t f = Fetch(s + len - 4);
1593 uint32_t h = static_cast<uint32_t>(len);
1594
1595 return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
1596}
1597
1598STATIC_INLINE uint32_t Hash32Len0to4(const char *s, size_t len) {
1599 uint32_t b = 0;
1600 uint32_t c = 9;
1601 for (size_t i = 0; i < len; i++) {
1602 signed char v = s[i];
1603 b = b * c1 + v;
1604 c ^= b;
1605 }
1606 return fmix(Mur(b, Mur(static_cast<uint32_t>(len), c)));
1607}
1608
1609STATIC_INLINE uint32_t Hash32Len5to12(const char *s, size_t len) {
1610 uint32_t a = static_cast<uint32_t>(len), b = static_cast<uint32_t>(len * 5), c = 9, d = b;
1611 a += Fetch(s);
1612 b += Fetch(s + len - 4);
1613 c += Fetch(s + ((len >> 1) & 4));
1614 return fmix(Mur(c, Mur(b, Mur(a, d))));
1615}
1616
1617uint32_t Hash32(const char *s, size_t len) {
1618 if (len <= 24) {
1619 return len <= 12 ?
1620 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
1621 Hash32Len13to24(s, len);
1622 }
1623
1624 // len > 24
1625 uint32_t h = static_cast<uint32_t>(len), g = static_cast<uint32_t>(c1 * len), f = g;
1626 uint32_t a0 = Rotate(Fetch(s + len - 4) * c1, 17) * c2;
1627 uint32_t a1 = Rotate(Fetch(s + len - 8) * c1, 17) * c2;
1628 uint32_t a2 = Rotate(Fetch(s + len - 16) * c1, 17) * c2;
1629 uint32_t a3 = Rotate(Fetch(s + len - 12) * c1, 17) * c2;
1630 uint32_t a4 = Rotate(Fetch(s + len - 20) * c1, 17) * c2;
1631 h ^= a0;
1632 h = Rotate(h, 19);
1633 h = h * 5 + 0xe6546b64;
1634 h ^= a2;
1635 h = Rotate(h, 19);
1636 h = h * 5 + 0xe6546b64;
1637 g ^= a1;
1638 g = Rotate(g, 19);
1639 g = g * 5 + 0xe6546b64;
1640 g ^= a3;
1641 g = Rotate(g, 19);
1642 g = g * 5 + 0xe6546b64;
1643 f += a4;
1644 f = Rotate(f, 19);
1645 f = f * 5 + 0xe6546b64;
1646 size_t iters = (len - 1) / 20;
1647 do {
1648 uint32_t a0 = Rotate(Fetch(s) * c1, 17) * c2;
1649 uint32_t a1 = Fetch(s + 4);
1650 uint32_t a2 = Rotate(Fetch(s + 8) * c1, 17) * c2;
1651 uint32_t a3 = Rotate(Fetch(s + 12) * c1, 17) * c2;
1652 uint32_t a4 = Fetch(s + 16);
1653 h ^= a0;
1654 h = Rotate(h, 18);
1655 h = h * 5 + 0xe6546b64;
1656 f += a1;
1657 f = Rotate(f, 19);
1658 f = f * c1;
1659 g += a2;
1660 g = Rotate(g, 18);
1661 g = g * 5 + 0xe6546b64;
1662 h ^= a3 + a1;
1663 h = Rotate(h, 19);
1664 h = h * 5 + 0xe6546b64;
1665 g ^= a4;
1666 g = Bswap(g) * 5;
1667 h += a4 * 5;
1668 h = Bswap(h);
1669 f += a0;
1670 PERMUTE3(f, h, g);
1671 s += 20;
1672 } while (--iters != 0);
1673 g = Rotate(g, 11) * c1;
1674 g = Rotate(g, 17) * c1;
1675 f = Rotate(f, 11) * c1;
1676 f = Rotate(f, 17) * c1;
1677 h = Rotate(h + g, 19);
1678 h = h * 5 + 0xe6546b64;
1679 h = Rotate(h, 17) * c1;
1680 h = Rotate(h + f, 19);
1681 h = h * 5 + 0xe6546b64;
1682 h = Rotate(h, 17) * c1;
1683 return h;
1684}
1685
1686uint32_t Hash32WithSeed(const char *s, size_t len, uint32_t seed) {
1687 if (len <= 24) {
1688 if (len >= 13) return farmhashmk::Hash32Len13to24(s, len, seed * c1);
1689 else if (len >= 5) return farmhashmk::Hash32Len5to12(s, len, seed);
1690 else return farmhashmk::Hash32Len0to4(s, len, seed);
1691 }
1692 uint32_t h = farmhashmk::Hash32Len13to24(s, 24, seed ^ static_cast<uint32_t>(len));
1693 return Mur(Hash32(s + 24, len - 24) + seed, h);
1694}
1695
1696#undef Fetch
1697#define Fetch Fetch64
1698
1699#undef Rotate
1700#define Rotate Rotate64
1701
1702#undef Bswap
1703#define Bswap Bswap64
1704
1705STATIC_INLINE uint64_t ShiftMix(uint64_t val) {
1706 return val ^ (val >> 47);
1707}
1708
1709STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v) {
1710 return Hash128to64(Uint128(u, v));
1711}
1712
1713STATIC_INLINE uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
1714 // Murmur-inspired hashing.
1715 uint64_t a = (u ^ v) * mul;
1716 a ^= (a >> 47);
1717 uint64_t b = (v ^ a) * mul;
1718 b ^= (b >> 47);
1719 b *= mul;
1720 return b;
1721}
1722
1723STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
1724 if (len >= 8) {
1725 uint64_t mul = k2 + len * 2;
1726 uint64_t a = Fetch(s) + k2;
1727 uint64_t b = Fetch(s + len - 8);
1728 uint64_t c = Rotate(b, 37) * mul + a;
1729 uint64_t d = (Rotate(a, 25) + b) * mul;
1730 return HashLen16(c, d, mul);
1731 }
1732 if (len >= 4) {
1733 uint64_t mul = k2 + len * 2;
1734 uint64_t a = Fetch32(s);
1735 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
1736 }
1737 if (len > 0) {
1738 uint8_t a = s[0];
1739 uint8_t b = s[len >> 1];
1740 uint8_t c = s[len - 1];
1741 uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
1742 uint32_t z = static_cast<uint32_t>(len + (static_cast<uint32_t>(c) << 2));
1743 return ShiftMix(y * k2 ^ z * k0) * k2;
1744 }
1745 return k2;
1746}
1747
1748// Return a 16-byte hash for 48 bytes. Quick and dirty.
1749// Callers do best to use "random-looking" values for a and b.
1750STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1751 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
1752 a += w;
1753 b = Rotate(b + a + z, 21);
1754 uint64_t c = a;
1755 a += x;
1756 a += y;
1757 b += Rotate(a, 44);
1758 return make_pair(a + z, b + c);
1759}
1760
1761// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
1762STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
1763 const char* s, uint64_t a, uint64_t b) {
1764 return WeakHashLen32WithSeeds(Fetch(s),
1765 Fetch(s + 8),
1766 Fetch(s + 16),
1767 Fetch(s + 24),
1768 a,
1769 b);
1770}
1771
1772
1773
1774// A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
1775// of any length representable in signed long. Based on City and Murmur.
1776STATIC_INLINE NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t CityMurmur(const char *s, size_t len, NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t seed) {
1777 uint64_t a = Uint128Low64(seed);
1778 uint64_t b = Uint128High64(seed);
1779 uint64_t c = 0;
1780 uint64_t d = 0;
1781 signed long l = static_cast<signed long>(len) - 16;
1782 if (l <= 0) { // len <= 16
1783 a = ShiftMix(a * k1) * k1;
1784 c = b * k1 + HashLen0to16(s, len);
1785 d = ShiftMix(a + (len >= 8 ? Fetch(s) : c));
1786 } else { // len > 16
1787 c = HashLen16(Fetch(s + len - 8) + k1, a);
1788 d = HashLen16(b + len, c + Fetch(s + len - 16));
1789 a += d;
1790 do {
1791 a ^= ShiftMix(Fetch(s) * k1) * k1;
1792 a *= k1;
1793 b ^= a;
1794 c ^= ShiftMix(Fetch(s + 8) * k1) * k1;
1795 c *= k1;
1796 d ^= c;
1797 s += 16;
1798 l -= 16;
1799 } while (l > 0);
1800 }
1801 a = HashLen16(a, c);
1802 b = HashLen16(d, b);
1803 return Uint128(a ^ b, HashLen16(b, a));
1804}
1805
1806NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t CityHash128WithSeed(const char *s, size_t len, NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t seed) {
1807 if (len < 128) {
1808 return CityMurmur(s, len, seed);
1809 }
1810
1811 // We expect len >= 128 to be the common case. Keep 56 bytes of state:
1812 // v, w, x, y, and z.
1813 pair<uint64_t, uint64_t> v, w;
1814 uint64_t x = Uint128Low64(seed);
1815 uint64_t y = Uint128High64(seed);
1816 uint64_t z = len * k1;
1817 v.first = Rotate(y ^ k1, 49) * k1 + Fetch(s);
1818 v.second = Rotate(v.first, 42) * k1 + Fetch(s + 8);
1819 w.first = Rotate(y + z, 35) * k1 + x;
1820 w.second = Rotate(x + Fetch(s + 88), 53) * k1;
1821
1822 // This is the same inner loop as CityHash64(), manually unrolled.
1823 do {
1824 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1825 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1826 x ^= w.second;
1827 y += v.first + Fetch(s + 40);
1828 z = Rotate(z + w.first, 33) * k1;
1829 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1830 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1831 std::swap(z, x);
1832 s += 64;
1833 x = Rotate(x + y + v.first + Fetch(s + 8), 37) * k1;
1834 y = Rotate(y + v.second + Fetch(s + 48), 42) * k1;
1835 x ^= w.second;
1836 y += v.first + Fetch(s + 40);
1837 z = Rotate(z + w.first, 33) * k1;
1838 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
1839 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch(s + 16));
1840 std::swap(z, x);
1841 s += 64;
1842 len -= 128;
1843 } while (LIKELY(len >= 128));
1844 x += Rotate(v.first + z, 49) * k0;
1845 y = y * k0 + Rotate(w.second, 37);
1846 z = z * k0 + Rotate(w.first, 27);
1847 w.first *= 9;
1848 v.first *= k0;
1849 // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
1850 for (size_t tail_done = 0; tail_done < len; ) {
1851 tail_done += 32;
1852 y = Rotate(x + y, 42) * k0 + v.second;
1853 w.first += Fetch(s + len - tail_done + 16);
1854 x = x * k0 + w.first;
1855 z += w.second + Fetch(s + len - tail_done);
1856 w.second += v.first;
1857 v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
1858 v.first *= k0;
1859 }
1860 // At this point our 56 bytes of state should contain more than
1861 // enough information for a strong 128-bit hash. We use two
1862 // different 56-byte-to-8-byte hashes to get a 16-byte final result.
1863 x = HashLen16(x, v.first);
1864 y = HashLen16(y + z, w.first);
1865 return Uint128(HashLen16(x + v.second, w.second) + y,
1866 HashLen16(x + w.second, y + v.second));
1867}
1868
1869STATIC_INLINE NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t CityHash128(const char *s, size_t len) {
1870 return len >= 16 ?
1871 CityHash128WithSeed(s + 16, len - 16,
1872 Uint128(Fetch(s), Fetch(s + 8) + k0)) :
1873 CityHash128WithSeed(s, len, Uint128(k0, k1));
1874}
1875
1876NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Fingerprint128(const char* s, size_t len) {
1877 return CityHash128(s, len);
1878}
1879} // namespace farmhashcc
1880namespace NAMESPACE_FOR_HASH_FUNCTIONS {
1881
1882// BASIC STRING HASHING
1883
1884// Hash function for a byte array. See also Hash(), below.
1885// May change from time to time, may differ on different platforms, may differ
1886// depending on NDEBUG.
1887uint32_t Hash32(const char* s, size_t len) {
1888 return DebugTweak(
1889 (can_use_sse41 & x86_64) ? farmhashnt::Hash32(s, len) :
1890 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32(s, len) :
1891 can_use_sse42 ? farmhashsa::Hash32(s, len) :
1892 farmhashmk::Hash32(s, len));
1893}
1894
1895// Hash function for a byte array. For convenience, a 32-bit seed is also
1896// hashed into the result.
1897// May change from time to time, may differ on different platforms, may differ
1898// depending on NDEBUG.
1899uint32_t Hash32WithSeed(const char* s, size_t len, uint32_t seed) {
1900 return DebugTweak(
1901 (can_use_sse41 & x86_64) ? farmhashnt::Hash32WithSeed(s, len, seed) :
1902 (can_use_sse42 & can_use_aesni) ? farmhashsu::Hash32WithSeed(s, len, seed) :
1903 can_use_sse42 ? farmhashsa::Hash32WithSeed(s, len, seed) :
1904 farmhashmk::Hash32WithSeed(s, len, seed));
1905}
1906
1907// Hash function for a byte array. For convenience, a 64-bit seed is also
1908// hashed into the result. See also Hash(), below.
1909// May change from time to time, may differ on different platforms, may differ
1910// depending on NDEBUG.
1911uint64_t Hash64(const char* s, size_t len) {
1912 return DebugTweak(
1913 (can_use_sse42 & x86_64) ?
1914 farmhashte::Hash64(s, len) :
1915 farmhashxo::Hash64(s, len));
1916}
1917
1918// Hash function for a byte array.
1919// May change from time to time, may differ on different platforms, may differ
1920// depending on NDEBUG.
1921size_t Hash(const char* s, size_t len) {
1922 return sizeof(size_t) == 8 ? Hash64(s, len) : Hash32(s, len);
1923}
1924
1925// Hash function for a byte array. For convenience, a 64-bit seed is also
1926// hashed into the result.
1927// May change from time to time, may differ on different platforms, may differ
1928// depending on NDEBUG.
1929uint64_t Hash64WithSeed(const char* s, size_t len, uint64_t seed) {
1930 return DebugTweak(farmhashna::Hash64WithSeed(s, len, seed));
1931}
1932
1933// Hash function for a byte array. For convenience, two seeds are also
1934// hashed into the result.
1935// May change from time to time, may differ on different platforms, may differ
1936// depending on NDEBUG.
1937uint64_t Hash64WithSeeds(const char* s, size_t len, uint64_t seed0, uint64_t seed1) {
1938 return DebugTweak(farmhashna::Hash64WithSeeds(s, len, seed0, seed1));
1939}
1940
1941// Hash function for a byte array.
1942// May change from time to time, may differ on different platforms, may differ
1943// depending on NDEBUG.
1944NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Hash128(const char* s, size_t len) {
1945 return DebugTweak(farmhashcc::Fingerprint128(s, len));
1946}
1947
1948// Hash function for a byte array. For convenience, a 128-bit seed is also
1949// hashed into the result.
1950// May change from time to time, may differ on different platforms, may differ
1951// depending on NDEBUG.
1952NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Hash128WithSeed(const char* s, size_t len, NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t seed) {
1953 return DebugTweak(farmhashcc::CityHash128WithSeed(s, len, seed));
1954}
1955
1956// BASIC NON-STRING HASHING
1957
1958// FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
1959
1960// Fingerprint function for a byte array. Most useful in 32-bit binaries.
1961uint32_t Fingerprint32(const char* s, size_t len) {
1962 return farmhashmk::Hash32(s, len);
1963}
1964
1965// Fingerprint function for a byte array.
1966uint64_t Fingerprint64(const char* s, size_t len) {
1967 return farmhashna::Hash64(s, len);
1968}
1969
1970// Fingerprint function for a byte array.
1971NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t Fingerprint128(const char* s, size_t len) {
1972 return farmhashcc::Fingerprint128(s, len);
1973}
1974
1975// Older and still available but perhaps not as fast as the above:
1976// farmhashns::Hash32{,WithSeed}()
1977
1978} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
1979
1980#if FARMHASHSELFTEST
1981
1982#ifndef FARMHASH_SELF_TEST_GUARD
1983#define FARMHASH_SELF_TEST_GUARD
1984#include <cstdio>
1985#include <iostream>
1986#include <string.h>
1987
1988using std::cout;
1989using std::cerr;
1990using std::endl;
1991using std::hex;
1992
1993static const uint64_t kSeed0 = 1234567;
1994static const uint64_t kSeed1 = k0;
1995static const int kDataSize = 1 << 20;
1996static const int kTestSize = 300;
1997#define kSeed128 Uint128(kSeed0, kSeed1)
1998
1999static char data[kDataSize];
2000
2001static int completed_self_tests = 0;
2002static int errors = 0;
2003
2004// Initialize data to pseudorandom values.
2005void Setup() {
2006 if (completed_self_tests == 0) {
2007 uint64_t a = 9;
2008 uint64_t b = 777;
2009 for (int i = 0; i < kDataSize; i++) {
2010 a += b;
2011 b += a;
2012 a = (a ^ (a >> 41)) * k0;
2013 b = (b ^ (b >> 41)) * k0 + i;
2014 uint8_t u = b >> 37;
2015 memcpy(data + i, &u, 1); // uint8_t -> char
2016 }
2017 }
2018}
2019
2020int NoteErrors() {
2021#define NUM_SELF_TESTS 9
2022 if (++completed_self_tests == NUM_SELF_TESTS)
2023 std::exit(errors > 0);
2024 return errors;
2025}
2026
2027template <typename T> inline bool IsNonZero(T x) {
2028 return x != 0;
2029}
2030
2031template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
2032 return x != Uint128(0, 0);
2033}
2034
2035#endif // FARMHASH_SELF_TEST_GUARD
2036
2037namespace farmhashccTest {
2038
2039uint32_t CreateSeed(int offset, int salt) {
2040 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
2041 h = h * c1;
2042 h ^= (h >> 17);
2043 h = h * c1;
2044 h ^= (h >> 17);
2045 h = h * c1;
2046 h ^= (h >> 17);
2047 h += static_cast<uint32_t>(offset & 0xffffffff);
2048 h = h * c1;
2049 h ^= (h >> 17);
2050 h = h * c1;
2051 h ^= (h >> 17);
2052 h = h * c1;
2053 h ^= (h >> 17);
2054 return h;
2055}
2056
2057#undef SEED
2058#undef SEED1
2059#undef SEED0
2060#define SEED CreateSeed(offset, -1)
2061#define SEED0 CreateSeed(offset, 0)
2062#define SEED1 CreateSeed(offset, 1)
2063
2064#undef TESTING
2065#define TESTING 1
2066#if TESTING
2067uint32_t expected[] = {
20684223616069u,
20693696677242u,
20701039179260u, 1690343979u, 1018511555u, 2464489001u,
207120368522u, 2663783964u, 175201532u, 1619210592u,
20724081014168u,
20732576519988u,
20743285042206u, 502478099u, 739479538u, 1500332790u,
207513754768u, 3789353455u, 3473868058u, 1909255088u,
20762212771159u,
20771112731063u,
2078826915357u, 2893489933u, 118369799u, 1848668220u,
20791308219822u, 249416982u, 64306364u, 4221800195u,
20801020067935u,
20813955445564u,
2082563346294u, 550236731u, 2339016688u, 1826259714u,
20833872358639u, 2295981050u, 1870005390u, 4015628802u,
20841451961420u,
2085653440099u,
20861292493871u, 164377749u, 1717712483u, 463414587u,
20873924343675u, 1050492084u, 3566618804u, 2046983362u,
208831917516u,
20892957164615u,
2090230718965u, 999595115u, 3534822176u, 2175709186u,
2091965707431u, 441796222u, 2481718051u, 1827777486u,
20922590087362u,
20933879448744u,
20943515079898u, 1601433082u, 982764532u, 254808716u,
20951293372530u, 4205605817u, 947001462u, 1138890052u,
2096176305566u,
20972447367541u,
20982973802542u, 4123621138u, 3083865840u, 1706367795u,
2099792114347u, 2880110657u, 440613768u, 195054868u,
21001359016305u,
21013363804638u,
2102649488537u, 1624045597u, 1441938215u, 3147758996u,
21033199173578u, 2597283203u, 2191333609u, 3763129144u,
21041117290165u,
21051062549743u,
21062565615889u, 1046361554u, 1581968261u, 1058773671u,
21071123053168u, 3807622275u, 1486749916u, 3900816089u,
21082437877004u,
21091894455839u,
21101912520953u, 1914997013u, 561048608u, 1643267444u,
21113671572006u, 194811086u, 1468911468u, 2179206286u,
2112673206794u,
21133486923651u,
21143741426466u, 3292160512u, 697001377u, 1900763774u,
21153726097344u, 629282039u, 3578723715u, 2868028489u,
21163269862919u,
21172303349487u,
21183643953525u, 2307255916u, 849996280u, 732080434u,
2119909961480u, 3542445214u, 2628347095u, 4236856917u,
21201380660650u,
21212631821908u,
21222007289004u, 3509705198u, 3788541675u, 789457322u,
21233090670546u, 638977894u, 3503881773u, 947102987u,
21241525325287u,
21251816697045u,
21262706647405u, 288763142u, 3505438495u, 481308609u,
21272882636782u, 3745162621u, 3503467033u, 428247823u,
2128176408838u,
2129333551502u,
21301001068721u, 1681483651u, 75380831u, 4191469679u,
21313627361839u, 2736617386u, 3120737438u, 1297502456u,
2132864896482u,
213385674920u,
21342886047255u, 4119881331u, 2496990525u, 3442502055u,
21351806582817u, 3186345024u, 4099591287u, 2560171465u,
21363489229104u,
21373065015872u,
21382755089808u, 3098442882u, 378524719u, 2664097023u,
21391771960725u, 2901182183u, 55258521u, 1266621443u,
2140581644891u,
214137790450u,
21421800731704u, 3601350920u, 53428754u, 2759476837u,
21433391093099u, 1496510311u, 2511119507u, 2636877410u,
2144631613207u,
21451573846064u,
2146260484875u, 1088212603u, 2369525206u, 322522428u,
21473191396600u, 2076543340u, 1552496658u, 2739811558u,
21483867875546u,
21492051584261u,
21502126250818u, 901517871u, 3651631165u, 1323139145u,
21511521111765u, 477802997u, 3508559783u, 383954241u,
21523804516756u,
21534250206331u,
21542655954340u, 2484996477u, 1417544845u, 1520282298u,
21552745204366u, 2869345147u, 1872738335u, 2592877343u,
21561619744564u,
21571804962124u,
21583458679890u, 423948620u, 273645618u, 4187865426u,
2159376057175u, 2943431463u, 3581950599u, 1035398331u,
21601088213445u,
2161861988903u,
21621323370244u, 777069428u, 506235917u, 369720851u,
21632789995854u, 230915180u, 1505086948u, 940361236u,
21643727873235u,
21651159167499u,
21661860302871u, 3456858862u, 3923555152u, 2131072714u,
21672910461068u, 3671950363u, 2010742682u, 4088068851u,
21683616470388u,
21692087714788u,
2170221675509u, 1230154072u, 3450704646u, 1463226695u,
21711998357699u, 266026801u, 619568740u, 3560427266u,
21724148162586u,
21733150417316u,
21741356375822u, 2056097622u, 627905802u, 3881675638u,
21752309738053u, 971916703u, 3447805361u, 1673575328u,
2176673084328u,
21773317849401u,
21782836362782u, 2377208890u, 3275350588u, 158350552u,
21792553241779u, 2497264995u, 3262882649u, 3897937187u,
21801598963653u,
21813068514414u,
2182601541505u, 374517071u, 3380795976u, 235752573u,
2183284670003u, 2990192160u, 904937105u, 2306579150u,
21842117362589u,
21851635274830u,
21863355572906u, 170799903u, 1226685528u, 664567688u,
2187413219134u, 878324258u, 4026159448u, 3620649295u,
21881823625377u,
21893175888439u,
21901759344347u, 2640637095u, 3549558u, 2192984935u,
2191978623493u, 804017880u, 3877562323u, 3843116489u,
21921641748342u,
21931853539444u,
21943001178468u, 3443560727u, 2685426077u, 1653064722u,
2195349231508u, 2726789654u, 3136215581u, 768402830u,
2196269384321u,
2197531936536u,
21982592883487u, 1343156334u, 3628619802u, 1477143570u,
21994269458419u, 3285611028u, 959104925u, 2712290710u,
22003480237248u,
2201835796333u,
22022020636251u, 1191914589u, 126521603u, 4288023938u,
22033731699932u, 2136758855u, 985780142u, 193807575u,
22041850544433u,
2205653947619u,
22063929316796u, 381871169u, 950486363u, 1787262279u,
2207360480382u, 1800636585u, 1039258631u, 3682073259u,
22081262819303u,
22091786000319u,
22101570627191u, 893065837u, 301304916u, 1478469809u,
2211623018819u, 2742232545u, 2058913014u, 1706060059u,
22122421125401u,
22131315829592u,
22143208766775u, 1805586156u, 575853086u, 3085025513u,
22154010908260u, 2344058256u, 3814407434u, 1458485673u,
22162474514786u,
22173581895658u,
22182710719679u, 190812706u, 2135454262u, 2620080728u,
22193400757986u, 1669914857u, 1559978393u, 1629811331u,
22203096616493u,
22211391424435u,
22224158376003u, 1015657076u, 794783832u, 479952178u,
22231150290207u, 2497437906u, 231815090u, 755078067u,
22243832053281u,
222563649475u,
22262415822606u, 4105027719u, 1706992318u, 1106598740u,
22273941945667u, 1271300761u, 505882259u, 760186809u,
22282657183368u,
22291925422058u,
22301039773764u, 880219458u, 4275949176u, 1556833823u,
2231925882132u, 4216310340u, 757497522u, 461833914u,
22323884002070u,
22332790957660u,
22342100050089u, 651959176u, 1380301291u, 1289124125u,
2235452314403u, 226156280u, 3306924715u, 1750807758u,
22362290180542u,
22371953760569u,
22382253069096u, 3960924806u, 1786291620u, 60736185u,
22392569018293u, 3870479674u, 2247005661u, 2239850953u,
22404261808536u,
22413282975782u,
2242780945879u, 3349849383u, 1579362556u, 2265045884u,
2243905088740u, 725212379u, 3156479246u, 2501620391u,
22443062836263u,
22454070422690u,
2246996797869u, 4082582315u, 976105756u, 303983602u,
22471862104804u, 3864508254u, 3383979677u, 2835500286u,
22482798364010u,
2249519359476u,
22503447342725u, 194373889u, 3313466630u, 232399983u,
22512841787856u, 1672751454u, 3345183154u, 1805381384u,
22522226129336u,
22532847829057u,
22542350774567u, 2838540121u, 2757948482u, 1017002062u,
22552329150951u, 2171488196u, 3668619047u, 3874977844u,
22563287966998u,
2257262346753u,
22582493054715u, 2298644430u, 2926101182u, 1528457638u,
2259598656233u, 2615845874u, 989110727u, 820441411u,
2260253617372u,
22612201077208u,
22622047569338u, 3114356329u, 3335563734u, 2967673540u,
2263768438341u, 1417708203u, 3873718246u, 1538441843u,
22641279167650u,
22653917966776u,
22662218481734u, 1015935150u, 1957845042u, 1318150213u,
22673146423971u, 4218994877u, 1162470863u, 1519718292u,
22682594658906u,
2269665870414u,
22703430347817u, 3933868731u, 1597041394u, 3138684682u,
22713398212027u, 1064647658u, 1576321132u, 14792918u,
2272224938029u,
22733706456050u,
2274847274786u, 2645698692u, 1743374687u, 2343133224u,
22753066596790u, 2857270120u, 200596308u, 452055528u,
22762319312082u,
22773488655402u,
22784146865894u, 608206438u, 2699777051u, 3687240713u,
2279327957508u, 3664730153u, 568134564u, 2993484554u,
22804159860363u,
22814274533921u,
22821079994063u, 2360220210u, 3609597760u, 3639708902u,
22832836180437u, 1069910270u, 1892427666u, 1874729790u,
22841267712826u,
2285121886940u,
22863572289214u, 2475945610u, 783779452u, 588827737u,
22871531395014u, 2085084212u, 2219189792u, 3981444548u,
22882218885336u,
22891691622694u,
22902053232885u, 1386558530u, 2182946189u, 2365247285u,
22911871081313u, 2935751853u, 38413723u, 543465863u,
2292900691890u,
22932899905665u,
2294575120562u, 93133904u, 457154948u, 2983705792u,
22954232229200u, 2038565963u, 614693984u, 3405328302u,
22964083090010u,
22972088004171u,
2298244031209u, 1861889294u, 2417109253u, 3299562328u,
22994158642443u, 4199064449u, 3161611046u, 885015950u,
23003677904099u,
23012969861785u,
2302772348805u, 1712263832u, 3219357614u, 484271305u,
23033645706114u, 2059620251u, 409557488u, 2278896731u,
2304224475749u,
23053523022952u,
23062057140088u, 449131785u, 1149879244u, 4255363996u,
23073602720135u, 1690010854u, 2503998822u, 2750828466u,
23083340671802u,
23091447583863u,
23102649684943u, 2764747249u, 3046070595u, 3441726138u,
23113840332559u, 3156747501u, 1288666680u, 1472744459u,
23123452391933u,
23131617542784u,
2314217869690u, 3718469527u, 348639731u, 590532355u,
231543789787u, 22606314u, 1621559290u, 2231743261u,
23162234620879u,
2317544748955u,
23183169387920u, 203343594u, 3272552527u, 1078282365u,
2319809576321u, 854207584u, 3625491053u, 1193737267u,
23201628966807u,
23212661421060u,
23222433442061u, 3886639039u, 2149304418u, 303000565u,
23231432830882u, 137378235u, 1135974068u, 318705754u,
23242491227157u,
23252627534472u,
23263520352233u, 2488397682u, 3969194920u, 3843962181u,
23272135981459u, 2611933220u, 799460731u, 2300968851u,
23283412851628u,
23293070914013u,
23303555224260u, 4125937572u, 240359903u, 722496673u,
23312061023600u, 3843919221u, 2759960043u, 1191155322u,
23321504041490u,
23333735253656u,
23341773124736u, 101110011u, 1627699578u, 2645634551u,
2335263603947u, 1388368439u, 677146538u, 1644201982u,
23362625699644u,
23372403862553u,
23382426069017u, 3613511705u, 915141802u, 2981654265u,
23393474818167u, 2611101773u, 627891434u, 762754924u,
23402143021902u,
234151067670u,
23424017746573u, 2269879853u, 3037857950u, 2388899692u,
2343582729171u, 1886116725u, 2281219772u, 264704948u,
23443509984037u,
23454078683368u,
23462172959411u, 1807195632u, 3357092302u, 2253764928u,
23472320369390u, 3076335959u, 2623583210u, 168378015u,
23481435562650u,
23491100977467u,
23503160490319u, 2550328495u, 2396855930u, 1347823908u,
23511617990918u, 3849653099u, 3224111576u, 1681539821u,
23524171542880u,
2353552200045u,
23543562947778u, 1676237880u, 3747732307u, 2453332913u,
2355865530667u, 3566636849u, 3485502777u, 336779723u,
23562535942410u,
23571685000184u,
2358820545711u, 1893670486u, 1273910461u, 1193758569u,
2359970365241u, 381205962u, 3612810852u, 1160577445u,
2360541488143u,
23614005031080u,
23622333965236u, 2419855455u, 3484533538u, 3073937876u,
2363908466956u, 661391539u, 2342122412u, 1467049112u,
23641785800827u,
2365135343033u,
2366139643209u, 2438375667u, 974654058u, 3216478230u,
23673807620420u, 779043363u, 2812846449u, 333254784u,
23681025244024u,
23692242303095u,
23702476683742u, 350018683u, 174652916u, 933097576u,
2371826905896u, 559603581u, 2777181260u, 164915169u,
23724070353203u,
23731459055748u,
2374297303985u, 3103837241u, 3812514233u, 232265137u,
23752032819099u, 1523091376u, 3531238208u, 1403510182u,
23762886832080u,
23772599705941u,
23782789695716u, 68437968u, 3823813791u, 1040994569u,
23793024194990u, 2461740520u, 3735391266u, 2042207153u,
23802461678616u,
23813519231840u,
23821344224923u, 411442756u, 1179779351u, 7661528u,
2383778352196u, 3288808867u, 589356197u, 2627504511u,
23843374744599u,
23853312172905u,
2386357423007u, 3539567796u, 4044452215u, 1445118403u,
23872937983820u, 184089910u, 346201845u, 2427295202u,
23881345448010u,
23892884434843u,
23903085001879u, 2640105409u, 315310640u, 3530289798u,
23913362974764u, 963602652u, 75228477u, 3509381180u,
23924012777756u,
23932380345941u,
23941073137836u, 2083960378u, 1220315185u, 3628720934u,
23953508867818u, 67148343u, 3558085158u, 1753943368u,
2396863309561u,
23972844713625u,
2398441921850u, 854732254u, 816793316u, 2555428747u,
23993440623414u, 1707304366u, 3189874375u, 1623229221u,
24001220335976u,
2401806745430u,
24023909262947u, 1680369031u, 2926179486u, 3410391660u,
24033991630434u, 2876458763u, 1179167079u, 536360759u,
24041592117159u,
24051514343977u,
24061032622306u, 2057494855u, 784938958u, 178402996u,
24071152907972u, 2326185495u, 2939973666u, 4181120253u,
2408552831733u,
2409664251856u,
24101297139539u, 1969357631u, 1474065957u, 3055419017u,
24113395829380u, 3316562752u, 2168409017u, 614624786u,
24123585854336u,
2413668291094u,
24141162889217u, 3773171307u, 2263271126u, 355089668u,
24153195850578u, 3396793277u, 3519870267u, 527857605u,
24163972392320u,
24172224315010u,
24184047225561u, 3271434798u, 3192704713u, 2798505213u,
24193932215896u, 3792924012u, 3796843756u, 453872975u,
24204050552799u,
24211056432676u,
2422928166947u, 121311642u, 930989547u, 2087070683u,
24231288978057u, 1556325239u, 1812435626u, 1682385724u,
24241214364933u,
2425904760776u,
24263957045528u, 3949822847u, 2411065880u, 3716420732u,
24273424837835u, 3833550693u, 1799375326u, 2012368921u,
24282768764136u,
24291786111037u,
24304055479315u, 3751639533u, 2808224623u, 3492656387u,
24311306824780u, 2624000170u, 3134795218u, 1778409297u,
24323900821801u,
2433593336325u,
24342772069220u, 2980873673u, 3574497158u, 3994780459u,
24354246519854u, 3482758570u, 4228015183u, 33101083u,
24361769887734u,
24374158035314u,
24383690638998u, 1119035482u, 4134969651u, 2483207353u,
24393932823321u, 285829887u, 3485140138u, 1304815138u,
2440995608264u,
24413133997465u,
24421195477617u, 2147693728u, 3506673112u, 4234467492u,
24431183174337u, 1395340482u, 769199343u, 193262308u,
24442798920256u,
24453827889422u,
24463399695609u, 3036045724u, 2999477386u, 3567001759u,
24472682864314u, 1414023907u, 3699872975u, 3369870701u,
24482662284872u,
24492179640019u,
24502485080099u, 3234415609u, 3755915606u, 1339453220u,
24511567403399u, 2076272391u, 293946298u, 3861962750u,
24521291949822u,
24532916864995u,
2454132642326u, 2215117062u, 2205863575u, 2488805750u,
2455405632860u, 3248129390u, 2952606864u, 896734759u,
24562047417173u,
24573865951392u,
2458657296855u, 1328547532u, 3966511825u, 3959682388u,
24594171801020u, 2981416957u, 1868896247u, 790081075u,
24603143666398u,
24612950766549u,
24622065854887u, 2737081890u, 995061774u, 1510712611u,
24632865954809u, 565044286u, 1565631102u, 1500654931u,
2464494822108u,
24652803515503u,
24661058154996u, 3506280187u, 856885925u, 4204610546u,
2467800905649u, 1130711562u, 558146282u, 2053400666u,
2468449794061u,
24692643520245u,
24702101248725u, 3123292429u, 3583524041u, 983372394u,
24711587743780u, 672870813u, 444833475u, 100741452u,
2472366232251u,
24731717951248u,
2474524144122u, 1362432726u, 1304947719u, 674306020u,
2475405665887u, 4081931036u, 1580408204u, 2343242778u,
24763901654006u,
24772627173567u,
24783015148205u, 814686701u, 1327920712u, 1346494176u,
24792468632605u, 2259795544u, 2519278184u, 2129281928u,
24802860266380u,
24814001619412u,
24821154910973u, 2841022216u, 1199925485u, 1372200293u,
24832713179055u, 3609776550u, 2896463880u, 1056406892u,
2484177413841u,
248540180172u,
24863274788406u, 660921784u, 1686225028u, 4003382965u,
24872532691887u, 4256809101u, 1186018983u, 667359096u,
24882375266493u,
24892760222015u,
2490745187078u, 312264012u, 396822261u, 2588536966u,
24912026998998u, 1766454365u, 3218807676u, 3915487497u,
24922630550356u,
24934130063378u,
24944231937074u, 752212123u, 3085144349u, 3267186363u,
24954103872100u, 4193207863u, 1306401710u, 3014853131u,
24961067760598u,
24972306188342u,
24982437881506u, 4258185052u, 2506507580u, 130876929u,
24991076894205u, 4106981702u, 2799540844u, 945747327u,
25001436722291u,
25012499772225u,
25022571537041u, 2038830635u, 2066826058u, 2892892912u,
2503524875858u, 3392572161u, 2869992096u, 1308273341u,
2504923668994u,
25051980407857u,
25062275009652u, 240598096u, 2658376530u, 3505603048u,
25071022603789u, 582423424u, 846379327u, 4092636095u,
25084177298326u,
25091004173023u,
25102154027018u, 2993634669u, 1098364089u, 3035642175u,
25111335688126u, 1376393415u, 1252369770u, 3815033328u,
25121999309358u,
25131234054757u,
25141388595255u, 2859334775u, 366532860u, 3453410395u,
25154226967708u, 1321729870u, 2078463405u, 156766592u,
25163157683394u,
25173549293384u,
25183348214547u, 2879648344u, 1144813399u, 2758966254u,
2519647753581u, 813615926u, 2035441590u, 1961053117u,
2520600168686u,
25212192833387u,
25223156481401u, 3627320321u, 383550248u, 81209584u,
25232339331745u, 1284116690u, 1980144976u, 2955724163u,
2524789301728u,
25253842040415u,
25261115881490u, 965249078u, 4098663322u, 1870257033u,
25272923150701u, 4217108433u, 183816559u, 2104089285u,
25282640095343u,
25293173757052u,
2530927847464u, 2383114981u, 4287174363u, 1886129652u,
253170635161u, 1182924521u, 1121440038u, 4246220730u,
25323890583049u,
2533975913757u,
25342436253031u, 1074894869u, 1301280627u, 992471939u,
2535735658128u, 244441856u, 1541612456u, 3457776165u,
25363503534059u,
25371931651133u,
2538349142786u, 3669028584u, 1828812038u, 99128389u,
25391364272849u, 1963678455u, 3971963311u, 2316950886u,
25401308901796u,
25412789591580u,
25421460494965u, 2380227479u, 1577190651u, 1755822080u,
25432911014607u, 859387544u, 13023113u, 2319243370u,
25442522582211u,
25452299110490u,
25463342378874u, 2589323490u, 1884430765u, 3739058655u,
25472419330954u, 355389916u, 273950915u, 3670136553u,
2548410946824u,
25493174041420u,
25502609010298u, 3059091350u, 2300275014u, 725729828u,
25512548380995u, 1738849964u, 1257081412u, 79430455u,
2552810321297u,
25533246190593u,
25541007937684u, 912115394u, 40880059u, 3450073327u,
25554289832174u, 2253485111u, 1065639151u, 2953189309u,
2556124779113u,
2557654299738u,
2558115760833u, 1250932069u, 884995826u, 3998908281u,
25591382882981u, 1134187162u, 3202324501u, 487502928u,
25603032756345u,
25614057517628u,
2562933197381u, 2319223127u, 2044528655u, 2554572663u,
25634049450620u, 1620812836u, 2832905391u, 2273005481u,
25641913090121u,
25651055456023u,
2566510593296u, 3285343192u, 2912822536u, 1645225063u,
2567638418430u, 452701300u, 1025483165u, 1639370512u,
2568167948643u,
25692809842730u,
25702983135664u, 407521332u, 1543756616u, 3949773145u,
25714283462892u, 659962275u, 3878013463u, 1000748756u,
25724053212051u,
25734099239406u,
25743467581965u, 354635541u, 21301844u, 3831212473u,
25753189450571u, 2264401966u, 4096484849u, 1736448515u,
25763976926096u,
25773727194724u,
25782243487039u, 585209095u, 3143046007u, 969558123u,
25793037113502u, 3594170243u, 2835860223u, 3775493975u,
25802787220812u,
25812274252217u,
25822915380701u, 3077533278u, 1252871826u, 1519790952u,
2583205297661u, 2950557658u, 3956882191u, 2724439401u,
25843694608025u,
2585124028038u,
2586216019153u, 1533010676u, 2259986336u, 2014061617u,
25872068617849u, 3078123052u, 2692046098u, 1582812948u,
2588396916232u,
25891470894001u,
25901694309312u, 300268215u, 1553892743u, 671176040u,
25911544988994u, 2793402821u, 4194972569u, 2296476154u,
2592748354332u,
25933491325898u,
25944261053291u, 1104998242u, 797816835u, 243564059u,
25952197717393u, 299029458u, 1675252188u, 3139770041u,
2596583018574u,
25972532106100u,
25982099391658u, 3760526730u, 3422719327u, 3556917689u,
25992374009285u, 2130865894u, 3710563151u, 1437538307u,
26003938030842u,
26012006930694u,
26022151243336u, 1939741287u, 1957068175u, 2135147479u,
2603649553342u, 1713643042u, 4188696599u, 1698739939u,
26043549427584u,
26051016382174u,
2606322644378u, 2476164549u, 2037263020u, 88036019u,
26072548960923u, 539867919u, 2871157727u, 4031659929u,
2608754087252u,
2609972656559u,
26104246379429u, 3877308578u, 2059459630u, 3614934323u,
26111410565271u, 2102980459u, 215395636u, 1083393481u,
26123775523015u,
26132062750105u,
26142475645882u, 3041186774u, 3534315423u, 758607219u,
26151686100614u, 180500983u, 1155581185u, 1476664671u,
26162918661695u,
26173812731350u,
26184003853737u, 4148884881u, 1468469436u, 3278880418u,
26191045838071u, 1049161262u, 360450415u, 3158065524u,
2620814443735u,
26213391401707u,
2622729968410u, 738771593u, 3662738792u, 1672830580u,
26234199496163u, 188487238u, 219098233u, 2141731267u,
26243890250614u,
26252988780375u,
26264026279523u, 3489429375u, 2468433807u, 1178270701u,
26272685094218u, 2716621497u, 3718335529u, 2273344755u,
2628701110882u,
26291925717409u,
26301515176562u, 2325460593u, 3954798930u, 784566105u,
26313769422266u, 1641530321u, 2703876862u, 2907480267u,
26321828076455u,
26331805635221u,
26343883381245u, 1476756210u, 2072514392u, 3658557081u,
26352003610746u, 2556845550u, 729594004u, 3303898266u,
26361968227254u,
2637423204951u,
2638231828688u, 4223697811u, 698619045u, 3636824418u,
26392738779239u, 2333529003u, 2833158642u, 580285428u,
26403038148234u,
26411012378004u,
26421113647298u, 1424593483u, 4053247723u, 1167152941u,
26432677383578u, 3419485379u, 2135673840u, 440478166u,
26441682229112u,
26453226724137u,
26461217439806u, 3828726923u, 3636576271u, 3467643156u,
26472005614908u, 2655346461u, 2345488441u, 1027557096u,
26483594084220u,
26491372306343u,
26502342583762u, 4291342905u, 4094931814u, 3254771759u,
2651821978248u, 2404930117u, 1143937655u, 3156949255u,
26523460606610u,
2653449701786u,
26543474906110u, 1932585294u, 2283357584u, 1808481478u,
26553522851029u, 3040164731u, 1530172182u, 2950426149u,
26561402416557u,
2657756419859u,
26584132576145u, 724994790u, 2852015871u, 2177908339u,
2659899914731u, 139675671u, 1423281870u, 3198458070u,
2660807581308u,
26612021611521u,
26621801452575u, 1425984297u, 2833835949u, 1536827865u,
26633902351840u, 164546042u, 1872840974u, 3986194780u,
2664792156290u,
26653378681896u,
2666941547959u, 3931328334u, 3661060482u, 2386420777u,
26673920146272u, 3458621279u, 3348500844u, 2269586542u,
2668797371473u,
26693188953649u,
267080514771u, 2913333490u, 1246325623u, 3253846094u,
26711723906239u, 1606413555u, 587500718u, 1412413859u,
26722310046829u,
26732113313263u,
26743855635608u, 47271944u, 1112281934u, 3440228404u,
26752633519166u, 425094457u, 307659635u, 67338587u,
26762412987939u,
26772363930989u,
26782853008596u, 2844637339u, 922568813u, 130379293u,
26792825204405u, 2904442145u, 1176875333u, 1511685505u,
2680599177514u,
26811872681372u,
2682682394826u, 1888849790u, 3635304282u, 1761257265u,
26831571292431u, 355247075u, 1177210823u, 1691529530u,
26843629531121u,
26853760474006u,
26861129340625u, 868116266u, 3908237785u, 1942124366u,
26871266630014u, 3214841995u, 334023850u, 1110037019u,
2688369650727u,
26891288666741u,
269070535706u, 20230114u, 4284225520u, 727856157u,
2691293696779u, 1244943770u, 3976592462u, 560421917u,
26924171688499u,
26932438786950u,
26941218144639u, 3809125983u, 1302395746u, 534542359u,
26952121993015u, 2899519374u, 3192177626u, 1761707794u,
26963101683464u,
26971555403906u,
26983225675390u, 1875263768u, 4278894569u, 651707603u,
26992111591484u, 3802716028u, 2900262228u, 1181469202u,
27003254743797u,
27011822684466u,
2702860641829u, 3046128268u, 1284833012u, 1125261608u,
2703461384524u, 2331344566u, 1274400010u, 990498321u,
27043462536298u,
27053796842585u,
27062346607194u, 279495949u, 3951194590u, 3522664971u,
27073169688303u, 726831706u, 1123875117u, 1816166599u,
27083759808754u,
27092918558151u,
27103713203220u, 3369939267u, 466047109u, 384042536u,
2711587271104u, 2191634696u, 2449929095u, 1157932232u,
27122084466674u,
2713841370485u,
27143241372562u, 4277738486u, 2150836793u, 1173569449u,
2715778768930u, 2594706485u, 3065269405u, 3019263663u,
27162660146610u,
27172789946230u,
271877056913u, 728174395u, 3647185904u, 804562358u,
27192697276483u, 881311175u, 1178696435u, 2059173891u,
27202308303791u,
2721221481230u,
272250241451u, 3689414100u, 1969074761u, 2732071529u,
27231900890356u, 840789500u, 2100609300u, 985565597u,
27241220850414u,
27252456636259u,
2726223607678u, 1016310244u, 1937434395u, 85717256u,
2727275058190u, 3712011133u, 171916016u, 2389569096u,
27283679765802u,
27293575358777u,
27303481108261u, 3178286380u, 2489642395u, 2931039055u,
27313086601621u, 3079518902u, 3027718495u, 2506894644u,
27322976869602u,
27332134336365u,
27342420172217u, 918054427u, 661522682u, 1403791357u,
27353587174388u, 2623673551u, 1355661457u, 4159477684u,
27361109013587u,
27373112183488u,
27382217849279u, 3500291996u, 2419603731u, 2929886201u,
27393854470013u, 1358382103u, 1357666555u, 21053566u,
27402716621233u,
27413094836862u,
27423309729704u, 57086558u, 839187419u, 2757944838u,
27433651040558u, 3607536716u, 3691257732u, 2312878285u,
27441202511724u,
2745183479927u,
27462509829803u, 109313218u, 478173887u, 2072044014u,
2747190631406u, 2495604975u, 1010416260u, 3679857586u,
2748726566957u,
2749258500881u,
27501805873908u, 3081447051u, 2352101327u, 534922207u,
27511584552873u, 813470716u, 255914637u, 249169434u,
27523193498057u,
27531038802706u,
27542590158653u, 3147907290u, 663060128u, 1156177857u,
2755634616100u, 312879189u, 1545020368u, 2054634247u,
27563271451914u,
27573438291534u,
27582181454946u, 3864535432u, 2398586877u, 896491075u,
27592810631478u, 2770357487u, 3372930052u, 898070638u,
27602051007323u,
2761392959778u,
276236645539u, 3743556044u, 4134529680u, 4124451188u,
2763566806297u, 2936523982u, 1304761965u, 537399498u,
27641940818842u,
276540862381u,
276636288410u, 3063605629u, 2826611650u, 3961972098u,
27671871578006u, 2392095486u, 1136931591u, 513864488u,
2768173276451u,
27693039055682u,
27703543322032u, 1943592006u, 657217094u, 1751698246u,
27712969618445u, 456616022u, 900309519u, 113892716u,
27721126392103u,
27731235651045u,
27741882073852u, 2136610853u, 2353639710u, 2819956700u,
27753980083530u, 828773559u, 224069850u, 902434120u,
27762802008036u,
277794358995u,
27782777723394u, 2812641403u, 2525832595u, 4157388110u,
27794235563782u, 937800324u, 141690749u, 568062536u,
2780550123849u,
27811330316521u,
27821949488696u, 2296431366u, 1958465262u, 3564751729u,
27833748252207u, 120455129u, 1607318832u, 2525729790u,
27842640987481u,
27852332096657u,
27861775969159u, 1555085077u, 2913525137u, 1347085183u,
27872376253113u, 3194050574u, 1806090610u, 678641356u,
27881499146713u,
2789383849715u,
27903299835823u, 2284860330u, 2614269636u, 3913628844u,
27912761334210u, 1959484587u, 529797021u, 239966995u,
27923102194829u,
27933602307804u,
27941122192627u, 3577510006u, 164486066u, 1680137310u,
27951473396395u, 1467801424u, 903493660u, 1185943071u,
27962798556505u,
27972306744492u,
27983167201310u, 3577947177u, 3067592134u, 2905506289u,
27991210366329u, 204484056u, 2347778932u, 3862374472u,
28003277439508u,
28014187414621u,
28021646699310u, 621385800u, 3934869089u, 3975491588u,
28033580085916u, 1925674500u, 2436305348u, 3983301539u,
28042739439523u,
28053291507446u,
28063395637920u, 3753389171u, 2955202032u, 2654255623u,
28073771089254u, 2140443405u, 2779834738u, 3261942805u,
28083526889244u,
28091842009139u,
28104048484340u, 2106218403u, 2161244271u, 772152700u,
28111158647659u, 3776791619u, 3882186721u, 699525237u,
28122954670460u,
28131007105869u,
28143359152025u, 1146388699u, 1401550303u, 2326582541u,
28154181783540u, 1085644043u, 1942143795u, 1038368308u,
28161526153809u,
28174042547244u,
28181891441000u, 2573991874u, 1281441253u, 3635098284u,
28191980545715u, 825985487u, 3934748116u, 4228386979u,
28201480870944u,
28211042194545u,
28222397771642u, 2248490001u, 3817869868u, 878654626u,
28233785629484u, 1672470870u, 3229367873u, 1894538933u,
28241010692731u,
28251733824268u,
2826656620328u, 3048283803u, 3353340056u, 2324965120u,
28274192585951u, 2284524675u, 3483884368u, 1510168293u,
28281554942691u,
28291309709396u,
28301241133168u, 3162179280u, 4046378054u, 3171681593u,
28311165297136u, 3496703563u, 150437903u, 1948622072u,
28321076332463u,
28332292479143u,
28341464229958u, 3479738093u, 2328067598u, 2334503110u,
2835833324834u, 3981605747u, 3002629155u, 2854644186u,
28362832201336u,
283795796957u,
28383269249397u, 2358313329u, 3411860910u, 4283292480u,
28392802208697u, 1305947955u, 2156803420u, 1991340283u,
2840189678024u,
2841447602599u,
28421055411517u, 1531748363u, 1555852656u, 412402681u,
28433774988152u, 20597551u, 2925024131u, 1423989620u,
28443749428061u,
28451541439448u,
2846112270416u, 1936224776u, 132162941u, 3772011507u,
28473814102518u, 1908807815u, 444154079u, 823765347u,
28483362275567u,
28493419047430u,
28502108287005u, 2315102125u, 658593738u, 3195094029u,
28513721937534u, 3176229204u, 3398835373u, 1271898712u,
28521142546577u,
28533185986817u,
28543562705803u, 2046119567u, 912990621u, 1829977672u,
28553459576979u, 1118045834u, 1369529376u, 3320601076u,
28563954988953u,
28574002467635u,
28583359456351u, 1314849568u, 1766750942u, 2998874853u,
28591181800239u, 707328036u, 3314954697u, 2066721120u,
2860598194215u,
28611124451278u,
28623156679616u, 3742684743u, 2960199690u, 2683497915u,
28632566077529u, 937014607u, 102095219u, 4262922475u,
28643132264275u,
28651262099830u,
2866862722905u, 2717653494u, 3245583534u, 3427209989u,
28673220278124u, 85457091u, 2222333500u, 3513997967u,
28683522324951u,
28692830855552u,
28702215004781u, 3482411840u, 4227160614u, 2030964411u,
28711741393851u, 2643723748u, 942813508u, 403442675u,
28723112048748u,
2873530556423u,
28743817755244u, 3543286628u, 2247276090u, 1532920842u,
28754101962711u, 1446540991u, 3297821473u, 1861255389u,
28761984398u,
28772366525138u,
2878377589481u, 3549193828u, 1427765914u, 506831657u,
2879277278988u, 1447652775u, 3214362239u, 3142198690u,
28802843087541u,
2881468915015u,
2882807895062u, 2198723907u, 4031145069u, 2417156212u,
28834027298697u, 637175947u, 1229254212u, 1773257887u,
28841659444818u,
2885451148891u,
28862099741368u, 735351990u, 2534775713u, 3261804619u,
2887712519954u, 3527962772u, 3758642738u, 4245823575u,
28881281314264u,
28891167866160u,
28901489546151u, 1197354389u, 1043278102u, 2563326586u,
2891371937794u, 2320164817u, 3189512691u, 573685198u,
28924108603513u,
28933758899588u,
28943507030163u, 2947201212u, 2529492585u, 578234375u,
28953362349842u, 3318878925u, 3611203517u, 3059253190u,
28964270755916u,
28974291274625u,
28984237586791u, 4137422245u, 2927218651u, 2444687041u,
2899797128811u, 2043057612u, 396533859u, 2665256178u,
29003346510674u,
29011779586176u,
29023076562062u, 1882746214u, 921095362u, 2026988397u,
2903514514911u, 3886379478u, 4218272420u, 1480386793u,
29043900160816u,
29052292273451u,
29061276138356u, 1125461821u, 1912885715u, 3365266013u,
29071333211627u, 4085009861u, 1390530102u, 3347984752u,
29082721771301u,
29091419492325u,
29104066766256u, 3250852311u, 820111852u, 1382201318u,
29112366036798u, 938032241u, 3100979439u, 487048687u,
29122292851045u,
29133241399180u,
29143912670510u, 2416437067u, 2973194517u, 3507707986u,
29151935099406u, 2533441488u, 104616731u, 2892622820u,
29163801190339u,
29174239188808u,
2918807238241u, 3300121546u, 2249406147u, 4032114017u,
29193713738189u, 3324425575u, 4275607376u, 3663120298u,
29204173658372u,
29213984289690u,
29221827636846u, 3264588778u, 3297165529u, 558623533u,
29232728945672u, 1566297318u, 3447249966u, 481719551u,
29241596842050u,
29251838185946u,
2926265271620u, 1050246315u, 4046655705u, 1844193138u,
29273807563245u, 1075384804u, 1292554949u, 1506525927u,
29282921816148u,
29292051885269u,
29301930534041u, 3872721086u, 1564489377u, 2272482181u,
29312849358683u, 589618304u, 2262072443u, 290363051u,
2932299168363u,
29333867603931u,
29342868688756u, 2545263115u, 1092098533u, 3885725603u,
29352352430409u, 1981595469u, 2047946646u, 1332642839u,
2936793806516u,
2937214858837u,
29381061484659u, 3192394476u, 1115054785u, 3690637234u,
2939996792368u, 2023479706u, 3046498231u, 4205835102u,
29403870714754u,
2941257472875u,
29423549864599u, 2040276129u, 2414778670u, 812235477u,
29432674248196u, 1864096101u, 2257492689u, 1332556794u,
29441079540713u,
2945465530720u,
29462304763972u, 830724724u, 3354588920u, 2510713652u,
29473103749409u, 468835585u, 1707620787u, 3038024846u,
29481000303198u,
29493462270146u,
29502748698899u, 2100348093u, 511537258u, 1237187486u,
2951102049383u, 2268226698u, 3162251739u, 4219404629u,
2952838822407u,
29531481440623u,
29542989224077u, 2676681975u, 3246551821u, 3812079906u,
2955370572963u, 2283154352u, 3084789986u, 1961085583u,
29561955640586u,
29572409348147u,
29582284780581u, 1634818716u, 4018221729u, 2320761377u,
29593566831899u, 1799560520u, 91431959u, 1754113747u,
29601459430477u,
29613613658517u,
2962924489906u, 3406317699u, 866289774u, 3924821603u,
29631265394945u, 1870668109u, 151949856u, 2747006534u,
29643111906201u,
296564039467u,
29662314447545u, 2600195638u, 4095795204u, 4162096026u,
29671026756826u, 2460047982u, 52686887u, 823198739u,
29681518045160u,
29692867527376u,
2970566410761u, 2200433819u, 2114146405u, 2893790965u,
2971881504901u, 974783212u, 490815659u, 937300283u,
29721523735309u,
29732511976468u,
29742634644947u, 355119367u, 1373773092u, 309232995u,
29753088671051u, 787126032u, 3442836843u, 4289194567u,
29762177850062u,
29771174136430u,
29783248982914u, 3129039732u, 1166851580u, 2196451882u,
2979469595580u, 2130837700u, 3783349021u, 3745262548u,
29801236930515u,
29813032131496u,
29821525591437u, 1823628217u, 1939019255u, 1950270463u,
29833659899927u, 3688643445u, 3004399289u, 1155199552u,
2984357547234u,
29852213110526u,
29863122658210u, 2667800490u, 2718690333u, 3512372076u,
29871098611683u, 2657518392u, 4248458835u, 3109874532u,
29881592908438u,
29892864927516u,
29903635248840u, 1251777186u, 3797340158u, 3508496870u,
2991303354834u, 1482394062u, 2087100120u, 1595931912u,
2992608574156u,
2993723367884u,
2994907938402u, 3357047807u, 1619629851u, 3092082995u,
299589030300u, 916336992u, 1861180168u, 3436334155u,
29961375000544u,
29973472936241u,
29981321217853u, 791356402u, 2872410224u, 2326250297u,
29992657644088u, 1748314108u, 4146771421u, 2913114440u,
30002924821844u,
30012101101496u,
30023268017251u, 2109603066u, 690665520u, 1830067573u,
3003951427661u, 2982533150u, 3884512506u, 2358657479u,
30042833210784u,
30053419798214u,
30063785893994u, 2103940206u, 86759766u, 4031230616u,
30073745237192u, 2739453927u, 497038072u, 3303159408u,
30081251537249u,
30091993408196u,
30103185905715u, 2885948408u, 3154277110u, 2444150313u,
30112505582079u, 2120610195u, 3266465773u, 1814611964u,
30123080050407u,
30131079915522u,
30141819346505u, 2529946763u, 892097374u, 3740257161u,
30153618100441u, 1079900094u, 3607172225u, 737863389u,
3016360704560u,
30173341993089u,
30181139047381u, 3132219631u, 1248981859u, 1109338159u,
30192004908615u, 4022302594u, 4166640860u, 2959140950u,
30203949235962u,
30212832278473u,
30222200524012u, 2634933043u, 2495844522u, 2613799818u,
30234034096813u, 683271795u, 1673546817u, 1363163726u,
30241805395136u,
3025511749501u,
30261231032599u, 2305979751u, 345737783u, 3339868854u,
30272931857933u, 2323251738u, 1332068477u, 51846558u,
30283927238177u,
30291387182179u,
30301701238601u, 1419275173u, 2580882268u, 3357874599u,
30311726558907u, 1292901039u, 1371322339u, 1311713044u,
30323526735232u,
30334017884184u,
30343366093428u, 77140994u, 2128996229u, 1357915765u,
30354019691901u, 483989024u, 2390311750u, 2766065288u,
30363938587520u,
30373064810344u,
30381054589198u, 1274997019u, 4040589616u, 1277751144u,
30392274907047u, 4170399945u, 2886368209u, 4168922115u,
30403901237033u,
30413252972311u,
30422205185840u, 3403097556u, 3385493699u, 2809751370u,
3043555319628u, 399539034u, 2998971454u, 1521596214u,
3044178870216u,
30451471733541u,
3046519629198u, 514159209u, 1500582242u, 1928616587u,
30472686427928u, 4133138798u, 1225914083u, 1432713584u,
30483559310915u,
30493925489366u,
30501055613123u, 4126676029u, 2723867653u, 3290604111u,
30511377022957u, 2373608155u, 3615237379u, 594338683u,
30522645257602u,
30532408427260u,
3054917033274u, 750455097u, 625657657u, 121713200u,
30552191273413u, 4043949724u, 3293146785u, 3809297972u,
30563947296919u,
3057115456894u,
30581529576616u, 1459278275u, 2157117997u, 1747859293u,
30594106665903u, 996939232u, 2007976332u, 4274649009u,
30601017725787u,
30614244666096u,
30621219631331u, 3072426253u, 3547691720u, 1620822012u,
30631397717508u, 2031597325u, 3345983430u, 2459068000u,
30643645130467u,
30652308642742u,
3066359955852u, 1348467968u, 1133123059u, 2435919062u,
30672800365907u, 4213217210u, 4056565603u, 2811666556u,
30682318007236u,
30693823652401u,
30703654086429u, 1273260424u, 1591610446u, 943349350u,
30713441227678u, 3779964757u, 233818224u, 3469971032u,
30723764095096u,
30734009204587u,
3074678472092u, 1990559652u, 2583121088u, 2978143652u,
30752496370864u, 2139539656u, 4287972050u, 295832576u,
30763536742861u,
30772257466133u,
30782738052161u, 1988611898u, 2466189642u, 3294419573u,
30792311186273u, 474374532u, 3081964174u, 2515138278u,
3080835731677u,
30811178182694u,
30823352119543u, 2884763225u, 3462399574u, 2900817210u,
30831993698511u, 2868445043u, 2746444849u, 1205258179u,
30842353442946u,
30854079040070u,
30863624133102u, 2907136076u, 2902521697u, 426813211u,
30871418185512u, 3711189488u, 1351506552u, 1934749519u,
308846595543u,
3089401688809u,
30903514602124u, 1396852607u, 1951477943u, 2502249173u,
30913199695820u, 2890250638u, 4205072507u, 1715623846u,
30923266686789u,
30933218688128u,
30941697759742u, 851227671u, 2358709645u, 4174233268u,
3095500583683u, 3805940955u, 736234120u, 2710563712u,
30961949664540u,
30973139414003u,
30984293073253u, 1284406972u, 1785182449u, 1051548274u,
30992994248357u, 2499882522u, 717208669u, 2039517285u,
3100518424929u,
3101143136433u,
31022303774671u, 1272930860u, 2286410920u, 788459311u,
3103273225293u, 2439291703u, 2254505236u, 3446287701u,
31043655156558u,
31051546628787u,
3106340081500u, 3285722006u, 1324810435u, 1053980860u,
31071779472859u, 2700355724u, 686005017u, 3762376315u,
31083963193100u,
31091370881135u,
3110661300087u, 1152753704u, 2349891598u, 3910051187u,
31112109444785u, 1311123870u, 2639837565u, 1896770931u,
31121081414128u,
3113869877586u,
31144284220400u, 63045374u, 235968615u, 184451062u,
31151271099822u, 1319179857u, 3274963209u, 4172272710u,
31163388797445u,
31172965973320u,
31183793110097u, 3327241723u, 2991804005u, 1199544355u,
3119771553759u, 2031749842u, 2596517372u, 1199888213u,
3120858347951u,
31213340178832u,
31222903875412u, 763490382u, 76949161u, 2056544406u,
31231145227689u, 998233136u, 2354530024u, 427713587u,
31243537837347u,
3125604661755u,
3126923986833u, 1023730418u, 798294227u, 432557449u,
3127801802449u, 1861313429u, 3899128441u, 4068407979u,
31282352677083u,
31293783539925u,
313010731973u, 3390767975u, 3949540249u, 1920121661u,
31313248580201u, 641956426u, 2104847395u, 604835744u,
31321491663404u,
31334255204651u,
31341520970746u, 2845653368u, 3247412938u, 3730629005u,
3135855569514u, 3073294700u, 2429691698u, 3818342476u,
31363938869985u,
31372731201328u,
31382335202643u, 778117742u, 13298408u, 228780590u,
31392871715314u, 3253688653u, 4150999702u, 3846220408u,
3140930808u,
31411397128726u,
31421964216488u, 2781092828u, 116285375u, 2271239476u,
31433724347554u, 2931203895u, 3893169206u, 1883912528u,
31442093892660u,
31453658787024u,
31463095016046u, 1094059199u, 3640239610u, 558564267u,
31472102812456u, 464734873u, 925262247u, 1609838036u,
3148588364741u,
31491731409233u,
31501576165139u, 3933979268u, 375316394u, 4247099643u,
31513670508019u, 4080496835u, 2371248533u, 183762693u,
31522078935389u,
31532699810414u,
31541491815683u, 2999180789u, 1831158425u, 1603373553u,
31552006136905u, 3210230591u, 416748595u, 1536971415u,
31563271869367u,
31571266062739u,
31582138414557u, 3337114778u, 1634586826u, 36472629u,
31594482244u, 568009609u, 2721216780u, 4037289545u,
31602235138807u,
31611789351460u,
31624067539527u, 1323062829u, 3864620647u, 4192026301u,
31634278901241u, 1399025382u, 2826652805u, 1363860382u,
31641801770651u,
31651613381526u,
31661165249276u, 4046576622u, 2535596946u, 3260388176u,
31671078898578u, 2259750862u, 643387587u, 237144235u,
31684199571427u,
31693440917581u,
31703067939258u, 2018625455u, 1460528353u, 3138629939u,
31711666223528u, 3841139376u, 2528281125u, 885565193u,
31722609492686u,
31732517257479u,
3174560864620u, 2261471820u, 3491559165u, 1329620416u,
3175622383582u, 1759597655u, 2877873893u, 584692817u,
31761901728399u,
31772599000260u,
31783169771644u, 296332336u, 774719455u, 4175920823u,
31792287316070u, 4115615023u, 1073335619u, 4240292725u,
31801359158837u,
31811960974237u,
31823173724597u, 1619084286u, 2876340752u, 4065675347u,
3183480741335u, 1237329941u, 701055566u, 3729009837u,
31841314736422u,
31854003180069u,
31863118519317u, 3035354420u, 3380357671u, 4020909015u,
3187253958714u, 3545798863u, 3008185002u, 2624719888u,
31883219955575u,
31893060719376u,
3190573101682u, 1580316843u, 2610493412u, 3490983536u,
31913601975611u, 851470366u, 635384901u, 3427048824u,
31921470002757u,
31933592460087u,
31942265226856u, 4124282457u, 2106385486u, 3334305617u,
31954208282753u, 3798749815u, 225396466u, 118791182u,
31962523395972u,
3197194595464u,
31982563824631u, 2521301383u, 4224409406u, 468670274u,
31991761966400u, 1300908277u, 2570709228u, 1847901526u,
32001470099163u,
32012690466752u,
32021472536718u, 2399279735u, 4150607803u, 1775080054u,
32032082537685u, 4080034578u, 1256001880u, 392967725u,
32042055838940u,
32053349115816u,
32061745947263u, 2213925887u, 1836572741u, 2417722792u,
3207636223705u, 2423329294u, 3960951311u, 1543591052u,
32081547914361u,
32092760945653u,
32103519014111u, 313543871u, 4119598884u, 1071003714u,
32112192556597u, 1526995535u, 3929839778u, 536388591u,
32123040873792u,
32133752682932u,
32141640614237u, 2432794021u, 385337403u, 2794410617u,
32152386128075u, 1055206708u, 1422747714u, 3759330929u,
32162533597496u,
321730440955u,
32181482899460u, 3350385050u, 616259409u, 3980103795u,
32191211364140u, 1040071544u, 594746920u, 1645973936u,
32202547331531u,
32211097726368u,
3222700666526u, 2976247482u, 1144906608u, 996506677u,
32231997130756u, 800321417u, 1392942823u, 1601662248u,
32242079778663u,
3225529512908u,
32262925120134u, 4106433085u, 630221833u, 2423086156u,
32271119859778u, 1726827981u, 1870859181u, 2559832707u,
32281792284257u,
32292059356387u,
32303572353364u, 3229407475u, 575621095u, 3221893291u,
32312372428048u, 2020123035u, 961449593u, 2243824063u,
32323803906611u,
32333735348189u,
32342981620804u, 4180681078u, 1555330629u, 230736535u,
32352075526640u, 749652975u, 713664372u, 2152096659u,
32362142067223u,
32373322302242u,
32381421646830u, 2092832615u, 1213735101u, 3192136753u,
32391106723940u, 3455398230u, 2541685524u, 2529956739u,
32403789430647u,
32411950084508u,
32422157395621u, 850457360u, 2758902426u, 2848030169u,
32436506379u, 1162213157u, 2981459221u, 272690871u,
32443059420255u,
32454242691285u,
3246588065598u, 1206949936u, 3968214184u, 566348532u,
3247126142880u, 1480567086u, 2959621988u, 2050218418u,
32482242731195u,
32493833514449u,
32501898070331u, 3687399477u, 3891859374u, 868185955u,
32512335308774u, 3676335246u, 3871121805u, 2189032743u,
32523275728647u,
3253860492892u,
32541590764344u, 4130384758u, 262871548u, 3004764525u,
32552685542071u, 991231482u, 435122019u, 3031116998u,
32562898921700u,
32572917932604u,
32584238665148u, 2459072654u, 3444612545u, 4207731740u,
32591808564313u, 2798532269u, 3944553556u, 3926395409u,
32601633200670u,
32614138335224u,
32622524878605u, 4184292650u, 3563398268u, 4288943552u,
32633802121210u, 957502058u, 2410820887u, 4227117506u,
32644018625153u,
32654284329158u,
3266530216712u, 2978986531u, 863452221u, 1910162118u,
32674088211378u, 4091971261u, 3150811451u, 4200871487u,
32683794038652u,
32693041564310u,
32702045287082u, 887805614u, 2889167251u, 4120352181u,
32711699912580u, 3478922097u, 3211994687u, 3136177842u,
32721500806861u,
32733211881347u,
32742147976385u, 3342722260u, 3359650541u, 4197378460u,
3275781354073u, 1533623029u, 2204677828u, 3228172832u,
32763248592437u,
32773355841359u,
3278560815159u, 1144951236u, 4027015711u, 2882625391u,
3279339363613u, 2354572719u, 1769831876u, 4238589331u,
32801519732871u,
32812185834614u,
32821601096831u, 129709881u, 39655633u, 367604993u,
32831737681770u, 3259114599u, 2767070452u, 872365177u,
32841574125529u,
32853405020189u,
32864181346685u, 1134030380u, 403769171u, 2193351164u,
32871426232618u, 2885309450u, 3033612627u, 924948363u,
3288935514094u,
32893202053329u,
3290912294839u, 1618472324u, 4159158431u, 3744999487u,
3291777064358u, 3974213124u, 1990246048u, 309725290u,
32922449849392u,
32931943692420u,
32942288635750u, 2433793635u, 2168904061u, 683315308u,
32953081493019u, 3477759434u, 3815496269u, 2823504699u,
3296586945121u,
32973088963200u,
32983492287335u, 636875049u, 1111206944u, 2037346120u,
32991282050044u, 1409681512u, 1786128584u, 755810950u,
33002332676758u,
33012178142310u,
3302957827166u, 1014983590u, 1888800725u, 3608595803u,
33033200072714u, 2534008478u, 659336139u, 1281728287u,
33044060560529u,
33052915575125u,
33063521503774u, 2926487340u, 1096297674u, 653489861u,
33072352326980u, 2561136777u, 1224141198u, 1250479629u,
33081297625391u,
33092409997371u,
33101942483722u, 2481835750u, 1394715707u, 1673070941u,
33112456039704u, 3980558014u, 3547934764u, 1882038812u,
33121078160498u,
33132488279087u,
33141848235245u, 1211914722u, 2264928765u, 2807773070u,
3315270145554u, 583747883u, 3826009010u, 2996618216u,
3316425727157u,
3317992726957u,
33183384462280u, 726650661u, 1955043265u, 1923879512u,
33191854693773u, 2987614542u, 2660044993u, 2457260810u,
3320426299370u,
33212671892900u,
33221827308087u, 3083953443u, 1791749638u, 3265087416u,
33232119752201u, 2547122538u, 3990783236u, 1912713468u,
33243688865211u,
33251815780016u,
3326303699291u, 2416763742u, 2690891610u, 1535193548u,
33271107803989u, 1504143133u, 2235270371u, 2545884083u,
33282276278682u,
3329411724404u,
33303416925704u, 2565792091u, 3383911757u, 546058824u,
33313374654444u, 2364630415u, 2693473470u, 2622125691u,
3332261864817u,
333355682470u,
3334857617568u, 141304067u, 1885488541u, 155368182u,
33351281949051u, 3384522408u, 3254816901u, 1959816782u,
33361452224057u,
33372830267691u,
33383709231247u, 58988202u, 4218130458u, 2984061349u,
33391888707848u, 4223605071u, 4241442486u, 375269213u,
33403208327038u,
33412199916493u,
3342550337252u, 2855061437u, 276088636u, 114362204u,
33432321163647u, 2127813633u, 3289403024u, 2686973202u,
33442717376797u,
33453593428039u,
33463648831666u, 890925902u, 3289404818u, 3289516821u,
33474248913260u, 1858916580u, 3303932308u, 1752797086u,
33481628149686u,
33493245893605u,
33501568537311u, 2844194502u, 1593855770u, 2408174109u,
3351124797514u, 2085649512u, 3188565660u, 2264996276u,
33521926696513u,
33533053957740u,
33542238806881u, 2189050973u, 203685243u, 379855590u,
33553920271562u, 1058600179u, 3698061923u, 4255106849u,
3356608401664u,
33571598041932u,
33583318266418u, 2535016555u, 852760884u, 1918098822u,
33592200437599u, 1532285043u, 3425662132u, 3561293706u,
33602231633206u,
33614108785088u,
33623359152801u, 173534780u, 208383607u, 2862988169u,
33632406642243u, 426814583u, 2777335795u, 3322703596u,
3364954190623u,
3365615093090u,
33664179102978u, 2452847930u, 100239619u, 42471741u,
3367818352432u, 2190624654u, 504379960u, 3631619975u,
3368633412456u,
33691018421783u,
3370842645419u, 711808707u, 3424580813u, 2132457941u,
33711158335882u, 3567952480u, 2302183699u, 1145788151u,
33723474264138u,
33733105085243u,
33743115506027u, 2783713015u, 3871785309u, 539583269u,
33751400252405u, 3857849984u, 4231186588u, 1278653799u,
33761760227022u,
3377761044088u,
33783838185417u, 2439542532u, 585283357u, 2055995220u,
3379937117124u, 3831944855u, 1823586038u, 3287917855u,
3380485082427u,
33813209172809u,
33821984570176u, 2818337297u, 2691869057u, 3790476953u,
3383839035557u, 3203129010u, 669981176u, 4121157385u,
33843519870450u,
33853792633352u,
33863017650322u, 1603459507u, 4225677666u, 376555451u,
3387473780127u, 2018786277u, 3299822439u, 1010254499u,
33882383887565u,
33893155009499u,
33903108110655u, 2641738274u, 3684908622u, 1606463047u,
33913311068174u, 52708046u, 754181455u, 1018079176u,
33923915670272u,
33933366999425u,
33941012880204u, 1339439715u, 466437962u, 1402662350u,
33952504046911u, 736323938u, 2037800124u, 1725908589u,
3396716341840u,
33971750123474u,
33983366342464u, 1743666195u, 2975303189u, 3821364027u,
33993253707772u, 3635548377u, 3840413796u, 1955642085u,
34001018315169u,
34011258092848u,
34022095540656u, 1076256607u, 117289557u, 1311658655u,
34032118301000u, 68721550u, 2886814107u, 2712432819u,
34044201862886u,
3405753807148u,
34061940229047u, 731347296u, 1068901393u, 3873155894u,
34072852787666u, 1973464853u, 79735652u, 3966380587u,
34083245740712u,
34092525773438u,
3410734938109u, 3045656416u, 3335746354u, 4099732691u,
34111911896517u, 1697006473u, 1145487066u, 1605663299u,
34123053606724u,
34132386289465u,
34143821211369u, 1006215345u, 1256304829u, 1053001668u,
34151289194958u, 118761054u, 1853688730u, 2803418011u,
3416188650809u,
34173763686458u,
34181006829556u, 2961984133u, 3390525025u, 2061199893u,
3419141792681u, 2439893463u, 2652982650u, 1804942682u,
34201546510005u,
34211246961405u,
34222407577046u, 565772575u, 3751844810u, 2943166103u,
34233750052451u, 3022527280u, 25162928u, 397381043u,
34241818337632u,
34253447363730u,
34263936437150u, 2569420703u, 2215592390u, 2171555672u,
34273665571006u, 4021712412u, 2939158353u, 4057813172u,
34281823237318u,
3429103999245u,
34303251978010u, 3591914940u, 3582495283u, 2519035265u,
34313905726135u, 3180393349u, 2743117123u, 55247368u,
34323325286701u,
3433705195946u,
34341857526853u, 1480518550u, 3809990433u, 1398189338u,
34353126362926u, 3959531492u, 1503658285u, 1977847740u,
34363043964489u,
34372613086143u,
34381518119282u, 4238434900u, 3905746486u, 3064949667u,
34391028122931u, 3309119457u, 4071194920u, 3096098907u,
34404137180520u,
3441494467959u,
34421231408687u, 1691606157u, 1793452569u, 2722196118u,
34433478603952u, 1059665738u, 2282032278u, 3990268388u,
34441719514651u,
34454248311578u,
34463799146721u, 898026304u, 3367808954u, 4162472815u,
3447170495870u, 1308116609u, 3428285344u, 1714716475u,
3448395576794u,
34494153638621u,
34502999745812u, 3483315953u, 304980828u, 595337120u,
34513486516729u, 2331563143u, 2583609459u, 1885928417u,
34523834283777u,
3453979337825u,
3454932057378u, 3124081189u, 1930356777u, 3865887996u,
34554178282217u, 4214219408u, 3669465884u, 1472413856u,
34563356866587u,
34571012769806u,
34583043639963u, 996996396u, 207308216u, 982967331u,
34592991319933u, 318066902u, 721489670u, 1249967713u,
3460749240921u,
3461591392325u,
34622379365192u, 2250868849u, 2163259329u, 143191325u,
34633778285606u, 982149096u, 3536906200u, 2244353244u,
34641443862317u,
34653161549210u,
34662183127464u, 2015409516u, 547003700u, 2032484282u,
3467523677821u, 4275663308u, 3827205526u, 3903778273u,
34682444530525u,
34692543645801u,
34701173958423u, 784740616u, 2878693675u, 3127696736u,
34713832037316u, 3161002398u, 4084166400u, 4213346853u,
3472223390424u,
34734273380883u,
34742130315482u, 3429606032u, 3367732613u, 1912357694u,
3475422632590u, 1266957023u, 3437535648u, 736404240u,
34762281709372u,
3477415859912u,
3478212948797u, 351612650u, 3920561440u, 112963586u,
34792230727543u, 2851076612u, 1990662634u, 2264296857u,
34803131463650u,
34812704034623u,
34823541637839u, 2954232792u, 533986918u, 4158757533u,
348365174248u, 4232639593u, 865906667u, 1948225652u,
3484779656112u,
34853873989249u,
34862372984749u, 2346988193u, 1104345713u, 1165654138u,
34874045762610u, 3588205178u, 461363991u, 1111215752u,
34881389675192u,
34892404325151u,
34902152228101u, 3808973622u, 1901235912u, 3458690696u,
3491314513238u, 2539459143u, 2847998873u, 952026138u,
34922325705328u,
3493407844712u,
34943727960715u, 2996448351u, 2374336760u, 3138756390u,
34952600015243u, 539980418u, 1876285352u, 1670330799u,
34961709360377u,
34972868531654u,
3498494777964u, 2773053597u, 599486162u, 3962209577u,
34991871328846u, 2171933018u, 110279472u, 384074780u,
35004147021936u,
35012333589647u,
35024251778066u, 40493468u, 3099342316u, 4108779767u,
35032812424588u, 954542332u, 2040682331u, 2251152306u,
350445915516u,
3505259525626u,
35061045384743u, 4134656562u, 749389261u, 874399445u,
3507616549904u, 2200447504u, 436024539u, 78972290u,
35083210485762u,
35091907985531u,
35103013721395u, 4214533685u, 4198804243u, 534879265u,
35111517190881u, 3756787754u, 1152563554u, 1718750948u,
3512777737463u,
35131402478860u,
35141824562784u, 1879401449u, 3515818786u, 513165201u,
35151423491227u, 2103067918u, 2291777410u, 1097943000u,
3516};
3517
3518// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
3519bool Test(int offset, int len = 0) {
3520#undef Check
3521#undef IsAlive
3522
3523#define Check(x) do { \
3524 const uint32_t actual = (x), e = expected[index++]; \
3525 bool ok = actual == e; \
3526 if (!ok) { \
3527 cerr << "expected " << hex << e << " but got " << actual << endl; \
3528 ++errors; \
3529 } \
3530 assert(ok); \
3531} while (0)
3532
3533#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
3534
3535 // After the following line is where the uses of "Check" and such will go.
3536 static int index = 0;
3537if (offset == -1) { int alive = 0; IsAlive(farmhashcc::Hash32WithSeed(data, len++, SEED)); IsAlive(farmhashcc::Hash32(data, len++)); { NAMESPACE_FOR_HASH_FUNCTIONS::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; }
3538Check(farmhashcc::Hash32WithSeed(data + offset, len, SEED));
3539Check(farmhashcc::Hash32(data + offset, len));
3540{ NAMESPACE_FOR_HASH_FUNCTIONS::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); }
3541{ NAMESPACE_FOR_HASH_FUNCTIONS::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); }
3542
3543 return true;
3544#undef Check
3545#undef IsAlive
3546}
3547
3548int RunTest() {
3549 Setup();
3550 int i = 0;
3551 cout << "Running farmhashccTest";
3552 if (!Test(-1)) {
3553 cout << "... Unavailable\n";
3554 return NoteErrors();
3555 }
3556 // Good. The function is attempting to hash, so run the full test.
3557 int errors_prior_to_test = errors;
3558 for ( ; i < kTestSize - 1; i++) {
3559 Test(i * i, i);
3560 }
3561 for ( ; i < kDataSize; i += i / 7) {
3562 Test(0, i);
3563 }
3564 Test(0, kDataSize);
3565 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
3566 return NoteErrors();
3567}
3568
3569#else
3570
3571// After the following line is where the code to print hash codes will go.
3572void Dump(int offset, int len) {
3573cout << farmhashcc::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
3574cout << farmhashcc::Hash32(data + offset, len) << "u," << endl;
3575{ NAMESPACE_FOR_HASH_FUNCTIONS::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; }
3576{ NAMESPACE_FOR_HASH_FUNCTIONS::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; }
3577}
3578
3579#endif
3580
3581#undef SEED
3582#undef SEED1
3583#undef SEED0
3584
3585} // namespace farmhashccTest
3586
3587#if !TESTING
3588int main(int argc, char** argv) {
3589 Setup();
3590 cout << "uint32_t expected[] = {\n";
3591 int i = 0;
3592 for ( ; i < kTestSize - 1; i++) {
3593 farmhashccTest::Dump(i * i, i);
3594 }
3595 for ( ; i < kDataSize; i += i / 7) {
3596 farmhashccTest::Dump(0, i);
3597 }
3598 farmhashccTest::Dump(0, kDataSize);
3599 cout << "};\n";
3600}
3601#endif
3602#ifndef FARMHASH_SELF_TEST_GUARD
3603#define FARMHASH_SELF_TEST_GUARD
3604#include <cstdio>
3605#include <iostream>
3606#include <string.h>
3607
3608using std::cout;
3609using std::cerr;
3610using std::endl;
3611using std::hex;
3612
3613static const uint64_t kSeed0 = 1234567;
3614static const uint64_t kSeed1 = k0;
3615static const int kDataSize = 1 << 20;
3616static const int kTestSize = 300;
3617#define kSeed128 Uint128(kSeed0, kSeed1)
3618
3619static char data[kDataSize];
3620
3621static int completed_self_tests = 0;
3622static int errors = 0;
3623
3624// Initialize data to pseudorandom values.
3625void Setup() {
3626 if (completed_self_tests == 0) {
3627 uint64_t a = 9;
3628 uint64_t b = 777;
3629 for (int i = 0; i < kDataSize; i++) {
3630 a += b;
3631 b += a;
3632 a = (a ^ (a >> 41)) * k0;
3633 b = (b ^ (b >> 41)) * k0 + i;
3634 uint8_t u = b >> 37;
3635 memcpy(data + i, &u, 1); // uint8_t -> char
3636 }
3637 }
3638}
3639
3640int NoteErrors() {
3641#define NUM_SELF_TESTS 9
3642 if (++completed_self_tests == NUM_SELF_TESTS)
3643 std::exit(errors > 0);
3644 return errors;
3645}
3646
3647template <typename T> inline bool IsNonZero(T x) {
3648 return x != 0;
3649}
3650
3651template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
3652 return x != Uint128(0, 0);
3653}
3654
3655#endif // FARMHASH_SELF_TEST_GUARD
3656
3657namespace farmhashmkTest {
3658
3659uint32_t CreateSeed(int offset, int salt) {
3660 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
3661 h = h * c1;
3662 h ^= (h >> 17);
3663 h = h * c1;
3664 h ^= (h >> 17);
3665 h = h * c1;
3666 h ^= (h >> 17);
3667 h += static_cast<uint32_t>(offset & 0xffffffff);
3668 h = h * c1;
3669 h ^= (h >> 17);
3670 h = h * c1;
3671 h ^= (h >> 17);
3672 h = h * c1;
3673 h ^= (h >> 17);
3674 return h;
3675}
3676
3677#undef SEED
3678#undef SEED1
3679#undef SEED0
3680#define SEED CreateSeed(offset, -1)
3681#define SEED0 CreateSeed(offset, 0)
3682#define SEED1 CreateSeed(offset, 1)
3683
3684#undef TESTING
3685#define TESTING 1
3686#if TESTING
3687uint32_t expected[] = {
36884223616069u,
36893696677242u,
36904081014168u,
36912576519988u,
36922212771159u,
36931112731063u,
36941020067935u,
36953955445564u,
36961451961420u,
3697653440099u,
369831917516u,
36992957164615u,
37002590087362u,
37013879448744u,
3702176305566u,
37032447367541u,
37041359016305u,
37053363804638u,
37061117290165u,
37071062549743u,
37082437877004u,
37091894455839u,
3710673206794u,
37113486923651u,
37123269862919u,
37132303349487u,
37141380660650u,
3715595525107u,
37161525325287u,
37172025609358u,
3718176408838u,
37191592885012u,
3720864896482u,
37212101378090u,
37223489229104u,
37232118965695u,
3724581644891u,
37252718789079u,
3726631613207u,
37274228658372u,
37283867875546u,
37293531368319u,
37303804516756u,
37313317755099u,
37321619744564u,
37332884717286u,
37341088213445u,
37352667691076u,
37363727873235u,
37372330406762u,
37383616470388u,
3739967660719u,
37404148162586u,
3741315219121u,
3742673084328u,
37433047602355u,
37441598963653u,
37451267826661u,
37462117362589u,
37472861192253u,
37481823625377u,
37491380350078u,
37501641748342u,
37511176094482u,
3752269384321u,
37532178982315u,
37543480237248u,
37552660755208u,
37561850544433u,
37573429699438u,
37581262819303u,
3759640556464u,
37602421125401u,
37612188368608u,
37622612932825u,
37631474432581u,
3764173790449u,
37652124882189u,
3766831272654u,
3767622960146u,
37684238751051u,
37693250317967u,
37702120810248u,
37711948231495u,
37721389029321u,
37732200398357u,
37742134232963u,
37752948072329u,
3776617717625u,
3777681164587u,
3778114859387u,
3779430545646u,
378057239089u,
37813163338012u,
37823482496399u,
3783557662576u,
37841102441413u,
37852670159360u,
3786991116729u,
3787846014240u,
37884233741566u,
37891802317242u,
37903129528802u,
37911459456375u,
37921305643039u,
37933258671612u,
37941578285833u,
3795868590079u,
37961631034517u,
37971695432937u,
3798561078856u,
37991004115553u,
38003086090507u,
38013818348650u,
3802731596645u,
3803780926790u,
38042544205955u,
3805158479164u,
38063983514188u,
38072004735250u,
38083436218400u,
3809673684751u,
38101463431419u,
38112880490219u,
38123223748024u,
38132218318859u,
38141474466194u,
38152636437533u,
38162206794961u,
3817140995728u,
38181186394086u,
38191805716888u,
38201640037724u,
38213942729099u,
38221944727013u,
3823918951560u,
3824498666871u,
38253486974657u,
38262967205462u,
38271167253804u,
38281884281041u,
38292866015002u,
38304158319270u,
38312627220079u,
38323733319624u,
38333317092271u,
3834438323662u,
38353195868065u,
38363426606709u,
3837360708338u,
38381905491012u,
3839650004803u,
38401351266252u,
38413133279000u,
38423722811115u,
38432722412434u,
3844918432408u,
38453678271248u,
3846269599647u,
3847621514057u,
38483117077855u,
38491545425390u,
38502597567410u,
38511221437820u,
38523493254589u,
3853102787342u,
3854918861168u,
3855348795089u,
38563439883229u,
38572353641807u,
38582209585469u,
38594035884492u,
38602686995435u,
38611649888022u,
38623852893848u,
38633042700028u,
3864314103172u,
3865726977769u,
38662489830276u,
38672872753660u,
38681316214989u,
38691488801501u,
38701811420390u,
3871639581627u,
38722362837215u,
38733634581834u,
38743648576802u,
38751257314182u,
3876762118371u,
38774268447045u,
3878730167096u,
3879755561509u,
3880882614845u,
38813696972894u,
3882228263661u,
38831478636142u,
38842767751651u,
38851532617116u,
38863838657661u,
38871944359935u,
38881401102137u,
38893772933173u,
38901050098254u,
38911658079354u,
38921846025728u,
38932204244794u,
38942017217424u,
38951275162853u,
38961429816745u,
38972175565479u,
38981716109139u,
38991187506761u,
39002434641075u,
39012725597783u,
39021795687662u,
39031393312782u,
39043511565397u,
3905627885430u,
39064145733164u,
39072519005353u,
3908231414775u,
39091242015635u,
39102760723497u,
39112185540568u,
3912727314436u,
39132358790354u,
39141186393454u,
39154234795645u,
3916350567813u,
3917866773875u,
39183145590392u,
39191158374055u,
39203903123687u,
39211862119793u,
39222204587556u,
39234266276976u,
39244151548555u,
3925915250402u,
39262874695320u,
39272360311410u,
39281099212769u,
39291271542714u,
39303473148363u,
39311637325418u,
39321807795989u,
39332493819794u,
39343800917924u,
39354001205856u,
39362582153621u,
39373365872040u,
39382890146216u,
39392626363824u,
39403133351295u,
39414046827296u,
39423053118771u,
39434113026751u,
3944884356716u,
39453828347401u,
394610608262u,
3947830987972u,
39481841080500u,
39493202717763u,
39503561778749u,
39511906000052u,
39523058284660u,
39531432904514u,
39542567431677u,
39552550162530u,
3956665557986u,
3957936887821u,
39582101205308u,
39594253535847u,
39601662043545u,
39611253611611u,
39622091370094u,
39632635077370u,
39642602176041u,
39653624115809u,
3966748442714u,
39672709749154u,
39681023493343u,
3969860291012u,
39703924715584u,
39711536436740u,
39722551145800u,
39732391782865u,
39741467705048u,
39752583909796u,
39763616666170u,
39771162857372u,
39784228631071u,
39791510132376u,
39802739165009u,
39812656606142u,
39823454996358u,
39833155038853u,
39841022087316u,
3985100044110u,
3986494208296u,
39872746186477u,
39884216782431u,
3989225448834u,
39903728320521u,
3991335282866u,
39923148194874u,
3993953503703u,
39941293353960u,
3995202372387u,
39961326119870u,
39974045123735u,
39983819994846u,
39991629004186u,
40001081099186u,
40013591584153u,
40021670825804u,
40033404257979u,
40043262192301u,
40052572846095u,
40063714992543u,
40074264142572u,
4008529616678u,
40092882154574u,
40103006354178u,
40113865969421u,
40122007174907u,
4013308283107u,
40142629833703u,
40153159124075u,
40161146492131u,
4017494104332u,
4018493149727u,
40191342910585u,
4020521642387u,
40212201695937u,
40222517980959u,
40232426821287u,
4024777374655u,
40252228189792u,
40264027055486u,
4027228976000u,
40283842083468u,
40291723920223u,
40301192126094u,
4031787744493u,
40322740368380u,
40332284153001u,
40342773829458u,
4035442000614u,
4036387830783u,
40372169780670u,
40382253144627u,
40393532502484u,
40401969684059u,
40411165351416u,
40423055056536u,
40433582324253u,
4044231419363u,
4045770979865u,
40463213983597u,
40473690452836u,
4048935794639u,
40493230602762u,
40502841762457u,
4051407598927u,
40521164479891u,
40533721799696u,
4054354738136u,
40551801566618u,
40563206038542u,
40572621379981u,
40581943487262u,
40593534745636u,
40601074424589u,
40611304517521u,
40624133400969u,
40632339317978u,
40642135116860u,
40654180643791u,
40662415309340u,
40671855926417u,
40683418648630u,
40691968113037u,
4070597304222u,
40713668824865u,
40723810008716u,
40733014702569u,
40743151212026u,
4075156057449u,
4076373134533u,
40772068234004u,
4078191580563u,
40793832754488u,
40802924104199u,
40812026044494u,
40824065780435u,
4083122565840u,
40844194985167u,
40852744823717u,
40862494098735u,
40873753793370u,
40881885739217u,
40892488161225u,
40903643797615u,
40912653367310u,
40922494061477u,
4093189968132u,
4094899646597u,
4095392100396u,
40964012318310u,
40973855777086u,
40983566860954u,
40992698574996u,
41002414249905u,
41011330623339u,
41021263222732u,
41031277741760u,
41042194959402u,
41051629656136u,
4106120494320u,
41071072368005u,
41081084245077u,
41094011372748u,
41101366613353u,
41113108643228u,
41123332219532u,
41132114746095u,
41143964007334u,
4115371687128u,
41161084813876u,
4117126459896u,
41184292782331u,
4119321283184u,
4120398168499u,
41213604983506u,
4122560701543u,
41232073961354u,
41244240841868u,
41254151211362u,
41261338986875u,
41274093476832u,
41282269279497u,
41293500846299u,
41302510225147u,
4131598000444u,
41321330391422u,
41331432533385u,
41344171226231u,
4135426821154u,
41362932270996u,
41373378981077u,
41382217871549u,
41391619647984u,
41404051608043u,
41413180237819u,
414212919578u,
41431375401767u,
4144371320427u,
41452986640571u,
41462336669859u,
41473796464715u,
41481892383284u,
4149306814912u,
41502125823211u,
41511863678891u,
41523249703818u,
41533840225752u,
4154281579900u,
4155264680257u,
41564266359110u,
41574182229890u,
41582239659703u,
41593627947372u,
41602373929191u,
4161224082765u,
41624053639058u,
41631862360303u,
41643187739624u,
41653392706679u,
4166948039509u,
4167817505760u,
41681215842393u,
41693462222651u,
4170536021853u,
4171182346832u,
41722731944883u,
41732346674384u,
41742640961678u,
41753446695687u,
41762271722179u,
41771301069656u,
41782803881468u,
41792832614405u,
41801691544398u,
4181698756814u,
41823980620906u,
41833565421410u,
4184754769376u,
41854115923404u,
41863909962218u,
41872747614077u,
41882888289845u,
41891016920862u,
41902790946178u,
41913067070960u,
41923173251481u,
41931572132982u,
4194255048203u,
41952996538818u,
41963405398987u,
4197136106013u,
41983581605228u,
41994277437977u,
42002147300534u,
42013728426265u,
42023483629996u,
42031478452694u,
420420756076u,
42052774992067u,
4206432987927u,
42071516771026u,
42083511588664u,
42092130994978u,
4210509385406u,
4211873090347u,
42122163904107u,
42134192239086u,
42142532489989u,
42151090772651u,
42163910797408u,
42173710882132u,
4218155010959u,
42191369823531u,
42201599664937u,
42214035593587u,
42221212746925u,
4223795822552u,
4224116689518u,
42253674240941u,
42261135576664u,
4227756750261u,
42281027431362u,
4229390555140u,
42302228460216u,
42311506940482u,
42323733857700u,
42333048762971u,
42342511703196u,
4235548609887u,
42361607354252u,
4237659053982u,
4238259884450u,
42391793130460u,
42404083364495u,
42413148555881u,
42421764350138u,
42432436485683u,
42444031563025u,
42453261860724u,
42462475833430u,
42472101726086u,
42483191176464u,
42492646658847u,
42502127042126u,
4251771316100u,
42522115922959u,
42533208515045u,
42542355437783u,
42553621147793u,
42561580163615u,
42573211555675u,
42583299188490u,
4259191613920u,
4260466733956u,
42612939029038u,
42621509152039u,
4263130591314u,
42641892874677u,
42651646908044u,
42663452406523u,
42673998376606u,
42681199243832u,
42692187108812u,
42703189230066u,
42714161151481u,
42723371454980u,
42733681788646u,
4274180842187u,
42753685022399u,
42763058749895u,
42773250165163u,
42782895367943u,
42792627101723u,
4280771755098u,
42811332921024u,
42823638871848u,
4283514215135u,
42843591227378u,
42852300310870u,
42863689533503u,
4287851607114u,
4288114330368u,
42892709027386u,
42901743034877u,
42911013693860u,
4292288169008u,
42933545190686u,
42941052165084u,
42953995862307u,
429696902755u,
42971097819851u,
42982645431442u,
42992184148618u,
43002151206566u,
4301350979797u,
43023467920900u,
4303421116779u,
43041246252u,
43054057835428u,
4306329324407u,
43074104482417u,
4308844624570u,
43093306265806u,
43103787625025u,
43114263241191u,
43123251413927u,
43132921204431u,
43142931915325u,
4315992134330u,
43163986338354u,
43171327895216u,
43181458363596u,
43191480608532u,
4320728594368u,
43213804366693u,
4322794404223u,
43231643240863u,
4324793417255u,
43254167916443u,
43262683488959u,
43273124925324u,
43284184843652u,
43293750971752u,
4330308509829u,
43311054550805u,
43322797511972u,
43334043123412u,
43341587158240u,
43354050518606u,
43363030062190u,
43372589912753u,
4338603440067u,
4339937013191u,
43401071662315u,
43412100661456u,
43422602005741u,
4343435516078u,
43442260470147u,
43451256268350u,
43463612035u,
43473368856141u,
4348151516099u,
43493081868591u,
43503363755681u,
43512049963149u,
43522885320434u,
435384682005u,
43542411758308u,
43552695174275u,
43563099904644u,
43571787308684u,
43581132379308u,
4359564634346u,
4360510236510u,
43612804443681u,
43623931864252u,
43632064427949u,
43641893979229u,
43652916544974u,
43661885887717u,
43672978018250u,
4368494192125u,
43692642662373u,
4370901112508u,
4371636035003u,
43721658643797u,
4373172746975u,
4374517504890u,
43753440019372u,
43764144498044u,
43771854755456u,
43783672653905u,
43794176892856u,
4380382159097u,
4381282871690u,
43823629300472u,
43832500754041u,
43841677659759u,
43851067175061u,
4386161654075u,
43871672575536u,
4388346120493u,
43892730229631u,
4390203466442u,
43911244549529u,
4392199761971u,
43932744895408u,
43943195315331u,
43952124618519u,
43963261045496u,
4397985339699u,
43983385585455u,
43991545740710u,
44003636652160u,
44012167020081u,
44021207897204u,
440328752417u,
44042895834146u,
44053640845375u,
44063750293073u,
4407548997850u,
44084207814196u,
44094183030708u,
44102462810989u,
44113929965401u,
4412};
4413
4414// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
4415bool Test(int offset, int len = 0) {
4416#undef Check
4417#undef IsAlive
4418
4419#define Check(x) do { \
4420 const uint32_t actual = (x), e = expected[index++]; \
4421 bool ok = actual == e; \
4422 if (!ok) { \
4423 cerr << "expected " << hex << e << " but got " << actual << endl; \
4424 ++errors; \
4425 } \
4426 assert(ok); \
4427} while (0)
4428
4429#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
4430
4431 // After the following line is where the uses of "Check" and such will go.
4432 static int index = 0;
4433if (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; }
4434Check(farmhashmk::Hash32WithSeed(data + offset, len, SEED));
4435Check(farmhashmk::Hash32(data + offset, len));
4436
4437 return true;
4438#undef Check
4439#undef IsAlive
4440}
4441
4442int RunTest() {
4443 Setup();
4444 int i = 0;
4445 cout << "Running farmhashmkTest";
4446 if (!Test(-1)) {
4447 cout << "... Unavailable\n";
4448 return NoteErrors();
4449 }
4450 // Good. The function is attempting to hash, so run the full test.
4451 int errors_prior_to_test = errors;
4452 for ( ; i < kTestSize - 1; i++) {
4453 Test(i * i, i);
4454 }
4455 for ( ; i < kDataSize; i += i / 7) {
4456 Test(0, i);
4457 }
4458 Test(0, kDataSize);
4459 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
4460 return NoteErrors();
4461}
4462
4463#else
4464
4465// After the following line is where the code to print hash codes will go.
4466void Dump(int offset, int len) {
4467cout << farmhashmk::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
4468cout << farmhashmk::Hash32(data + offset, len) << "u," << endl;
4469}
4470
4471#endif
4472
4473#undef SEED
4474#undef SEED1
4475#undef SEED0
4476
4477} // namespace farmhashmkTest
4478
4479#if !TESTING
4480int main(int argc, char** argv) {
4481 Setup();
4482 cout << "uint32_t expected[] = {\n";
4483 int i = 0;
4484 for ( ; i < kTestSize - 1; i++) {
4485 farmhashmkTest::Dump(i * i, i);
4486 }
4487 for ( ; i < kDataSize; i += i / 7) {
4488 farmhashmkTest::Dump(0, i);
4489 }
4490 farmhashmkTest::Dump(0, kDataSize);
4491 cout << "};\n";
4492}
4493#endif
4494#ifndef FARMHASH_SELF_TEST_GUARD
4495#define FARMHASH_SELF_TEST_GUARD
4496#include <cstdio>
4497#include <iostream>
4498#include <string.h>
4499
4500using std::cout;
4501using std::cerr;
4502using std::endl;
4503using std::hex;
4504
4505static const uint64_t kSeed0 = 1234567;
4506static const uint64_t kSeed1 = k0;
4507static const int kDataSize = 1 << 20;
4508static const int kTestSize = 300;
4509#define kSeed128 Uint128(kSeed0, kSeed1)
4510
4511static char data[kDataSize];
4512
4513static int completed_self_tests = 0;
4514static int errors = 0;
4515
4516// Initialize data to pseudorandom values.
4517void Setup() {
4518 if (completed_self_tests == 0) {
4519 uint64_t a = 9;
4520 uint64_t b = 777;
4521 for (int i = 0; i < kDataSize; i++) {
4522 a += b;
4523 b += a;
4524 a = (a ^ (a >> 41)) * k0;
4525 b = (b ^ (b >> 41)) * k0 + i;
4526 uint8_t u = b >> 37;
4527 memcpy(data + i, &u, 1); // uint8_t -> char
4528 }
4529 }
4530}
4531
4532int NoteErrors() {
4533#define NUM_SELF_TESTS 9
4534 if (++completed_self_tests == NUM_SELF_TESTS)
4535 std::exit(errors > 0);
4536 return errors;
4537}
4538
4539template <typename T> inline bool IsNonZero(T x) {
4540 return x != 0;
4541}
4542
4543template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
4544 return x != Uint128(0, 0);
4545}
4546
4547#endif // FARMHASH_SELF_TEST_GUARD
4548
4549namespace farmhashnaTest {
4550
4551uint32_t CreateSeed(int offset, int salt) {
4552 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
4553 h = h * c1;
4554 h ^= (h >> 17);
4555 h = h * c1;
4556 h ^= (h >> 17);
4557 h = h * c1;
4558 h ^= (h >> 17);
4559 h += static_cast<uint32_t>(offset & 0xffffffff);
4560 h = h * c1;
4561 h ^= (h >> 17);
4562 h = h * c1;
4563 h ^= (h >> 17);
4564 h = h * c1;
4565 h ^= (h >> 17);
4566 return h;
4567}
4568
4569#undef SEED
4570#undef SEED1
4571#undef SEED0
4572#define SEED CreateSeed(offset, -1)
4573#define SEED0 CreateSeed(offset, 0)
4574#define SEED1 CreateSeed(offset, 1)
4575
4576#undef TESTING
4577#define TESTING 1
4578#if TESTING
4579uint32_t expected[] = {
45801140953930u, 861465670u,
45813277735313u, 2681724312u,
45822598464059u, 797982799u,
4583890626835u, 800175912u,
45842603993599u, 921001710u,
45851410420968u, 2134990486u,
45863283896453u, 1867689945u,
45872914424215u, 2244477846u,
4588255297188u, 2992121793u,
45891110588164u, 4186314283u,
4590161451183u, 3943596029u,
45914019337850u, 452431531u,
4592283198166u, 2741341286u,
45933379021470u, 2557197665u,
4594299850021u, 2532580744u,
4595452473466u, 1706958772u,
45961298374911u, 3099673830u,
45972199864459u, 3696623795u,
4598236935126u, 2976578695u,
45994055299123u, 3281581178u,
46001053458494u, 1882212500u,
46012305012065u, 2169731866u,
46023456121707u, 275903667u,
4603458884671u, 3033004529u,
46043058973506u, 2379411653u,
46051898235244u, 1402319660u,
46062700149065u, 2699376854u,
4607147814787u, 720739346u,
46082433714046u, 4222949502u,
46094220361840u, 1712034059u,
46103425469811u, 3690733394u,
46114148372108u, 1330324210u,
4612594028478u, 2921867846u,
46131635026870u, 192883107u,
4614780716741u, 1728752234u,
46153280331829u, 326029180u,
46163969463346u, 1436364519u,
4617393215742u, 3349570000u,
46183824583307u, 1612122221u,
46192859809759u, 3808705738u,
46201379537552u, 1646032583u,
46212233466664u, 1432476832u,
46224023053163u, 2650381482u,
46232052294713u, 3552092450u,
46241628777059u, 1499109081u,
46253476440786u, 3829307897u,
46262960536756u, 1554038301u,
46271145519619u, 3190844552u,
46282902102606u, 3600725550u,
4629237495366u, 540224401u,
463065721842u, 489963606u,
46311448662590u, 397635823u,
46321596489240u, 1562872448u,
46331790705123u, 2128624475u,
4634180854224u, 2604346966u,
46351435705557u, 1262831810u,
4636155445229u, 1672724608u,
46371669465176u, 1341975128u,
4638663607706u, 2077310004u,
46393610042449u, 1911523866u,
46401043692997u, 1454396064u,
46412563776023u, 294527927u,
46421099072299u, 1389770549u,
4643703505868u, 678706990u,
46442952353448u, 2026137563u,
46453603803785u, 629449419u,
46461933894405u, 3043213226u,
4647226132789u, 2489287368u,
46481552847036u, 645684964u,
46493828089804u, 3632594520u,
4650187883449u, 230403464u,
46513151491850u, 3272648435u,
46523729087873u, 1303930448u,
46532002861219u, 165370827u,
4654916494250u, 1230085527u,
46553103338579u, 3064290191u,
46563807265751u, 3628174014u,
4657231181488u, 851743255u,
46582295806711u, 1781190011u,
46592988893883u, 1554380634u,
46601142264800u, 3667013118u,
46611968445277u, 315203929u,
46622638023604u, 2290487377u,
4663732137533u, 1909203251u,
4664440398219u, 1891630171u,
46651380301172u, 1498556724u,
46664072067757u, 4165088768u,
46674204318635u, 441430649u,
46683931792696u, 197618179u,
4669956300927u, 914413116u,
46703010839769u, 2837339569u,
46712148126371u, 1913303225u,
46723074915312u, 3117299654u,
46734139181436u, 2993479124u,
46743178848746u, 1357272220u,
46751438494951u, 507436733u,
4676667183474u, 2084369203u,
46773854939912u, 1413396341u,
4678126024219u, 146044391u,
46791016656857u, 3022024459u,
46803254014218u, 429095991u,
4681165589978u, 1578546616u,
4682985653208u, 1718653828u,
4683623071693u, 366414107u,
4684249776086u, 1207522198u,
46853047342438u, 2991127487u,
46863120876698u, 1684583131u,
468746987739u, 1157614300u,
4688863214540u, 1087193030u,
4689199124911u, 520792961u,
46903614377032u, 586863115u,
46913331828431u, 1013201099u,
46921716848157u, 4033596884u,
46931164298657u, 4140791139u,
46941146169032u, 1434258493u,
46953824360466u, 3242407770u,
46963725511003u, 232064808u,
4697872586426u, 762243036u,
46982736953692u, 816692935u,
4699512845449u, 3748861010u,
47002266795890u, 3781899767u,
47014290630595u, 517646945u,
470222638523u, 648000590u,
4703959214578u, 558910384u,
47041283799121u, 3047062993u,
47051024246061u, 4027776454u,
47063544509313u, 622325861u,
4707834785312u, 382936554u,
4708411505255u, 1973395102u,
47091825135056u, 2725923798u,
4710580988377u, 2826990641u,
47113474970689u, 1029055034u,
4712812546227u, 2506885666u,
47132584372201u, 1758123094u,
4714589567754u, 325737734u,
4715345313518u, 2022370576u,
47163886113119u, 3338548567u,
4717257578986u, 3698087965u,
47181776047957u, 1771384107u,
47193604937815u, 3198590202u,
47202305332220u, 191910725u,
47214232136669u, 427759438u,
47224244322689u, 542201663u,
47233315355162u, 2135941665u,
4724556609672u, 45845311u,
47251175961330u, 3948351189u,
472623075771u, 3252374102u,
47271634635545u, 4151937410u,
4728713127376u, 1467786451u,
4729663013031u, 3444053918u,
47302638154051u, 810082938u,
47313077742128u, 1062268187u,
47322115441882u, 4081398201u,
47333735739145u, 2794294783u,
47342335576331u, 2560479831u,
47351379288194u, 4225182569u,
47362442302747u, 3948961926u,
47373958366652u, 3067277639u,
47383667516477u, 1709989541u,
47391516711748u, 2339636583u,
47404188504038u, 59581167u,
47412725013602u, 3639843023u,
47422658147000u, 2643979752u,
47433758739543u, 4189944477u,
47442470483982u, 877580602u,
47452995362413u, 118817200u,
47463252925478u, 2062343506u,
47473981838403u, 3762572073u,
47481231633714u, 4168280671u,
47492931588131u, 3284356565u,
47501129162571u, 732225574u,
47514173605289u, 1407328702u,
47521677744031u, 3532596884u,
47533232041815u, 1652884780u,
47542256541290u, 3459463480u,
47553740979556u, 259034107u,
47562227121257u, 1426140634u,
47573606709555u, 3424793077u,
4758315836068u, 3200749877u,
47591386256573u, 24035717u,
47602982018998u, 1811050648u,
4761234531934u, 1115203611u,
47621598686658u, 3146815575u,
47631603559457u, 323296368u,
47642632963283u, 1778459926u,
4765739944537u, 579625482u,
47663486330348u, 492621815u,
47671231665285u, 2457048126u,
47683903349120u, 389846205u,
47693355404249u, 3275550588u,
47701052645068u, 862072556u,
47712834153464u, 1481069623u,
47722657392572u, 4279236653u,
47731688445808u, 701920051u,
47743740748788u, 3388062747u,
47751873358321u, 2152785640u,
4776883382081u, 1005815394u,
47771020177209u, 734239551u,
47782371453141u, 100326520u,
47793488500412u, 1279682138u,
47802610427744u, 49703572u,
47813026361211u, 605900428u,
4782302392721u, 2509302188u,
47831416453607u, 2815915291u,
47841862819968u, 519710058u,
47852450888314u, 4017598378u,
4786937074653u, 3035635454u,
47871590230729u, 3268013438u,
47882710029305u, 12886044u,
47893711259084u, 2627383582u,
47903895772404u, 648534979u,
4791260307902u, 855990313u,
47923669691805u, 263366740u,
47932938543471u, 414331688u,
47943080542944u, 3405007814u,
47953565059103u, 1190977418u,
4796390836981u, 1606450012u,
47972649808239u, 2514169310u,
47982747519432u, 4129538640u,
47991721522849u, 492099164u,
4800792990594u, 3625507637u,
48012271095827u, 2993032712u,
48022302363854u, 4013112951u,
48031111617969u, 2183845740u,
4804795918276u, 1116991810u,
48053110898804u, 3963062126u,
48062737064702u, 462795667u,
4807937372240u, 1343017609u,
48081091041189u, 2790555455u,
4809277024217u, 25485284u,
48101166522068u, 1623631848u,
4811241727183u, 2836158787u,
48123112996740u, 573836428u,
48132721658101u, 1937681565u,
48144175169209u, 3190765433u,
48151970000788u, 1668258120u,
4816114616703u, 954762543u,
4817199237753u, 4094644498u,
48182522281978u, 732086117u,
48191756889687u, 2936126607u,
48202437031370u, 4103143808u,
48213883389541u, 3171090854u,
48222483004780u, 1927385370u,
48232360538162u, 2740855009u,
48244241185118u, 1492209542u,
48251672737098u, 2148675559u,
48261789864670u, 2434313103u,
48272319172611u, 2760941207u,
48282636210123u, 1338083267u,
48291128080590u, 822806371u,
48301199583556u, 314727461u,
48311335160250u, 2084630531u,
48321156261526u, 316766066u,
4833112090465u, 3129033323u,
48342746885618u, 636616055u,
48352582210744u, 1721064910u,
48363468394263u, 470463518u,
48372076016059u, 408721884u,
48382121041886u, 378460278u,
48391915948002u, 357324860u,
48402301682622u, 2691859523u,
48411869756364u, 2429314418u,
48422193146527u, 1185564327u,
48432614088922u, 1975527044u,
4844919067651u, 2855948894u,
48453662539576u, 1943802836u,
48463529473373u, 1490330107u,
4847366036094u, 3384241033u,
48484276268604u, 448403661u,
48494271796078u, 1910401882u,
48503077107698u, 299427366u,
48512035665349u, 3201262636u,
48523738454258u, 2554452696u,
48533588997135u, 3363895827u,
48541267505995u, 1852004679u,
48552237827073u, 2803250686u,
48563468044908u, 2143572850u,
48571728158656u, 1022551180u,
48581996680960u, 839529273u,
48592400647871u, 2201096054u,
48603606433628u, 2597259793u,
48613544595875u, 3909443124u,
4862819278607u, 3447346709u,
4863806136613u, 2711436388u,
48643656063205u, 837475154u,
4865694525336u, 4070212073u,
48664011303412u, 1068395209u,
4867438095290u, 484603494u,
48682673730227u, 737767009u,
4869642310823u, 3914002299u,
4870308425103u, 268427550u,
48711334387085u, 4069797497u,
48724280783219u, 2914011058u,
48734243643405u, 2849988118u,
48742504230175u, 1817156623u,
48752804200483u, 3406991497u,
48762948254999u, 2102063419u,
48771071272117u, 514889942u,
4878571972433u, 1246595599u,
48791735616066u, 1539151988u,
48801230831543u, 277987182u,
48814269526481u, 991511607u,
488295237878u, 2005032160u,
48831291113144u, 626619670u,
48843560835907u, 164940926u,
48851433635018u, 116647396u,
48863039097112u, 2868163232u,
48871141645918u, 1764165478u,
4888881378302u, 2159170082u,
48892953647681u, 1011320066u,
4890184856151u, 1723308975u,
4891336034862u, 2017579106u,
48921476681709u, 147523618u,
48933896252223u, 2264728166u,
4894944743644u, 1694443528u,
48952690700128u, 1947321519u,
4896735478508u, 4058183171u,
4897260177668u, 505662155u,
48982391691262u, 1920739747u,
48993216960415u, 1898176786u,
49003722741628u, 1511077569u,
4901449636564u, 983350414u,
49022580237367u, 2055059789u,
49031103819072u, 2089123665u,
49043873755579u, 2718467458u,
49053124338704u, 3204250304u,
49062475035432u, 1120017626u,
49073873758287u, 1982999824u,
49082950794582u, 780634378u,
49092842141483u, 4029205195u,
49101656892865u, 3330993377u,
491180890710u, 1953796601u,
49123873078673u, 136118734u,
49132317676604u, 4199091610u,
49141864448181u, 3063437608u,
49151699452298u, 1403506686u,
49161513069466u, 2348491299u,
49174273657745u, 4055855649u,
49181805475756u, 2562064338u,
4919973124563u, 4197091358u,
4920172861513u, 2858726767u,
49214271866024u, 3071338162u,
49223590386266u, 2328277259u,
49231096050703u, 1189614342u,
4924459509140u, 771592405u,
4925817999971u, 3740825152u,
4926520400189u, 1941874618u,
4927185232757u, 4032960199u,
49283928245258u, 3527721294u,
49291301118856u, 752188080u,
49303512945009u, 308584855u,
49312105373972u, 752872278u,
49323823368815u, 3760952096u,
49334250142168u, 2565680167u,
49343646354146u, 1259957455u,
49351085857127u, 3471066607u,
493638924274u, 3770488806u,
49371083869477u, 3312508103u,
493871956383u, 3738784936u,
49393099963860u, 1255084262u,
49404286969992u, 3621849251u,
49411190908967u, 1831557743u,
49422363435042u, 54945052u,
49434059585566u, 4023974274u,
49441788578453u, 3442180039u,
49452534883189u, 2432427547u,
49463909757989u, 731996369u,
49474168347425u, 1356028512u,
49482741583197u, 1280920000u,
4949312887059u, 3259015297u,
49503946278527u, 4135481831u,
49511281043691u, 1121403845u,
49523312292477u, 1819941269u,
49531741932545u, 3293015483u,
49542127558730u, 713121337u,
49552635469238u, 486003418u,
49564015067527u, 2976737859u,
49572108187161u, 927011680u,
49581970188338u, 4177613234u,
49591799789551u, 2118505126u,
49604134691985u, 1958963937u,
49611929210029u, 2555835851u,
49622768832862u, 910892050u,
49632567532373u, 4075249328u,
496486689814u, 3726640307u,
49651392137718u, 1240000030u,
49664104757832u, 3026358429u,
4967313797689u, 1435798509u,
49683101500919u, 1241665335u,
49693573008472u, 3615577014u,
49703767659003u, 3134294021u,
49714063565523u, 2296824134u,
49721541946015u, 3087190425u,
49732693152531u, 2199672572u,
49742123763822u, 1034244398u,
4975857839960u, 2515339233u,
49762228007483u, 1628096047u,
49772116502287u, 2502657424u,
49782809830736u, 460237542u,
4979450205998u, 3646921704u,
49803818199357u, 1808504491u,
49811950698961u, 2069753399u,
49823657033172u, 3734547671u,
49834067859590u, 3292597295u,
49841106466069u, 356742959u,
49852469567432u, 3495418823u,
4986183440071u, 3248055817u,
49873662626864u, 1750561299u,
49883926138664u, 4088592524u,
4989567122118u, 3810297651u,
4990992181339u, 3384018814u,
49913272124369u, 3177596743u,
4992320086295u, 2316548367u,
4993100741310u, 451656820u,
49944086604273u, 3759628395u,
49952553391092u, 1745659881u,
49963650357479u, 2390172694u,
4997330172533u, 767377322u,
4998526742034u, 4102497288u,
49992088767754u, 164402616u,
50002482632320u, 2352347393u,
50011873658044u, 3861555476u,
50022751052984u, 1767810825u,
500320037241u, 545143220u,
50042594532522u, 472304191u,
50053441135892u, 3323383489u,
5006258785117u, 2977745165u,
50072781737565u, 2963590112u,
50082756998822u, 207428029u,
50092581558559u, 3824717027u,
50101258619503u, 3472047571u,
50112648427775u, 2360400900u,
50122393763818u, 2332399088u,
50133932701729u, 884421165u,
50141396468647u, 1377764574u,
50154061795938u, 1559119087u,
50163343596838u, 3604258095u,
50171435134775u, 1099809675u,
5018908163739u, 1418405656u,
5019368446627u, 3741651161u,
50203374512975u, 3542220540u,
50213244772570u, 200009340u,
50223198975081u, 2521038253u,
50234081637863u, 337070226u,
50243235259030u, 3897262827u,
5025736956644u, 641040550u,
5026644850146u, 1306761320u,
50274219448634u, 193750500u,
50283293278106u, 1383997679u,
50291242645122u, 4109252858u,
5030450747727u, 3716617561u,
5031362725793u, 2252520167u,
50323377483696u, 1788337208u,
50338130777u, 3226734120u,
5034759239140u, 1012411364u,
50351658628529u, 2911512007u,
50361002580201u, 1681898320u,
50373039016929u, 4294520281u,
5038367022558u, 3071359622u,
50393205848570u, 152989999u,
50403839042136u, 2357687350u,
50414273132307u, 3898950547u,
50421176841812u, 1314157485u,
504375443951u, 1027027239u,
50441858986613u, 2040551642u,
504536574105u, 2603059541u,
50463456147251u, 2137668425u,
50474077477194u, 3565689036u,
5048491832241u, 363703593u,
50492579177168u, 3589545214u,
5050265993036u, 1864569342u,
50514149035573u, 3189253455u,
50521072259310u, 3153745937u,
5053923017956u, 490608221u,
5054855846773u, 845706553u,
50551018226240u, 1604548872u,
50563833372385u, 3287246572u,
50572757959551u, 2452872151u,
50581553870564u, 1713154780u,
50592649450292u, 500120236u,
506084251717u, 661869670u,
50611444911517u, 2489716881u,
50622810524030u, 1561519055u,
50633884088359u, 2509890699u,
50644247155916u, 1005636939u,
50653224066062u, 2774151984u,
50662035978240u, 2514910366u,
50671478837908u, 3144450144u,
50682107011431u, 96459446u,
50693587732908u, 2389230590u,
50703287635953u, 250533792u,
50711235983679u, 4237425634u,
50723704645833u, 3882376657u,
50732976369049u, 1187061987u,
5074276949224u, 4100839753u,
50751698347543u, 1629662314u,
50761556151829u, 3784939568u,
5077427484362u, 4246879223u,
50783155311770u, 4285163791u,
50791693376813u, 124492786u,
50801858777639u, 3476334357u,
50811941442701u, 1121980173u,
50823485932087u, 820852908u,
5083358032121u, 2511026735u,
50841873607283u, 2556067450u,
50852248275536u, 1528632094u,
50861535473864u, 556796152u,
50871499201704u, 1472623890u,
50881526518503u, 3692729434u,
50891476438092u, 2913077464u,
5090335109599u, 2167614601u,
50914121131078u, 3158127917u,
50923051522276u, 4046477658u,
50932857717851u, 1863977403u,
50941341023343u, 692059110u,
50951802040304u, 990407433u,
50963285847572u, 319814144u,
5097561105582u, 1540183799u,
50984052924496u, 2926590471u,
50992244539806u, 439121871u,
51003317903224u, 3178387550u,
51014265214507u, 82077489u,
51021978918971u, 4279668976u,
5103128732476u, 2853224222u,
5104464407878u, 4190838199u,
5105997819001u, 3250520802u,
51062330081301u, 4095846095u,
5107733509243u, 1583801700u,
5108722314527u, 3552883023u,
51091403784280u, 432327540u,
51101877837196u, 3912423882u,
5111505219998u, 696031431u,
5112908238873u, 4189387259u,
51138759461u, 2540185277u,
51143385159748u, 381355877u,
51152519951681u, 1679786240u,
51162019419351u, 4051584612u,
51171933923923u, 3768201861u,
51181670133081u, 3454981037u,
5119700836153u, 1675560450u,
5120371560700u, 338262316u,
5121847351840u, 2222395828u,
51223130433948u, 405251683u,
51233037574880u, 184098830u,
5124453340528u, 1385561439u,
51252224044848u, 4071581802u,
51261431235296u, 5570097u,
5127570114376u, 2287305551u,
51282272418128u, 803575837u,
51293943113491u, 414959787u,
5130708083137u, 2452657767u,
51314019147902u, 3841480082u,
51323791794715u, 2965956183u,
51332763690963u, 2350937598u,
51343424361375u, 779434428u,
51351274947212u, 686105485u,
51363426668051u, 3692865672u,
51373057021940u, 2285701422u,
5138349809124u, 1379278508u,
51393623750518u, 215970497u,
51401783152480u, 823305654u,
5141216118434u, 1787189830u,
51423692048450u, 2272612521u,
51433032187389u, 4159715581u,
51441388133148u, 1611772864u,
51452544383526u, 552925303u,
51463420960112u, 3198900547u,
51473503230228u, 2603352423u,
51482318375898u, 4064071435u,
51493006227299u, 4194096960u,
51501283392422u, 1510460996u,
5151174272138u, 3671038966u,
51521775955687u, 1719108984u,
51531763892006u, 1385029063u,
51544083790740u, 406757708u,
5155684087286u, 531310503u,
51563329923157u, 3492083607u,
51571059031410u, 3037314475u,
51583105682208u, 3382290593u,
51592292208503u, 426380557u,
516097373678u, 3842309471u,
5161777173623u, 3241407531u,
5162303065016u, 1477104583u,
51634234905200u, 2512514774u,
51642649684057u, 1397502982u,
51651802596032u, 3973022223u,
51662543566442u, 3139578968u,
51673193669211u, 811750340u,
51684013496209u, 567361887u,
51694169410406u, 3622282782u,
51703403136990u, 2540585554u,
5171895210040u, 3862229802u,
51721145435213u, 4146963980u,
5173784952939u, 943914610u,
5174573034522u, 464420660u,
51752356867109u, 3054347639u,
51763985088434u, 1911188923u,
5177583391304u, 176468511u,
51782990150068u, 2338031599u,
5179519948041u, 3181425568u,
5180496106033u, 4110294665u,
51812736756930u, 1196757691u,
51821089679033u, 240953857u,
51833399092928u, 4040779538u,
51842843673626u, 240495962u,
51853017658263u, 3828377737u,
51864243717901u, 2448373688u,
51872759616657u, 2246245780u,
5188308018483u, 4262383425u,
51892731780771u, 328023017u,
51902884443148u, 841480070u,
51913188015819u, 4051263539u,
51922298178908u, 2944209234u,
51931372958390u, 4164532914u,
51944074952232u, 1683612329u,
51952155036654u, 1872815858u,
51962041174279u, 2368092311u,
5197206775997u, 2283918569u,
5198645945606u, 115406202u,
51994206471368u, 3923500892u,
52002217060665u, 350160869u,
5201706531239u, 2824302286u,
5202509981657u, 1469342315u,
5203140980u, 1891558063u,
5204164887091u, 3094962711u,
52053437115622u, 13327420u,
5206422986366u, 330624974u,
52073630863408u, 2425505046u,
5208824008515u, 3543885677u,
5209918718096u, 376390582u,
52103224043675u, 3724791476u,
52111837192976u, 2968738516u,
52123424344721u, 3187805406u,
52131550978788u, 1743089918u,
52144251270061u, 645016762u,
52153855037968u, 1928519266u,
52161373803416u, 2289007286u,
52171889218686u, 1610271373u,
52183059200728u, 2108753646u,
5219582042641u, 812347242u,
52203188172418u, 191994904u,
52211343511943u, 2247006571u,
5222463291708u, 2697254095u,
52231534175504u, 1106275740u,
5224622521957u, 917121602u,
52254095777215u, 3955972648u,
52263852234638u, 2845309942u,
52273299763344u, 2864033668u,
52282554947496u, 799569078u,
52292551629074u, 1102873346u,
52302661022773u, 2006922227u,
52312900438444u, 1448194126u,
52321321567432u, 1983773590u,
52331237256330u, 3449066284u,
52341691553115u, 3274671549u,
52354271625619u, 2741371614u,
52363285899651u, 786322314u,
52371586632825u, 564385522u,
52382530557509u, 2974240289u,
52391244759631u, 3263135197u,
52403592389776u, 3570296884u,
52412749873561u, 521432811u,
5242987586766u, 3206261120u,
52431327840078u, 4078716491u,
52441753812954u, 976892272u,
52451827135136u, 1781944746u,
52461328622957u, 1015377974u,
52473439601008u, 2209584557u,
52482482286699u, 1109175923u,
5249874877499u, 2036083451u,
5250483570344u, 1091877599u,
52514190721328u, 1129462471u,
5252640035849u, 1867372700u,
5253920761165u, 3273688770u,
52541623777358u, 3389003793u,
52553241132743u, 2734783008u,
5256696674661u, 2502161880u,
52571646071378u, 1164309901u,
5258350411888u, 1978005963u,
52592253937037u, 7371540u,
5260989577914u, 3626554867u,
52613214796883u, 531343826u,
5262398899695u, 1145247203u,
52631516846461u, 3656006011u,
5264529303412u, 3318455811u,
52653062828129u, 1696355359u,
52663698796465u, 3155218919u,
52671457595996u, 3191404246u,
52681395609912u, 2917345728u,
52691237411891u, 1854985978u,
52701091884675u, 3504488111u,
52713109924189u, 1628881950u,
52723939149151u, 878608872u,
5273778235395u, 1052990614u,
5274903730231u, 2069566979u,
52752437686324u, 3163786257u,
52762257884264u, 2123173186u,
5277939764916u, 2933010098u,
52781235300371u, 1256485167u,
52791950274665u, 2180372319u,
52802648400302u, 122035049u,
52811883344352u, 2083771672u,
52823712110541u, 321199441u,
52831896357377u, 508560958u,
52843066325351u, 2770847216u,
52853177982504u, 296902736u,
52861486926688u, 456842861u,
5287601221482u, 3992583643u,
52882794121515u, 1533934172u,
52891706465470u, 4281971893u,
52902557027816u, 900741486u,
5291227175484u, 550595824u,
5292690918144u, 2825943628u,
529390375300u, 300318232u,
52941985329734u, 1440763373u,
52953670603707u, 2533900859u,
52963253901179u, 542270815u,
52973677388841u, 307706478u,
52982570910669u, 3320103693u,
52991273768482u, 1216399252u,
53001652924805u, 1043647584u,
53011120323676u, 639941430u,
5302325675502u, 3652676161u,
53034241680335u, 1545838362u,
53041991398008u, 4100211814u,
53051097584090u, 3262252593u,
53062254324292u, 1765019121u,
53074060211241u, 2315856188u,
53083704419305u, 411263051u,
5309238929055u, 3540688404u,
53103094544537u, 3250435765u,
53113460621305u, 1967599860u,
53122016157366u, 847389916u,
53131659615591u, 4020453639u,
5314901109753u, 2682611693u,
53151661364280u, 177155177u,
53163210561911u, 3802058181u,
5317797089608u, 3286110054u,
53182110358240u, 1353279028u,
53192479975820u, 471725410u,
53202219863904u, 3623364733u,
53213167128228u, 1052188336u,
53223656587111u, 721788662u,
53233061255808u, 1615375832u,
5324924941453u, 2547780700u,
53253328169224u, 1310964134u,
53262701956286u, 4145497671u,
53271421461094u, 1221397398u,
53281589183618u, 1492533854u,
5329449740816u, 2686506989u,
53303035198924u, 1682886232u,
53312529760244u, 3342031659u,
53321235084019u, 2151665147u,
53332315686577u, 3282027660u,
53341140138691u, 2754346599u,
53352091754612u, 1178454681u,
53364226896579u, 2942520471u,
53372122168506u, 3751680858u,
53383213794286u, 2601416506u,
53394142747914u, 3951404257u,
53404243249649u, 748595836u,
53414004834921u, 238887261u,
53421927321047u, 2217148444u,
5343205977665u, 1885975275u,
5344186020771u, 2367569534u,
53452941662631u, 2608559272u,
53463342096731u, 741809437u,
53471962659444u, 3539886328u,
53483036596491u, 2282550094u,
53492366462727u, 2748286642u,
53502144472852u, 1390394371u,
53511257385924u, 2205425874u,
53522119055686u, 46865323u,
53533597555910u, 3188438773u,
53542372320753u, 3641116924u,
53553116286108u, 2680722658u,
53563371014971u, 2058751609u,
53572966943726u, 2345078707u,
53582330535244u, 4013841927u,
53591169588594u, 857915866u,
53601875260989u, 3175831309u,
53613193475664u, 1955181430u,
5362923161569u, 4068653043u,
5363776445899u, 954196929u,
536461509556u, 4248237857u,
53653808667664u, 581227317u,
53662893240187u, 4159497403u,
53674212264930u, 3973886195u,
53682077539039u, 851579036u,
53692957587591u, 772351886u,
53701173659554u, 946748363u,
53712794103714u, 2094375930u,
53724234750213u, 3671645488u,
53732614250782u, 2620465358u,
53743122317317u, 2365436865u,
53753393973390u, 523513960u,
53763645735309u, 2766686992u,
53772023960931u, 2312244996u,
53781875932218u, 3253711056u,
53793622416881u, 3274929205u,
5380612094988u, 1555465129u,
53812114270406u, 3553762793u,
53821832633644u, 1087551556u,
53833306195841u, 1702313921u,
53843675066046u, 1735998785u,
53851690923980u, 1482649756u,
53861171351291u, 2043136409u,
53871962596992u, 461214626u,
53883278253346u, 1392428048u,
53893744621107u, 1028502697u,
53903991171462u, 1014064003u,
53913642345425u, 3186995039u,
53926114625u, 3359104346u,
5393414856965u, 2814387514u,
53943583605071u, 2497896367u,
53951024572712u, 1927582962u,
53962892797583u, 845302635u,
5397328548052u, 1523379748u,
53983392622118u, 1347167673u,
53991012316581u, 37767602u,
54002647726017u, 1070326065u,
54012075035198u, 4202817168u,
54022502924707u, 2612406822u,
54032187115553u, 1180137213u,
5404701024148u, 1481965992u,
54053223787553u, 2083541843u,
5406203230202u, 3876887380u,
54071334816273u, 2870251538u,
54082186205850u, 3985213979u,
5409333533378u, 806507642u,
54101010064531u, 713520765u,
54113084131515u, 2637421459u,
54121703168933u, 1517562266u,
54134089081247u, 3231042924u,
54143079916123u, 3154574447u,
54152253948262u, 1725190035u,
54162452539325u, 1343734533u,
5417213706059u, 2519409656u,
5418108055211u, 2916327746u,
5419587001593u, 1917607088u,
54204202913084u, 926304016u,
5421469255411u, 4042080256u,
54223498936874u, 246692543u,
5423495780578u, 438717281u,
54242259272650u, 4011324645u,
54252836854664u, 2317249321u,
5426946828752u, 1280403658u,
54271905648354u, 2034241661u,
5428774652981u, 1285694082u,
54292200307766u, 2158671727u,
54301135162148u, 232040752u,
5431397012087u, 1717527689u,
54321720414106u, 918797022u,
54332580119304u, 3568069742u,
54342904461070u, 3893453420u,
5435973817938u, 667499332u,
54363785870412u, 2088861715u,
54371565179401u, 600903026u,
5438591806775u, 3512242245u,
5439997964515u, 2339605347u,
54401134342772u, 3234226304u,
54414084179455u, 302315791u,
54422445626811u, 2590372496u,
5443345572299u, 2274770442u,
54443600587867u, 3706939009u,
54451430507980u, 2656330434u,
54461079209397u, 2122849632u,
54471423705223u, 3826321888u,
54483683385276u, 1057038163u,
54491242840526u, 3987000643u,
54502398253089u, 1538190921u,
54511295898647u, 3570196893u,
54523065138774u, 3111336863u,
54532524949549u, 4203895425u,
54543025864372u, 968800353u,
54551023721001u, 3763083325u,
5456526350786u, 635552097u,
54572308118370u, 2166472723u,
54582196937373u, 2643841788u,
54593040011470u, 4010301879u,
54602782379560u, 3474682856u,
54614201389782u, 4223278891u,
54621457302296u, 2251842132u,
54631090062008u, 3188219189u,
5464292733931u, 1424229089u,
54651590782640u, 1365212370u,
54663975957073u, 3982969588u,
54672927147928u, 1048291071u,
54682766680094u, 884908196u,
546935237839u, 2221180633u,
54702490333812u, 4098360768u,
54714029081103u, 3490831871u,
54722392516272u, 3455379186u,
54733948800722u, 335456628u,
54742105117968u, 4181629008u,
54751044201772u, 3335754111u,
5476540133451u, 3313113759u,
54773786107905u, 2627207327u,
54783540337875u, 3473113388u,
54793430536378u, 2514123129u,
54802124531276u, 3872633376u,
54813272957388u, 3501994650u,
54822418881542u, 487365389u,
54833877672368u, 1512866656u,
54843486531087u, 2102955203u,
54851136054817u, 3004241477u,
54861549075351u, 1302002008u,
54873936430045u, 2258587644u,
54884109233936u, 3679809321u,
54893467083076u, 2484463221u,
54901594979755u, 529218470u,
54913527024461u, 1147434678u,
5492106799023u, 1823161970u,
54931704656738u, 1675883700u,
54943308746763u, 1875093248u,
54951352868568u, 1898561846u,
54962508994984u, 3177750780u,
54974217929592u, 400784472u,
549880090315u, 3564414786u,
54993841585648u, 3379293868u,
5500160353261u, 2413172925u,
55012378499279u, 673436726u,
55021505702418u, 1330977363u,
55031853298225u, 3201741245u,
55042135714208u, 4069554166u,
55053715612384u, 3692488887u,
55063680311316u, 4274382900u,
5507914186796u, 2264886523u,
55083869634032u, 1254199592u,
55091131020455u, 194781179u,
5510429923922u, 2763792336u,
55112052895198u, 3997373194u,
55123440090658u, 2165746386u,
55131575500242u, 3463310191u,
55142064974716u, 3779513671u,
55153106421434u, 880320527u,
55163281914119u, 286569042u,
55173909096631u, 122359727u,
55181429837716u, 252230074u,
55194111461225u, 762273136u,
552093658514u, 2766407143u,
55213623657004u, 3869801679u,
55223925695921u, 2390397316u,
55232499025338u, 2741806539u,
55242507199021u, 1659221866u,
5525361292116u, 4048761557u,
55263797133396u, 1517903247u,
55273121647246u, 3884308578u,
55281697201500u, 1558800262u,
55294150812360u, 3161302278u,
55302610217849u, 641564641u,
5531183814518u, 2075245419u,
5532611996508u, 2223461433u,
5533329123979u, 121860586u,
5534860985829u, 1137889144u,
55354018949439u, 2904348960u,
5536947795261u, 1992594155u,
55374255427501u, 2281583851u,
55382892637604u, 1478186924u,
55393050771207u, 2767035539u,
5540373510582u, 1963520320u,
55413763848370u, 3756817798u,
5542627269409u, 1806905031u,
55431814444610u, 3646665053u,
55441822693920u, 278515794u,
5545584050483u, 4142579188u,
55462149745808u, 3193071606u,
55471179706341u, 2693495182u,
55483259749808u, 644172091u,
5549880509048u, 3340630542u,
55503365160815u, 2384445068u,
55513053081915u, 2840648309u,
55521986990122u, 1084703471u,
55532370410550u, 1627743573u,
55542244943480u, 4057483496u,
55552611595995u, 2470013639u,
55564024732359u, 3987190386u,
5557873421687u, 2447660175u,
55583226583022u, 767655877u,
55592528024413u, 1962070688u,
55601233635843u, 2163464207u,
5561659054446u, 854207134u,
5562258410943u, 4197831420u,
55632515400215u, 3100476924u,
55641961549594u, 2219491151u,
55653997658851u, 163850514u,
5566470325051u, 2598261204u,
55673052145580u, 59836528u,
55681376188597u, 966733415u,
5569850667549u, 3622479237u,
55701083731990u, 1525777459u,
55714005126532u, 1428155540u,
55722781907007u, 943739431u,
55731493961005u, 2839096988u,
55742000057832u, 1941829603u,
55751901484772u, 939810041u,
55763377407371u, 3090115837u,
55773310840540u, 2068409688u,
55783261383939u, 2212130277u,
55792594774045u, 2912652418u,
55804179816101u, 3534504531u,
55813349254805u, 2796552902u,
55821385421283u, 4259908631u,
55833714780837u, 3070073945u,
55843372846298u, 3835884044u,
55853047965714u, 3009018735u,
5586744091167u, 1861124263u,
55872764936304u, 1338171648u,
55884222019554u, 1395200692u,
55891371426007u, 3338031581u,
55902525665319u, 4196233786u,
55912332743921u, 1474702008u,
55922274266301u, 4255175517u,
55932290169528u, 1793910997u,
55942188254024u, 354202001u,
55953864458796u, 4280290498u,
55961554419340u, 1733094688u,
55972010552302u, 1561807039u,
5598664313606u, 2548990879u,
55991084699349u, 3233936866u,
5600973895284u, 2386881969u,
56011831995860u, 2961465052u,
56021428704144u, 3269904970u,
5603231648253u, 2602483763u,
56044125013173u, 3319187387u,
56053347011944u, 1892898231u,
56064019114049u, 868879116u,
56074085937045u, 2378411019u,
56081072588531u, 3547435717u,
56092208070766u, 1069899078u,
56103142980597u, 2337088907u,
56111593338562u, 919414554u,
5612688077849u, 3625708135u,
56131472447348u, 1947711896u,
56143953006207u, 877438080u,
5615845995820u, 3150361443u,
56163053496713u, 2484577841u,
5617224271045u, 2914958001u,
56182682612949u, 806655563u,
56192436224507u, 1907729235u,
56202920583824u, 1251814062u,
56212070814520u, 4034325578u,
5622497847539u, 2714317144u,
5623385182008u, 640855184u,
56241327075087u, 1062468773u,
56251757405994u, 1374270191u,
56264263183176u, 3041193150u,
56271037871524u, 3633173991u,
56284231821821u, 2830131945u,
56293505072908u, 2830570613u,
56304195208715u, 575398021u,
56313992840257u, 3691788221u,
56321949847968u, 2999344380u,
56333183782163u, 3723754342u,
5634759716128u, 3284107364u,
56351714496583u, 15918244u,
5636820509475u, 2553936299u,
56372201876606u, 4237151697u,
56382605688266u, 3253705097u,
56391008333207u, 712158730u,
56401722280252u, 1933868287u,
56414152736859u, 2097020806u,
5642584426382u, 2836501956u,
56432522777566u, 1996172430u,
56442122199776u, 1069285218u,
56451474209360u, 690831894u,
5646107482532u, 3695525410u,
5647670591796u, 768977505u,
56482412057331u, 3647886687u,
56493110327607u, 1072658422u,
5650379861934u, 1557579480u,
56514124127129u, 2271365865u,
56523880613089u, 739218494u,
5653547346027u, 388559045u,
56543147335977u, 176230425u,
56553094853730u, 2554321205u,
56561495176194u, 4093461535u,
56573521297827u, 4108148413u,
56581913727929u, 1177947623u,
56591911655402u, 1053371241u,
56603265708874u, 1266515850u,
56611045540427u, 3194420196u,
56623717104621u, 1144474110u,
56631464392345u, 52070157u,
56644144237690u, 3350490823u,
56654166253320u, 2747410691u,
5666};
5667
5668// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
5669bool Test(int offset, int len = 0) {
5670#undef Check
5671#undef IsAlive
5672
5673#define Check(x) do { \
5674 const uint32_t actual = (x), e = expected[index++]; \
5675 bool ok = actual == e; \
5676 if (!ok) { \
5677 cerr << "expected " << hex << e << " but got " << actual << endl; \
5678 ++errors; \
5679 } \
5680 assert(ok); \
5681} while (0)
5682
5683#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
5684
5685 // After the following line is where the uses of "Check" and such will go.
5686 static int index = 0;
5687if (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; }
5688{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
5689{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
5690{ uint64_t h = farmhashna::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
5691
5692 return true;
5693#undef Check
5694#undef IsAlive
5695}
5696
5697int RunTest() {
5698 Setup();
5699 int i = 0;
5700 cout << "Running farmhashnaTest";
5701 if (!Test(-1)) {
5702 cout << "... Unavailable\n";
5703 return NoteErrors();
5704 }
5705 // Good. The function is attempting to hash, so run the full test.
5706 int errors_prior_to_test = errors;
5707 for ( ; i < kTestSize - 1; i++) {
5708 Test(i * i, i);
5709 }
5710 for ( ; i < kDataSize; i += i / 7) {
5711 Test(0, i);
5712 }
5713 Test(0, kDataSize);
5714 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
5715 return NoteErrors();
5716}
5717
5718#else
5719
5720// After the following line is where the code to print hash codes will go.
5721void Dump(int offset, int len) {
5722{ uint64_t h = farmhashna::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5723{ uint64_t h = farmhashna::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5724{ uint64_t h = farmhashna::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
5725}
5726
5727#endif
5728
5729#undef SEED
5730#undef SEED1
5731#undef SEED0
5732
5733} // namespace farmhashnaTest
5734
5735#if !TESTING
5736int main(int argc, char** argv) {
5737 Setup();
5738 cout << "uint32_t expected[] = {\n";
5739 int i = 0;
5740 for ( ; i < kTestSize - 1; i++) {
5741 farmhashnaTest::Dump(i * i, i);
5742 }
5743 for ( ; i < kDataSize; i += i / 7) {
5744 farmhashnaTest::Dump(0, i);
5745 }
5746 farmhashnaTest::Dump(0, kDataSize);
5747 cout << "};\n";
5748}
5749#endif
5750#ifndef FARMHASH_SELF_TEST_GUARD
5751#define FARMHASH_SELF_TEST_GUARD
5752#include <cstdio>
5753#include <iostream>
5754#include <string.h>
5755
5756using std::cout;
5757using std::cerr;
5758using std::endl;
5759using std::hex;
5760
5761static const uint64_t kSeed0 = 1234567;
5762static const uint64_t kSeed1 = k0;
5763static const int kDataSize = 1 << 20;
5764static const int kTestSize = 300;
5765#define kSeed128 Uint128(kSeed0, kSeed1)
5766
5767static char data[kDataSize];
5768
5769static int completed_self_tests = 0;
5770static int errors = 0;
5771
5772// Initialize data to pseudorandom values.
5773void Setup() {
5774 if (completed_self_tests == 0) {
5775 uint64_t a = 9;
5776 uint64_t b = 777;
5777 for (int i = 0; i < kDataSize; i++) {
5778 a += b;
5779 b += a;
5780 a = (a ^ (a >> 41)) * k0;
5781 b = (b ^ (b >> 41)) * k0 + i;
5782 uint8_t u = b >> 37;
5783 memcpy(data + i, &u, 1); // uint8_t -> char
5784 }
5785 }
5786}
5787
5788int NoteErrors() {
5789#define NUM_SELF_TESTS 9
5790 if (++completed_self_tests == NUM_SELF_TESTS)
5791 std::exit(errors > 0);
5792 return errors;
5793}
5794
5795template <typename T> inline bool IsNonZero(T x) {
5796 return x != 0;
5797}
5798
5799template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
5800 return x != Uint128(0, 0);
5801}
5802
5803#endif // FARMHASH_SELF_TEST_GUARD
5804
5805namespace farmhashntTest {
5806
5807uint32_t CreateSeed(int offset, int salt) {
5808 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
5809 h = h * c1;
5810 h ^= (h >> 17);
5811 h = h * c1;
5812 h ^= (h >> 17);
5813 h = h * c1;
5814 h ^= (h >> 17);
5815 h += static_cast<uint32_t>(offset & 0xffffffff);
5816 h = h * c1;
5817 h ^= (h >> 17);
5818 h = h * c1;
5819 h ^= (h >> 17);
5820 h = h * c1;
5821 h ^= (h >> 17);
5822 return h;
5823}
5824
5825#undef SEED
5826#undef SEED1
5827#undef SEED0
5828#define SEED CreateSeed(offset, -1)
5829#define SEED0 CreateSeed(offset, 0)
5830#define SEED1 CreateSeed(offset, 1)
5831
5832#undef TESTING
5833#define TESTING 1
5834#if TESTING
5835uint32_t expected[] = {
58362681724312u,
5837797982799u,
5838921001710u,
58392134990486u,
58402244477846u,
58412992121793u,
58423943596029u,
5843452431531u,
58442557197665u,
58452532580744u,
58463099673830u,
58473696623795u,
58483281581178u,
58491882212500u,
5850275903667u,
58513033004529u,
58521402319660u,
58532699376854u,
58544222949502u,
58551712034059u,
58561330324210u,
58572921867846u,
58581728752234u,
5859326029180u,
58603349570000u,
58611612122221u,
58621646032583u,
58631432476832u,
58643552092450u,
58651499109081u,
58661554038301u,
58673190844552u,
5868540224401u,
5869489963606u,
58701562872448u,
58712128624475u,
58721262831810u,
58731672724608u,
58742077310004u,
58751911523866u,
5876294527927u,
58771389770549u,
58782026137563u,
5879629449419u,
58802489287368u,
5881645684964u,
5882230403464u,
58833272648435u,
5884165370827u,
58851230085527u,
58863628174014u,
5887851743255u,
58881554380634u,
58893667013118u,
58902290487377u,
58911909203251u,
58921498556724u,
58934165088768u,
5894197618179u,
5895914413116u,
58961913303225u,
58973117299654u,
58981357272220u,
5899507436733u,
59001413396341u,
5901146044391u,
5902429095991u,
59033056862311u,
5904366414107u,
59052293458109u,
59061684583131u,
59071170404994u,
5908520792961u,
59091577421232u,
59104033596884u,
59114229339322u,
59123242407770u,
59132649785113u,
5914816692935u,
59153555213933u,
5916517646945u,
59172180594090u,
59183047062993u,
59192391606125u,
5920382936554u,
5921788479970u,
59222826990641u,
59233167748333u,
59241758123094u,
5925389974094u,
59263338548567u,
59272583576230u,
59283198590202u,
59294155628142u,
5930542201663u,
59312856634168u,
59323948351189u,
59334194218315u,
59341467786451u,
59352743592929u,
59361062268187u,
59373810665822u,
59382560479831u,
5939997658837u,
59403067277639u,
59411211737169u,
594259581167u,
59431389679610u,
59444189944477u,
5945100876854u,
59462062343506u,
59473088828656u,
59483284356565u,
59493130054947u,
59503532596884u,
59513887208531u,
5952259034107u,
59533233195759u,
59543200749877u,
5955760633989u,
59561115203611u,
59571516407838u,
59581778459926u,
59592146672889u,
59602457048126u,
59612217471853u,
5962862072556u,
59633745267835u,
5964701920051u,
5965581695350u,
59661410111809u,
59673326135446u,
59682187968410u,
59694267859263u,
5970479241367u,
59712868987960u,
5972704325635u,
59731418509533u,
5974735688735u,
59753283299459u,
5976813690332u,
59771439630796u,
59783195309868u,
59791616408198u,
59803254795114u,
59812799925823u,
59823929484338u,
59831798536177u,
59844205965408u,
59851499475160u,
59864247675634u,
59873779953975u,
5988785893184u,
59892778575413u,
59901160134629u,
5991823113169u,
59924116162021u,
59934167766971u,
59942487440590u,
59954004655503u,
59964044418876u,
59971462554406u,
59982011102035u,
59994265993528u,
6000576405853u,
60014038839101u,
60022425317635u,
60031401013391u,
60043062418115u,
60053167030094u,
60062602636307u,
60074264167741u,
60084017058800u,
60091029665228u,
60104036354071u,
60112670703363u,
6012688472265u,
60131054670286u,
6014338058159u,
60151539305024u,
6016146827036u,
60174060134777u,
60182502815838u,
60191603444633u,
60202448966429u,
60213891353218u,
60221082330589u,
6023201837927u,
60242848283092u,
6025883849006u,
60261982110346u,
6027541496720u,
6028133643215u,
60293847827123u,
60304015671361u,
60312849988118u,
60323452457457u,
60332102063419u,
60343281002516u,
60351539151988u,
60361147951686u,
60372005032160u,
60382415262714u,
6039116647396u,
60401029284767u,
60412159170082u,
60421919171906u,
60432017579106u,
60442473524405u,
60451694443528u,
60463671562289u,
6047505662155u,
60481019936943u,
60491511077569u,
6050773792826u,
60512089123665u,
6052484732447u,
60531120017626u,
60542809286837u,
60554029205195u,
60561097806406u,
6057136118734u,
60584017075736u,
60591403506686u,
60601516736273u,
60612562064338u,
60622984955003u,
60633071338162u,
60641923531348u,
6065771592405u,
60662586632018u,
60674032960199u,
60682687561076u,
6069308584855u,
60701692079268u,
60712565680167u,
60723674576684u,
60733770488806u,
607469201295u,
60751255084262u,
60763593730713u,
607754945052u,
60781939595371u,
60792432427547u,
60802295501078u,
60811280920000u,
608282177963u,
60831121403845u,
60842889101923u,
6085713121337u,
60861747052377u,
6087927011680u,
60884142246789u,
60891958963937u,
60901636932722u,
60914075249328u,
60922025886508u,
60933026358429u,
60941845587644u,
60953615577014u,
60961363253259u,
60973087190425u,
6098341851980u,
60992515339233u,
61001276595523u,
6101460237542u,
61024198897105u,
61032069753399u,
61044278599955u,
6105356742959u,
61063735275001u,
61071750561299u,
6108668829411u,
61093384018814u,
61104233785523u,
6111451656820u,
6112107312677u,
61132390172694u,
61141216645846u,
6115164402616u,
61161689811113u,
61171767810825u,
61181397772514u,
61193323383489u,
61202986430557u,
6121207428029u,
61222260498180u,
61232360400900u,
61241263709570u,
61251377764574u,
61264252610345u,
61271099809675u,
61282776960536u,
61293542220540u,
61303752806924u,
6131337070226u,
61323267551635u,
61331306761320u,
61342220373824u,
61354109252858u,
6136896322512u,
61371788337208u,
61381336556841u,
61392911512007u,
61403712582785u,
61413071359622u,
61422561488770u,
61433898950547u,
6144536047554u,
61452040551642u,
61463528794619u,
61473565689036u,
61481197100813u,
61491864569342u,
61503329594980u,
6151490608221u,
61521174785921u,
61533287246572u,
61542163330264u,
6155500120236u,
61562520062970u,
61571561519055u,
61584042710240u,
61592774151984u,
61603160666939u,
616196459446u,
61621878067032u,
61634237425634u,
61642952135524u,
61654100839753u,
61661265237690u,
61674246879223u,
6168834830418u,
61693476334357u,
61704277111759u,
61712511026735u,
61723065234219u,
6173556796152u,
6174198182691u,
61752913077464u,
61761535115487u,
61774046477658u,
6178140762681u,
6179990407433u,
61802198985327u,
61812926590471u,
6182559702706u,
618382077489u,
61841096697687u,
61854190838199u,
61863046872820u,
61871583801700u,
61882185339100u,
61893912423882u,
61903703603898u,
61912540185277u,
61921446869792u,
61934051584612u,
61942719373510u,
61951675560450u,
61961996164093u,
6197405251683u,
61982864244470u,
61994071581802u,
62002028708916u,
6201803575837u,
6202557660441u,
62033841480082u,
6204255451671u,
6205779434428u,
62063452203069u,
62072285701422u,
62081568745354u,
6209823305654u,
62103184047862u,
62114159715581u,
62123160134214u,
62133198900547u,
62141566527339u,
62154194096960u,
62161496132623u,
62171719108984u,
62182584236470u,
6219531310503u,
62203456882941u,
62213382290593u,
6222467441309u,
62233241407531u,
62242540270567u,
62251397502982u,
62263348545480u,
6227811750340u,
62281017047954u,
62292540585554u,
62303531646869u,
6231943914610u,
62321903578924u,
62331911188923u,
6234241574049u,
62353181425568u,
62363529565564u,
6237240953857u,
62382964595704u,
62393828377737u,
62404260564140u,
62414262383425u,
6242383233885u,
62434051263539u,
6244919677938u,
62451683612329u,
62464204155962u,
62472283918569u,
62484153726847u,
6249350160869u,
62501387233546u,
62511891558063u,
6252740563169u,
6253330624974u,
62542948665536u,
6255376390582u,
62563799363969u,
62573187805406u,
62582263421398u,
62591928519266u,
62602746577402u,
62612108753646u,
6262768287270u,
62632247006571u,
6264212490675u,
6265917121602u,
62662549835613u,
62672864033668u,
62683738062408u,
62692006922227u,
62702616619070u,
62713449066284u,
6272431292293u,
6273786322314u,
62741415970351u,
62753263135197u,
62762954777083u,
62773206261120u,
62782287507921u,
62791781944746u,
62804081586725u,
62811109175923u,
62821813855658u,
62831129462471u,
62841037031473u,
62853389003793u,
62863122687303u,
62871164309901u,
62883193251135u,
62893626554867u,
62903071568023u,
62913656006011u,
62921167681812u,
62933155218919u,
62942704165015u,
62951854985978u,
62961712976649u,
6297878608872u,
62984155949943u,
62993163786257u,
63001626463554u,
63011256485167u,
6302582664250u,
63032083771672u,
6304804336148u,
63052770847216u,
63061674051445u,
63073992583643u,
63082966108111u,
6309900741486u,
63104014551783u,
6311300318232u,
63123517585534u,
6313542270815u,
6314760762191u,
63151216399252u,
6316643179562u,
63173652676161u,
63182990167340u,
63193262252593u,
63202134299399u,
6321411263051u,
63221342880802u,
63231967599860u,
6324853593042u,
63252682611693u,
6326850464484u,
63273286110054u,
63283842907484u,
63293623364733u,
63303693536939u,
63311615375832u,
63322318423400u,
63334145497671u,
63341728968857u,
63352686506989u,
63361502282913u,
63372151665147u,
63383651607391u,
63391178454681u,
63404146839064u,
63412601416506u,
63421448097974u,
6343238887261u,
63444093725287u,
63452367569534u,
6346679517009u,
63473539886328u,
63483086277222u,
63491390394371u,
6350119173722u,
63511766260771u,
6352751439914u,
6353215917713u,
63542656990891u,
63551570750352u,
63563533987737u,
63573576119563u,
6358963183826u,
63593796810515u,
6360136547246u,
63612592925324u,
6362427154472u,
63631228758574u,
63641464255968u,
63652984611177u,
63662001585786u,
63671525438381u,
63681348536411u,
63692861338018u,
6370764077711u,
63713785343245u,
6372457568934u,
63734104954272u,
63742381948487u,
63753148473363u,
63762180270337u,
63771387729170u,
6378951677556u,
63792721005055u,
638066786703u,
63811149351924u,
63821895026827u,
63833711056516u,
63843638638708u,
63852263003308u,
63863448840877u,
6387225333538u,
63883797521928u,
63893262952567u,
63902078619498u,
63911178073973u,
63923288261538u,
63931496966875u,
63942481012988u,
6395114945840u,
63961632780103u,
63972087949619u,
63983787017905u,
63992575395164u,
64002971726178u,
64013642087909u,
64023894199764u,
6403203853421u,
6404425935223u,
64053565833278u,
64061748785729u,
6407580966986u,
64082124704694u,
64091107045577u,
64101067532701u,
64111406028344u,
641218613994u,
64133476683808u,
64143762914298u,
64151844996900u,
6416904215228u,
64171118521573u,
64183657647605u,
64193136157065u,
64202287683323u,
6421126005630u,
64223555092974u,
642349515858u,
64241010661841u,
64251902040126u,
64261400735275u,
64272771676666u,
64282225229957u,
64293454177594u,
64302883475137u,
64314144472319u,
64321051332394u,
6433542648229u,
64341669710469u,
6435553041029u,
6436584127807u,
64372993670925u,
64383587959456u,
64391745399498u,
64401404723176u,
64411334333531u,
64423239516985u,
64431275954779u,
6444367320647u,
64453684418197u,
64464030809053u,
6447484559105u,
64484255931645u,
64494271715616u,
64503171911678u,
6451928543347u,
64522159512867u,
6453313902234u,
6454647086234u,
6455577214736u,
64561130129573u,
6457995791646u,
64581645086060u,
64594122335794u,
64601064648931u,
64612752145076u,
64623312498873u,
64634238535494u,
64641471227427u,
6465633688562u,
64661959779970u,
6467766642813u,
64681380896111u,
64693647601207u,
64701733961041u,
6471521947915u,
6472189164145u,
6473486382294u,
64743770038872u,
64753235740744u,
64761912506671u,
64772276864677u,
64781588060152u,
64792504457929u,
64801471020554u,
64813623212998u,
64823026631806u,
64832342164722u,
64841674890530u,
64853011542850u,
64863549160092u,
64874290680005u,
64883943068002u,
64892273781461u,
64902127663659u,
64911646681121u,
6492447810651u,
64932366308558u,
6494970504950u,
64952008155560u,
64962695940969u,
64973444688454u,
64981739318893u,
64992683090634u,
65002774816580u,
6501437560100u,
6502512012738u,
65033305170944u,
6504665292744u,
65053580039116u,
65061579404983u,
65073397891494u,
6508710590371u,
65092514565805u,
65103624609754u,
65113516075816u,
65121314000850u,
65131935166880u,
65143257747610u,
65153776931214u,
65163183054185u,
6517675129307u,
65183333261712u,
65191154611403u,
65202759854023u,
65211963228038u,
6522505138315u,
65231803966773u,
65244032705384u,
6525798395739u,
65263473799845u,
6527476400898u,
6528602972493u,
65293289878097u,
65302520311409u,
65313214794876u,
6532748160407u,
65331326769504u,
6534902775872u,
65351372805534u,
65361213925114u,
65373009384989u,
65383781981134u,
65392835608783u,
65402716786748u,
65411669490957u,
65421089334066u,
6543250756920u,
65444041016629u,
65452495807367u,
65462008251381u,
6547106212622u,
65481927268995u,
65492251978818u,
65503788056262u,
65513678660147u,
65522656772270u,
65531997584981u,
65542668998785u,
65552954162084u,
6556845687881u,
6557776018378u,
65582066910012u,
6559918315064u,
6560};
6561
6562// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
6563bool Test(int offset, int len = 0) {
6564#undef Check
6565#undef IsAlive
6566
6567#define Check(x) do { \
6568 const uint32_t actual = (x), e = expected[index++]; \
6569 bool ok = actual == e; \
6570 if (!ok) { \
6571 cerr << "expected " << hex << e << " but got " << actual << endl; \
6572 ++errors; \
6573 } \
6574 assert(ok); \
6575} while (0)
6576
6577#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
6578
6579 // After the following line is where the uses of "Check" and such will go.
6580 static int index = 0;
6581if (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; }
6582Check(farmhashnt::Hash32WithSeed(data + offset, len, SEED));
6583Check(farmhashnt::Hash32(data + offset, len));
6584
6585 return true;
6586#undef Check
6587#undef IsAlive
6588}
6589
6590int RunTest() {
6591 Setup();
6592 int i = 0;
6593 cout << "Running farmhashntTest";
6594 if (!Test(-1)) {
6595 cout << "... Unavailable\n";
6596 return NoteErrors();
6597 }
6598 // Good. The function is attempting to hash, so run the full test.
6599 int errors_prior_to_test = errors;
6600 for ( ; i < kTestSize - 1; i++) {
6601 Test(i * i, i);
6602 }
6603 for ( ; i < kDataSize; i += i / 7) {
6604 Test(0, i);
6605 }
6606 Test(0, kDataSize);
6607 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
6608 return NoteErrors();
6609}
6610
6611#else
6612
6613// After the following line is where the code to print hash codes will go.
6614void Dump(int offset, int len) {
6615cout << farmhashnt::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
6616cout << farmhashnt::Hash32(data + offset, len) << "u," << endl;
6617}
6618
6619#endif
6620
6621#undef SEED
6622#undef SEED1
6623#undef SEED0
6624
6625} // namespace farmhashntTest
6626
6627#if !TESTING
6628int main(int argc, char** argv) {
6629 Setup();
6630 cout << "uint32_t expected[] = {\n";
6631 int i = 0;
6632 for ( ; i < kTestSize - 1; i++) {
6633 farmhashntTest::Dump(i * i, i);
6634 }
6635 for ( ; i < kDataSize; i += i / 7) {
6636 farmhashntTest::Dump(0, i);
6637 }
6638 farmhashntTest::Dump(0, kDataSize);
6639 cout << "};\n";
6640}
6641#endif
6642#ifndef FARMHASH_SELF_TEST_GUARD
6643#define FARMHASH_SELF_TEST_GUARD
6644#include <cstdio>
6645#include <iostream>
6646#include <string.h>
6647
6648using std::cout;
6649using std::cerr;
6650using std::endl;
6651using std::hex;
6652
6653static const uint64_t kSeed0 = 1234567;
6654static const uint64_t kSeed1 = k0;
6655static const int kDataSize = 1 << 20;
6656static const int kTestSize = 300;
6657#define kSeed128 Uint128(kSeed0, kSeed1)
6658
6659static char data[kDataSize];
6660
6661static int completed_self_tests = 0;
6662static int errors = 0;
6663
6664// Initialize data to pseudorandom values.
6665void Setup() {
6666 if (completed_self_tests == 0) {
6667 uint64_t a = 9;
6668 uint64_t b = 777;
6669 for (int i = 0; i < kDataSize; i++) {
6670 a += b;
6671 b += a;
6672 a = (a ^ (a >> 41)) * k0;
6673 b = (b ^ (b >> 41)) * k0 + i;
6674 uint8_t u = b >> 37;
6675 memcpy(data + i, &u, 1); // uint8_t -> char
6676 }
6677 }
6678}
6679
6680int NoteErrors() {
6681#define NUM_SELF_TESTS 9
6682 if (++completed_self_tests == NUM_SELF_TESTS)
6683 std::exit(errors > 0);
6684 return errors;
6685}
6686
6687template <typename T> inline bool IsNonZero(T x) {
6688 return x != 0;
6689}
6690
6691template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
6692 return x != Uint128(0, 0);
6693}
6694
6695#endif // FARMHASH_SELF_TEST_GUARD
6696
6697namespace farmhashsaTest {
6698
6699uint32_t CreateSeed(int offset, int salt) {
6700 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
6701 h = h * c1;
6702 h ^= (h >> 17);
6703 h = h * c1;
6704 h ^= (h >> 17);
6705 h = h * c1;
6706 h ^= (h >> 17);
6707 h += static_cast<uint32_t>(offset & 0xffffffff);
6708 h = h * c1;
6709 h ^= (h >> 17);
6710 h = h * c1;
6711 h ^= (h >> 17);
6712 h = h * c1;
6713 h ^= (h >> 17);
6714 return h;
6715}
6716
6717#undef SEED
6718#undef SEED1
6719#undef SEED0
6720#define SEED CreateSeed(offset, -1)
6721#define SEED0 CreateSeed(offset, 0)
6722#define SEED1 CreateSeed(offset, 1)
6723
6724#undef TESTING
6725#define TESTING 1
6726#if TESTING
6727uint32_t expected[] = {
67284223616069u,
67293696677242u,
67304081014168u,
67312576519988u,
67322212771159u,
67331112731063u,
67341020067935u,
67353955445564u,
67361451961420u,
6737653440099u,
673831917516u,
67392957164615u,
67402590087362u,
67413879448744u,
6742176305566u,
67432447367541u,
67441359016305u,
67453363804638u,
67461117290165u,
67471062549743u,
67482437877004u,
67491894455839u,
6750673206794u,
67513486923651u,
67523269862919u,
67532303349487u,
67541380660650u,
6755595525107u,
67561525325287u,
67572025609358u,
6758176408838u,
67591592885012u,
6760864896482u,
67612101378090u,
67623489229104u,
67632118965695u,
6764581644891u,
67652718789079u,
6766631613207u,
67674228658372u,
67683867875546u,
67693531368319u,
67703804516756u,
67713317755099u,
67721619744564u,
67732884717286u,
67741088213445u,
67752667691076u,
67763727873235u,
67772330406762u,
6778858590707u,
6779123802208u,
67804150036245u,
6781182283099u,
67821478882570u,
67833282617403u,
6784819171187u,
67851172627392u,
67864254302102u,
67872957028020u,
6788437030323u,
67892452147680u,
67902868246750u,
67913530169402u,
67923154852132u,
6793215019192u,
6794357580983u,
67951354454461u,
67961108813287u,
67972324008118u,
67982315997713u,
67994181601562u,
68001360882441u,
680192423273u,
68023048866755u,
68033369188505u,
68043664371439u,
68052920710428u,
68061027891570u,
68072653166430u,
68083461888315u,
68091475780447u,
6810292769636u,
68111737473313u,
68124064110516u,
68134170160075u,
6814762850927u,
68153630603695u,
68162803307356u,
6817844987665u,
6818460980967u,
68193005635467u,
68202802568977u,
6821588668033u,
68222148940781u,
68233239099984u,
68241266953698u,
68253197808789u,
68263519942533u,
68272511995334u,
68282553810188u,
6829871667697u,
68301358675720u,
68311499319171u,
68322044931270u,
68331210355103u,
6834807152540u,
68353262320756u,
68362810214575u,
68371813386141u,
68384089465863u,
6839903928165u,
68401388899322u,
68413209183659u,
6842834536144u,
68432733354550u,
68442742289921u,
68453689042563u,
68462655593281u,
68474169686303u,
6848415985561u,
6849138892376u,
6850516115393u,
685165683883u,
68524162865100u,
6853889944635u,
6854313566528u,
68553346420907u,
68561504303591u,
68572256809275u,
6858742243229u,
6859779775302u,
68603140940172u,
68612312556111u,
68622304095772u,
68631151741606u,
68642194712422u,
68651714084652u,
68663272736835u,
68671311540658u,
6868191179665u,
68693996605106u,
68701657345233u,
68714205442903u,
68721553339212u,
68732351843044u,
68741647502006u,
68752525516233u,
6876292202846u,
68771498646290u,
68781429323381u,
6879974274898u,
68803759331561u,
68812881238887u,
6882826787221u,
68831069622448u,
6884221991032u,
68851462969082u,
68862799661508u,
6887364022781u,
68882594244377u,
6889797773898u,
68904097839290u,
68911529150125u,
68922456805570u,
6893541503425u,
68943936326142u,
68953112719954u,
6896775223581u,
68973074018423u,
68983198488875u,
68991772191849u,
69002456535211u,
69013154686028u,
69021520862019u,
69034005829426u,
69041306433767u,
69051943028506u,
69062246000782u,
69071057766454u,
69083761996982u,
69093441075333u,
6910898641979u,
69113450209088u,
69123941329307u,
69133289922449u,
69143085075827u,
69151814193220u,
6916690422997u,
69172627846676u,
69182653520704u,
69193739145533u,
69203996776010u,
69212287072592u,
69221346671698u,
69233082629900u,
69242298811274u,
69253639722036u,
69261729419228u,
69271836765953u,
69283708118742u,
6929213436u,
6930950223749u,
69313734247682u,
69322924575678u,
69331382024841u,
69342431637732u,
69353448846682u,
69361341301397u,
69374206956590u,
69381730650902u,
69392581075456u,
69401542359141u,
6941707222542u,
69422925350541u,
69433846303536u,
69443579103295u,
69453932175763u,
69461339615732u,
6947848825750u,
69481070170828u,
69491964973818u,
6950577060344u,
6951607721296u,
69524031023048u,
6953406883794u,
69543991905552u,
69551198544082u,
6956872468460u,
69571044847096u,
69583159976313u,
69593020028266u,
69602108700400u,
69613373767922u,
6962264431841u,
69632817097007u,
69643700061048u,
69651733731531u,
69663459415893u,
696780378591u,
69681479875104u,
696919735612u,
69701382658977u,
69713416562245u,
69721959852842u,
69732384002344u,
6974124683828u,
69753725782174u,
69762300301222u,
6977393852269u,
69781302492002u,
69793623776492u,
69803787086417u,
69811730024749u,
69821710531361u,
6983443700716u,
69841461987482u,
6985671998131u,
69863018380746u,
69872592292305u,
69883390799372u,
69893945101155u,
69903743494852u,
69913716045582u,
6992996005166u,
6993320698449u,
69943420221765u,
69951518157951u,
69962555810666u,
69973381929684u,
69982019638523u,
69993088262796u,
70002072178906u,
70013433649364u,
7002203906916u,
700334663784u,
7004290301305u,
70051188021504u,
70063754681145u,
70073920313139u,
70082840496520u,
70091656802962u,
70102288475489u,
70113399185138u,
70121296000826u,
70132362384746u,
7014309633360u,
70152719851778u,
7016776035930u,
70173200733043u,
7018365690832u,
70193326378243u,
70201500331457u,
70211625708592u,
70224230903462u,
7023715344888u,
70243363777768u,
70252243620288u,
70262890765789u,
7027553154234u,
70284044100108u,
70294056887320u,
70301185656496u,
70313671476744u,
70321064586897u,
70331154949698u,
70343493481974u,
70351294573722u,
70361869224012u,
70372530084956u,
7038995321553u,
7039833419249u,
7040563815282u,
7041250258043u,
70422970801822u,
7043441007535u,
704442246961u,
70452820426655u,
70462878882436u,
70472363245780u,
70482138489282u,
70492972360481u,
70502312619393u,
70513598664848u,
70523071556076u,
7053776990325u,
70543220427357u,
70552257939577u,
70563817305903u,
70571502979698u,
70583159755934u,
70593955997276u,
70602423850008u,
70611959927572u,
70621219782288u,
70634119776679u,
70641124253854u,
70653678052422u,
70662620644947u,
70671262408666u,
70683480072280u,
70692627137665u,
7070807538749u,
70713276646337u,
7072518510128u,
70731137828655u,
70741498449110u,
70753031692317u,
70761125635969u,
70771130096111u,
7078780007336u,
70793111856399u,
70801014917264u,
7081780877352u,
70822909458336u,
70834235949214u,
70842423879289u,
7085275888892u,
70863891926795u,
70873538163953u,
708854815161u,
7089162228302u,
7090258154068u,
70913554455591u,
70921801469029u,
70932801563220u,
7094726560058u,
70952450221940u,
70963677582978u,
7097440993800u,
7098424762443u,
70992624525253u,
71002587715329u,
71012292264424u,
71021074856749u,
71033294752007u,
71043164112672u,
71052399146799u,
71061920182465u,
71073858835361u,
7108193755240u,
71093333610311u,
71101757504059u,
71112576027039u,
71122775253365u,
71132939191561u,
71141046147275u,
7115235149906u,
71164262218222u,
71172900542726u,
71182260154702u,
71191019551635u,
71201194720570u,
71213519118691u,
71223039483153u,
712384918216u,
71243053381097u,
71252572396843u,
71263849763371u,
71272782686780u,
71283710049554u,
71293403430713u,
71302346080784u,
71312496307442u,
71321597281872u,
7133696018239u,
7134704625714u,
7135623026921u,
71363182413559u,
71373794540330u,
7138305497722u,
71391592680199u,
71402377854072u,
71413060601746u,
71423953057908u,
71433941551588u,
71441033716182u,
71452765716854u,
71461309699058u,
71473519400181u,
71483073370877u,
7149115583008u,
71504032909296u,
71512944563574u,
71523762753718u,
7153192842727u,
71541711348701u,
71553086147235u,
71561658229443u,
71571479783872u,
71583839977157u,
7159225619117u,
71601349684817u,
71611964813173u,
7162565753187u,
71632530252046u,
7164840014353u,
71651645183704u,
71663668429078u,
71673438418557u,
7168639704059u,
7169360837811u,
71702531807958u,
71711572353913u,
71722116037299u,
71731948437512u,
7174744553393u,
71752380697034u,
71763775234105u,
71773816065157u,
7178301868653u,
71792960939561u,
71803306528247u,
71812389296549u,
7182805918610u,
71831759358265u,
71841760876328u,
71852827601706u,
71862944594708u,
71873313666458u,
71882022601495u,
7189730938791u,
7190193539397u,
71912026103244u,
7192802928398u,
71932630934308u,
7194782805818u,
71953499326016u,
7196293509489u,
71973646131514u,
71983182478647u,
7199854800333u,
72002284531628u,
7201438528022u,
72022339298129u,
72031692289216u,
72042427728723u,
720546501288u,
7206350652353u,
72071355971222u,
7208889682372u,
7209944799254u,
72102763906061u,
72112807550612u,
72122683762637u,
7213100870317u,
72142449357318u,
72152638348436u,
72164206088869u,
72171788948473u,
72183537588549u,
72192782490204u,
7220134406470u,
72212409190528u,
72222362439849u,
72231861661528u,
72242101513194u,
72251424834765u,
72263581765745u,
72273185999525u,
72282057487100u,
72292303941176u,
72303639628788u,
72311180265315u,
7232230437935u,
72332108319366u,
72341131685143u,
72351055685292u,
72361509007009u,
72371258485140u,
7238560525005u,
72393598799040u,
72403835680585u,
72411851859628u,
7242332858996u,
7243641769248u,
72444252450037u,
7245865386707u,
7246720719117u,
72473133612164u,
72483833045874u,
72493492515435u,
72502465970289u,
72514234420011u,
7252573859916u,
7253252532886u,
7254870392318u,
72554051320920u,
7256894929092u,
72573748361688u,
7258699355960u,
72591885212350u,
72601609756949u,
7261461896870u,
72621337065461u,
72631775211059u,
72641786193749u,
72652815154643u,
72662128729882u,
7267969639529u,
72683960427545u,
7269859416958u,
72702739758802u,
72712698032197u,
72722813292418u,
72731985467524u,
7274396604317u,
72754122172759u,
72761201259789u,
72774282051702u,
72783270018895u,
7279961215209u,
7280961075860u,
72814211926998u,
72824088374597u,
7283577510509u,
72843058349487u,
72854025377754u,
72862815478438u,
7287471023164u,
72883947959608u,
72894161486934u,
72902299888461u,
72911103571511u,
72922450153872u,
72931839939275u,
7294108299608u,
7295858086440u,
72961030152945u,
72973895328530u,
72983009080718u,
72993690840454u,
73003847025277u,
7301152331362u,
7302161365689u,
7303831319961u,
73042166017294u,
73053945322722u,
73064059970216u,
73071420824131u,
73082770648308u,
73091567250186u,
73102181067149u,
73111939743488u,
73123080158120u,
73133435218248u,
73142495237495u,
73153814085102u,
73163180983013u,
73173199054292u,
73182204745908u,
73191140337267u,
73202213569784u,
73211941879842u,
73222105562605u,
73233618835614u,
73242247103645u,
73252492473487u,
7326856414299u,
7327166022030u,
73284080104712u,
73293218935344u,
73303284220561u,
73314261581452u,
73321206944836u,
73333496705432u,
73342215996876u,
73353154627465u,
73363384005496u,
7337742170556u,
73381333047620u,
7339802680366u,
7340156833431u,
73412682100354u,
73422493654830u,
7343584848366u,
73441691693131u,
73452169934170u,
7346779968026u,
73472099545800u,
73481423039695u,
73494292110968u,
73504266576788u,
7351149142597u,
7352748501873u,
73533865014822u,
73541913588198u,
7355130285614u,
73563500768879u,
7357915458923u,
73583071792750u,
73591339986633u,
73604143929149u,
73614048379479u,
7362725193827u,
73631375113643u,
73642425277412u,
73654144659274u,
7366465714768u,
7367226991589u,
73682212127704u,
73693936145258u,
73702891024846u,
73713816000225u,
7372979331165u,
73731749907536u,
737453847318u,
73751462525833u,
73762961425455u,
7377368859113u,
73783572721452u,
7379453048644u,
73801628629918u,
73813497673923u,
73823619079585u,
7383139870565u,
73841518176798u,
73853933074281u,
73861878623729u,
73872074035641u,
73883016759257u,
73891313053591u,
73902557706970u,
73912348296582u,
7392962370022u,
73932337285014u,
73941618936717u,
73951915877085u,
73962743743122u,
73973250783882u,
73981346652536u,
7399143311109u,
74002443788461u,
74011048248964u,
74022806619339u,
74033263266976u,
74041668146349u,
74053397428868u,
74063276188862u,
74071774196343u,
74081993847813u,
74092771079610u,
7410476672419u,
74112119050359u,
74122918326659u,
74132245402721u,
74142692910474u,
74152374383269u,
7416342400227u,
74172961437795u,
74183899230368u,
7419337787132u,
74203664444935u,
74211269451153u,
74222971526729u,
74231486511182u,
7424791070133u,
74252570319890u,
74263482497490u,
74272134230518u,
74284273391202u,
74291825511330u,
74303947753714u,
74311389755724u,
74323995075516u,
74332081052615u,
74343626343470u,
74354213603435u,
74362137917278u,
74372898987303u,
74383059215715u,
74393383237881u,
74403003674434u,
7441409174425u,
74421911915604u,
74432087728055u,
74442942005882u,
74453386522440u,
7446714936074u,
7447261924004u,
74483268784033u,
74491141188757u,
74502413217552u,
74511515163433u,
7452};
7453
7454// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
7455bool Test(int offset, int len = 0) {
7456#undef Check
7457#undef IsAlive
7458
7459#define Check(x) do { \
7460 const uint32_t actual = (x), e = expected[index++]; \
7461 bool ok = actual == e; \
7462 if (!ok) { \
7463 cerr << "expected " << hex << e << " but got " << actual << endl; \
7464 ++errors; \
7465 } \
7466 assert(ok); \
7467} while (0)
7468
7469#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
7470
7471 // After the following line is where the uses of "Check" and such will go.
7472 static int index = 0;
7473if (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; }
7474Check(farmhashsa::Hash32WithSeed(data + offset, len, SEED));
7475Check(farmhashsa::Hash32(data + offset, len));
7476
7477 return true;
7478#undef Check
7479#undef IsAlive
7480}
7481
7482int RunTest() {
7483 Setup();
7484 int i = 0;
7485 cout << "Running farmhashsaTest";
7486 if (!Test(-1)) {
7487 cout << "... Unavailable\n";
7488 return NoteErrors();
7489 }
7490 // Good. The function is attempting to hash, so run the full test.
7491 int errors_prior_to_test = errors;
7492 for ( ; i < kTestSize - 1; i++) {
7493 Test(i * i, i);
7494 }
7495 for ( ; i < kDataSize; i += i / 7) {
7496 Test(0, i);
7497 }
7498 Test(0, kDataSize);
7499 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
7500 return NoteErrors();
7501}
7502
7503#else
7504
7505// After the following line is where the code to print hash codes will go.
7506void Dump(int offset, int len) {
7507cout << farmhashsa::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
7508cout << farmhashsa::Hash32(data + offset, len) << "u," << endl;
7509}
7510
7511#endif
7512
7513#undef SEED
7514#undef SEED1
7515#undef SEED0
7516
7517} // namespace farmhashsaTest
7518
7519#if !TESTING
7520int main(int argc, char** argv) {
7521 Setup();
7522 cout << "uint32_t expected[] = {\n";
7523 int i = 0;
7524 for ( ; i < kTestSize - 1; i++) {
7525 farmhashsaTest::Dump(i * i, i);
7526 }
7527 for ( ; i < kDataSize; i += i / 7) {
7528 farmhashsaTest::Dump(0, i);
7529 }
7530 farmhashsaTest::Dump(0, kDataSize);
7531 cout << "};\n";
7532}
7533#endif
7534#ifndef FARMHASH_SELF_TEST_GUARD
7535#define FARMHASH_SELF_TEST_GUARD
7536#include <cstdio>
7537#include <iostream>
7538#include <string.h>
7539
7540using std::cout;
7541using std::cerr;
7542using std::endl;
7543using std::hex;
7544
7545static const uint64_t kSeed0 = 1234567;
7546static const uint64_t kSeed1 = k0;
7547static const int kDataSize = 1 << 20;
7548static const int kTestSize = 300;
7549#define kSeed128 Uint128(kSeed0, kSeed1)
7550
7551static char data[kDataSize];
7552
7553static int completed_self_tests = 0;
7554static int errors = 0;
7555
7556// Initialize data to pseudorandom values.
7557void Setup() {
7558 if (completed_self_tests == 0) {
7559 uint64_t a = 9;
7560 uint64_t b = 777;
7561 for (int i = 0; i < kDataSize; i++) {
7562 a += b;
7563 b += a;
7564 a = (a ^ (a >> 41)) * k0;
7565 b = (b ^ (b >> 41)) * k0 + i;
7566 uint8_t u = b >> 37;
7567 memcpy(data + i, &u, 1); // uint8_t -> char
7568 }
7569 }
7570}
7571
7572int NoteErrors() {
7573#define NUM_SELF_TESTS 9
7574 if (++completed_self_tests == NUM_SELF_TESTS)
7575 std::exit(errors > 0);
7576 return errors;
7577}
7578
7579template <typename T> inline bool IsNonZero(T x) {
7580 return x != 0;
7581}
7582
7583template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
7584 return x != Uint128(0, 0);
7585}
7586
7587#endif // FARMHASH_SELF_TEST_GUARD
7588
7589namespace farmhashsuTest {
7590
7591uint32_t CreateSeed(int offset, int salt) {
7592 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
7593 h = h * c1;
7594 h ^= (h >> 17);
7595 h = h * c1;
7596 h ^= (h >> 17);
7597 h = h * c1;
7598 h ^= (h >> 17);
7599 h += static_cast<uint32_t>(offset & 0xffffffff);
7600 h = h * c1;
7601 h ^= (h >> 17);
7602 h = h * c1;
7603 h ^= (h >> 17);
7604 h = h * c1;
7605 h ^= (h >> 17);
7606 return h;
7607}
7608
7609#undef SEED
7610#undef SEED1
7611#undef SEED0
7612#define SEED CreateSeed(offset, -1)
7613#define SEED0 CreateSeed(offset, 0)
7614#define SEED1 CreateSeed(offset, 1)
7615
7616#undef TESTING
7617#define TESTING 1
7618#if TESTING
7619uint32_t expected[] = {
76204223616069u,
76213696677242u,
76224081014168u,
76232576519988u,
76242212771159u,
76251112731063u,
76261020067935u,
76273955445564u,
76281451961420u,
7629653440099u,
763031917516u,
76312957164615u,
76322590087362u,
76333879448744u,
7634176305566u,
76352447367541u,
76361359016305u,
76373363804638u,
76381117290165u,
76391062549743u,
76402437877004u,
76411894455839u,
7642673206794u,
76433486923651u,
76443269862919u,
76452303349487u,
76461380660650u,
7647595525107u,
76481525325287u,
76492025609358u,
7650176408838u,
76511592885012u,
7652864896482u,
76532101378090u,
76543489229104u,
76552118965695u,
7656581644891u,
76572718789079u,
7658631613207u,
76594228658372u,
76603867875546u,
76613531368319u,
76623804516756u,
76633317755099u,
76641619744564u,
76652884717286u,
76661088213445u,
76672667691076u,
76683727873235u,
76692330406762u,
7670858590707u,
7671457744844u,
76724150036245u,
76732000404290u,
76741478882570u,
7675901678172u,
7676819171187u,
7677195942998u,
76784254302102u,
76793967266927u,
7680437030323u,
76814018009204u,
76822868246750u,
76833540087514u,
76843154852132u,
76853319116625u,
7686357580983u,
76873177665294u,
76881108813287u,
76891253366798u,
76902315997713u,
7691510718750u,
76921360882441u,
76932770216279u,
76943048866755u,
76953406961221u,
76963664371439u,
76971151145514u,
76981027891570u,
76992699067992u,
77003461888315u,
7701198061905u,
7702292769636u,
77031106771795u,
77044064110516u,
77053258279756u,
7706762850927u,
77071818699721u,
77082803307356u,
77093919169404u,
7710460980967u,
77113125535078u,
77122802568977u,
77133582546426u,
77142148940781u,
77153963274378u,
77161266953698u,
7717204185123u,
77181100034381u,
77193009193601u,
77204200651967u,
7721274889605u,
77222700589508u,
7723952511689u,
77243765324859u,
77253465498478u,
77264014967037u,
77272070988082u,
77282972423530u,
77293068638223u,
77304156773651u,
7731489509804u,
77321323863238u,
77333731914806u,
77342846098469u,
77352728930632u,
7736346814072u,
7737848146907u,
7738551160669u,
77394165126521u,
77402039095001u,
77414179859388u,
77422434936359u,
77432764414551u,
7744238491210u,
7745732483969u,
77463366512764u,
7747478307468u,
77484124179572u,
77494142733597u,
77501953448206u,
77514199329278u,
7752865077060u,
77532627662116u,
77542802499360u,
77553141206831u,
77561959218197u,
7757911371451u,
7758125987200u,
77592821366175u,
77602530992747u,
77612409206225u,
7762117991880u,
77632133402461u,
7764895510531u,
7765428719601u,
77663036014536u,
77671223783733u,
7768733793540u,
7769970650405u,
7770547701766u,
7771570764615u,
77723224485368u,
77733192714940u,
7774319942831u,
77753940200341u,
7776362056204u,
77772832368105u,
77781853281226u,
77793296434636u,
77803752508307u,
7781604292768u,
77822231940616u,
77831204094681u,
7784866194005u,
77852405201650u,
77862466384396u,
7787380829379u,
7788230033818u,
77892783417588u,
77904249886729u,
7791829569301u,
77922988322580u,
77932299983554u,
779474748560u,
7795737514425u,
77963153050211u,
7797652642663u,
77981270205115u,
7799227197032u,
78002773091790u,
7801325849216u,
780249998791u,
78034043203010u,
78043662748068u,
78051709364383u,
78061179105165u,
78071478504366u,
78082980456610u,
78091167476429u,
78101590390732u,
78111306256496u,
7812292008135u,
7813374690995u,
78141809200819u,
78151680595904u,
7816646040226u,
78171742445560u,
78182435776844u,
78193703683804u,
7820478742495u,
7821814967947u,
78222698190177u,
78231003617993u,
78241436118705u,
7825217056304u,
78261412287094u,
78272738417466u,
78282933279339u,
78293461877733u,
78301203141205u,
78312119492857u,
78321134895723u,
78331560001021u,
78343786320122u,
78353748116258u,
78363486219595u,
7837702138030u,
78381062984182u,
7839232789133u,
78401566523968u,
78413885443778u,
78421820171888u,
78433655858585u,
78442316903005u,
78452678779620u,
7846395625433u,
78471609107564u,
78483108726411u,
78492937837224u,
78503911907151u,
7851557272509u,
78523893435978u,
78531542613576u,
78541079886893u,
78552624566322u,
78561413700616u,
78572796974006u,
78581922556114u,
7859562820464u,
78602845409784u,
786154180312u,
78621898782464u,
78633681814953u,
78642417064617u,
78651815464483u,
7866911626132u,
78672964575550u,
78681852696128u,
78692319647785u,
78701998904590u,
7871619992689u,
78723073207513u,
78731238163512u,
78743199435982u,
7875828667254u,
78763561155502u,
78773943095163u,
78781045711849u,
78792238679131u,
78802114975398u,
7881713808403u,
78823871787494u,
78832572031161u,
78842360934075u,
78852337781107u,
7886262596504u,
7887693836699u,
78882129369850u,
78893543189427u,
7890962205222u,
78913685581020u,
7892692974477u,
7893725182211u,
7894646123906u,
78952368836544u,
78962505872733u,
78971999977610u,
78981639885802u,
78991475058032u,
7900207023609u,
79012773581234u,
79023524857793u,
79033433371102u,
79043243027613u,
79051787668353u,
7906985757946u,
79073896012929u,
7908702356957u,
79093559331129u,
7910884084870u,
79114009998120u,
7912648888720u,
79131403349048u,
79141624342778u,
79151766674171u,
79162518582204u,
79173251243146u,
7918792751003u,
79191377201813u,
79203629686054u,
79211583734324u,
79223647107626u,
79234258564381u,
79241469878609u,
79251940598241u,
79262755003690u,
79271907120418u,
7928109916701u,
7929775347954u,
79302090960874u,
7931611281803u,
79323470490146u,
79333301663253u,
79341835412158u,
79351803066146u,
7936591872433u,
7937550703713u,
79381495089683u,
7939826492808u,
7940817200035u,
79414177474571u,
7942688070143u,
7943971427632u,
79441442499481u,
79453568640348u,
79462789993738u,
794785808128u,
79482058346726u,
7949394058570u,
79503466511434u,
7951318905230u,
79524149248030u,
7953415308316u,
7954165997598u,
79551219639412u,
79561648022659u,
79572857432523u,
79581422508004u,
7959468095522u,
7960296968649u,
7961430250611u,
79621775562314u,
79632976361671u,
79641040036362u,
79651372510167u,
7966292746272u,
79673408238954u,
7968626061886u,
79691317637569u,
79701237775792u,
79711218490455u,
79722224234499u,
7973590942419u,
7974713995643u,
79753541889330u,
79764140218960u,
79773529791107u,
7978354462673u,
7979842607274u,
7980365048533u,
79812638303414u,
79823560458014u,
798331621379u,
79844210854794u,
79851273118792u,
79862572743762u,
79873513175801u,
7988402066986u,
7989602524471u,
7990565029192u,
7991180576438u,
79921288605959u,
79932896244423u,
79941420543484u,
79951329862227u,
79961791567324u,
79974248690247u,
799812917038u,
79993483481310u,
80002082050731u,
80011611921143u,
80022443766548u,
80032216338811u,
80042528006095u,
80052984009021u,
8006674210884u,
80072857608106u,
80082155534809u,
80091023105067u,
80102968955846u,
80113303624302u,
80122502112850u,
8013245749006u,
80143175229091u,
80153342796184u,
80163613785362u,
80171614168851u,
80182582149283u,
8019895403488u,
8020416205023u,
80213792242000u,
8022529397534u,
8023299415203u,
80244284673348u,
80252096851282u,
80261864524731u,
80272012577738u,
80283426363316u,
80291387308508u,
80301143610148u,
80312027467219u,
80323772856163u,
80333453862623u,
80342661437174u,
80352047145955u,
80362533381447u,
80372059534115u,
8038439426587u,
80391537543414u,
80402384289877u,
80413174229055u,
80422658017753u,
80432293148474u,
80442359450158u,
80453930242475u,
80461510302397u,
80473354288821u,
8048920095603u,
80492415746928u,
80502729472638u,
80512261143371u,
8052848667611u,
8053919157153u,
80543322393117u,
80554103299943u,
8056413569608u,
805768911216u,
80583334990170u,
80591228068652u,
80601570056373u,
80611905477543u,
80622622302276u,
80632935063895u,
80643224810004u,
80654211768578u,
8066828688131u,
80673556122839u,
80681930935348u,
80692605825202u,
80701540993970u,
80713209115883u,
8072122847500u,
8073665638794u,
8074506571051u,
80752691795295u,
80763996966556u,
8077714660621u,
80783662432239u,
8079470651837u,
80801807432621u,
80813755290953u,
8082359878860u,
80832793081615u,
80844065031431u,
8085904653062u,
80862317800777u,
8087568501094u,
80883492871707u,
80892738806116u,
80902883859610u,
80913242080257u,
8092364246691u,
80933601786516u,
80943159362524u,
80951578272201u,
80961283574375u,
80972912186103u,
80982256279032u,
80991540671086u,
81002356088973u,
81012892277779u,
81023441449267u,
81032225005503u,
81043846428419u,
81052014549218u,
81062290734767u,
81072126684614u,
81084235463487u,
81093811556204u,
8110174739661u,
8111767525888u,
811247684458u,
81134211168099u,
8114889063422u,
8115469864411u,
8116767407110u,
8117413337343u,
81181618456644u,
81192814499820u,
81202401124192u,
8121632089437u,
81221234980238u,
81231288585402u,
81243153169944u,
81252917822069u,
81261843320264u,
81273794359132u,
81283074573530u,
8129258629454u,
81303813357060u,
81313806887248u,
81321665524736u,
81333324533324u,
81343005091922u,
8135793108368u,
81361529669805u,
81372332660395u,
81382217730223u,
81392634687611u,
8140442806463u,
81411968135266u,
8142454523002u,
81433177866230u,
81442808960136u,
81454259114138u,
81464103264843u,
81473103714075u,
81482462967542u,
81491466891491u,
8150477973764u,
8151834565647u,
8152741089037u,
8153218837573u,
81541710536528u,
81552469088212u,
81561229072375u,
81572828341u,
8158176923431u,
8159985763350u,
81604095477420u,
81611984145538u,
81621870791084u,
8163674956677u,
81641978138947u,
81651296493993u,
81661818183554u,
81673443333721u,
81682124949983u,
81692549590262u,
81702700850794u,
81712662736367u,
8172739638109u,
81734061447096u,
81742960078422u,
81752453781158u,
8176929570940u,
81773200328383u,
81782406328791u,
81791419180666u,
81802152455739u,
81812805741044u,
81823305999074u,
81833183816361u,
81842303165050u,
81854922104u,
818663096005u,
8187936656347u,
81883104453886u,
81891088673880u,
81901113407526u,
81911457890086u,
8192453478383u,
81931107686695u,
81943626027824u,
81951159687359u,
81962248467888u,
81972004578380u,
81983274954621u,
81991787958646u,
82002628726704u,
82011138419798u,
82023735442315u,
8203692385301u,
8204313807213u,
82052329068673u,
820659375364u,
82073261084359u,
82082088644507u,
82092471153194u,
8210788336435u,
82114024527246u,
8212141504460u,
82132307553888u,
82141930559950u,
821548975711u,
82162745693338u,
8217230161982u,
82183429230862u,
82191335968626u,
8220609591304u,
822157435073u,
82224279281136u,
82233152151665u,
82243984484924u,
82253459883943u,
8226397478330u,
82271738762229u,
82283033590066u,
82293611539498u,
82301363463523u,
82313319364965u,
82322671169141u,
82333819548561u,
82341691193757u,
82352423834608u,
82362820147055u,
82371378120632u,
82381240565187u,
82393180720050u,
8240680831086u,
82413309658414u,
82421986166490u,
8243762099827u,
8244510883662u,
82452047373648u,
82463606742294u,
82473894965352u,
82482342078853u,
82491091255717u,
8250776594727u,
82513217317445u,
82521574468485u,
82533844504016u,
82542819598918u,
82551037401010u,
82562550943503u,
82573867184001u,
82581687911772u,
8259165313836u,
82601679575281u,
82612418947263u,
82622038774952u,
82633913543652u,
82643209155736u,
8265149905221u,
82663859604717u,
8267713919631u,
82684069810796u,
82691882959164u,
82701019939034u,
82712379867302u,
82723666323035u,
82731157389013u,
82742422300650u,
82753366777340u,
82762526452062u,
82771313747885u,
82781039617868u,
82791620553692u,
82802032976978u,
8281578789528u,
82821592846839u,
82832270630604u,
8284897850577u,
82851603294178u,
82863105664807u,
82871442670138u,
82881728019360u,
828979313861u,
82901683031101u,
82911913067024u,
82924070719870u,
8293708986470u,
82942586453359u,
82953993348863u,
82963358251279u,
82973003552537u,
8298750174793u,
8299836888956u,
83004190747426u,
83014251291318u,
83024145164938u,
83031366883260u,
83041912910955u,
8305510192669u,
83061851315039u,
83073574241274u,
83083220062924u,
83092821142039u,
83101317082195u,
83112274293302u,
83121839219569u,
8313126586168u,
83143989293643u,
83152680178207u,
8316347056948u,
8317799681430u,
83182864517481u,
83193180404853u,
8320213140045u,
83211956305184u,
83221474675286u,
83233085723423u,
83242841859626u,
8325308421914u,
83263670309263u,
83271765052231u,
8328245459238u,
8329113434331u,
83304079521092u,
83312115235526u,
83322943408816u,
83331055476938u,
83341506442339u,
83352291296392u,
83363267864332u,
83371282145528u,
83383700108015u,
83391932843667u,
83402677701670u,
83416041177u,
83423889648557u,
83431461025478u,
8344};
8345
8346// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
8347bool Test(int offset, int len = 0) {
8348#undef Check
8349#undef IsAlive
8350
8351#define Check(x) do { \
8352 const uint32_t actual = (x), e = expected[index++]; \
8353 bool ok = actual == e; \
8354 if (!ok) { \
8355 cerr << "expected " << hex << e << " but got " << actual << endl; \
8356 ++errors; \
8357 } \
8358 assert(ok); \
8359} while (0)
8360
8361#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
8362
8363 // After the following line is where the uses of "Check" and such will go.
8364 static int index = 0;
8365if (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; }
8366Check(farmhashsu::Hash32WithSeed(data + offset, len, SEED));
8367Check(farmhashsu::Hash32(data + offset, len));
8368
8369 return true;
8370#undef Check
8371#undef IsAlive
8372}
8373
8374int RunTest() {
8375 Setup();
8376 int i = 0;
8377 cout << "Running farmhashsuTest";
8378 if (!Test(-1)) {
8379 cout << "... Unavailable\n";
8380 return NoteErrors();
8381 }
8382 // Good. The function is attempting to hash, so run the full test.
8383 int errors_prior_to_test = errors;
8384 for ( ; i < kTestSize - 1; i++) {
8385 Test(i * i, i);
8386 }
8387 for ( ; i < kDataSize; i += i / 7) {
8388 Test(0, i);
8389 }
8390 Test(0, kDataSize);
8391 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
8392 return NoteErrors();
8393}
8394
8395#else
8396
8397// After the following line is where the code to print hash codes will go.
8398void Dump(int offset, int len) {
8399cout << farmhashsu::Hash32WithSeed(data + offset, len, SEED) << "u," << endl;
8400cout << farmhashsu::Hash32(data + offset, len) << "u," << endl;
8401}
8402
8403#endif
8404
8405#undef SEED
8406#undef SEED1
8407#undef SEED0
8408
8409} // namespace farmhashsuTest
8410
8411#if !TESTING
8412int main(int argc, char** argv) {
8413 Setup();
8414 cout << "uint32_t expected[] = {\n";
8415 int i = 0;
8416 for ( ; i < kTestSize - 1; i++) {
8417 farmhashsuTest::Dump(i * i, i);
8418 }
8419 for ( ; i < kDataSize; i += i / 7) {
8420 farmhashsuTest::Dump(0, i);
8421 }
8422 farmhashsuTest::Dump(0, kDataSize);
8423 cout << "};\n";
8424}
8425#endif
8426#ifndef FARMHASH_SELF_TEST_GUARD
8427#define FARMHASH_SELF_TEST_GUARD
8428#include <cstdio>
8429#include <iostream>
8430#include <string.h>
8431
8432using std::cout;
8433using std::cerr;
8434using std::endl;
8435using std::hex;
8436
8437static const uint64_t kSeed0 = 1234567;
8438static const uint64_t kSeed1 = k0;
8439static const int kDataSize = 1 << 20;
8440static const int kTestSize = 300;
8441#define kSeed128 Uint128(kSeed0, kSeed1)
8442
8443static char data[kDataSize];
8444
8445static int completed_self_tests = 0;
8446static int errors = 0;
8447
8448// Initialize data to pseudorandom values.
8449void Setup() {
8450 if (completed_self_tests == 0) {
8451 uint64_t a = 9;
8452 uint64_t b = 777;
8453 for (int i = 0; i < kDataSize; i++) {
8454 a += b;
8455 b += a;
8456 a = (a ^ (a >> 41)) * k0;
8457 b = (b ^ (b >> 41)) * k0 + i;
8458 uint8_t u = b >> 37;
8459 memcpy(data + i, &u, 1); // uint8_t -> char
8460 }
8461 }
8462}
8463
8464int NoteErrors() {
8465#define NUM_SELF_TESTS 9
8466 if (++completed_self_tests == NUM_SELF_TESTS)
8467 std::exit(errors > 0);
8468 return errors;
8469}
8470
8471template <typename T> inline bool IsNonZero(T x) {
8472 return x != 0;
8473}
8474
8475template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
8476 return x != Uint128(0, 0);
8477}
8478
8479#endif // FARMHASH_SELF_TEST_GUARD
8480
8481namespace farmhashteTest {
8482
8483uint32_t CreateSeed(int offset, int salt) {
8484 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
8485 h = h * c1;
8486 h ^= (h >> 17);
8487 h = h * c1;
8488 h ^= (h >> 17);
8489 h = h * c1;
8490 h ^= (h >> 17);
8491 h += static_cast<uint32_t>(offset & 0xffffffff);
8492 h = h * c1;
8493 h ^= (h >> 17);
8494 h = h * c1;
8495 h ^= (h >> 17);
8496 h = h * c1;
8497 h ^= (h >> 17);
8498 return h;
8499}
8500
8501#undef SEED
8502#undef SEED1
8503#undef SEED0
8504#define SEED CreateSeed(offset, -1)
8505#define SEED0 CreateSeed(offset, 0)
8506#define SEED1 CreateSeed(offset, 1)
8507
8508#undef TESTING
8509#define TESTING 1
8510#if TESTING
8511uint32_t expected[] = {
85121140953930u, 861465670u,
85133277735313u, 2681724312u,
85142598464059u, 797982799u,
8515890626835u, 800175912u,
85162603993599u, 921001710u,
85171410420968u, 2134990486u,
85183283896453u, 1867689945u,
85192914424215u, 2244477846u,
8520255297188u, 2992121793u,
85211110588164u, 4186314283u,
8522161451183u, 3943596029u,
85234019337850u, 452431531u,
8524283198166u, 2741341286u,
85253379021470u, 2557197665u,
8526299850021u, 2532580744u,
8527452473466u, 1706958772u,
85281298374911u, 3099673830u,
85292199864459u, 3696623795u,
8530236935126u, 2976578695u,
85314055299123u, 3281581178u,
85321053458494u, 1882212500u,
85332305012065u, 2169731866u,
85343456121707u, 275903667u,
8535458884671u, 3033004529u,
85363058973506u, 2379411653u,
85371898235244u, 1402319660u,
85382700149065u, 2699376854u,
8539147814787u, 720739346u,
85402433714046u, 4222949502u,
85414220361840u, 1712034059u,
85423425469811u, 3690733394u,
85434148372108u, 1330324210u,
8544594028478u, 2921867846u,
85451635026870u, 192883107u,
8546780716741u, 1728752234u,
85473280331829u, 326029180u,
85483969463346u, 1436364519u,
8549393215742u, 3349570000u,
85503824583307u, 1612122221u,
85512859809759u, 3808705738u,
85521379537552u, 1646032583u,
85532233466664u, 1432476832u,
85544023053163u, 2650381482u,
85552052294713u, 3552092450u,
85561628777059u, 1499109081u,
85573476440786u, 3829307897u,
85582960536756u, 1554038301u,
85591145519619u, 3190844552u,
85602902102606u, 3600725550u,
8561237495366u, 540224401u,
856265721842u, 489963606u,
85631448662590u, 397635823u,
85641596489240u, 1562872448u,
85651790705123u, 2128624475u,
8566180854224u, 2604346966u,
85671435705557u, 1262831810u,
8568155445229u, 1672724608u,
85691669465176u, 1341975128u,
8570663607706u, 2077310004u,
85713610042449u, 1911523866u,
85721043692997u, 1454396064u,
85732563776023u, 294527927u,
85741099072299u, 1389770549u,
8575703505868u, 678706990u,
85762952353448u, 2026137563u,
85773603803785u, 629449419u,
85781933894405u, 3043213226u,
8579226132789u, 2489287368u,
85801552847036u, 645684964u,
85813828089804u, 3632594520u,
8582187883449u, 230403464u,
85833151491850u, 3272648435u,
85843729087873u, 1303930448u,
85852002861219u, 165370827u,
8586916494250u, 1230085527u,
85873103338579u, 3064290191u,
85883807265751u, 3628174014u,
8589231181488u, 851743255u,
85902295806711u, 1781190011u,
85912988893883u, 1554380634u,
85921142264800u, 3667013118u,
85931968445277u, 315203929u,
85942638023604u, 2290487377u,
8595732137533u, 1909203251u,
8596440398219u, 1891630171u,
85971380301172u, 1498556724u,
85984072067757u, 4165088768u,
85994204318635u, 441430649u,
86003931792696u, 197618179u,
8601956300927u, 914413116u,
86023010839769u, 2837339569u,
86032148126371u, 1913303225u,
86043074915312u, 3117299654u,
86054139181436u, 2993479124u,
86063178848746u, 1357272220u,
86071438494951u, 507436733u,
8608667183474u, 2084369203u,
86093854939912u, 1413396341u,
8610126024219u, 146044391u,
86111016656857u, 3022024459u,
86123254014218u, 429095991u,
8613990500595u, 3056862311u,
8614985653208u, 1718653828u,
8615623071693u, 366414107u,
86161771289760u, 2293458109u,
86173047342438u, 2991127487u,
86183120876698u, 1684583131u,
86193638043310u, 1170404994u,
8620863214540u, 1087193030u,
8621199124911u, 520792961u,
86223169775996u, 1577421232u,
86233331828431u, 1013201099u,
86241716848157u, 4033596884u,
86251770708857u, 4229339322u,
86261146169032u, 1434258493u,
86273824360466u, 3242407770u,
86281926419493u, 2649785113u,
8629872586426u, 762243036u,
86302736953692u, 816692935u,
86311571283333u, 3555213933u,
86322266795890u, 3781899767u,
86334290630595u, 517646945u,
86343006163611u, 2180594090u,
8635959214578u, 558910384u,
86361283799121u, 3047062993u,
86373830962609u, 2391606125u,
86383544509313u, 622325861u,
8639834785312u, 382936554u,
86401421463872u, 788479970u,
86411825135056u, 2725923798u,
8642580988377u, 2826990641u,
8643247825043u, 3167748333u,
8644812546227u, 2506885666u,
86452584372201u, 1758123094u,
86461891789696u, 389974094u,
8647345313518u, 2022370576u,
86483886113119u, 3338548567u,
86491083486947u, 2583576230u,
86501776047957u, 1771384107u,
86513604937815u, 3198590202u,
86523027522813u, 4155628142u,
86534232136669u, 427759438u,
86544244322689u, 542201663u,
86551549591985u, 2856634168u,
8656556609672u, 45845311u,
86571175961330u, 3948351189u,
86584165739882u, 4194218315u,
86591634635545u, 4151937410u,
8660713127376u, 1467786451u,
86611327394015u, 2743592929u,
86622638154051u, 810082938u,
86633077742128u, 1062268187u,
86644084325664u, 3810665822u,
86653735739145u, 2794294783u,
86662335576331u, 2560479831u,
8667690240711u, 997658837u,
86682442302747u, 3948961926u,
86693958366652u, 3067277639u,
86702059157774u, 1211737169u,
86711516711748u, 2339636583u,
86724188504038u, 59581167u,
86732767897792u, 1389679610u,
86742658147000u, 2643979752u,
86753758739543u, 4189944477u,
86761454470782u, 100876854u,
86772995362413u, 118817200u,
86783252925478u, 2062343506u,
86792804483644u, 3088828656u,
86801231633714u, 4168280671u,
86812931588131u, 3284356565u,
86821255909792u, 3130054947u,
86834173605289u, 1407328702u,
86841677744031u, 3532596884u,
86853162657845u, 3887208531u,
86862256541290u, 3459463480u,
86873740979556u, 259034107u,
8688392987633u, 3233195759u,
86893606709555u, 3424793077u,
8690315836068u, 3200749877u,
86914065431359u, 760633989u,
86922982018998u, 1811050648u,
8693234531934u, 1115203611u,
86943897494162u, 1516407838u,
86951603559457u, 323296368u,
86962632963283u, 1778459926u,
86972879836826u, 2146672889u,
86983486330348u, 492621815u,
86991231665285u, 2457048126u,
87003438440082u, 2217471853u,
87013355404249u, 3275550588u,
87021052645068u, 862072556u,
87034110617119u, 3745267835u,
87042657392572u, 4279236653u,
87051688445808u, 701920051u,
8706956734128u, 581695350u,
87073157862788u, 2585726058u,
87081192588249u, 1410111809u,
87091651193125u, 3326135446u,
87101073280453u, 97376972u,
87112513844237u, 2187968410u,
87123976859649u, 4267859263u,
87133429034542u, 564493077u,
87143000537321u, 479241367u,
87153845637831u, 2868987960u,
871651544337u, 1029173765u,
8717393624922u, 704325635u,
87182357610553u, 1418509533u,
87192007814586u, 3866658271u,
87203082385053u, 735688735u,
8721916110004u, 3283299459u,
87221051684175u, 1083796807u,
87234074716319u, 813690332u,
8724144264390u, 1439630796u,
87251508556987u, 675582689u,
87263748881891u, 3195309868u,
8727362884708u, 1616408198u,
872843233176u, 837301135u,
8729881504822u, 3254795114u,
87301385506591u, 2799925823u,
87311469874582u, 3464841997u,
8732497175391u, 3929484338u,
87333975771289u, 1798536177u,
87342926265846u, 1374242438u,
87353675707838u, 4205965408u,
87363153165629u, 1499475160u,
8737187287713u, 548490821u,
87383255259608u, 4247675634u,
87391940181471u, 3779953975u,
8740687167150u, 2319566715u,
87411742785722u, 785893184u,
87422296977392u, 2778575413u,
87431794720651u, 48131484u,
87444084891412u, 1160134629u,
87453737623280u, 823113169u,
87463423207646u, 3803213486u,
8747710625654u, 4116162021u,
87483693420287u, 4167766971u,
87491666602807u, 295320990u,
87503513255468u, 2487440590u,
8751234080704u, 4004655503u,
87522971762528u, 1479656873u,
87534090178629u, 4044418876u,
8754391947536u, 1462554406u,
87553909295855u, 1239580330u,
87561515601363u, 2011102035u,
87571442068334u, 4265993528u,
87581191921695u, 2291355695u,
87594257172787u, 576405853u,
8760314332944u, 4038839101u,
876155559918u, 2378985842u,
8762711098718u, 2425317635u,
87631644327317u, 1401013391u,
87644193760037u, 2958260436u,
87653167371443u, 3062418115u,
87663800755475u, 3167030094u,
87673489648204u, 1405430357u,
8768526177822u, 2602636307u,
8769915406019u, 4264167741u,
87701484090483u, 3070944737u,
8771254529415u, 4017058800u,
87721702710265u, 1029665228u,
87732000382906u, 3185573940u,
87741381258384u, 4036354071u,
87752900841028u, 2670703363u,
87762921748807u, 2899069938u,
87774130543625u, 688472265u,
87784186808827u, 1054670286u,
87791132985391u, 2840525968u,
87804175776103u, 338058159u,
87811735964501u, 1539305024u,
87823497121710u, 1568260669u,
87832227290760u, 146827036u,
87843977176001u, 4060134777u,
8785857488494u, 250055052u,
87864284109679u, 2502815838u,
87872592281721u, 1603444633u,
87881390562014u, 1556658131u,
8789616327404u, 2448966429u,
87903051191726u, 3891353218u,
87911213304082u, 762328245u,
87922239052397u, 1082330589u,
87932455957292u, 201837927u,
8794405397452u, 3079886794u,
87952583939798u, 2848283092u,
87963750724631u, 883849006u,
87973204198988u, 3341327098u,
87981855234968u, 1982110346u,
87991485529487u, 541496720u,
88004117290321u, 3607433551u,
88012168864636u, 133643215u,
88021055817409u, 3847827123u,
88032960769387u, 4046101649u,
88041176127003u, 4015671361u,
88054243643405u, 2849988118u,
8806517111221u, 1796672358u,
88072045051700u, 3452457457u,
88082948254999u, 2102063419u,
88091556410577u, 1536380876u,
88103776661467u, 3281002516u,
88111735616066u, 1539151988u,
88121087795162u, 3332431596u,
8813685631442u, 1147951686u,
881495237878u, 2005032160u,
88154012206915u, 4224354805u,
88163204999386u, 2415262714u,
88171433635018u, 116647396u,
881883167836u, 2881562655u,
88192729416454u, 1029284767u,
8820881378302u, 2159170082u,
8821555057366u, 1169104445u,
88223963877000u, 1919171906u,
8823336034862u, 2017579106u,
88244059340529u, 3020819343u,
8825865146997u, 2473524405u,
8826944743644u, 1694443528u,
88271804513294u, 2904752429u,
8828617975720u, 3671562289u,
8829260177668u, 505662155u,
88301885941445u, 2504509403u,
88312260041112u, 1019936943u,
88323722741628u, 1511077569u,
88333100701179u, 1379422864u,
88341535670711u, 773792826u,
88351103819072u, 2089123665u,
88361157547425u, 329152940u,
88374142587430u, 484732447u,
88382475035432u, 1120017626u,
8839412145504u, 965125959u,
8840324924679u, 2809286837u,
88412842141483u, 4029205195u,
88422974306813u, 515627448u,
88433791551981u, 1097806406u,
88443873078673u, 136118734u,
88451872130856u, 3632422367u,
88463574135531u, 4017075736u,
88471699452298u, 1403506686u,
8848344414660u, 1189129691u,
88493487080616u, 1516736273u,
88501805475756u, 2562064338u,
8851163335594u, 2732147834u,
88524077452507u, 2984955003u,
88534271866024u, 3071338162u,
88542347111903u, 873829983u,
88551948409509u, 1923531348u,
8856459509140u, 771592405u,
88571750124750u, 2334938333u,
8858213811117u, 2586632018u,
8859185232757u, 4032960199u,
88602447383637u, 284777551u,
88611654276320u, 2687561076u,
88623512945009u, 308584855u,
88631861027147u, 4102279334u,
88643203802620u, 1692079268u,
88654250142168u, 2565680167u,
88661507046104u, 841195925u,
8867520565830u, 3674576684u,
886838924274u, 3770488806u,
88692414430882u, 3978473838u,
88703703994407u, 69201295u,
88713099963860u, 1255084262u,
8872690971838u, 3539996781u,
88733696902571u, 3593730713u,
88742363435042u, 54945052u,
88751785765213u, 184911581u,
88761586241476u, 1939595371u,
88772534883189u, 2432427547u,
88782374171993u, 2039128933u,
88792955715987u, 2295501078u,
88802741583197u, 1280920000u,
8881686818699u, 1238742497u,
88823843660102u, 82177963u,
88831281043691u, 1121403845u,
88841697846708u, 284852964u,
8885278661677u, 2889101923u,
88862127558730u, 713121337u,
8887872502474u, 511142139u,
88881261140657u, 1747052377u,
88892108187161u, 927011680u,
8890955328267u, 3821994995u,
88912707230761u, 4142246789u,
88924134691985u, 1958963937u,
88932498463509u, 1977988705u,
88941419293714u, 1636932722u,
88952567532373u, 4075249328u,
8896240575705u, 1956681213u,
88972598802768u, 2025886508u,
88984104757832u, 3026358429u,
88993242615202u, 4026813725u,
8900255108733u, 1845587644u,
89013573008472u, 3615577014u,
89021222733548u, 1205557630u,
8903917608574u, 1363253259u,
89041541946015u, 3087190425u,
89051138008081u, 1444019663u,
8906109793386u, 341851980u,
8907857839960u, 2515339233u,
8908156283211u, 1906768669u,
89093886713057u, 1276595523u,
89102809830736u, 460237542u,
89113420452099u, 142985419u,
8912205970448u, 4198897105u,
89131950698961u, 2069753399u,
89141142216925u, 1113051162u,
89151033680610u, 4278599955u,
89161106466069u, 356742959u,
8917531521052u, 3494863964u,
8918225629455u, 3735275001u,
89193662626864u, 1750561299u,
89201012864651u, 2101846429u,
89211074553219u, 668829411u,
8922992181339u, 3384018814u,
89233330664522u, 860966321u,
89241885071395u, 4233785523u,
8925100741310u, 451656820u,
89262148187612u, 1063001151u,
8927360256231u, 107312677u,
89283650357479u, 2390172694u,
892922452685u, 237319043u,
89303600462351u, 1216645846u,
89312088767754u, 164402616u,
89322418980170u, 926137824u,
893394638678u, 1689811113u,
89342751052984u, 1767810825u,
8935271289013u, 3896132233u,
8936103797041u, 1397772514u,
89373441135892u, 3323383489u,
89382491268371u, 1662561885u,
89391612872497u, 2986430557u,
89402756998822u, 207428029u,
8941937973965u, 2791656726u,
89421949717207u, 2260498180u,
89432648427775u, 2360400900u,
89442080496169u, 486358863u,
89451582022990u, 1263709570u,
89461396468647u, 1377764574u,
8947363008508u, 1293502429u,
8948224580012u, 4252610345u,
89491435134775u, 1099809675u,
8950533671980u, 1533438766u,
89511820532305u, 2776960536u,
89523374512975u, 3542220540u,
8953822810075u, 3716663290u,
89541157398049u, 3752806924u,
89554081637863u, 337070226u,
89563866585976u, 359270190u,
89572110942730u, 3267551635u,
8958644850146u, 1306761320u,
8959746972907u, 934259457u,
89602341378668u, 2220373824u,
89611242645122u, 4109252858u,
89621625266099u, 1173698481u,
8963383517064u, 896322512u,
89643377483696u, 1788337208u,
8965455496839u, 3194373887u,
89661837689083u, 1336556841u,
89671658628529u, 2911512007u,
89683838343487u, 2757664765u,
89691537187340u, 3712582785u,
8970367022558u, 3071359622u,
89713926147070u, 35432879u,
89723093195926u, 2561488770u,
89734273132307u, 3898950547u,
89742838251049u, 2103926083u,
89752549435227u, 536047554u,
89761858986613u, 2040551642u,
89771147412575u, 1972369852u,
89784166184983u, 3528794619u,
89794077477194u, 3565689036u,
8980808048238u, 3826350461u,
89811359641525u, 1197100813u,
8982265993036u, 1864569342u,
8983725164342u, 2264788336u,
89841831223342u, 3329594980u,
8985923017956u, 490608221u,
89863818634478u, 258154469u,
89871441714797u, 1174785921u,
89883833372385u, 3287246572u,
89891677395563u, 3569218731u,
8990868981704u, 2163330264u,
89912649450292u, 500120236u,
8992465161780u, 746438382u,
89931145009669u, 2520062970u,
89942810524030u, 1561519055u,
89951479878006u, 3864969305u,
89962686075657u, 4042710240u,
89973224066062u, 2774151984u,
89982226179547u, 1643626042u,
89992328730865u, 3160666939u,
90002107011431u, 96459446u,
90013920328742u, 3336407558u,
9002829404209u, 1878067032u,
90031235983679u, 4237425634u,
9004466519055u, 3870676863u,
9005934312076u, 2952135524u,
9006276949224u, 4100839753u,
9007424001484u, 1955120893u,
90084015478120u, 1265237690u,
9009427484362u, 4246879223u,
90103452969617u, 1724363362u,
90111553513184u, 834830418u,
90121858777639u, 3476334357u,
90134144030366u, 2450047160u,
90142950762705u, 4277111759u,
9015358032121u, 2511026735u,
9016167923105u, 2059208280u,
9017251949572u, 3065234219u,
90181535473864u, 556796152u,
90191513237478u, 3150857516u,
90201103404394u, 198182691u,
90211476438092u, 2913077464u,
9022207119516u, 3963810232u,
90232954651680u, 1535115487u,
90243051522276u, 4046477658u,
9025917804636u, 864395565u,
9026632704095u, 140762681u,
90271802040304u, 990407433u,
90283771506212u, 4106024923u,
90291287729497u, 2198985327u,
90304052924496u, 2926590471u,
90313084557148u, 1472898694u,
90321009870118u, 559702706u,
90334265214507u, 82077489u,
90343067891003u, 3295678907u,
90352402308151u, 1096697687u,
9036464407878u, 4190838199u,
90374269578403u, 3060919438u,
90382899950405u, 3046872820u,
9039733509243u, 1583801700u,
904040453902u, 3879773881u,
90411993425202u, 2185339100u,
90421877837196u, 3912423882u,
90433293122640u, 4104318469u,
90441679617763u, 3703603898u,
90458759461u, 2540185277u,
90461152198475u, 2038345882u,
90472503579743u, 1446869792u,
90482019419351u, 4051584612u,
90493178289407u, 3992503830u,
90502879018745u, 2719373510u,
9051700836153u, 1675560450u,
90524121245793u, 2064715719u,
9053343595772u, 1996164093u,
90543130433948u, 405251683u,
90552804817126u, 1607133689u,
9056463852893u, 2864244470u,
90572224044848u, 4071581802u,
90582537107938u, 2246347953u,
90593207234525u, 2028708916u,
90602272418128u, 803575837u,
906138655481u, 2170452091u,
90623272166407u, 557660441u,
90634019147902u, 3841480082u,
9064298459606u, 2600943364u,
90652440657523u, 255451671u,
90663424361375u, 779434428u,
90673088526123u, 490671625u,
90681322855877u, 3452203069u,
90693057021940u, 2285701422u,
90702014993457u, 2390431709u,
90712002090272u, 1568745354u,
90721783152480u, 823305654u,
90734053862835u, 2200236540u,
90743009412313u, 3184047862u,
90753032187389u, 4159715581u,
90762966902888u, 252986948u,
90771849329144u, 3160134214u,
90783420960112u, 3198900547u,
9079749160960u, 379139040u,
90801208883495u, 1566527339u,
90813006227299u, 4194096960u,
9082556075248u, 497404038u,
90831717327230u, 1496132623u,
90841775955687u, 1719108984u,
90851014328900u, 4189966956u,
90862108574735u, 2584236470u,
9087684087286u, 531310503u,
90884264509527u, 773405691u,
90893088905079u, 3456882941u,
90903105682208u, 3382290593u,
90912289363624u, 3296306400u,
90924168438718u, 467441309u,
9093777173623u, 3241407531u,
90941183994815u, 1132983260u,
90951610606159u, 2540270567u,
90962649684057u, 1397502982u,
9097146657385u, 3318434267u,
90982109315753u, 3348545480u,
90993193669211u, 811750340u,
91001073256162u, 3571673088u,
9101546596661u, 1017047954u,
91023403136990u, 2540585554u,
91031477047647u, 4145867423u,
91042826408201u, 3531646869u,
9105784952939u, 943914610u,
91062717443875u, 3657384638u,
91071806867885u, 1903578924u,
91083985088434u, 1911188923u,
91091764002686u, 3672748083u,
91101832925325u, 241574049u,
9111519948041u, 3181425568u,
91122939747257u, 1634174593u,
91133429894862u, 3529565564u,
91141089679033u, 240953857u,
91152025369941u, 2695166650u,
9116517086873u, 2964595704u,
91173017658263u, 3828377737u,
91182144895011u, 994799311u,
91191184683823u, 4260564140u,
9120308018483u, 4262383425u,
91211374752558u, 3431057723u,
91221572637805u, 383233885u,
91233188015819u, 4051263539u,
9124233319221u, 3794788167u,
91252017406667u, 919677938u,
91264074952232u, 1683612329u,
91274213676186u, 327142514u,
91283032591014u, 4204155962u,
9129206775997u, 2283918569u,
91302395147154u, 3427505379u,
91312211319468u, 4153726847u,
91322217060665u, 350160869u,
91332493667051u, 1648200185u,
91343441709766u, 1387233546u,
9135140980u, 1891558063u,
9136760080239u, 2088061981u,
91371580964938u, 740563169u,
9138422986366u, 330624974u,
91394264507722u, 150928357u,
91402738323042u, 2948665536u,
9141918718096u, 376390582u,
91423966098971u, 717653678u,
91433219466255u, 3799363969u,
91443424344721u, 3187805406u,
9145375347278u, 3490350144u,
91461992212097u, 2263421398u,
91473855037968u, 1928519266u,
91483866327955u, 1129127000u,
91491782515131u, 2746577402u,
91503059200728u, 2108753646u,
91512738070963u, 1336849395u,
91521705302106u, 768287270u,
91531343511943u, 2247006571u,
91541956142255u, 1780259453u,
91553475618043u, 212490675u,
9156622521957u, 917121602u,
91571852992332u, 1267987847u,
91583170016833u, 2549835613u,
91593299763344u, 2864033668u,
91603378768767u, 1236609378u,
91614169365948u, 3738062408u,
91622661022773u, 2006922227u,
91632760592161u, 3828932355u,
91642636387819u, 2616619070u,
91651237256330u, 3449066284u,
91662871755260u, 3729280948u,
91673862686086u, 431292293u,
91683285899651u, 786322314u,
91692531158535u, 724901242u,
91702377363130u, 1415970351u,
91711244759631u, 3263135197u,
9172965248856u, 174024139u,
91732297418515u, 2954777083u,
9174987586766u, 3206261120u,
91754059515114u, 3903854066u,
91761931934525u, 2287507921u,
91771827135136u, 1781944746u,
9178574617451u, 2299034788u,
91792650140034u, 4081586725u,
91802482286699u, 1109175923u,
9181458483596u, 618705848u,
91824059852729u, 1813855658u,
91834190721328u, 1129462471u,
91844089998050u, 3575732749u,
91852375584220u, 1037031473u,
91861623777358u, 3389003793u,
9187546597541u, 352770237u,
91881383747654u, 3122687303u,
91891646071378u, 1164309901u,
9190290870767u, 830691298u,
9191929335420u, 3193251135u,
9192989577914u, 3626554867u,
9193591974737u, 3996958215u,
91943163711272u, 3071568023u,
91951516846461u, 3656006011u,
91962698625268u, 2510865430u,
9197340274176u, 1167681812u,
91983698796465u, 3155218919u,
91994102288238u, 1673474350u,
92003069708839u, 2704165015u,
92011237411891u, 1854985978u,
92023646837503u, 3625406022u,
9203921552000u, 1712976649u,
92043939149151u, 878608872u,
92053406359248u, 1068844551u,
92061834682077u, 4155949943u,
92072437686324u, 3163786257u,
92082645117577u, 1988168803u,
9209747285578u, 1626463554u,
92101235300371u, 1256485167u,
92111914142538u, 4141546431u,
92123838102563u, 582664250u,
92131883344352u, 2083771672u,
92142611657933u, 2139079047u,
92152250573853u, 804336148u,
92163066325351u, 2770847216u,
92174275641370u, 1455750577u,
92183346357270u, 1674051445u,
9219601221482u, 3992583643u,
92201402445097u, 3622527604u,
92212509017299u, 2966108111u,
92222557027816u, 900741486u,
92231790771021u, 2912643797u,
92242631381069u, 4014551783u,
922590375300u, 300318232u,
92263269968032u, 2679371729u,
92272664752123u, 3517585534u,
92283253901179u, 542270815u,
92291188641600u, 365479232u,
92302210121140u, 760762191u,
92311273768482u, 1216399252u,
92323484324231u, 4287337666u,
923316322182u, 643179562u,
9234325675502u, 3652676161u,
92353120716054u, 3330259752u,
92361011990087u, 2990167340u,
92371097584090u, 3262252593u,
92381829409951u, 3665087267u,
92391214854475u, 2134299399u,
92403704419305u, 411263051u,
92411625446136u, 549838529u,
92424283196353u, 1342880802u,
92433460621305u, 1967599860u,
92444282843369u, 1275671016u,
92452544665755u, 853593042u,
9246901109753u, 2682611693u,
9247110631633u, 797487791u,
92481472073141u, 850464484u,
9249797089608u, 3286110054u,
9250350397471u, 2775631060u,
9251366448238u, 3842907484u,
92522219863904u, 3623364733u,
92531850985302u, 4009616991u,
9254294963924u, 3693536939u,
92553061255808u, 1615375832u,
92561920066675u, 4113028420u,
92574032223840u, 2318423400u,
92582701956286u, 4145497671u,
92593991532344u, 2536338351u,
92601679099863u, 1728968857u,
9261449740816u, 2686506989u,
9262685242457u, 97590863u,
92633258354115u, 1502282913u,
92641235084019u, 2151665147u,
9265528459289u, 231097464u,
92662477280726u, 3651607391u,
92672091754612u, 1178454681u,
9268980597335u, 1604483865u,
92691842333726u, 4146839064u,
92703213794286u, 2601416506u,
9271754220096u, 3571436033u,
9272488595746u, 1448097974u,
92734004834921u, 238887261u,
92743320337489u, 1416989070u,
92752928916831u, 4093725287u,
9276186020771u, 2367569534u,
92773046087671u, 4090084518u,
92783548184546u, 679517009u,
92791962659444u, 3539886328u,
92804192003933u, 1678423485u,
92813827951761u, 3086277222u,
92822144472852u, 1390394371u,
92832976322029u, 1574517163u,
92843553313841u, 119173722u,
92851702434637u, 1766260771u,
92863629581771u, 1407497759u,
9287895654784u, 751439914u,
92884008409498u, 215917713u,
92891482103833u, 695551833u,
92901288382231u, 2656990891u,
92912581779077u, 1570750352u,
92923710689053u, 1741390464u,
92932666411616u, 3533987737u,
92944289478316u, 3576119563u,
92954118694920u, 108199666u,
92963869794273u, 963183826u,
92972081410737u, 3796810515u,
9298791123882u, 2525792704u,
92991036883117u, 136547246u,
9300875691100u, 2592925324u,
9301614302599u, 3013176417u,
93022689342539u, 427154472u,
9303532957601u, 1228758574u,
93041898117151u, 1181643858u,
93051908591042u, 1464255968u,
9306446980910u, 2984611177u,
930758509511u, 1046943619u,
93083508927906u, 2001585786u,
93092544767379u, 1525438381u,
9310552181222u, 1959725830u,
9311879448844u, 1348536411u,
93124242243590u, 2861338018u,
93131082052441u, 1034351453u,
9314601175800u, 764077711u,
9315530635011u, 3785343245u,
93162178026726u, 117256687u,
93172378297261u, 457568934u,
931876438221u, 4104954272u,
9319956793873u, 3783168634u,
93202485968477u, 2381948487u,
93214226929450u, 3148473363u,
93222518273601u, 3569490233u,
9323879369091u, 2180270337u,
93243674375989u, 1387729170u,
9325977997984u, 4270646856u,
9326568650985u, 951677556u,
93274213877384u, 2721005055u,
93281073364549u, 2563403831u,
93291678669911u, 66786703u,
93302273631661u, 1149351924u,
93313651298990u, 1581883443u,
9332246723096u, 1895026827u,
93333810605772u, 3711056516u,
93344058833288u, 2193790614u,
93352080120290u, 3638638708u,
93362915672708u, 2263003308u,
93372361934197u, 4136767460u,
93381976115991u, 3448840877u,
93392019238520u, 225333538u,
9340874340815u, 2976159827u,
93411555273378u, 3797521928u,
93421942347150u, 3262952567u,
9343435997738u, 340403353u,
93442817830907u, 2078619498u,
9345749534111u, 1178073973u,
9346894654712u, 3361226032u,
9347841092198u, 3288261538u,
93481696412169u, 1496966875u,
9349697501571u, 1059158875u,
93503739946319u, 2481012988u,
9351568983526u, 114945840u,
93521559249010u, 2218244008u,
93532841706923u, 1632780103u,
93544020169654u, 2087949619u,
93552438736103u, 24032648u,
9356833416317u, 3787017905u,
93572373238993u, 2575395164u,
93583434544481u, 3228481067u,
93592542976862u, 2971726178u,
93602880371864u, 3642087909u,
93612407477975u, 2239080836u,
93621043714217u, 3894199764u,
93632235879182u, 203853421u,
93642933669448u, 2504940536u,
9365834683330u, 425935223u,
93663560796393u, 3565833278u,
93671668000829u, 3683399154u,
93683414330886u, 1748785729u,
93691023171602u, 580966986u,
93702531038985u, 3227325488u,
93712657385925u, 2124704694u,
9372233442446u, 1107045577u,
93733407293834u, 552770757u,
93743899097693u, 1067532701u,
9375115667924u, 1406028344u,
93761707768231u, 3724015962u,
93772419657149u, 18613994u,
93782532882091u, 3476683808u,
93791560838678u, 811220224u,
9380895961699u, 3762914298u,
93811328752423u, 1844996900u,
93821420427894u, 1848067707u,
93831210281744u, 904215228u,
93844055325594u, 1118521573u,
93852496554183u, 2579259919u,
93863996647489u, 3657647605u,
9387325254059u, 3136157065u,
93883951522674u, 4052925250u,
93893341068436u, 2287683323u,
93901313073005u, 126005630u,
93912505120084u, 1194725057u,
9392853746559u, 3555092974u,
93932689238752u, 49515858u,
93941244776042u, 1069300695u,
939561073168u, 1010661841u,
93961269521335u, 1902040126u,
9397990632502u, 2378708922u,
93983858321250u, 1400735275u,
93992974699176u, 2771676666u,
9400170995186u, 2877798589u,
9401545726212u, 2225229957u,
94021086473152u, 3454177594u,
94033859483262u, 1499729584u,
94042088002891u, 2883475137u,
94053222194252u, 4144472319u,
94062212229854u, 4146740722u,
9407567988835u, 1051332394u,
94083932046135u, 542648229u,
94093017852446u, 1277887997u,
9410162888005u, 1669710469u,
94111492500905u, 553041029u,
94121434876932u, 533989516u,
94133817492747u, 584127807u,
94144147115982u, 2993670925u,
94154020312558u, 710021255u,
94163509733475u, 3587959456u,
94172088550465u, 1745399498u,
94182952242967u, 1259815443u,
9419869648362u, 1404723176u,
94203947542735u, 1334333531u,
94213873471582u, 229399758u,
942259634866u, 3239516985u,
94233844250972u, 1275954779u,
9424492891666u, 1029533080u,
94251552951157u, 367320647u,
9426699480890u, 3684418197u,
94273707014310u, 471105777u,
94281824587258u, 4030809053u,
94293489914436u, 484559105u,
94301235750398u, 1428453396u,
94314230459084u, 4255931645u,
94321848597055u, 4271715616u,
9433331780381u, 482425775u,
94342435323270u, 3171911678u,
94353507210587u, 928543347u,
94364197807526u, 3680046204u,
94372766042024u, 2159512867u,
9438179373257u, 313902234u,
94394024837592u, 294795361u,
94401622282562u, 647086234u,
94412825039429u, 577214736u,
94424043412446u, 2426981244u,
94431277736097u, 1130129573u,
94442601395338u, 995791646u,
944536668922u, 3344746679u,
94461521532225u, 1645086060u,
94472622763015u, 4122335794u,
94482936887705u, 494465807u,
94492580840343u, 1064648931u,
94501247887787u, 2752145076u,
94511277612417u, 1249660507u,
94522288678613u, 3312498873u,
94532459273912u, 4238535494u,
94543117488020u, 2571979978u,
94552680188909u, 1471227427u,
94561616494033u, 633688562u,
94572268653416u, 3268237290u,
94583021962815u, 1959779970u,
94593321382074u, 766642813u,
9460204429780u, 1323319858u,
94613676032891u, 1380896111u,
94624030639049u, 3647601207u,
94631830028502u, 2830263774u,
94641375962216u, 1733961041u,
9465939765180u, 521947915u,
94663903267364u, 497472767u,
94671619700946u, 189164145u,
94683115593885u, 486382294u,
94691262445920u, 4062496162u,
94702464795849u, 3770038872u,
94714032121374u, 3235740744u,
94723757765258u, 1777199847u,
94732167243108u, 1912506671u,
94744180515317u, 2276864677u,
9475536034089u, 2384915026u,
9476162938278u, 1588060152u,
94774018349945u, 2504457929u,
9478841450426u, 2790120722u,
94792719983588u, 1471020554u,
94801390856732u, 3623212998u,
94812506944218u, 1035080801u,
9482348812127u, 3026631806u,
9483746483541u, 2342164722u,
9484122104390u, 4074122771u,
94853986865419u, 1674890530u,
94863693306023u, 3011542850u,
94871294951725u, 899303190u,
94883577146915u, 3549160092u,
94891241677652u, 4290680005u,
94903193053279u, 2029187390u,
94913298063095u, 3943068002u,
94923946220635u, 2273781461u,
9493889053698u, 1376304022u,
94941486839612u, 2127663659u,
9495344127443u, 1646681121u,
94962780117810u, 2142045764u,
94972694572773u, 447810651u,
94982185527146u, 2366308558u,
9499290335413u, 584901173u,
95002012370276u, 970504950u,
95013258236042u, 2008155560u,
95023945579565u, 614796295u,
950324452072u, 2695940969u,
95043983727134u, 3444688454u,
95051327044473u, 3545633451u,
95061875293322u, 1739318893u,
95071707527799u, 2683090634u,
95082848082386u, 2814622471u,
95094111401777u, 2774816580u,
95103849839194u, 437560100u,
95112238350150u, 2462124836u,
9512665017710u, 512012738u,
95132945294779u, 3305170944u,
9514819477765u, 59419271u,
9515155125658u, 665292744u,
9516444722813u, 3580039116u,
95172355675635u, 663735032u,
95183247800169u, 1579404983u,
95191985115003u, 3397891494u,
9520358696453u, 1474896279u,
9521516388613u, 710590371u,
95223490497111u, 2514565805u,
95232386143445u, 477509654u,
9524412854590u, 3624609754u,
95253214388668u, 3516075816u,
95262731288520u, 1369482895u,
95274033204378u, 1314000850u,
9528829769325u, 1935166880u,
95291608191643u, 2607067237u,
9530423820371u, 3257747610u,
95311355298041u, 3776931214u,
95324105054901u, 2107080812u,
95331911521879u, 3183054185u,
95343910177801u, 675129307u,
95351209358971u, 4205727791u,
95361435726287u, 3333261712u,
95371400982708u, 1154611403u,
95381663501483u, 2837596667u,
95393164734053u, 2759854023u,
95404012043629u, 1963228038u,
95413981675284u, 2677557877u,
9542520119591u, 505138315u,
9543897271356u, 1803966773u,
95441016663294u, 616691903u,
95452254742522u, 4032705384u,
95462468470796u, 798395739u,
95473025169002u, 3570037122u,
95481461093710u, 3473799845u,
95493702624858u, 476400898u,
95501043039728u, 2304070437u,
9551181576948u, 602972493u,
95523996616030u, 3289878097u,
95532068516226u, 3922247304u,
95541299968266u, 2520311409u,
95551968824721u, 3214794876u,
95561581813122u, 2668800905u,
95573297613974u, 748160407u,
95581145536484u, 1326769504u,
95592973323521u, 3775262814u,
95603218653169u, 902775872u,
95613498603433u, 1372805534u,
9562704686363u, 3626542352u,
95632271580579u, 1213925114u,
956446329775u, 3009384989u,
95651330254048u, 1194824134u,
9566514204310u, 3781981134u,
9567442526164u, 2835608783u,
95683460471867u, 510634034u,
9569546406434u, 2716786748u,
95702840500021u, 1669490957u,
95712536189149u, 3251421224u,
95721358736072u, 1089334066u,
95733260749330u, 250756920u,
95742974806681u, 1513718866u,
957582635635u, 4041016629u,
95763391765744u, 2495807367u,
95773962674316u, 2822889695u,
9578753413337u, 2008251381u,
95793123390177u, 106212622u,
9580490570565u, 1684884205u,
9581793892547u, 1927268995u,
95822344148164u, 2251978818u,
9583437424236u, 2774023200u,
95842674940754u, 3788056262u,
95852597882666u, 3678660147u,
95863797434193u, 3838215866u,
9587279687080u, 2656772270u,
95882190204787u, 1997584981u,
95893384401882u, 3160208845u,
95903629379425u, 2668998785u,
95911050036757u, 2954162084u,
9592917091826u, 1744374041u,
95931454282570u, 845687881u,
95942997173625u, 776018378u,
95951137560602u, 1938378389u,
95961748082354u, 2066910012u,
95972677675207u, 918315064u,
9598};
9599
9600// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
9601bool Test(int offset, int len = 0) {
9602#undef Check
9603#undef IsAlive
9604
9605#define Check(x) do { \
9606 const uint32_t actual = (x), e = expected[index++]; \
9607 bool ok = actual == e; \
9608 if (!ok) { \
9609 cerr << "expected " << hex << e << " but got " << actual << endl; \
9610 ++errors; \
9611 } \
9612 assert(ok); \
9613} while (0)
9614
9615#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
9616
9617 // After the following line is where the uses of "Check" and such will go.
9618 static int index = 0;
9619if (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; }
9620{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
9621{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
9622{ uint64_t h = farmhashte::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
9623
9624 return true;
9625#undef Check
9626#undef IsAlive
9627}
9628
9629int RunTest() {
9630 Setup();
9631 int i = 0;
9632 cout << "Running farmhashteTest";
9633 if (!Test(-1)) {
9634 cout << "... Unavailable\n";
9635 return NoteErrors();
9636 }
9637 // Good. The function is attempting to hash, so run the full test.
9638 int errors_prior_to_test = errors;
9639 for ( ; i < kTestSize - 1; i++) {
9640 Test(i * i, i);
9641 }
9642 for ( ; i < kDataSize; i += i / 7) {
9643 Test(0, i);
9644 }
9645 Test(0, kDataSize);
9646 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
9647 return NoteErrors();
9648}
9649
9650#else
9651
9652// After the following line is where the code to print hash codes will go.
9653void Dump(int offset, int len) {
9654{ uint64_t h = farmhashte::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9655{ uint64_t h = farmhashte::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9656{ uint64_t h = farmhashte::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
9657}
9658
9659#endif
9660
9661#undef SEED
9662#undef SEED1
9663#undef SEED0
9664
9665} // namespace farmhashteTest
9666
9667#if !TESTING
9668int main(int argc, char** argv) {
9669 Setup();
9670 cout << "uint32_t expected[] = {\n";
9671 int i = 0;
9672 for ( ; i < kTestSize - 1; i++) {
9673 farmhashteTest::Dump(i * i, i);
9674 }
9675 for ( ; i < kDataSize; i += i / 7) {
9676 farmhashteTest::Dump(0, i);
9677 }
9678 farmhashteTest::Dump(0, kDataSize);
9679 cout << "};\n";
9680}
9681#endif
9682#ifndef FARMHASH_SELF_TEST_GUARD
9683#define FARMHASH_SELF_TEST_GUARD
9684#include <cstdio>
9685#include <iostream>
9686#include <string.h>
9687
9688using std::cout;
9689using std::cerr;
9690using std::endl;
9691using std::hex;
9692
9693static const uint64_t kSeed0 = 1234567;
9694static const uint64_t kSeed1 = k0;
9695static const int kDataSize = 1 << 20;
9696static const int kTestSize = 300;
9697#define kSeed128 Uint128(kSeed0, kSeed1)
9698
9699static char data[kDataSize];
9700
9701static int completed_self_tests = 0;
9702static int errors = 0;
9703
9704// Initialize data to pseudorandom values.
9705void Setup() {
9706 if (completed_self_tests == 0) {
9707 uint64_t a = 9;
9708 uint64_t b = 777;
9709 for (int i = 0; i < kDataSize; i++) {
9710 a += b;
9711 b += a;
9712 a = (a ^ (a >> 41)) * k0;
9713 b = (b ^ (b >> 41)) * k0 + i;
9714 uint8_t u = b >> 37;
9715 memcpy(data + i, &u, 1); // uint8_t -> char
9716 }
9717 }
9718}
9719
9720int NoteErrors() {
9721#define NUM_SELF_TESTS 9
9722 if (++completed_self_tests == NUM_SELF_TESTS)
9723 std::exit(errors > 0);
9724 return errors;
9725}
9726
9727template <typename T> inline bool IsNonZero(T x) {
9728 return x != 0;
9729}
9730
9731template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
9732 return x != Uint128(0, 0);
9733}
9734
9735#endif // FARMHASH_SELF_TEST_GUARD
9736
9737namespace farmhashuoTest {
9738
9739uint32_t CreateSeed(int offset, int salt) {
9740 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
9741 h = h * c1;
9742 h ^= (h >> 17);
9743 h = h * c1;
9744 h ^= (h >> 17);
9745 h = h * c1;
9746 h ^= (h >> 17);
9747 h += static_cast<uint32_t>(offset & 0xffffffff);
9748 h = h * c1;
9749 h ^= (h >> 17);
9750 h = h * c1;
9751 h ^= (h >> 17);
9752 h = h * c1;
9753 h ^= (h >> 17);
9754 return h;
9755}
9756
9757#undef SEED
9758#undef SEED1
9759#undef SEED0
9760#define SEED CreateSeed(offset, -1)
9761#define SEED0 CreateSeed(offset, 0)
9762#define SEED1 CreateSeed(offset, 1)
9763
9764#undef TESTING
9765#define TESTING 1
9766#if TESTING
9767uint32_t expected[] = {
97683277735313u, 2681724312u,
97692598464059u, 797982799u,
97702603993599u, 921001710u,
97711410420968u, 2134990486u,
97722914424215u, 2244477846u,
9773255297188u, 2992121793u,
9774161451183u, 3943596029u,
97754019337850u, 452431531u,
97763379021470u, 2557197665u,
9777299850021u, 2532580744u,
97781298374911u, 3099673830u,
97792199864459u, 3696623795u,
97804055299123u, 3281581178u,
97811053458494u, 1882212500u,
97823456121707u, 275903667u,
9783458884671u, 3033004529u,
97841898235244u, 1402319660u,
97852700149065u, 2699376854u,
97862433714046u, 4222949502u,
97874220361840u, 1712034059u,
97884148372108u, 1330324210u,
9789594028478u, 2921867846u,
9790780716741u, 1728752234u,
97913280331829u, 326029180u,
9792393215742u, 3349570000u,
97933824583307u, 1612122221u,
97941379537552u, 1646032583u,
97952233466664u, 1432476832u,
97962052294713u, 3552092450u,
97971628777059u, 1499109081u,
97982960536756u, 1554038301u,
97991145519619u, 3190844552u,
9800237495366u, 540224401u,
980165721842u, 489963606u,
98021596489240u, 1562872448u,
98031790705123u, 2128624475u,
98041435705557u, 1262831810u,
9805155445229u, 1672724608u,
9806663607706u, 2077310004u,
98073610042449u, 1911523866u,
98082563776023u, 294527927u,
98091099072299u, 1389770549u,
98102952353448u, 2026137563u,
98113603803785u, 629449419u,
9812226132789u, 2489287368u,
98131552847036u, 645684964u,
9814187883449u, 230403464u,
98153151491850u, 3272648435u,
98162002861219u, 165370827u,
9817916494250u, 1230085527u,
98183807265751u, 3628174014u,
9819231181488u, 851743255u,
98202988893883u, 1554380634u,
98211142264800u, 3667013118u,
98222638023604u, 2290487377u,
9823732137533u, 1909203251u,
98241380301172u, 1498556724u,
98254072067757u, 4165088768u,
98263931792696u, 197618179u,
9827956300927u, 914413116u,
98282148126371u, 1913303225u,
98293074915312u, 3117299654u,
98303178848746u, 1357272220u,
98311438494951u, 507436733u,
98323854939912u, 1413396341u,
9833126024219u, 146044391u,
98343254014218u, 429095991u,
9835165589978u, 1578546616u,
9836623071693u, 366414107u,
9837249776086u, 1207522198u,
98383120876698u, 1684583131u,
983946987739u, 1157614300u,
9840199124911u, 520792961u,
98413614377032u, 586863115u,
98421716848157u, 4033596884u,
98431164298657u, 4140791139u,
98443824360466u, 3242407770u,
98453725511003u, 232064808u,
98462736953692u, 816692935u,
9847512845449u, 3748861010u,
98484290630595u, 517646945u,
984922638523u, 648000590u,
98501283799121u, 3047062993u,
98511024246061u, 4027776454u,
9852834785312u, 382936554u,
9853411505255u, 1973395102u,
9854580988377u, 2826990641u,
98553474970689u, 1029055034u,
98562584372201u, 1758123094u,
9857589567754u, 325737734u,
98583886113119u, 3338548567u,
9859257578986u, 3698087965u,
98603604937815u, 3198590202u,
98612305332220u, 191910725u,
98624244322689u, 542201663u,
98633315355162u, 2135941665u,
98641175961330u, 3948351189u,
986523075771u, 3252374102u,
9866713127376u, 1467786451u,
9867663013031u, 3444053918u,
98683077742128u, 1062268187u,
98692115441882u, 4081398201u,
98702335576331u, 2560479831u,
98711379288194u, 4225182569u,
98723958366652u, 3067277639u,
98733667516477u, 1709989541u,
98744188504038u, 59581167u,
98752725013602u, 3639843023u,
98763758739543u, 4189944477u,
98772470483982u, 877580602u,
98783252925478u, 2062343506u,
98793981838403u, 3762572073u,
98802931588131u, 3284356565u,
98811129162571u, 732225574u,
98821677744031u, 3532596884u,
98833232041815u, 1652884780u,
98843740979556u, 259034107u,
98852227121257u, 1426140634u,
9886315836068u, 3200749877u,
98871386256573u, 24035717u,
9888234531934u, 1115203611u,
98891598686658u, 3146815575u,
98902632963283u, 1778459926u,
9891739944537u, 579625482u,
98921231665285u, 2457048126u,
98933903349120u, 389846205u,
98941052645068u, 862072556u,
98952834153464u, 1481069623u,
98961688445808u, 701920051u,
98973740748788u, 3388062747u,
98981192588249u, 1410111809u,
98992633463887u, 4050419847u,
99002513844237u, 2187968410u,
99012951683019u, 3015806005u,
99023000537321u, 479241367u,
9903252167538u, 1231057113u,
9904393624922u, 704325635u,
99051467197045u, 2066433573u,
99063082385053u, 735688735u,
9907956434529u, 4028590195u,
99084074716319u, 813690332u,
99092124740535u, 804073145u,
99103748881891u, 3195309868u,
9911841856605u, 2585865274u,
9912881504822u, 3254795114u,
99131241815736u, 970796142u,
9914497175391u, 3929484338u,
99154264993211u, 1835322201u,
99163675707838u, 4205965408u,
9917300298607u, 3858319990u,
99183255259608u, 4247675634u,
99191095823272u, 1197245408u,
99201742785722u, 785893184u,
99211702965674u, 850401405u,
99224084891412u, 1160134629u,
99232555998391u, 1972759056u,
9924710625654u, 4116162021u,
99253352753742u, 85121177u,
99263513255468u, 2487440590u,
99272480032715u, 2287747045u,
99284090178629u, 4044418876u,
99291703944517u, 486290428u,
99301515601363u, 2011102035u,
9931573985957u, 3536053779u,
99324257172787u, 576405853u,
99331523550693u, 1014952061u,
9934711098718u, 2425317635u,
99353460807169u, 3688987163u,
99363167371443u, 3062418115u,
99373330028292u, 1713171303u,
9938526177822u, 2602636307u,
99391245357025u, 3346699703u,
9940254529415u, 4017058800u,
99411829738451u, 2164236533u,
99421381258384u, 4036354071u,
99431749181924u, 4118435443u,
99444130543625u, 688472265u,
99452731071299u, 2547657502u,
99464175776103u, 338058159u,
99473729582129u, 4181845558u,
99482227290760u, 146827036u,
99492459178427u, 1025353883u,
99504284109679u, 2502815838u,
9951825124804u, 2533140036u,
9952616327404u, 2448966429u,
9953413992636u, 2334782461u,
99542239052397u, 1082330589u,
99553381164715u, 199381437u,
99562583939798u, 2848283092u,
99572300168091u, 2156336315u,
99581855234968u, 1982110346u,
99592482046810u, 3158163887u,
99602168864636u, 133643215u,
99613904021624u, 3646514568u,
99621176127003u, 4015671361u,
9963100525019u, 3534706803u,
99642045051700u, 3452457457u,
99651492267772u, 2308393828u,
99663776661467u, 3281002516u,
99674246334524u, 743955039u,
9968685631442u, 1147951686u,
99692040912376u, 2911148054u,
99703204999386u, 2415262714u,
9971313209105u, 777065474u,
99722729416454u, 1029284767u,
99731632078298u, 1817552554u,
99743963877000u, 1919171906u,
99753843219958u, 3073580867u,
9976865146997u, 2473524405u,
99772593817617u, 3643076308u,
9978617975720u, 3671562289u,
9979121812599u, 2902367378u,
99802260041112u, 1019936943u,
9981320945955u, 2337845588u,
99821535670711u, 773792826u,
99833152195900u, 4090794518u,
99844142587430u, 484732447u,
9985419191319u, 3377973345u,
9986324924679u, 2809286837u,
99871562277603u, 1378362199u,
99883791551981u, 1097806406u,
99891386297408u, 2304900033u,
99903574135531u, 4017075736u,
99911161238398u, 1358056883u,
99923487080616u, 1516736273u,
9993851615042u, 2927899494u,
99944077452507u, 2984955003u,
99953907754394u, 3578173844u,
99961948409509u, 1923531348u,
99973578472493u, 3710074193u,
9998213811117u, 2586632018u,
99991922589216u, 274958014u,
100001654276320u, 2687561076u,
100012569061755u, 3122046057u,
100023203802620u, 1692079268u,
10003477806878u, 140587742u,
10004520565830u, 3674576684u,
1000591246882u, 1010215946u,
100063703994407u, 69201295u,
10007776213083u, 3677771507u,
100083696902571u, 3593730713u,
100092907901228u, 3239753796u,
100101586241476u, 1939595371u,
100112268396558u, 3468719670u,
100122955715987u, 2295501078u,
100132775848696u, 1358532390u,
100143843660102u, 82177963u,
100154094477877u, 191727221u,
10016278661677u, 2889101923u,
100171352525614u, 2844977667u,
100181261140657u, 1747052377u,
100192334120653u, 645125282u,
100202707230761u, 4142246789u,
100211068639717u, 2288162940u,
100221419293714u, 1636932722u,
100233252686293u, 318543902u,
100242598802768u, 2025886508u,
100252250788464u, 2711763065u,
10026255108733u, 1845587644u,
100273719270134u, 3940707863u,
10028917608574u, 1363253259u,
10029788659330u, 673256220u,
10030109793386u, 341851980u,
100312698465479u, 3011229884u,
100323886713057u, 1276595523u,
100332439962760u, 2700515456u,
10034205970448u, 4198897105u,
10035875511891u, 371715572u,
100361033680610u, 4278599955u,
100373120038721u, 1256300069u,
10038225629455u, 3735275001u,
100393961944123u, 1769389163u,
100401074553219u, 668829411u,
100411098679359u, 2573697509u,
100421885071395u, 4233785523u,
100432513878053u, 2030193788u,
10044360256231u, 107312677u,
10045310517502u, 2618936366u,
100463600462351u, 1216645846u,
100472970730323u, 4278812598u,
1004894638678u, 1689811113u,
100494125738800u, 3103759730u,
10050103797041u, 1397772514u,
100511669653333u, 572567964u,
100521612872497u, 2986430557u,
10053214990655u, 3117607990u,
100541949717207u, 2260498180u,
100551493936866u, 3554860960u,
100561582022990u, 1263709570u,
100571244120487u, 3416600761u,
10058224580012u, 4252610345u,
10059286306391u, 814956796u,
100601820532305u, 2776960536u,
100613082703465u, 1659265982u,
100621157398049u, 3752806924u,
100633508246460u, 2902716664u,
100642110942730u, 3267551635u,
10065902835431u, 405228165u,
100662341378668u, 2220373824u,
100673303626294u, 1175118221u,
10068383517064u, 896322512u,
100691697257567u, 2202820683u,
100701837689083u, 1336556841u,
10071914535232u, 3634083711u,
100721537187340u, 3712582785u,
100731088201893u, 3270984620u,
100743093195926u, 2561488770u,
100751962968100u, 236189500u,
100762549435227u, 536047554u,
10077422609195u, 2958815818u,
100784166184983u, 3528794619u,
100791042329086u, 3914176886u,
100801359641525u, 1197100813u,
100811269739674u, 3301844628u,
100821831223342u, 3329594980u,
100832433669782u, 494908536u,
100841441714797u, 1174785921u,
100851933050423u, 958901065u,
10086868981704u, 2163330264u,
100873243110680u, 1443133429u,
100881145009669u, 2520062970u,
100893851564853u, 2664619323u,
100902686075657u, 4042710240u,
100912125408249u, 4165697916u,
100922328730865u, 3160666939u,
10093588683409u, 2126275847u,
10094829404209u, 1878067032u,
100952567792910u, 897670516u,
10096934312076u, 2952135524u,
10097504832490u, 3312698056u,
100984015478120u, 1265237690u,
100993376133707u, 967674402u,
101001553513184u, 834830418u,
101012396504772u, 3278582098u,
101022950762705u, 4277111759u,
101034159211303u, 1290097509u,
10104251949572u, 3065234219u,
101051832020534u, 312136369u,
101061103404394u, 198182691u,
101071369599600u, 3906710870u,
101082954651680u, 1535115487u,
101092389327507u, 1813520230u,
10110632704095u, 140762681u,
101113123202913u, 3336005523u,
101121287729497u, 2198985327u,
101132470730783u, 3821758006u,
101141009870118u, 559702706u,
101154274686257u, 3187546567u,
101162402308151u, 1096697687u,
10117678932329u, 3716363135u,
101182899950405u, 3046872820u,
101193754655641u, 2021741414u,
101201993425202u, 2185339100u,
101212838253700u, 3099212100u,
101221679617763u, 3703603898u,
101231135665833u, 3559875668u,
101242503579743u, 1446869792u,
10125879818611u, 3788305533u,
101262879018745u, 2719373510u,
101273606051203u, 2166567748u,
10128343595772u, 1996164093u,
101291577656121u, 475248376u,
10130463852893u, 2864244470u,
101311332049663u, 3326459767u,
101323207234525u, 2028708916u,
10133938916154u, 3115246264u,
101343272166407u, 557660441u,
101351265684026u, 245033807u,
101362440657523u, 255451671u,
101373811885130u, 1399880284u,
101381322855877u, 3452203069u,
101391324994449u, 3796404024u,
101402002090272u, 1568745354u,
101413700047753u, 31799506u,
101423009412313u, 3184047862u,
10143728680761u, 3848624873u,
101441849329144u, 3160134214u,
101451272923193u, 1474278816u,
101461208883495u, 1566527339u,
101474136466541u, 630825649u,
101481717327230u, 1496132623u,
101492449386742u, 128106940u,
101502108574735u, 2584236470u,
101512872246579u, 397338552u,
101523088905079u, 3456882941u,
101531715915153u, 2940716269u,
101544168438718u, 467441309u,
10155872996731u, 3206901319u,
101561610606159u, 2540270567u,
101571301658081u, 2379410194u,
101582109315753u, 3348545480u,
101592041927873u, 2644077493u,
10160546596661u, 1017047954u,
101612596792972u, 2783958892u,
101622826408201u, 3531646869u,
101632219352672u, 4217451852u,
101641806867885u, 1903578924u,
101652076465705u, 2373061493u,
101661832925325u, 241574049u,
101671509517110u, 3703614272u,
101683429894862u, 3529565564u,
101694010000614u, 2256197939u,
10170517086873u, 2964595704u,
101713501035294u, 4079457298u,
101721184683823u, 4260564140u,
101732339268412u, 3871564102u,
101741572637805u, 383233885u,
101753351411126u, 3419328182u,
101762017406667u, 919677938u,
1017729804156u, 46276077u,
101783032591014u, 4204155962u,
101791172319502u, 969309871u,
101802211319468u, 4153726847u,
101813094193193u, 4240669441u,
101823441709766u, 1387233546u,
101834048882438u, 1217896566u,
101841580964938u, 740563169u,
101853691850348u, 3176426539u,
101862738323042u, 2948665536u,
101871474029445u, 3513354882u,
101883219466255u, 3799363969u,
101893961796122u, 1055550923u,
101901992212097u, 2263421398u,
101914289759174u, 2516844140u,
101921782515131u, 2746577402u,
10193721928440u, 3529570984u,
101941705302106u, 768287270u,
101953474902815u, 4000011125u,
101963475618043u, 212490675u,
10197549130471u, 2970128275u,
101983170016833u, 2549835613u,
101993691104824u, 2694324482u,
102004169365948u, 3738062408u,
10201602930397u, 2148954730u,
102022636387819u, 2616619070u,
10203301617872u, 374657036u,
102043862686086u, 431292293u,
102054225245165u, 1358580562u,
102062377363130u, 1415970351u,
102073885060756u, 1438379807u,
102082297418515u, 2954777083u,
102093970368221u, 1229801760u,
102101931934525u, 2287507921u,
102111713471510u, 2145608111u,
102122650140034u, 4081586725u,
102134196863572u, 1896558394u,
102144059852729u, 1813855658u,
102152618400836u, 1396056469u,
102162375584220u, 1037031473u,
10217249284003u, 2450077637u,
102181383747654u, 3122687303u,
102192664431743u, 3855028730u,
10220929335420u, 3193251135u,
10221137313762u, 1850894384u,
102223163711272u, 3071568023u,
10223418541677u, 3621223039u,
10224340274176u, 1167681812u,
102254106647531u, 4022465625u,
102263069708839u, 2704165015u,
102272332023349u, 641449034u,
10228921552000u, 1712976649u,
102291876484273u, 2343049860u,
102301834682077u, 4155949943u,
102312061821157u, 4240649383u,
10232747285578u, 1626463554u,
10233165503115u, 359629739u,
102343838102563u, 582664250u,
102353878924635u, 4117237498u,
102362250573853u, 804336148u,
10237331393443u, 4242530387u,
102383346357270u, 1674051445u,
102393348019777u, 1722242971u,
102402509017299u, 2966108111u,
102414189102509u, 3323592310u,
102422631381069u, 4014551783u,
102434250787412u, 3448394212u,
102442664752123u, 3517585534u,
102453605365141u, 1669471183u,
102462210121140u, 760762191u,
10247249697459u, 3416920106u,
1024816322182u, 643179562u,
102491564226597u, 2134630675u,
102501011990087u, 2990167340u,
102512349550842u, 1642428946u,
102521214854475u, 2134299399u,
102532704221532u, 2104175211u,
102544283196353u, 1342880802u,
10255198529755u, 2004468390u,
102562544665755u, 853593042u,
102572090611294u, 2970943872u,
102581472073141u, 850464484u,
102591407609278u, 3062461105u,
10260366448238u, 3842907484u,
10261488797416u, 1432670231u,
10262294963924u, 3693536939u,
102633390549825u, 1583234720u,
102644032223840u, 2318423400u,
102652965642867u, 930822729u,
102661679099863u, 1728968857u,
10267900822335u, 702309817u,
102683258354115u, 1502282913u,
102692811888503u, 3924947660u,
102702477280726u, 3651607391u,
102713788310204u, 1300369123u,
102721842333726u, 4146839064u,
102732468893861u, 4091095953u,
10274488595746u, 1448097974u,
102751159634090u, 1738834113u,
102762928916831u, 4093725287u,
10277530850094u, 291657799u,
102783548184546u, 679517009u,
10279399175380u, 2658337143u,
102803827951761u, 3086277222u,
102812067718397u, 3632376023u,
102823553313841u, 119173722u,
102831702434637u, 1766260771u,
10284895654784u, 751439914u,
102854008409498u, 215917713u,
102861288382231u, 2656990891u,
102872581779077u, 1570750352u,
102882666411616u, 3533987737u,
102894289478316u, 3576119563u,
102903869794273u, 963183826u,
102912081410737u, 3796810515u,
102921036883117u, 136547246u,
10293875691100u, 2592925324u,
102942689342539u, 427154472u,
10295532957601u, 1228758574u,
102961908591042u, 1464255968u,
10297446980910u, 2984611177u,
102983508927906u, 2001585786u,
102992544767379u, 1525438381u,
10300879448844u, 1348536411u,
103014242243590u, 2861338018u,
10302601175800u, 764077711u,
10303530635011u, 3785343245u,
103042378297261u, 457568934u,
1030576438221u, 4104954272u,
103062485968477u, 2381948487u,
103074226929450u, 3148473363u,
10308879369091u, 2180270337u,
103093674375989u, 1387729170u,
10310568650985u, 951677556u,
103114213877384u, 2721005055u,
103121678669911u, 66786703u,
103132273631661u, 1149351924u,
10314246723096u, 1895026827u,
103153810605772u, 3711056516u,
103162080120290u, 3638638708u,
103172915672708u, 2263003308u,
103181976115991u, 3448840877u,
103192019238520u, 225333538u,
103201555273378u, 3797521928u,
103211942347150u, 3262952567u,
103222817830907u, 2078619498u,
10323749534111u, 1178073973u,
10324841092198u, 3288261538u,
103251696412169u, 1496966875u,
103263739946319u, 2481012988u,
10327568983526u, 114945840u,
103282841706923u, 1632780103u,
103294020169654u, 2087949619u,
10330833416317u, 3787017905u,
103312373238993u, 2575395164u,
103322542976862u, 2971726178u,
103332880371864u, 3642087909u,
103341043714217u, 3894199764u,
103352235879182u, 203853421u,
10336834683330u, 425935223u,
103373560796393u, 3565833278u,
103383414330886u, 1748785729u,
103391023171602u, 580966986u,
103402657385925u, 2124704694u,
10341233442446u, 1107045577u,
103423899097693u, 1067532701u,
10343115667924u, 1406028344u,
103442419657149u, 18613994u,
103452532882091u, 3476683808u,
10346895961699u, 3762914298u,
103471328752423u, 1844996900u,
103481210281744u, 904215228u,
103494055325594u, 1118521573u,
103503996647489u, 3657647605u,
10351325254059u, 3136157065u,
103523341068436u, 2287683323u,
103531313073005u, 126005630u,
10354853746559u, 3555092974u,
103552689238752u, 49515858u,
1035661073168u, 1010661841u,
103571269521335u, 1902040126u,
103583858321250u, 1400735275u,
103592974699176u, 2771676666u,
10360545726212u, 2225229957u,
103611086473152u, 3454177594u,
103622088002891u, 2883475137u,
103633222194252u, 4144472319u,
10364567988835u, 1051332394u,
103653932046135u, 542648229u,
10366162888005u, 1669710469u,
103671492500905u, 553041029u,
103683817492747u, 584127807u,
103694147115982u, 2993670925u,
103703509733475u, 3587959456u,
103712088550465u, 1745399498u,
10372869648362u, 1404723176u,
103733947542735u, 1334333531u,
1037459634866u, 3239516985u,
103753844250972u, 1275954779u,
103762512155003u, 1685649437u,
10377639306006u, 2524620206u,
10378576786501u, 655707039u,
103792864351838u, 3736264674u,
103801200907897u, 2384379464u,
1038115823708u, 206117476u,
103821193310960u, 1093099415u,
103833696538026u, 4112584792u,
103842069527017u, 547588820u,
103854178147211u, 2827259351u,
10386940846775u, 1054995047u,
103872976960697u, 1934305529u,
103882199137382u, 1005722394u,
103891875867180u, 2064356511u,
103904019734130u, 3096333006u,
103912069509024u, 2906358341u,
103922232866485u, 1456016086u,
103931422674894u, 867282151u,
103941612503136u, 1739843072u,
10395134947567u, 2978775774u,
103961284167756u, 1090844589u,
10397831688783u, 2079216362u,
103981626991196u, 3644714163u,
103993678110059u, 898470030u,
104003916646913u, 3182422972u,
104013630426828u, 969847973u,
104023427164640u, 3463937250u,
104033044785046u, 897322257u,
104043443872170u, 4185408854u,
104052557463241u, 4080940424u,
104062048168570u, 2429169982u,
104073174690447u, 2513494106u,
104081213061732u, 3143736628u,
104093482268149u, 1250714337u,
1041031648125u, 3872383625u,
104111565760579u, 36665130u,
10412751041229u, 2257179590u,
104132915361862u, 280819225u,
104142907818413u, 4254297769u,
104153493178615u, 3755944354u,
104164043533423u, 1134196225u,
104174177134659u, 127246419u,
104182442615581u, 923049607u,
104191004426206u, 782768297u,
104202410586681u, 1430106871u,
104214103323427u, 3168399477u,
104223716682375u, 3616334719u,
104233413209549u, 656672786u,
104242876965944u, 182894450u,
10425456581318u, 2683752067u,
104263877875910u, 3190666241u,
104273240336907u, 4024807233u,
104281681224377u, 1576191191u,
104293599250276u, 2381111980u,
104303495321877u, 3956024585u,
104311611608524u, 3815677453u,
104322062334396u, 1656117707u,
104335457134u, 3234118251u,
10434470187419u, 2688566989u,
104353259870297u, 660100446u,
10436442236198u, 2542452448u,
10437493137955u, 392411099u,
10438947967568u, 1234595917u,
104394230082284u, 2762976773u,
104402870085764u, 1455086530u,
104412762099647u, 4011882747u,
104421215981925u, 3227517889u,
104433269061963u, 4037515364u,
104443168911474u, 4255057396u,
104452026092260u, 1736192508u,
104463909727042u, 3114708966u,
104471938800693u, 680793595u,
104481525265867u, 2808224480u,
104492122290603u, 1211197714u,
104503520488321u, 3979192396u,
104513540779343u, 4192918639u,
104522736030448u, 1120335563u,
104531698949078u, 3993310631u,
104541966048551u, 2228221363u,
10455597941119u, 3498018399u,
10456393987327u, 454500547u,
104571222959566u, 567151340u,
104583774764786u, 1492844524u,
104593308300614u, 805568076u,
10460868414882u, 177406999u,
104611608110313u, 642061169u,
104621027515771u, 3131251981u,
104632851936150u, 4272755262u,
104641532845092u, 709643652u,
10465682573592u, 1244104217u,
10466796769556u, 2500467040u,
104673002618826u, 1112998535u,
104681780193104u, 1243644607u,
104693691719535u, 2958853053u,
10470466635014u, 2277292580u,
104714082276003u, 1030800045u,
104721750863246u, 379050598u,
104733576413281u, 731493104u,
10474132259176u, 4115195437u,
104751769890695u, 2715470335u,
104761819263183u, 2028531518u,
104772154809766u, 3672399742u,
1047876727603u, 4198182186u,
104792304993586u, 1666387627u,
10480284366017u, 3359785538u,
104813469807328u, 2926494787u,
104823829072836u, 2493478921u,
104833738499303u, 3311304980u,
10484932916545u, 2235559063u,
104852909742396u, 1765719309u,
104861456588655u, 508290328u,
104871490719640u, 3356513470u,
104882908490783u, 251085588u,
10489830410677u, 3172220325u,
104903897208579u, 1940535730u,
10491151909546u, 2384458112u,
10492};
10493
10494// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
10495bool Test(int offset, int len = 0) {
10496#undef Check
10497#undef IsAlive
10498
10499#define Check(x) do { \
10500 const uint32_t actual = (x), e = expected[index++]; \
10501 bool ok = actual == e; \
10502 if (!ok) { \
10503 cerr << "expected " << hex << e << " but got " << actual << endl; \
10504 ++errors; \
10505 } \
10506 assert(ok); \
10507} while (0)
10508
10509#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
10510
10511 // After the following line is where the uses of "Check" and such will go.
10512 static int index = 0;
10513if (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; }
10514{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
10515{ uint64_t h = farmhashuo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
10516
10517 return true;
10518#undef Check
10519#undef IsAlive
10520}
10521
10522int RunTest() {
10523 Setup();
10524 int i = 0;
10525 cout << "Running farmhashuoTest";
10526 if (!Test(-1)) {
10527 cout << "... Unavailable\n";
10528 return NoteErrors();
10529 }
10530 // Good. The function is attempting to hash, so run the full test.
10531 int errors_prior_to_test = errors;
10532 for ( ; i < kTestSize - 1; i++) {
10533 Test(i * i, i);
10534 }
10535 for ( ; i < kDataSize; i += i / 7) {
10536 Test(0, i);
10537 }
10538 Test(0, kDataSize);
10539 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
10540 return NoteErrors();
10541}
10542
10543#else
10544
10545// After the following line is where the code to print hash codes will go.
10546void Dump(int offset, int len) {
10547{ uint64_t h = farmhashuo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10548{ uint64_t h = farmhashuo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
10549}
10550
10551#endif
10552
10553#undef SEED
10554#undef SEED1
10555#undef SEED0
10556
10557} // namespace farmhashuoTest
10558
10559#if !TESTING
10560int main(int argc, char** argv) {
10561 Setup();
10562 cout << "uint32_t expected[] = {\n";
10563 int i = 0;
10564 for ( ; i < kTestSize - 1; i++) {
10565 farmhashuoTest::Dump(i * i, i);
10566 }
10567 for ( ; i < kDataSize; i += i / 7) {
10568 farmhashuoTest::Dump(0, i);
10569 }
10570 farmhashuoTest::Dump(0, kDataSize);
10571 cout << "};\n";
10572}
10573#endif
10574#ifndef FARMHASH_SELF_TEST_GUARD
10575#define FARMHASH_SELF_TEST_GUARD
10576#include <cstdio>
10577#include <iostream>
10578#include <string.h>
10579
10580using std::cout;
10581using std::cerr;
10582using std::endl;
10583using std::hex;
10584
10585static const uint64_t kSeed0 = 1234567;
10586static const uint64_t kSeed1 = k0;
10587static const int kDataSize = 1 << 20;
10588static const int kTestSize = 300;
10589#define kSeed128 Uint128(kSeed0, kSeed1)
10590
10591static char data[kDataSize];
10592
10593static int completed_self_tests = 0;
10594static int errors = 0;
10595
10596// Initialize data to pseudorandom values.
10597void Setup() {
10598 if (completed_self_tests == 0) {
10599 uint64_t a = 9;
10600 uint64_t b = 777;
10601 for (int i = 0; i < kDataSize; i++) {
10602 a += b;
10603 b += a;
10604 a = (a ^ (a >> 41)) * k0;
10605 b = (b ^ (b >> 41)) * k0 + i;
10606 uint8_t u = b >> 37;
10607 memcpy(data + i, &u, 1); // uint8_t -> char
10608 }
10609 }
10610}
10611
10612int NoteErrors() {
10613#define NUM_SELF_TESTS 9
10614 if (++completed_self_tests == NUM_SELF_TESTS)
10615 std::exit(errors > 0);
10616 return errors;
10617}
10618
10619template <typename T> inline bool IsNonZero(T x) {
10620 return x != 0;
10621}
10622
10623template <> inline bool IsNonZero<NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t>(NAMESPACE_FOR_HASH_FUNCTIONS::uint128_t x) {
10624 return x != Uint128(0, 0);
10625}
10626
10627#endif // FARMHASH_SELF_TEST_GUARD
10628
10629namespace farmhashxoTest {
10630
10631uint32_t CreateSeed(int offset, int salt) {
10632 uint32_t h = static_cast<uint32_t>(salt & 0xffffffff);
10633 h = h * c1;
10634 h ^= (h >> 17);
10635 h = h * c1;
10636 h ^= (h >> 17);
10637 h = h * c1;
10638 h ^= (h >> 17);
10639 h += static_cast<uint32_t>(offset & 0xffffffff);
10640 h = h * c1;
10641 h ^= (h >> 17);
10642 h = h * c1;
10643 h ^= (h >> 17);
10644 h = h * c1;
10645 h ^= (h >> 17);
10646 return h;
10647}
10648
10649#undef SEED
10650#undef SEED1
10651#undef SEED0
10652#define SEED CreateSeed(offset, -1)
10653#define SEED0 CreateSeed(offset, 0)
10654#define SEED1 CreateSeed(offset, 1)
10655
10656#undef TESTING
10657#define TESTING 1
10658#if TESTING
10659uint32_t expected[] = {
106601140953930u, 861465670u,
106613277735313u, 2681724312u,
106622598464059u, 797982799u,
10663890626835u, 800175912u,
106642603993599u, 921001710u,
106651410420968u, 2134990486u,
106663283896453u, 1867689945u,
106672914424215u, 2244477846u,
10668255297188u, 2992121793u,
106691110588164u, 4186314283u,
10670161451183u, 3943596029u,
106714019337850u, 452431531u,
10672283198166u, 2741341286u,
106733379021470u, 2557197665u,
10674299850021u, 2532580744u,
10675452473466u, 1706958772u,
106761298374911u, 3099673830u,
106772199864459u, 3696623795u,
10678236935126u, 2976578695u,
106794055299123u, 3281581178u,
106801053458494u, 1882212500u,
106812305012065u, 2169731866u,
106823456121707u, 275903667u,
10683458884671u, 3033004529u,
106843058973506u, 2379411653u,
106851898235244u, 1402319660u,
106862700149065u, 2699376854u,
10687147814787u, 720739346u,
106882433714046u, 4222949502u,
106894220361840u, 1712034059u,
106903425469811u, 3690733394u,
106914148372108u, 1330324210u,
10692594028478u, 2921867846u,
106931635026870u, 192883107u,
10694780716741u, 1728752234u,
106953280331829u, 326029180u,
106963969463346u, 1436364519u,
10697393215742u, 3349570000u,
106983824583307u, 1612122221u,
106992859809759u, 3808705738u,
107001379537552u, 1646032583u,
107012233466664u, 1432476832u,
107024023053163u, 2650381482u,
107032052294713u, 3552092450u,
107041628777059u, 1499109081u,
107053476440786u, 3829307897u,
107062960536756u, 1554038301u,
107071145519619u, 3190844552u,
107082902102606u, 3600725550u,
10709237495366u, 540224401u,
1071065721842u, 489963606u,
107111448662590u, 397635823u,
107121596489240u, 1562872448u,
107131790705123u, 2128624475u,
10714180854224u, 2604346966u,
107151435705557u, 1262831810u,
10716155445229u, 1672724608u,
107171669465176u, 1341975128u,
10718663607706u, 2077310004u,
107193610042449u, 1911523866u,
107201043692997u, 1454396064u,
107212563776023u, 294527927u,
107221099072299u, 1389770549u,
10723703505868u, 678706990u,
107242952353448u, 2026137563u,
107253603803785u, 629449419u,
107261933894405u, 3043213226u,
10727226132789u, 2489287368u,
107281552847036u, 645684964u,
107293828089804u, 3632594520u,
10730187883449u, 230403464u,
107313151491850u, 3272648435u,
107323729087873u, 1303930448u,
107332002861219u, 165370827u,
10734916494250u, 1230085527u,
107353103338579u, 3064290191u,
107363807265751u, 3628174014u,
10737231181488u, 851743255u,
107382295806711u, 1781190011u,
107392988893883u, 1554380634u,
107401142264800u, 3667013118u,
107411968445277u, 315203929u,
107422638023604u, 2290487377u,
10743732137533u, 1909203251u,
10744440398219u, 1891630171u,
107451380301172u, 1498556724u,
107464072067757u, 4165088768u,
107474204318635u, 441430649u,
107483931792696u, 197618179u,
10749956300927u, 914413116u,
107503010839769u, 2837339569u,
107512148126371u, 1913303225u,
107523074915312u, 3117299654u,
107534139181436u, 2993479124u,
107543178848746u, 1357272220u,
107551438494951u, 507436733u,
10756667183474u, 2084369203u,
107573854939912u, 1413396341u,
10758126024219u, 146044391u,
107591016656857u, 3022024459u,
107603254014218u, 429095991u,
10761990500595u, 3056862311u,
10762985653208u, 1718653828u,
10763623071693u, 366414107u,
107641771289760u, 2293458109u,
107653047342438u, 2991127487u,
107663120876698u, 1684583131u,
107673638043310u, 1170404994u,
10768863214540u, 1087193030u,
10769199124911u, 520792961u,
107703169775996u, 1577421232u,
107713331828431u, 1013201099u,
107721716848157u, 4033596884u,
107731770708857u, 4229339322u,
107741146169032u, 1434258493u,
107753824360466u, 3242407770u,
107761926419493u, 2649785113u,
10777872586426u, 762243036u,
107782736953692u, 816692935u,
107791571283333u, 3555213933u,
107802266795890u, 3781899767u,
107814290630595u, 517646945u,
107823006163611u, 2180594090u,
10783959214578u, 558910384u,
107841283799121u, 3047062993u,
107853830962609u, 2391606125u,
107863544509313u, 622325861u,
10787834785312u, 382936554u,
107881421463872u, 788479970u,
107891825135056u, 2725923798u,
10790580988377u, 2826990641u,
10791247825043u, 3167748333u,
10792812546227u, 2506885666u,
107932584372201u, 1758123094u,
107941891789696u, 389974094u,
10795345313518u, 2022370576u,
107963886113119u, 3338548567u,
107971083486947u, 2583576230u,
107981776047957u, 1771384107u,
107993604937815u, 3198590202u,
108003027522813u, 4155628142u,
108014232136669u, 427759438u,
108024244322689u, 542201663u,
108031549591985u, 2856634168u,
10804556609672u, 45845311u,
108051175961330u, 3948351189u,
108064165739882u, 4194218315u,
108071634635545u, 4151937410u,
10808713127376u, 1467786451u,
108091327394015u, 2743592929u,
108102638154051u, 810082938u,
108113077742128u, 1062268187u,
108124084325664u, 3810665822u,
108133735739145u, 2794294783u,
108142335576331u, 2560479831u,
10815690240711u, 997658837u,
108162442302747u, 3948961926u,
108173958366652u, 3067277639u,
108182059157774u, 1211737169u,
108191516711748u, 2339636583u,
108204188504038u, 59581167u,
108212767897792u, 1389679610u,
108222658147000u, 2643979752u,
108233758739543u, 4189944477u,
108241454470782u, 100876854u,
108252995362413u, 118817200u,
108263252925478u, 2062343506u,
108272804483644u, 3088828656u,
108281231633714u, 4168280671u,
108292931588131u, 3284356565u,
108301255909792u, 3130054947u,
108314173605289u, 1407328702u,
108321677744031u, 3532596884u,
108333162657845u, 3887208531u,
108342256541290u, 3459463480u,
108353740979556u, 259034107u,
10836392987633u, 3233195759u,
108373606709555u, 3424793077u,
10838315836068u, 3200749877u,
108394065431359u, 760633989u,
108402982018998u, 1811050648u,
10841234531934u, 1115203611u,
108423897494162u, 1516407838u,
108431603559457u, 323296368u,
108442632963283u, 1778459926u,
108452879836826u, 2146672889u,
108463486330348u, 492621815u,
108471231665285u, 2457048126u,
108483438440082u, 2217471853u,
108493355404249u, 3275550588u,
108501052645068u, 862072556u,
108514110617119u, 3745267835u,
108522657392572u, 4279236653u,
108531688445808u, 701920051u,
10854956734128u, 581695350u,
108553157862788u, 2585726058u,
108561192588249u, 1410111809u,
108571651193125u, 3326135446u,
108581073280453u, 97376972u,
108592513844237u, 2187968410u,
108603976859649u, 4267859263u,
108613429034542u, 564493077u,
108623000537321u, 479241367u,
108633845637831u, 2868987960u,
1086451544337u, 1029173765u,
10865393624922u, 704325635u,
108662357610553u, 1418509533u,
108672007814586u, 3866658271u,
108683082385053u, 735688735u,
10869916110004u, 3283299459u,
108701051684175u, 1083796807u,
108714074716319u, 813690332u,
10872144264390u, 1439630796u,
108731508556987u, 675582689u,
108743748881891u, 3195309868u,
10875362884708u, 1616408198u,
1087643233176u, 837301135u,
10877881504822u, 3254795114u,
108781385506591u, 2799925823u,
108791469874582u, 3464841997u,
10880497175391u, 3929484338u,
108813975771289u, 1798536177u,
108822926265846u, 1374242438u,
108833675707838u, 4205965408u,
108843153165629u, 1499475160u,
10885187287713u, 548490821u,
108863255259608u, 4247675634u,
108871940181471u, 3779953975u,
10888687167150u, 2319566715u,
108891742785722u, 785893184u,
108902296977392u, 2778575413u,
108911794720651u, 48131484u,
108924084891412u, 1160134629u,
108933737623280u, 823113169u,
108943423207646u, 3803213486u,
10895710625654u, 4116162021u,
108963693420287u, 4167766971u,
108971666602807u, 295320990u,
108983513255468u, 2487440590u,
10899234080704u, 4004655503u,
109002971762528u, 1479656873u,
109014090178629u, 4044418876u,
10902391947536u, 1462554406u,
109033909295855u, 1239580330u,
109041515601363u, 2011102035u,
109051442068334u, 4265993528u,
109061191921695u, 2291355695u,
109074257172787u, 576405853u,
10908314332944u, 4038839101u,
1090955559918u, 2378985842u,
10910711098718u, 2425317635u,
109111644327317u, 1401013391u,
109124193760037u, 2958260436u,
109133167371443u, 3062418115u,
109143800755475u, 3167030094u,
109153489648204u, 1405430357u,
10916526177822u, 2602636307u,
10917915406019u, 4264167741u,
109181484090483u, 3070944737u,
10919254529415u, 4017058800u,
109201702710265u, 1029665228u,
109212000382906u, 3185573940u,
109221381258384u, 4036354071u,
109232900841028u, 2670703363u,
109242921748807u, 2899069938u,
109254130543625u, 688472265u,
109264186808827u, 1054670286u,
109271132985391u, 2840525968u,
109284175776103u, 338058159u,
109291735964501u, 1539305024u,
109303497121710u, 1568260669u,
109312227290760u, 146827036u,
109323977176001u, 4060134777u,
10933857488494u, 250055052u,
109344284109679u, 2502815838u,
109352592281721u, 1603444633u,
109361390562014u, 1556658131u,
10937616327404u, 2448966429u,
109383051191726u, 3891353218u,
109391213304082u, 762328245u,
109402239052397u, 1082330589u,
109412455957292u, 201837927u,
10942405397452u, 3079886794u,
109432583939798u, 2848283092u,
109443750724631u, 883849006u,
109453204198988u, 3341327098u,
109461855234968u, 1982110346u,
109471485529487u, 541496720u,
109484117290321u, 3607433551u,
109492168864636u, 133643215u,
109501055817409u, 3847827123u,
109512960769387u, 4046101649u,
109521176127003u, 4015671361u,
109534243643405u, 2849988118u,
10954517111221u, 1796672358u,
109552045051700u, 3452457457u,
109562948254999u, 2102063419u,
109571556410577u, 1536380876u,
109583776661467u, 3281002516u,
109591735616066u, 1539151988u,
109601087795162u, 3332431596u,
10961685631442u, 1147951686u,
1096295237878u, 2005032160u,
109634012206915u, 4224354805u,
109643204999386u, 2415262714u,
109651433635018u, 116647396u,
1096683167836u, 2881562655u,
109672729416454u, 1029284767u,
10968881378302u, 2159170082u,
10969555057366u, 1169104445u,
109703963877000u, 1919171906u,
10971336034862u, 2017579106u,
109724059340529u, 3020819343u,
10973865146997u, 2473524405u,
10974944743644u, 1694443528u,
109751804513294u, 2904752429u,
10976617975720u, 3671562289u,
10977260177668u, 505662155u,
109781885941445u, 2504509403u,
109792260041112u, 1019936943u,
109803722741628u, 1511077569u,
109813100701179u, 1379422864u,
109821535670711u, 773792826u,
109831103819072u, 2089123665u,
109841157547425u, 329152940u,
109854142587430u, 484732447u,
109862475035432u, 1120017626u,
10987412145504u, 965125959u,
10988324924679u, 2809286837u,
109892842141483u, 4029205195u,
109902974306813u, 515627448u,
109913791551981u, 1097806406u,
109923873078673u, 136118734u,
109931872130856u, 3632422367u,
109943574135531u, 4017075736u,
109951699452298u, 1403506686u,
10996344414660u, 1189129691u,
109973487080616u, 1516736273u,
109981805475756u, 2562064338u,
10999163335594u, 2732147834u,
110004077452507u, 2984955003u,
110014271866024u, 3071338162u,
110022347111903u, 873829983u,
110031948409509u, 1923531348u,
11004459509140u, 771592405u,
110051750124750u, 2334938333u,
11006213811117u, 2586632018u,
11007185232757u, 4032960199u,
110082447383637u, 284777551u,
110091654276320u, 2687561076u,
110103512945009u, 308584855u,
110111861027147u, 4102279334u,
110123203802620u, 1692079268u,
110134250142168u, 2565680167u,
110141507046104u, 841195925u,
11015520565830u, 3674576684u,
1101638924274u, 3770488806u,
110172414430882u, 3978473838u,
110183703994407u, 69201295u,
110193099963860u, 1255084262u,
11020690971838u, 3539996781u,
110213696902571u, 3593730713u,
110222363435042u, 54945052u,
110231785765213u, 184911581u,
110241586241476u, 1939595371u,
110252534883189u, 2432427547u,
110262374171993u, 2039128933u,
110272955715987u, 2295501078u,
110282741583197u, 1280920000u,
11029686818699u, 1238742497u,
110303843660102u, 82177963u,
110311281043691u, 1121403845u,
110321697846708u, 284852964u,
11033278661677u, 2889101923u,
110342127558730u, 713121337u,
11035872502474u, 511142139u,
110361261140657u, 1747052377u,
110372108187161u, 927011680u,
11038955328267u, 3821994995u,
110392707230761u, 4142246789u,
110404134691985u, 1958963937u,
110412498463509u, 1977988705u,
110421419293714u, 1636932722u,
110432567532373u, 4075249328u,
11044240575705u, 1956681213u,
110452598802768u, 2025886508u,
110464104757832u, 3026358429u,
110473242615202u, 4026813725u,
11048255108733u, 1845587644u,
110493573008472u, 3615577014u,
110501222733548u, 1205557630u,
11051917608574u, 1363253259u,
110521541946015u, 3087190425u,
110531138008081u, 1444019663u,
11054109793386u, 341851980u,
11055857839960u, 2515339233u,
11056156283211u, 1906768669u,
110573886713057u, 1276595523u,
110582809830736u, 460237542u,
110593420452099u, 142985419u,
11060205970448u, 4198897105u,
110611950698961u, 2069753399u,
110621142216925u, 1113051162u,
110631033680610u, 4278599955u,
110641106466069u, 356742959u,
11065531521052u, 3494863964u,
11066225629455u, 3735275001u,
110673662626864u, 1750561299u,
110681012864651u, 2101846429u,
110691074553219u, 668829411u,
11070992181339u, 3384018814u,
110713330664522u, 860966321u,
110721885071395u, 4233785523u,
11073100741310u, 451656820u,
110742148187612u, 1063001151u,
11075360256231u, 107312677u,
110763650357479u, 2390172694u,
1107722452685u, 237319043u,
110783600462351u, 1216645846u,
110792088767754u, 164402616u,
110802418980170u, 926137824u,
1108194638678u, 1689811113u,
110822751052984u, 1767810825u,
11083271289013u, 3896132233u,
11084103797041u, 1397772514u,
110853441135892u, 3323383489u,
110862491268371u, 1662561885u,
110871612872497u, 2986430557u,
110882756998822u, 207428029u,
11089937973965u, 2791656726u,
110901949717207u, 2260498180u,
110912648427775u, 2360400900u,
110922080496169u, 486358863u,
110931582022990u, 1263709570u,
110941396468647u, 1377764574u,
11095363008508u, 1293502429u,
11096224580012u, 4252610345u,
110971435134775u, 1099809675u,
11098533671980u, 1533438766u,
110991820532305u, 2776960536u,
111003374512975u, 3542220540u,
11101822810075u, 3716663290u,
111021157398049u, 3752806924u,
111034081637863u, 337070226u,
111043866585976u, 359270190u,
111052110942730u, 3267551635u,
11106644850146u, 1306761320u,
11107746972907u, 934259457u,
111082341378668u, 2220373824u,
111091242645122u, 4109252858u,
111101625266099u, 1173698481u,
11111383517064u, 896322512u,
111123377483696u, 1788337208u,
11113455496839u, 3194373887u,
111141837689083u, 1336556841u,
111151658628529u, 2911512007u,
111163838343487u, 2757664765u,
111171537187340u, 3712582785u,
11118367022558u, 3071359622u,
111193926147070u, 35432879u,
111203093195926u, 2561488770u,
111214273132307u, 3898950547u,
111222838251049u, 2103926083u,
111232549435227u, 536047554u,
111241858986613u, 2040551642u,
111251147412575u, 1972369852u,
111264166184983u, 3528794619u,
111274077477194u, 3565689036u,
11128808048238u, 3826350461u,
111291359641525u, 1197100813u,
11130265993036u, 1864569342u,
11131725164342u, 2264788336u,
111321831223342u, 3329594980u,
11133923017956u, 490608221u,
111343818634478u, 258154469u,
111351441714797u, 1174785921u,
111363833372385u, 3287246572u,
111371677395563u, 3569218731u,
11138868981704u, 2163330264u,
111392649450292u, 500120236u,
11140465161780u, 746438382u,
111411145009669u, 2520062970u,
111422810524030u, 1561519055u,
111431479878006u, 3864969305u,
111442686075657u, 4042710240u,
111453224066062u, 2774151984u,
111462226179547u, 1643626042u,
111472328730865u, 3160666939u,
111482107011431u, 96459446u,
111493920328742u, 3336407558u,
11150829404209u, 1878067032u,
111511235983679u, 4237425634u,
11152466519055u, 3870676863u,
11153934312076u, 2952135524u,
11154276949224u, 4100839753u,
11155424001484u, 1955120893u,
111564015478120u, 1265237690u,
11157427484362u, 4246879223u,
111583452969617u, 1724363362u,
111591553513184u, 834830418u,
111601858777639u, 3476334357u,
111614144030366u, 2450047160u,
111622950762705u, 4277111759u,
11163358032121u, 2511026735u,
11164167923105u, 2059208280u,
11165251949572u, 3065234219u,
111661535473864u, 556796152u,
111671513237478u, 3150857516u,
111681103404394u, 198182691u,
111691476438092u, 2913077464u,
11170207119516u, 3963810232u,
111712954651680u, 1535115487u,
111723051522276u, 4046477658u,
11173917804636u, 864395565u,
11174632704095u, 140762681u,
111751802040304u, 990407433u,
111763771506212u, 4106024923u,
111771287729497u, 2198985327u,
111784052924496u, 2926590471u,
111793084557148u, 1472898694u,
111801009870118u, 559702706u,
111814265214507u, 82077489u,
111823067891003u, 3295678907u,
111832402308151u, 1096697687u,
11184464407878u, 4190838199u,
111854269578403u, 3060919438u,
111862899950405u, 3046872820u,
11187733509243u, 1583801700u,
1118840453902u, 3879773881u,
111891993425202u, 2185339100u,
111901877837196u, 3912423882u,
111913293122640u, 4104318469u,
111921679617763u, 3703603898u,
111938759461u, 2540185277u,
111941152198475u, 2038345882u,
111952503579743u, 1446869792u,
111962019419351u, 4051584612u,
111973178289407u, 3992503830u,
111982879018745u, 2719373510u,
11199700836153u, 1675560450u,
112004121245793u, 2064715719u,
11201343595772u, 1996164093u,
112023130433948u, 405251683u,
112032804817126u, 1607133689u,
11204463852893u, 2864244470u,
112052224044848u, 4071581802u,
112062537107938u, 2246347953u,
112073207234525u, 2028708916u,
112082272418128u, 803575837u,
1120938655481u, 2170452091u,
112103272166407u, 557660441u,
112114019147902u, 3841480082u,
11212298459606u, 2600943364u,
112132440657523u, 255451671u,
112143424361375u, 779434428u,
112153088526123u, 490671625u,
112161322855877u, 3452203069u,
112173057021940u, 2285701422u,
112182014993457u, 2390431709u,
112192002090272u, 1568745354u,
112201783152480u, 823305654u,
112214053862835u, 2200236540u,
112223009412313u, 3184047862u,
112233032187389u, 4159715581u,
112242966902888u, 252986948u,
112251849329144u, 3160134214u,
112263420960112u, 3198900547u,
11227749160960u, 379139040u,
112281208883495u, 1566527339u,
112293006227299u, 4194096960u,
11230556075248u, 497404038u,
112311717327230u, 1496132623u,
112321775955687u, 1719108984u,
112331014328900u, 4189966956u,
112342108574735u, 2584236470u,
11235684087286u, 531310503u,
112364264509527u, 773405691u,
112373088905079u, 3456882941u,
112383105682208u, 3382290593u,
112392289363624u, 3296306400u,
112404168438718u, 467441309u,
11241777173623u, 3241407531u,
112421183994815u, 1132983260u,
112431610606159u, 2540270567u,
112442649684057u, 1397502982u,
11245146657385u, 3318434267u,
112462109315753u, 3348545480u,
112473193669211u, 811750340u,
112481073256162u, 3571673088u,
11249546596661u, 1017047954u,
112503403136990u, 2540585554u,
112511477047647u, 4145867423u,
112522826408201u, 3531646869u,
11253784952939u, 943914610u,
112542717443875u, 3657384638u,
112551806867885u, 1903578924u,
112563985088434u, 1911188923u,
112571764002686u, 3672748083u,
112581832925325u, 241574049u,
11259519948041u, 3181425568u,
112602939747257u, 1634174593u,
112613429894862u, 3529565564u,
112621089679033u, 240953857u,
112632025369941u, 2695166650u,
11264517086873u, 2964595704u,
112653017658263u, 3828377737u,
112662144895011u, 994799311u,
112671184683823u, 4260564140u,
11268308018483u, 4262383425u,
112691374752558u, 3431057723u,
112701572637805u, 383233885u,
112713188015819u, 4051263539u,
11272233319221u, 3794788167u,
112732017406667u, 919677938u,
112744074952232u, 1683612329u,
112754213676186u, 327142514u,
112763032591014u, 4204155962u,
11277206775997u, 2283918569u,
112782395147154u, 3427505379u,
112792211319468u, 4153726847u,
112802217060665u, 350160869u,
112812493667051u, 1648200185u,
112823441709766u, 1387233546u,
11283140980u, 1891558063u,
11284760080239u, 2088061981u,
112851580964938u, 740563169u,
11286422986366u, 330624974u,
112874264507722u, 150928357u,
112882738323042u, 2948665536u,
11289918718096u, 376390582u,
112903966098971u, 717653678u,
112913219466255u, 3799363969u,
112923424344721u, 3187805406u,
11293375347278u, 3490350144u,
112941992212097u, 2263421398u,
112953855037968u, 1928519266u,
112963866327955u, 1129127000u,
112971782515131u, 2746577402u,
112983059200728u, 2108753646u,
112992738070963u, 1336849395u,
113001705302106u, 768287270u,
113011343511943u, 2247006571u,
113021956142255u, 1780259453u,
113033475618043u, 212490675u,
11304622521957u, 917121602u,
113051852992332u, 1267987847u,
113063170016833u, 2549835613u,
113073299763344u, 2864033668u,
113083378768767u, 1236609378u,
113094169365948u, 3738062408u,
113102661022773u, 2006922227u,
113112760592161u, 3828932355u,
113122636387819u, 2616619070u,
113131237256330u, 3449066284u,
113142871755260u, 3729280948u,
113153862686086u, 431292293u,
113163285899651u, 786322314u,
113172531158535u, 724901242u,
113182377363130u, 1415970351u,
113191244759631u, 3263135197u,
11320965248856u, 174024139u,
113212297418515u, 2954777083u,
11322987586766u, 3206261120u,
113234059515114u, 3903854066u,
113241931934525u, 2287507921u,
113251827135136u, 1781944746u,
11326574617451u, 2299034788u,
113272650140034u, 4081586725u,
113282482286699u, 1109175923u,
11329458483596u, 618705848u,
113304059852729u, 1813855658u,
113314190721328u, 1129462471u,
113324089998050u, 3575732749u,
113332375584220u, 1037031473u,
113341623777358u, 3389003793u,
11335546597541u, 352770237u,
113361383747654u, 3122687303u,
113371646071378u, 1164309901u,
11338290870767u, 830691298u,
11339929335420u, 3193251135u,
11340989577914u, 3626554867u,
11341591974737u, 3996958215u,
113423163711272u, 3071568023u,
113431516846461u, 3656006011u,
113442698625268u, 2510865430u,
11345340274176u, 1167681812u,
113463698796465u, 3155218919u,
113474102288238u, 1673474350u,
113483069708839u, 2704165015u,
113491237411891u, 1854985978u,
113503646837503u, 3625406022u,
11351921552000u, 1712976649u,
113523939149151u, 878608872u,
113533406359248u, 1068844551u,
113541834682077u, 4155949943u,
113552437686324u, 3163786257u,
113562645117577u, 1988168803u,
11357747285578u, 1626463554u,
113581235300371u, 1256485167u,
113591914142538u, 4141546431u,
113603838102563u, 582664250u,
113611883344352u, 2083771672u,
113622611657933u, 2139079047u,
113632250573853u, 804336148u,
113643066325351u, 2770847216u,
113654275641370u, 1455750577u,
113663346357270u, 1674051445u,
11367601221482u, 3992583643u,
113681402445097u, 3622527604u,
113692509017299u, 2966108111u,
113702557027816u, 900741486u,
113711790771021u, 2912643797u,
113722631381069u, 4014551783u,
1137390375300u, 300318232u,
113743269968032u, 2679371729u,
113752664752123u, 3517585534u,
113763253901179u, 542270815u,
113771188641600u, 365479232u,
113782210121140u, 760762191u,
113791273768482u, 1216399252u,
113803484324231u, 4287337666u,
1138116322182u, 643179562u,
11382325675502u, 3652676161u,
113833120716054u, 3330259752u,
113841011990087u, 2990167340u,
113851097584090u, 3262252593u,
113861829409951u, 3665087267u,
113871214854475u, 2134299399u,
113883704419305u, 411263051u,
113891625446136u, 549838529u,
113904283196353u, 1342880802u,
113913460621305u, 1967599860u,
113924282843369u, 1275671016u,
113932544665755u, 853593042u,
11394901109753u, 2682611693u,
11395110631633u, 797487791u,
113961472073141u, 850464484u,
11397797089608u, 3286110054u,
11398350397471u, 2775631060u,
11399366448238u, 3842907484u,
114002219863904u, 3623364733u,
114011850985302u, 4009616991u,
11402294963924u, 3693536939u,
114033061255808u, 1615375832u,
114041920066675u, 4113028420u,
114054032223840u, 2318423400u,
114062701956286u, 4145497671u,
114073991532344u, 2536338351u,
114081679099863u, 1728968857u,
11409449740816u, 2686506989u,
11410685242457u, 97590863u,
114113258354115u, 1502282913u,
114121235084019u, 2151665147u,
11413528459289u, 231097464u,
114142477280726u, 3651607391u,
114152091754612u, 1178454681u,
11416980597335u, 1604483865u,
114171842333726u, 4146839064u,
114183213794286u, 2601416506u,
11419754220096u, 3571436033u,
11420488595746u, 1448097974u,
114214004834921u, 238887261u,
114223320337489u, 1416989070u,
114232928916831u, 4093725287u,
11424186020771u, 2367569534u,
114253046087671u, 4090084518u,
114263548184546u, 679517009u,
114271962659444u, 3539886328u,
114284192003933u, 1678423485u,
114293827951761u, 3086277222u,
114302144472852u, 1390394371u,
114312976322029u, 1574517163u,
114323553313841u, 119173722u,
114331702434637u, 1766260771u,
114343629581771u, 1407497759u,
11435895654784u, 751439914u,
114364008409498u, 215917713u,
114371482103833u, 695551833u,
114381288382231u, 2656990891u,
114392581779077u, 1570750352u,
114403710689053u, 1741390464u,
114412666411616u, 3533987737u,
114424289478316u, 3576119563u,
114434118694920u, 108199666u,
114443869794273u, 963183826u,
114452081410737u, 3796810515u,
11446791123882u, 2525792704u,
114471036883117u, 136547246u,
11448875691100u, 2592925324u,
11449614302599u, 3013176417u,
114502689342539u, 427154472u,
11451532957601u, 1228758574u,
114521898117151u, 1181643858u,
114531908591042u, 1464255968u,
11454446980910u, 2984611177u,
1145558509511u, 1046943619u,
114563508927906u, 2001585786u,
114572544767379u, 1525438381u,
11458552181222u, 1959725830u,
11459879448844u, 1348536411u,
114604242243590u, 2861338018u,
114611082052441u, 1034351453u,
11462601175800u, 764077711u,
11463530635011u, 3785343245u,
114642178026726u, 117256687u,
114652378297261u, 457568934u,
1146676438221u, 4104954272u,
11467956793873u, 3783168634u,
114682485968477u, 2381948487u,
114694226929450u, 3148473363u,
114702518273601u, 3569490233u,
11471879369091u, 2180270337u,
114723674375989u, 1387729170u,
11473977997984u, 4270646856u,
11474568650985u, 951677556u,
114754213877384u, 2721005055u,
114761073364549u, 2563403831u,
114771678669911u, 66786703u,
114782273631661u, 1149351924u,
114793651298990u, 1581883443u,
11480246723096u, 1895026827u,
114813810605772u, 3711056516u,
114824058833288u, 2193790614u,
114832080120290u, 3638638708u,
114842915672708u, 2263003308u,
114852361934197u, 4136767460u,
114861976115991u, 3448840877u,
114872019238520u, 225333538u,
11488874340815u, 2976159827u,
114891555273378u, 3797521928u,
114901942347150u, 3262952567u,
11491435997738u, 340403353u,
114922817830907u, 2078619498u,
11493749534111u, 1178073973u,
11494894654712u, 3361226032u,
11495841092198u, 3288261538u,
114961696412169u, 1496966875u,
11497697501571u, 1059158875u,
114983739946319u, 2481012988u,
11499568983526u, 114945840u,
115001559249010u, 2218244008u,
115012841706923u, 1632780103u,
115024020169654u, 2087949619u,
115032438736103u, 24032648u,
11504833416317u, 3787017905u,
115052373238993u, 2575395164u,
115063434544481u, 3228481067u,
115072542976862u, 2971726178u,
115082880371864u, 3642087909u,
115092407477975u, 2239080836u,
115101043714217u, 3894199764u,
115112235879182u, 203853421u,
115122933669448u, 2504940536u,
11513834683330u, 425935223u,
115143560796393u, 3565833278u,
115151668000829u, 3683399154u,
115163414330886u, 1748785729u,
115171023171602u, 580966986u,
115182531038985u, 3227325488u,
115192657385925u, 2124704694u,
11520233442446u, 1107045577u,
115213407293834u, 552770757u,
115223899097693u, 1067532701u,
11523115667924u, 1406028344u,
115241707768231u, 3724015962u,
115252419657149u, 18613994u,
115262532882091u, 3476683808u,
115271560838678u, 811220224u,
11528895961699u, 3762914298u,
115291328752423u, 1844996900u,
115301420427894u, 1848067707u,
115311210281744u, 904215228u,
115324055325594u, 1118521573u,
115332496554183u, 2579259919u,
115343996647489u, 3657647605u,
11535325254059u, 3136157065u,
115363951522674u, 4052925250u,
115373341068436u, 2287683323u,
115381313073005u, 126005630u,
115392505120084u, 1194725057u,
11540853746559u, 3555092974u,
115412689238752u, 49515858u,
115421244776042u, 1069300695u,
1154361073168u, 1010661841u,
115441269521335u, 1902040126u,
11545990632502u, 2378708922u,
115463858321250u, 1400735275u,
115472974699176u, 2771676666u,
11548170995186u, 2877798589u,
11549545726212u, 2225229957u,
115501086473152u, 3454177594u,
115513859483262u, 1499729584u,
115522088002891u, 2883475137u,
115533222194252u, 4144472319u,
115542212229854u, 4146740722u,
11555567988835u, 1051332394u,
115563932046135u, 542648229u,
115573017852446u, 1277887997u,
11558162888005u, 1669710469u,
115591492500905u, 553041029u,
115601434876932u, 533989516u,
115613817492747u, 584127807u,
115624147115982u, 2993670925u,
115634020312558u, 710021255u,
115643509733475u, 3587959456u,
115652088550465u, 1745399498u,
115662952242967u, 1259815443u,
11567869648362u, 1404723176u,
115683947542735u, 1334333531u,
115693873471582u, 229399758u,
1157059634866u, 3239516985u,
115713844250972u, 1275954779u,
115721385684948u, 2243700741u,
115732512155003u, 1685649437u,
11574639306006u, 2524620206u,
11575955360345u, 1646776457u,
11576576786501u, 655707039u,
115772864351838u, 3736264674u,
11578655621239u, 362070173u,
115791200907897u, 2384379464u,
1158015823708u, 206117476u,
115813652870937u, 122927134u,
115821193310960u, 1093099415u,
115833696538026u, 4112584792u,
115841834541277u, 845639252u,
115852069527017u, 547588820u,
115864178147211u, 2827259351u,
115871764455305u, 3312003602u,
11588940846775u, 1054995047u,
115892976960697u, 1934305529u,
115903095615046u, 3354962706u,
115912199137382u, 1005722394u,
115921875867180u, 2064356511u,
115933363633633u, 2688499147u,
115944019734130u, 3096333006u,
115952069509024u, 2906358341u,
115963247463123u, 4191788132u,
115972232866485u, 1456016086u,
115981422674894u, 867282151u,
115991851386407u, 1268304058u,
116001612503136u, 1739843072u,
11601134947567u, 2978775774u,
116022051592101u, 1017127033u,
116031284167756u, 1090844589u,
11604831688783u, 2079216362u,
116052079309682u, 1950585801u,
116061626991196u, 3644714163u,
116073678110059u, 898470030u,
116081117570988u, 2517572125u,
116093916646913u, 3182422972u,
116103630426828u, 969847973u,
116112835126238u, 53541366u,
116123427164640u, 3463937250u,
116133044785046u, 897322257u,
11614103038235u, 3804506837u,
116153443872170u, 4185408854u,
116162557463241u, 4080940424u,
116173669923099u, 2789619871u,
116182048168570u, 2429169982u,
116193174690447u, 2513494106u,
116203099587829u, 2627855577u,
116211213061732u, 3143736628u,
116223482268149u, 1250714337u,
116233553412672u, 2689632914u,
1162431648125u, 3872383625u,
116251565760579u, 36665130u,
116261282106920u, 359361724u,
11627751041229u, 2257179590u,
116282915361862u, 280819225u,
11629954406473u, 4101682199u,
116302907818413u, 4254297769u,
116313493178615u, 3755944354u,
116323539557658u, 3330196096u,
116334043533423u, 1134196225u,
116344177134659u, 127246419u,
116354213770762u, 1978302978u,
116362442615581u, 923049607u,
116371004426206u, 782768297u,
116382702745496u, 1880389457u,
116392410586681u, 1430106871u,
116404103323427u, 3168399477u,
11641201787012u, 3105353527u,
116423716682375u, 3616334719u,
116433413209549u, 656672786u,
11644526032790u, 2895072131u,
116452876965944u, 182894450u,
11646456581318u, 2683752067u,
116471287916294u, 1270745752u,
116483877875910u, 3190666241u,
116493240336907u, 4024807233u,
116504227999465u, 2389301430u,
116511681224377u, 1576191191u,
116523599250276u, 2381111980u,
116533995044500u, 995595530u,
116543495321877u, 3956024585u,
116551611608524u, 3815677453u,
116561520987487u, 3669102590u,
116572062334396u, 1656117707u,
116585457134u, 3234118251u,
116594242065111u, 596879987u,
11660470187419u, 2688566989u,
116613259870297u, 660100446u,
116621042378442u, 2206034096u,
11663442236198u, 2542452448u,
11664493137955u, 392411099u,
116653111186954u, 438250493u,
11666947967568u, 1234595917u,
116674230082284u, 2762976773u,
11668421203727u, 3728409592u,
116692870085764u, 1455086530u,
116702762099647u, 4011882747u,
116711785430706u, 3684427488u,
116721215981925u, 3227517889u,
116733269061963u, 4037515364u,
116741749401388u, 2167451566u,
116753168911474u, 4255057396u,
116762026092260u, 1736192508u,
116774123254745u, 2319366806u,
116783909727042u, 3114708966u,
116791938800693u, 680793595u,
116803933041672u, 616863613u,
116811525265867u, 2808224480u,
116822122290603u, 1211197714u,
116831186177814u, 2395325006u,
116843520488321u, 3979192396u,
116853540779343u, 4192918639u,
116861763872074u, 3402419930u,
116872736030448u, 1120335563u,
116881698949078u, 3993310631u,
116892947659998u, 1461045789u,
116901966048551u, 2228221363u,
11691597941119u, 3498018399u,
116921441110751u, 2229999711u,
11693393987327u, 454500547u,
116941222959566u, 567151340u,
116952496952483u, 1708770195u,
116963774764786u, 1492844524u,
116973308300614u, 805568076u,
116984068812294u, 3404648243u,
11699868414882u, 177406999u,
117001608110313u, 642061169u,
117012093999089u, 222470301u,
117021027515771u, 3131251981u,
117032851936150u, 4272755262u,
117042763002551u, 1881527822u,
117051532845092u, 709643652u,
11706682573592u, 1244104217u,
11707440905170u, 1111321746u,
11708796769556u, 2500467040u,
117093002618826u, 1112998535u,
117101188525643u, 4212674512u,
117111780193104u, 1243644607u,
117123691719535u, 2958853053u,
117132813437721u, 4036584207u,
11714466635014u, 2277292580u,
117154082276003u, 1030800045u,
117161899531424u, 609466946u,
117171750863246u, 379050598u,
117183576413281u, 731493104u,
117192707384133u, 2289193651u,
11720132259176u, 4115195437u,
117211769890695u, 2715470335u,
117223348954692u, 2166575624u,
117231819263183u, 2028531518u,
117242154809766u, 3672399742u,
117251142139448u, 88299682u,
1172676727603u, 4198182186u,
117272304993586u, 1666387627u,
117282488475423u, 3832777692u,
11729284366017u, 3359785538u,
117303469807328u, 2926494787u,
117311914195188u, 1134129972u,
117323829072836u, 2493478921u,
117333738499303u, 3311304980u,
11734726951526u, 911080963u,
11735932916545u, 2235559063u,
117362909742396u, 1765719309u,
11737465269850u, 3803621553u,
117381456588655u, 508290328u,
117391490719640u, 3356513470u,
117402262196163u, 1451774941u,
117412908490783u, 251085588u,
11742830410677u, 3172220325u,
117434039692645u, 1383603170u,
117443897208579u, 1940535730u,
11745151909546u, 2384458112u,
11746};
11747
11748// Return false only if offset is -1 and a spot check of 3 hashes all yield 0.
11749bool Test(int offset, int len = 0) {
11750#undef Check
11751#undef IsAlive
11752
11753#define Check(x) do { \
11754 const uint32_t actual = (x), e = expected[index++]; \
11755 bool ok = actual == e; \
11756 if (!ok) { \
11757 cerr << "expected " << hex << e << " but got " << actual << endl; \
11758 ++errors; \
11759 } \
11760 assert(ok); \
11761} while (0)
11762
11763#define IsAlive(x) do { alive += IsNonZero(x); } while (0)
11764
11765 // After the following line is where the uses of "Check" and such will go.
11766 static int index = 0;
11767if (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; }
11768{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); Check(h >> 32); Check((h << 32) >> 32); }
11769{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); Check(h >> 32); Check((h << 32) >> 32); }
11770{ uint64_t h = farmhashxo::Hash64(data + offset, len); Check(h >> 32); Check((h << 32) >> 32); }
11771
11772 return true;
11773#undef Check
11774#undef IsAlive
11775}
11776
11777int RunTest() {
11778 Setup();
11779 int i = 0;
11780 cout << "Running farmhashxoTest";
11781 if (!Test(-1)) {
11782 cout << "... Unavailable\n";
11783 return NoteErrors();
11784 }
11785 // Good. The function is attempting to hash, so run the full test.
11786 int errors_prior_to_test = errors;
11787 for ( ; i < kTestSize - 1; i++) {
11788 Test(i * i, i);
11789 }
11790 for ( ; i < kDataSize; i += i / 7) {
11791 Test(0, i);
11792 }
11793 Test(0, kDataSize);
11794 cout << (errors == errors_prior_to_test ? "... OK\n" : "... Failed\n");
11795 return NoteErrors();
11796}
11797
11798#else
11799
11800// After the following line is where the code to print hash codes will go.
11801void Dump(int offset, int len) {
11802{ uint64_t h = farmhashxo::Hash64WithSeeds(data + offset, len, SEED0, SEED1); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11803{ uint64_t h = farmhashxo::Hash64WithSeed(data + offset, len, SEED); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11804{ uint64_t h = farmhashxo::Hash64(data + offset, len); cout << (h >> 32) << "u, " << ((h << 32) >> 32) << "u," << endl; }
11805}
11806
11807#endif
11808
11809#undef SEED
11810#undef SEED1
11811#undef SEED0
11812
11813} // namespace farmhashxoTest
11814
11815#if !TESTING
11816int main(int argc, char** argv) {
11817 Setup();
11818 cout << "uint32_t expected[] = {\n";
11819 int i = 0;
11820 for ( ; i < kTestSize - 1; i++) {
11821 farmhashxoTest::Dump(i * i, i);
11822 }
11823 for ( ; i < kDataSize; i += i / 7) {
11824 farmhashxoTest::Dump(0, i);
11825 }
11826 farmhashxoTest::Dump(0, kDataSize);
11827 cout << "};\n";
11828}
11829#endif
11830
11831int main() {
11832 farmhashccTest::RunTest();
11833 farmhashmkTest::RunTest();
11834 farmhashnaTest::RunTest();
11835 farmhashntTest::RunTest();
11836 farmhashsaTest::RunTest();
11837 farmhashsuTest::RunTest();
11838 farmhashteTest::RunTest();
11839 farmhashuoTest::RunTest();
11840 farmhashxoTest::RunTest();
11841 __builtin_unreachable();
11842}
11843
11844#endif // FARMHASHSELFTEST