Last active
November 2, 2018 12:33
-
-
Save samhocevar/e431e034fa341f55a82d9d231865779e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inflate(s,p,l)local r={}for i=0,255 do r[i]=0 for j=0,7 do r[i]+=band(i,2^j)*128/4^j end end local u={}for i=1,58 do u[sub("0123456789abcdefghijklmnopqrstuvwxyz!#%(){}[]<>+=/*:;.,~_ ",i,i)]=i end local e=0local sb=0local sb2=0local sn=0local o={}local op=1local function flb(n)sn-=n sb=lshr(sb,n)end local function h(n)while sn<n do if l and l>0then sb+=shr(peek(p),16-sn)sn+=8 p+=1 l-=1 elseif e==0then local x=2^-16local t={9,579}local p=0sb2=0 for i=1,8 do local c=u[sub(s,i,i)]or 0 sb2+=x%1*c p+=(lshr(x,16)+(t[i-6]or 0))*c x*=59 end s=sub(s,9)sb+=sb2%1*2^sn sn+=16 e+=1 sb2=p+shr(sb2,16)elseif e==1then sb+=sb2%1*2^sn sn+=16 e+=1 else sb+=lshr(sb2,16)*2^sn sn+=15 e=0 end end return lshr(shl(sb,32-n),16-n)end local function g(n)return h(n),flb(n)end local function v(t)h(t.n)local h=r[band(shl(sb,16),255)]local l=r[band(shl(sb,8),255)]local v=band(shr(256*h+l,16-t.n),2^t.n-1)flb(t[v]%1*16)return flr(t[v])end local function w(n)local d=(op)%1local p=flr(op)o[p]=n*256^(4*d-2)+(o[p]or 0)op+=1/4 end local function a(p)local d=(op-p/4)%1local p=flr(op-p/4)return band(o[p]/256^(4*d-2),255)end local function h(d)local t={n=1}local c={}for i=1,17 do c[i]=0 end for i=1,#d do local n=d[i]t.n=max(t.n,n)c[n+1]+=2 end c[1]=0 for i=2,t.n do c[i]+=c[i-1]c[i]+=c[i-1]end for i=1,#d do local l=d[i]if l>0then local c0=shl(c[l],t.n-l)c[l]+=1 local c1=shl(c[l],t.n-l)for j=c0,c1-1 do t[j]=i-1+l/16 end end end return t end local function b(t1,t2)local l repeat l=v(t1)if l<256then w(l)elseif l>256then l-=257 local n=0local z=3local d=1if l<8then z+=l elseif l<28then n=flr(l/4-1)z+=shl(l%4+4,n)z+=g(n)else z=258 end local v=v(t2)if v<4then d+=v else n=flr(v/2-1)d+=shl(v%2+2,n)d+=g(n)end for n=1,z do w(a(d))end end until l==256 end local f={}f[2]=function()local d={}local hl=257+g(5)local hd=1+g(5)local k=4+g(4)for i=1,19 do d[(i+15)%19+1]=i>k and 0or g(3)end local t=h(d)d={}local d2={}local c=0while#d+#d2<hl+hd do local v=v(t)if v<16then c=v add(#d<hl and d or d2,c)end if v==16then for j=-2,g(2)do add(#d<hl and d or d2,c)end end if v==17then c=0 for j=-2,g(3)do add(#d<hl and d or d2,c)end end if v==18then c=0 for j=-2,g(7)+8 do add(#d<hl and d or d2,c)end end end b(h(d),h(d2))end f[1]=function()local d={}for i=1,288 do d[i]=8 end for i=145,280 do d[i]+=sgn(256-i)end local d2={}for i=1,32 do d2[i]=5 end b(h(d),h(d2))end f[0]=function()flb(sn%8)local len=g(16)local nlen=g(16)for i=1,len do w(g(8))end end repeat local l=g(1)f[g(2)]()until l==1return o end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment