GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "defs.h"12extern char mult,inf0[],inf1[],inf2[],outf[],outft[],inf3[];3extern short *cst,**cpst,***cdpst,4csp[],*cpsp[],**cdpsp[],***coeff[];5extern int space,cptrsp,cspace;6extern short sp[],**mat[],*psp[],**imcos[],**cpco[],lorb[],pinv[],7wdl,ptrsp,cdptrsp,mpr,marg,8*spst,**pspst,npt,nb,nph,nph2,rno,orno,coh_index,*invg;9short *wd1,*wd2;10short *gno,*cord,cl,dim,prime,**vec,**spm,*spv,wv,*val;11FILE *ipr,*op,*ipx,*ip;1213int14crprog2 (void)15/* In the second half, the values of the words in H in the module or16multiplier are computed, using the coefficients computed in extprun.17*/18{ short i,j,k,l,m,n,rct,inct,x,l1,l2,*ps,*qs; short *p,*q,*r,*v2,*ex,c;19int prod;20printf("Beginning crprog2.\n");21spst=sp+nph2; pspst=psp; strcpy(inf0,inf2);22if (mult==0)23{ strcat(inf2,"mat");24if ((ip=fopen(inf2,"r"))==0)25{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}26fscanf(ip,"%hd%hd%hd",&prime,&dim,&k);27if (prime>mpr)28{ fprintf(stderr,"Prime too big. Increase MPR.\n"); return(-1);}29if (k!=nph) {fprintf(stderr,"No of mats wrong.\n"); return(-1); }30setpinv();31vec=psp; n=(nph2+1)*dim; pspst+=n;32if (pspst-psp>=ptrsp)33{ fprintf(stderr,"Out of ptr space. Increase PTRSP.\n"); return(-1);}34for (i=0;i<n;i++) vec[i]=spst-1+i*dim; spst+=(dim*n);35if (spst-sp>space)36{ fprintf(stderr,"Out of space. Increase SPACE.\n"); return(-1);}37for (i=0;i<=nph2;i++) mat[i]=vec-1+i*dim;38spm=mat[nph2]; spv=spm[1];39for (i=0;i<nph2;i+=2) {readmat(mat[i]); inv(mat[i],mat[i+1]); }40fclose(ip);41}4243/* Now we read in the output of extprun */44wd1=csp-1; wd2=wd1+wdl; cst=csp+2*wdl; cpst=cpsp; cdpst=cdpsp;45strcpy(inf2,inf0); strcat(inf2,".ep");46if ((ip=fopen(inf2,"r"))==0)47{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}48fscanf(ip,"%hd%hd",&i,&j);49if (i!=nb || (mult==0 && j!=dim))50{ fprintf(stderr,"%s has line 1 wrong.\n",inf2); return(-1); }51if (mult) { dim=j; cord=spst-1; spst+=dim; }52gno=spst-1; spst+=nb; val=spst-1; spst+=dim;53for (i=1;i<=nb;i++)54{ fscanf(ip,"%hd",&j);55if (j!=lorb[i]) {fprintf(stderr,"lorb wrong in %s.\n",inf2); return(-1); }56}57if (mult) for (i=1;i<=dim;i++) fscanf(ip,"%hd",cord+i);58for (i=1;i<=nb;i++) fscanf(ip,"%hd",gno+i);59for (i=1;i<=nb;i++)60{ n=gno[i];61if ((l=lorb[i])>1)62{ if (pspst+n-psp>ptrsp)63{ fprintf(stderr,"Out of ptrsp. Increase PTRSP.\n"); return(-1); }64if (cdpst+n-cdpsp>cdptrsp)65{ fprintf(stderr,"Out of cdsp. Increase CDPTRSP.\n");return(-1);}66prod=n*l;67if (spst+prod-sp>space)68{ fprintf(stderr,"Out of space. Increase SPACE.\n"); return(-1);}69if (cpst+prod-cpsp>cptrsp)70{ fprintf(stderr,"Out of cptrsp. Increase CPTRSP.\n"); return(-1); }71imcos[i]=pspst; pspst+=n; coeff[i]=cdpst; cdpst+=n;72for (j=0;j<n;j++)73{ imcos[i][j]=spst-1;74for (k=1;k<=l;k++) {fscanf(ip,"%hd",spst); spst++;}75coeff[i][j]=cpst-1;76for (k=1;k<=l;k++)77{ fscanf(ip,"%hd",&l1);78if (l1==0)79{ fscanf(ip,"%hd",&l2);80if (l2==0) *(cpst++)=0;81else82{ *(cpst++)=cst; *(cst++)=0; *(cst++)=l2;83for (m=1;m<=l2;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}84}85}86else87{ *(cpst++)=cst; *(cst++)=l1;88for (m=1;m<=l1;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}89fscanf(ip,"%hd",&l2); *(cst++)=l2;90for (m=1;m<=l2;m++) {fscanf(ip,"%hd",&x); *(cst++)=x;}91}92}93if (cst+marg-csp>cspace)94{ fprintf(stderr,"Running out of cspace. Increase CSP.\n");return(-1);}95}96}97}98fclose(ip);99/* End of input. Now computation can begin */100101op=fopen(outf,"w"); ipr=fopen(inf1,"r");102fscanf(ipr,"%hd",&i); fprintf(op,"%4d%4d\n",nb,dim);103for (i=1;i<=nb;i++) { fscanf(ipr,"%hd",&j); fprintf(op," %4d",j); }104while (getc(ipr)!='\n');105fprintf(op,"\n");106if (mult) {for (i=1;i<=dim;i++) fprintf(op,"%4d",cord[i]); fprintf(op,"\n");}107wv=wdl-dim-1;108ipx=fopen(outft,"r");109110for (rct=1;rct<=rno;rct++)111{ printf("Scanning relation no %d\n",rct);112if (rct==orno+1)113{ while ((c=getc(ipr))!='\n') putc(c,op); putc('\n',op); }114while ((c=getc(ipr))!='\n') putc(c,op); putc('\n',op);115if (mult==0)116{ if ((ip=fopen(inf3,"r"))==0)117{ fprintf(stderr,"Cannot open %s.\n",inf3); return(-1);}118fscanf(ip,"%hd%hd%hd",&i,&j,&k);119if (i!=prime || j!=dim || k!=(coh_index-1))120{ fprintf(stderr,"%s has line 1 wrong.\n",inf3); return(-1); }121}122for (j=1;j<=dim;j++) val[j]=0;123for (inct=1;inct<=coh_index;inct++)124{ fscanf(ipx,"%hd",&l2);125for (k=1;k<=l2;k++) {fscanf(ipx,"%hd",&l); wd2[k]=l;}126p=wd1+wv; q=wd2+wv; r=p+dim;127while (++p<=r) { *p=0; *(++q)=0; }128for (k=1;k<=nb;k++) if (lorb[k]>1)129{ if (scan(k,&l2)== -1) return(-1);130ex=wd1; wd1=wd2; wd2=ex;131}132v2=wd2+wv; ps=val;133if (inct>1 && mult==0)134{ readmat(spm);135for (i=1;i<=dim;i++)136{ ps++; p=v2;137for (j=1;j<=dim;j++)138{ *ps+= (*(++p)* spm[j][i]); *ps%=prime; }139}140}141else142{ p=v2; r=p+dim;143if (mult) while (++p<=r) {*(++ps)+= *p; x=cord[p-v2]; *ps%=x; }144else while (++p<=r) {*(++ps)+= *p; *ps%=prime; }145}146}147l=0; ps=val; qs=val+dim;148while (++ps<=qs) if (*ps!=0) l+=2;149fprintf(op,"%4d ",l);150ps=val;151while (++ps<=qs) if (*ps!=0) fprintf(op,"%4d%4d",ps-val,*ps);152fprintf(op,"\n");153if (mult==0) fclose(ip);154}155fclose(ipx); unlink(outft);156return(0);157}158159int160scan (int bno, short *la)161/* This is the computation of one word as described above */162{ short cos,nl,min,canct,**cim; short c,*v1,*conco,*p,*q,*r,***cco,*wp,*wr;163v1=wd1+wv; cco=coeff[bno]; cim=imcos[bno];164cos=1; wp=wd2; wr=wp+ *la; nl=0;165while (++wp<=wr)166{ conco=cco[*wp][cos]; cos=cim[*wp][cos];167if (conco!=0)168{ q=conco+ *conco+1; r=q+ *q;169if (mult)170{ while (++q<r) {c= *(q++); v1[c]+= *q; v1[c]%=cord[c]; }}171else172{ action(v1,conco);173while (++q<=r) {c= *(q++); v1[c]+= *q; v1[c]%=prime;}174}175min= (nl<= *conco) ? nl : *conco;176canct=0; p=wd1+nl; q=conco+1;177while (canct<min && *p==invg[*q]) {canct++; p--; q++; }178r=conco+ *conco;179while (q<=r) *(++p)= *(q++);180nl+= (*conco-2*canct);181}182}183if (cos!=1)184{ fprintf(stderr,185"One of the relations is not satisfied by the permutations.\n");186return(-1);187}188if (bno>1)189{ p=v1; q=wd2+wv; r=p+dim;190if (mult) while (++p<=r) {*p+= *(++q); *p%=cord[p-v1]; *q=0; }191else while (++p<=r) {*p+= *(++q); *p%=prime; *q=0; }192}193*la=nl;194if (nl>wdl)195{ fprintf(stderr,"Word too long. Increase WDL.\n"); return(-1); }196return(0);197}198199int200action (short *a, short *b)201{ short z,*be,c,*p,*ae; short *spve,*s,*v;202z=1; p=a; ae=a+dim;203while (++p<=ae) if (*p!=0) {z=0; break;}204if (z) return(0);205spve=spv+dim; be=b+ *b;206while (++b<=be)207{ s=spv;208while (++s<=spve) *s=0;209p=a;210while (++p<=ae) if ((c= *p)!=0)211{ v=mat[*b][p-a]; s=spv;212while (++s<=spve) {*s+=(c* *(++v)); *s%=prime; }213}214p=a; s=spv;215while (++p<=ae) *p= *(++s);216}217return(0);218}219220int221setpinv (void)222{ short i,j;223for (i=0;i<prime;i++) pinv[i]=0;224for (i=1;i<prime;i++) if (pinv[i]==0) for (j=1;j<prime;j++)225if (i*j % prime ==1) { pinv[i]=j; pinv[j]=i; break; }226return(0);227}228229230