You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
4.5 KiB

#include"a.h" // ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://codeberg.org/ngn/k/raw/branch/master/LICENSE
enum{bu,bv=32,bs=64,bg=72,bd=80,ba=88,bP,bi,bx,bI,bX,bm,bM,bG,bS,bl,bL,bz,bj,bA,bo,bp,bc};
#define h(a) {b[nb]=a;m[nb]=o;nb+=nb<255;}
#define hc(a) {N(lc(a,o));}
#define OK -1
#define Nr(a...) {I r=cr(a);P(r-OK,r);}
#define Nl(a...) {I r=cl(a);P(r-OK,r);}
#define fl uA[3]
S A u;S UC*b,*m;S I nb,lu[8];S A cr(A,I);
SN I lc(Ax/*1*/,I o)_(Ay=u;Nn=yn,i=4;W(i<n,B(mtc_(x,ya),x=x(0))i++)I(x,uq(x))h(i+bc-4);1)
SN I ig(Iv)_(Li=fI(gk,gn,v);P(i>=0,i)P(gn-(UC)gn,-1)gk[gn]=v;gv[gn]=0;gn++)
SN I il(Iv)_(Li=fAI(fl,v);P(i>=0,lu[i]=nb;i)-1)
S A cl(Ax,Ay/*00*/,I r)_(I o=xo;Q(xx==av||_t(xx)==tu)Iv=_v(xx);
Ys(P(xx==av&&_n(fl),Li=fpI(&fl,yv);P(i>15,ez0())lu[i]=nb;h(bs+i)I(r,h(bg+i))OK)
Ii=il(yv);P(i>=0,h(bm)h(i)h(v)I(r,h(bg+i))OK)i=ig(yv);P(i<0,ez0())h(v?bM:bS)h(i)I(v,h(v))I(r,h(bG)h(i))OK)
YS(hc(av+v)hc(au)hc(yR)h(bA)I(!r,h(bp))OK)
YA(In=yn-1;P(n-(UC)n,o)Az=yx;
P(ztS,hc(av+v)i(n,Nr(yA[n-i],1))h(bl)h(n)hc(zR)h(bA)I(!r,h(bp))OK)
P(zts,i(n,Nr(yA[n-i],1))h(bl)h(n);Ii=il(zv);P(i<0,hc(z)h(r?bX:bI)h(v)OK)h(r?bx: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101),0))1)*/0)
S A3(f3,/*0*/P(ADD<=x&&x<=MUL&&ytL&&ztL&&yn==zn&&yn<101,1)0)
S A1(qt,/*1*/xtsSA?enl(x):x)
S A1(cf,XA(P(xx==MKL,i(xn,Ay=xa;YsSA(x))a1(drp(1,x)))
P(xn==2?f2(xx,xy):xn==3?f3(xx,xy,xz):0,qt(N(val(x))))
Ay=rsh(xn,au);i(xn,ya=cf(xa);xa=au;P(!ya,die("cf")))AO(xo,x(y)))x) //preserve src offsets
S I mxs(Ii,I s)_(I r=s;W(1,UC c=b[i++];Q(s>=0)r=max(r,s);P(!c,r)P(c==bz,i++;s--;max(r,max(mxs(i,s),mxs(i+b[i-1],s))))
I(c>=bc||c==bo||c-bg<8u||c-bd<8u||c==bG,s++)J(c-bs<8u||c-bv<32u||c==bp||c==bm||c==bx||c==bM||c==bS,s--)
J(c==bi||c==bX,s-=2)J(c==bI||c==bA,s-=3)J(c==bL,s+=b[i])J(c==bl||c==ba||c==bP,s-=b[i]-1)
I(c==bm||c==bx||c==bM||c==bi,i+=2)J(c==bX||c==bI||c==bL||c==bl||c==ba||c==bP||c==bG||c==bS,i++)J(c==bj,i+=b[i]+1))r)
A3(cpl,/*src,ast,loc*/UC b0[256],m0[256];b=b0;m=m0;nb=1;Ik=zn;u=aV(tA,4,A(x,au,au,z));Ms(lu,-1,SZ lu);y=Nu(cf(y));
I r=cr(y,1);y(0);I o=0;h(bu);P(r-OK,eS(ux,r);u(0);ec0())P(_n(fl)>8||nb>=255||bc-4+un>255,eS(ux,0);u(0);ez0())
i(8,Ij=lu[i];I(j>=0&&b[j]==bg,b[j]=bd))*b=mxs(1,0);*m=-1;uy=aCn(b,nb);uz=aCn(m,nb);AK(k,AT(to,u)))
#define U(x,a...) B(!(x),a)
AX(run,Q(xto)P(n-xk,er8(a,n))S I d;P(++d>1024,es8(a,n))UC*b=_V(xy),c,ns=*b++,nl=_n(xA[3]);A t[ns+nl],*s=t+ns,*l=s;
Ms(t,0,SZ t);Mc(l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