// File: amadvance[P]tommyds/check.c
// Function: test_hash
void test_hash(void)
{
	unsigned i;
	unsigned char buffer[16];
	unsigned COUNT = 1024*1024*16;
	tommy_uint32_t hash32;
	tommy_uint64_t hash64;

	START("hash_test_vectors");

	for(i=0;HASH32[i].data;++i) {
		if (tommy_hash_u32(0xa766795d, HASH32[i].data, HASH32[i].len) != HASH32[i].hash)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	for(i=0;STRHASH32[i].data;++i) {
		if (tommy_strhash_u32(0xa766795d, STRHASH32[i].data) != STRHASH32[i].hash)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	for(i=0;HASH64[i].data;++i) {
		if (tommy_hash_u64(0x2f022773a766795dULL, HASH64[i].data, HASH64[i].len) != HASH64[i].hash)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	for(i=0;INTHASH32[i].value || !i;++i) {
		if (tommy_inthash_u32(INTHASH32[i].value) != INTHASH32[i].hash)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	for(i=0;INTHASH64[i].value || !i;++i) {
		if (tommy_inthash_u64(INTHASH64[i].value) != INTHASH64[i].hash)
			/* LCOV_EXCL_START */
			abort();
			/* LCOV_EXCL_STOP */
	}

	STOP();

	memset(buffer, 0xAA, sizeof(buffer));
	buffer[sizeof(buffer) - 1] = 0;

	hash32 = 0;
	hash64 = 0;

	START("hash_u32");

	for(i=0;i<COUNT;++i) {
		hash32 = tommy_hash_u32(hash32, buffer, sizeof(buffer));
	}

	STOP();

	START("strhash_u32");

	for(i=0;i<COUNT;++i) {
		hash32 = tommy_strhash_u32(hash32, buffer);
	}

	STOP();

	START("hash_u64");

	for(i=0;i<COUNT;++i) {
		hash64 = tommy_hash_u64(hash64, buffer, sizeof(buffer));
	}

	STOP();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x1000000, -0x24(%rbp) # imm = 0x1000000
leaq 0x8c8d(%rip), %rdi      # 0xa153
callq 0x13e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcb92(%rip), %rax      # 0xe070
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x154d
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcb79(%rip), %rax      # 0xe070
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcb63(%rip), %rax      # 0xe070
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movl $0xa766795d, %edi       # imm = 0xA766795D
callq 0x4aa0
movl -0x4(%rbp), %ecx
movl %ecx, %edx
leaq 0xcb41(%rip), %rcx      # 0xe070
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
je 0x1540
callq 0x1040
jmp 0x1542
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x14d2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcc90(%rip), %rax      # 0xe1f0
shlq $0x4, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x15b7
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcc77(%rip), %rax      # 0xe1f0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl $0xa766795d, %edi       # imm = 0xA766795D
callq 0x5220
movl -0x4(%rbp), %ecx
movl %ecx, %edx
leaq 0xcc57(%rip), %rcx      # 0xe1f0
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x15aa
callq 0x1040
jmp 0x15ac
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1554
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcda6(%rip), %rax      # 0xe370
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x1642
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcd8d(%rip), %rax      # 0xe370
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcd77(%rip), %rax      # 0xe370
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movabsq $0x2f022773a766795d, %rdi # imm = 0x2F022773A766795D
callq 0x4e50
movl -0x4(%rbp), %ecx
movl %ecx, %edx
leaq 0xcd50(%rip), %rcx      # 0xe370
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x10(%rcx), %rax
je 0x1632
callq 0x1040
jmp 0x1634
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x15be
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %edx
movb $0x1, %al
leaq 0xcf59(%rip), %rcx      # 0xe5b0
cmpl $0x0, (%rcx,%rdx,8)
movb %al, -0x31(%rbp)
jne 0x166c
cmpl $0x0, -0x4(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x1675
jmp 0x16ad
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xcf2f(%rip), %rax      # 0xe5b0
movl (%rax,%rcx,8), %edi
callq 0x1820
movl -0x4(%rbp), %ecx
movl %ecx, %edx
leaq 0xcf1b(%rip), %rcx      # 0xe5b0
cmpl 0x4(%rcx,%rdx,8), %eax
je 0x16a0
callq 0x1040
jmp 0x16a2
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1649
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
leaq 0xd102(%rip), %rcx      # 0xe7c0
shlq $0x4, %rax
addq %rax, %rcx
movb $0x1, %al
cmpq $0x0, (%rcx)
movb %al, -0x32(%rbp)
jne 0x16dc
cmpl $0x0, -0x4(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0x16e5
jmp 0x172b
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0xd0cf(%rip), %rax      # 0xe7c0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x1890
movl -0x4(%rbp), %ecx
movl %ecx, %edx
leaq 0xd0b4(%rip), %rcx      # 0xe7c0
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0x171e
callq 0x1040
jmp 0x1720
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x16b4
callq 0x1460
leaq -0x20(%rbp), %rdi
movl $0xaa, %esi
movl $0x10, %edx
callq 0x1090
movb $0x0, -0x11(%rbp)
movl $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
leaq 0x8a0b(%rip), %rdi      # 0xa168
callq 0x13e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x1790
movl -0x28(%rbp), %edi
leaq -0x20(%rbp), %rsi
movl $0x10, %edx
callq 0x4aa0
movl %eax, -0x28(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1769
callq 0x1460
leaq 0x89c9(%rip), %rdi      # 0xa165
callq 0x13e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x17cc
movl -0x28(%rbp), %eax
movl %eax, %edi
leaq -0x20(%rbp), %rsi
callq 0x5220
movl %eax, -0x28(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x17a8
callq 0x1460
leaq 0x8999(%rip), %rdi      # 0xa171
callq 0x13e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x180d
movq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x10, %edx
callq 0x4e50
movq %rax, -0x30(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x17e4
callq 0x1460
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)