Here is another one to try. I have rewritten the left-rotate, since there was a potential clamping from bp. So I have used a lookup table instead
rt[00]=0x1
rt[01]=0x2
rt[02]=0x4
rt[03]=0x8
rt[04]=0x10
rt[05]=0x20
rt[06]=0x40
rt[07]=0x80
rt[08]=0x100
rt[09]=0x200
rt[10]=0x400
rt[11]=0x800
rt[12]=0x1000
rt[13]=0x2000
rt[14]=0x4000
rt[15]=0x8000
rt[16]=0x10000
rt[17]=0x20000
rt[18]=0x40000
rt[19]=0x80000
rt[20]=0x100000
rt[21]=0x200000
rt[22]=0x400000
rt[23]=0x800000
rt[24]=0x1000000
rt[25]=0x2000000
rt[26]=0x4000000
rt[27]=0x8000000
rt[28]=0x10000000
rt[29]=0x20000000
rt[30]=0x40000000
rt[31]=0x80000000
function leftrotate(v,p)
local co,cq,x,y
x=v
y=0
if (x>=4294967296) then
x=x-4294967296
end if
for co=0 to 31
bi=x and rt[co]
cq=(co+p) and 0x1f
if (bi<>0) then
y=y or rt[cq]
end if
next
leftrotate=y
end function
X