// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Hashing algorithm inspired by
// wyhash: https://github.com/wangyi-fudan/wyhash

//go:build amd64 || arm64 || loong64 || mips64 || mips64le || ppc64 || ppc64le || riscv64 || s390x || wasm

package runtime

import (
	
	
)

const (
	m1 = 0xa0761d6478bd642f
	m2 = 0xe7037ed1a0b428db
	m3 = 0x8ebc6af09c88c6e3
	m4 = 0x589965cc75374cc3
	m5 = 0x1d8e4e27c47d124f
)

func ( unsafe.Pointer, ,  uintptr) uintptr {
	var ,  uintptr
	 ^= hashkey[0] ^ m1
	switch {
	case  == 0:
		return 
	case  < 4:
		 = uintptr(*(*byte)())
		 |= uintptr(*(*byte)(add(, >>1))) << 8
		 |= uintptr(*(*byte)(add(, -1))) << 16
	case  == 4:
		 = r4()
		 = 
	case  < 8:
		 = r4()
		 = r4(add(, -4))
	case  == 8:
		 = r8()
		 = 
	case  <= 16:
		 = r8()
		 = r8(add(, -8))
	default:
		 := 
		if  > 48 {
			 := 
			 := 
			for ;  > 48;  -= 48 {
				 = mix(r8()^m2, r8(add(, 8))^)
				 = mix(r8(add(, 16))^m3, r8(add(, 24))^)
				 = mix(r8(add(, 32))^m4, r8(add(, 40))^)
				 = add(, 48)
			}
			 ^=  ^ 
		}
		for ;  > 16;  -= 16 {
			 = mix(r8()^m2, r8(add(, 8))^)
			 = add(, 16)
		}
		 = r8(add(, -16))
		 = r8(add(, -8))
	}

	return mix(m5^, mix(^m2, ^))
}

func ( unsafe.Pointer,  uintptr) uintptr {
	 := r4()
	return mix(m5^4, mix(^m2, ^^hashkey[0]^m1))
}

func ( unsafe.Pointer,  uintptr) uintptr {
	 := r8()
	return mix(m5^8, mix(^m2, ^^hashkey[0]^m1))
}

func (,  uintptr) uintptr {
	,  := math.Mul64(uint64(), uint64())
	return uintptr( ^ )
}

func ( unsafe.Pointer) uintptr {
	return uintptr(readUnaligned32())
}

func ( unsafe.Pointer) uintptr {
	return uintptr(readUnaligned64())
}