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 csp[],*cpsp[],**cdpsp[],***coeff[];4extern int space,cspace;5extern short sp[],**mat[],*psp[],**imcos[],**cpco[],lorb[],6wdl,ptrsp,cdptrsp,mb;7short *cst,**cpst,***cdpst,**svptr,*cp,*rel;8short *spst,**pspst,**pptr,**cpptr,npt,nb,nph,nph2,npg,npg2,9rno,orno,coh_index,*invg;10FILE *ip,*op;1112void seeknln (void) { while (getc(ip)!='\n'); }1314/* This program differs from most other permutation programs in that perms are15all stored in the single array sp. Schreier vectors are stored in the short16array csp. This assumes that there are at most 127 perms, which will17probably always be the case. The first half of the program (crprog1)18involves relatively little short space, so it is assumed that there is enough19In the first half, coefficients as words in H generated by the relators20of G are computed using the output of conrun.21*/22int23crprog1 (void)24{ short *pc,*qc,ex,neg; int x;25short i,j,k,l,m,n,cl,rl,*p,ocl,im,pt,pt1,pn,ipt;26if ((ip=fopen(inf2,"r"))== 0)27{ fprintf(stderr,"Cannot open %s.\n",inf2); return(-1);}28fscanf(ip,"%hd%hd%hd%hd",&npt,&nph,&nb,&k);29if (nb>=mb) {fprintf(stderr,"nb too big. Increase MB.\n"); return(-1);}30if (k<=2) {fprintf(stderr,"inf2 has illegal format.\n"); return(-1); }31seeknln(); seeknln();32for (i=1;i<=nb;i++) fscanf(ip,"%hd",lorb+i);33pptr=psp-1; pspst=psp+nph; svptr=cpsp-1; cpst=cpsp+nb;34invg=sp; nph2=2*nph; spst=sp+nph2;35for (i=1;i<=nph;i++)36{ pptr[i]=spst+(i-1)*npt-1; p=pptr[i];37for (j=1;j<=npt;j++) {fscanf(ip,"%hd",&k); p[k]=j; }38invg[2*i-2]=2*i-1; invg[2*i-1]=2*i-2;39seeknln();40}41spst+=(npt*nph);42for (i=1;i<=nb;i++)43{ svptr[i]=csp+(i-1)*npt-1; pc=svptr[i];44for (j=1;j<=npt;j++) {fscanf(ip,"%hd",&k); pc[j]= k>0 ? (k+1)/2 : k;}45}46cp=csp+nb*npt; rel=cp+wdl;47fclose(ip);48/* It is assumed that there is enough space so far. */4950strcpy(inf1,inf0); strcat(inf1,".cp");51if ((ip=fopen(inf1,"r"))==0)52{ fprintf(stderr,"Cannot open %s.\n",inf1); return(-1);}53fscanf(ip,"%hd%hd",&coh_index,&npg); npg2=2*npg-1;54x= (nb+2)*npg*coh_index;55if (spst+x-sp>space)56{ fprintf(stderr,"Not enough space. Increase SPACE.\n"); return(-1); }57if (pspst+(nb+2)*npg-psp>ptrsp)58{ fprintf(stderr,"Not enough ptrsp. Increase PTRSP.\n"); return(-1); }59cpptr=pspst; pspst+=2*npg;60for (i=0;i<=npg2;i++) { cpptr[i]=spst-1; spst+=coh_index; }61for (i=1;i<=nb;i++)62{ cpco[i]=pspst-1; pspst+=npg;63for (j=1;j<=npg;j++) {cpco[i][j]=spst-1; spst+=coh_index;}64}65for (i=1;i<=npg;i++)66{ j=2*i-2; k=j+1;67for (l=1;l<=coh_index;l++)68{ for (m=1;m<=nb;m++) fscanf(ip,"%hd",cpco[m][i]+l);69fscanf(ip,"%hd",&m); cpptr[j][l]=m; cpptr[k][m]=l;70}71}72fclose(ip);7374strcpy(inf1,inf0); strcat(inf1,".rel");75if ((ip=fopen(inf1,"r"))==0)76{ fprintf(stderr,"Cannot open %s.\n",inf1); return(-1);}77fscanf(ip,"%hd%hd",&k,&rno); seeknln();78op=fopen(outft,"w");79/* Now we have read everything in, and the computation can start */80orno=0;81for (i=1;i<=rno;i++)82{ fscanf(ip,"%hd",&rl);83printf("Scanning rel no %d.\n",i);84for (j=1;j<=rl;j++) { fscanf(ip,"%hd",&k); rel[j]=k; }85for (j=1;j<=coh_index;j++)86{ pt=j; cl=0;87for (k=rl;k>=1;k--)88{ l=rel[k]; im=cpptr[l][pt];89if (l%2==1) {neg=1;pt1=im; m=(l+1)/2;}90else {neg=0; pt1=pt; m=(l+2)/2;}91ocl=cl;92for (n=1;n<=nb;n++)93{ ipt=cpco[n][m][pt1]; pn=svptr[n][ipt];94while (pn!= -1)95{ cl++; cp[cl]=2*(pn-1); ipt=pptr[pn][ipt]; pn=svptr[n][ipt]; }96}97if (neg)98{ pc=cp+ocl+1; qc=cp+cl;99while (pc<=qc)100{ if (pc==qc) (*pc)++;101else {ex= *pc; *pc= *qc+1; *qc= ex+1;}102pc++; qc--;103}104}105pt=im;106}107if (pt!=j)108{ fprintf(stderr,109"Relation number %d is not satisfied by the permutations.\n",i);110return(-1);111}112fprintf(op,"%4d",cl);113for (k=cl;k>=1;k--) fprintf(op," %2d",cp[k]);114fprintf(op,"\n");115} /* j loop */116if (i==rno && orno==0)117{ orno=rno; if (fscanf(ip,"%hd",&j)>0) rno+=j;}118119} /* i loop */120printf("All relations scanned.\n");121fclose(op); fclose(ip);122return(0);123}124125126