local n={}local W=bit32.band local Y=bit32.bor local v=bit32.bxor n.uint32_lrot=bit32.lrotate n.byte_xor=v n.uint32_xor_3=v n.uint32_xor_4=v function n.uint32_ternary(n,Y,g)return v(g,W(n,v(Y,g)))end function n.uint32_majority(n,v,g)return Y(W(n,Y(v,g)),W(v,g))end return n
local ops = {}

local band = bit32.band
local bor = bit32.bor
local bxor = bit32.bxor

ops.uint32_lrot = bit32.lrotate
ops.byte_xor = bxor
ops.uint32_xor_3 = bxor
ops.uint32_xor_4 = bxor

function ops.uint32_ternary(a, b, c)
   -- c ~ (a & (b ~ c)) has less bitwise operations than (a & b) | (~a & c).
   return bxor(c, band(a, bxor(b, c)))
end

function ops.uint32_majority(a, b, c)
   -- (a & (b | c)) | (b & c) has less bitwise operations than (a & b) | (a & c) | (b & c).
   return bor(band(a, bor(b, c)), band(b, c))
end

return ops
