def hash32
import bend-ml-llama@0.2.1.0/main.bend as BendMlLlamaimport Base
1120# Chris Wellons' lowbias32 hash (public domain): xor-shifts and two odd multipliers, a bijection on U32
1121def hash32(+x: U32) -> U32:
1122 +a = U32.xor(x, U32.shrn(x, 16n))
1123 +b = U32.mul(a, 2146121005)
1124 +c = U32.xor(b, U32.shrn(b, 15n))
1125 +d = U32.mul(c, 2221713035)
1126 U32.xor(d, U32.shrn(d, 16n))