// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/tommyds/./tommyhash.c
// Function: tommy_strhash_u32
tommy_uint32_t tommy_strhash_u32(tommy_uint64_t init_val, const void* void_key)
{
	const unsigned char* key = tommy_cast(const unsigned char*, void_key);
	tommy_uint32_t a, b, c;
	tommy_uint32_t m[3] = { 0xff, 0xff00, 0xff0000 };

	a = b = c = 0xdeadbeef + init_val;
	/* this is different than original lookup3 and the result won't match */

	while (1) {
		tommy_uint32_t v = tommy_le_uint32_read(key);

		if (tommy_haszero_u32(v)) {
			if (v & m[0]) {
				a += v & m[0];
				if (v & m[1]) {
					a += v & m[1];
					if (v & m[2])
						a += v & m[2];
				}
			}

			break;
		}

		a += v;

		v = tommy_le_uint32_read(key + 4);

		if (tommy_haszero_u32(v)) {
			if (v & m[0]) {
				b += v & m[0];
				if (v & m[1]) {
					b += v & m[1];
					if (v & m[2])
						b += v & m[2];
				}
			}

			break;
		}

		b += v;

		v = tommy_le_uint32_read(key + 8);

		if (tommy_haszero_u32(v)) {
			if (v & m[0]) {
				c += v & m[0];
				if (v & m[1]) {
					c += v & m[1];
					if (v & m[2])
						c += v & m[2];
				}
			}

			break;
		}

		c += v;

		tommy_mix(a, b, c);

		key += 12;
	}

	/* for lengths that are multiplers of 12 we already have called mix */
	/* this is different than the original lookup3 and the result won't match */

	tommy_final(a, b, c);

	return c;
}

// Assembly:
movq %rdi, %rax
addl $0xdeadbeef, %eax       # imm = 0xDEADBEEF
movl %eax, %ecx
movl %eax, %edx
movl (%rsi), %edi
movl $0x1010100, %r8d        # imm = 0x1010100
subl %edi, %r8d
orl %edi, %r8d
notl %r8d
testl $0x80808080, %r8d       # imm = 0x80808080
jne 0x19bd
addl %edi, %edx
movl 0x4(%rsi), %edi
movl $0x1010100, %r8d        # imm = 0x1010100
subl %edi, %r8d
orl %edi, %r8d
notl %r8d
testl $0x80808080, %r8d       # imm = 0x80808080
jne 0x19de
addl %edi, %ecx
movl 0x8(%rsi), %edi
movl $0x1010100, %r8d        # imm = 0x1010100
subl %edi, %r8d
orl %edi, %r8d
notl %r8d
testl $0x80808080, %r8d       # imm = 0x80808080
jne 0x19ff
addl %eax, %edi
subl %edi, %edx
movl %edi, %eax
roll $0x4, %eax
xorl %edx, %eax
addl %ecx, %edi
subl %eax, %ecx
movl %eax, %r8d
roll $0x6, %r8d
xorl %ecx, %r8d
addl %edi, %eax
subl %r8d, %edi
movl %r8d, %r9d
roll $0x8, %r9d
xorl %edi, %r9d
addl %eax, %r8d
subl %r9d, %eax
movl %r9d, %edx
roll $0x10, %edx
xorl %eax, %edx
addl %r8d, %r9d
subl %edx, %r8d
movl %edx, %ecx
roll $0x13, %ecx
xorl %r8d, %ecx
addl %r9d, %edx
subl %ecx, %r9d
movl %ecx, %eax
roll $0x4, %eax
xorl %r9d, %eax
addl %edx, %ecx
addq $0xc, %rsi
movb $0x1, %dil
jmp 0x1a20
movl %edi, %r8d
andl $0xff, %r8d
je 0x1a1e
addl %r8d, %edx
testl $0xff00, %edi           # imm = 0xFF00
je 0x1a1e
andl $0xffff00, %edi         # imm = 0xFFFF00
addl %edi, %edx
jmp 0x1a1e
movl %edi, %r8d
andl $0xff, %r8d
je 0x1a1e
addl %r8d, %ecx
testl $0xff00, %edi           # imm = 0xFF00
je 0x1a1e
andl $0xffff00, %edi         # imm = 0xFFFF00
addl %edi, %ecx
jmp 0x1a1e
movl %edi, %r8d
andl $0xff, %r8d
je 0x1a1e
addl %r8d, %eax
testl $0xff00, %edi           # imm = 0xFF00
je 0x1a1e
andl $0xffff00, %edi         # imm = 0xFFFF00
addl %edi, %eax
xorl %edi, %edi
testb %dil, %dil
jne 0x1900
xorl %ecx, %eax
movl %ecx, %esi
roll $0xe, %esi
subl %esi, %eax
xorl %eax, %edx
movl %eax, %esi
roll $0xb, %esi
subl %esi, %edx
xorl %edx, %ecx
movl %edx, %esi
roll $0x19, %esi
subl %esi, %ecx
movl %ecx, %esi
roll $0x10, %esi
xorl %ecx, %eax
subl %esi, %eax
xorl %eax, %edx
movl %eax, %esi
roll $0x4, %esi
subl %esi, %edx
xorl %edx, %ecx
roll $0xe, %edx
subl %edx, %ecx
xorl %ecx, %eax
roll $0x18, %ecx
subl %ecx, %eax
retq