// File: dudulu233[P]EMA-Tool/ema_tool.cpp
// Function: murmurhash(char const*, unsigned int, unsigned int)
uint32_t murmurhash(const char* key, uint32_t len, uint32_t seed) {
	uint32_t c1 = 0xcc9e2d51;
	uint32_t c2 = 0x1b873593;
	uint32_t r1 = 15;
	uint32_t r2 = 13;
	uint32_t m = 5;
	uint32_t n = 0xe6546b64;
	uint32_t h = 0;
	uint32_t k = 0;
	uint8_t* d = (uint8_t*)key; // 32 bit extract from `key'
	const uint32_t* chunks = NULL;
	const uint8_t* tail = NULL; // tail - last 8 bytes
	int i = 0;
	int l = len / 4; // chunk length

	h = seed;

	chunks = (const uint32_t*)(d + l * 4); // body
	tail = (const uint8_t*)(d + l * 4); // last 8 byte chunk of `key'

	// for each 4 byte chunk of `key'
	for (i = -l; i != 0; ++i) {
		// next 4 byte chunk of `key'
		k = chunks[i];

		// encode next 4 byte chunk of `key'
		k *= c1;
		k = (k << r1) | (k >> (32 - r1));
		k *= c2;

		// append to hash
		h ^= k;
		h = (h << r2) | (h >> (32 - r2));
		h = h * m + n;
	}

	k = 0;

	// remainder
	switch (len & 3) { // `len % 4'
	case 3: k ^= (tail[2] << 16);
	case 2: k ^= (tail[1] << 8);

	case 1:
		k ^= tail[0];
		k *= c1;
		k = (k << r1) | (k >> (32 - r1));
		k *= c2;
		h ^= k;
	}

	h ^= len;

	h ^= (h >> 16);
	h *= 0x85ebca6b;
	h ^= (h >> 13);
	h *= 0xc2b2ae35;
	h ^= (h >> 16);

	return h;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl $0xcc9e2d51, -0x14(%rbp) # imm = 0xCC9E2D51
movl $0x1b873593, -0x18(%rbp) # imm = 0x1B873593
movl $0xf, -0x1c(%rbp)
movl $0xd, -0x20(%rbp)
movl $0x5, -0x24(%rbp)
movl $0xe6546b64, -0x28(%rbp) # imm = 0xE6546B64
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0xc(%rbp), %eax
shrl $0x2, %eax
movl %eax, -0x50(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movl -0x50(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movl -0x50(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
subl -0x50(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x4628
movq -0x40(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
movl -0x30(%rbp), %edx
movl $0x20, %ecx
subl -0x1c(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x18(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x20(%rbp), %ecx
shll %cl, %eax
movl -0x2c(%rbp), %edx
movl $0x20, %ecx
subl -0x20(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
imull -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x45a4
movl $0x0, -0x30(%rbp)
movl -0xc(%rbp), %eax
andl $0x3, %eax
movl %eax, -0x54(%rbp)
subl $0x1, %eax
je 0x4675
jmp 0x463f
movl -0x54(%rbp), %eax
subl $0x2, %eax
je 0x4664
jmp 0x4649
movl -0x54(%rbp), %eax
subl $0x3, %eax
jne 0x46bb
jmp 0x4653
movq -0x48(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x10, %eax
xorl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
xorl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
xorl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
movl -0x30(%rbp), %edx
movl $0x20, %ecx
subl -0x1c(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x18(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0xc(%rbp), %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x10, %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
imull $0x85ebca6b, -0x2c(%rbp), %eax # imm = 0x85EBCA6B
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0xd, %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
imull $0xc2b2ae35, -0x2c(%rbp), %eax # imm = 0xC2B2AE35
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x10, %eax
xorl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)