GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "defs.h"12#define tmalloc(D,T,N) {D = (T *) malloc(sizeof(T)*(N)); \3if (D==0) { fprintf(stderr,"Out of space.\n"); return(-1);}}4#define tfree(D) {if (D) free( (char *) D); D=0;}56extern char mult;7extern short wd1[],wd2[],wd3[],wd4[],8*cst,*cend,***coeff,fullsc,clsd,lkah,conch,**cco,**def;9extern short invg[],mwdl,endr,*fpt,*bpt,nelim,lo,**imcos,dim,10ccos,lastd,cind,nfree,stcr,endcr,fcos,bcos,lcl,np2,*rel,11ng;1213int14scanrel (void)15{ short i,j,k,l,m,necr,*s,*t; short compfsc,*p,*q,*r,esc;16fullsc=1; stcr=endcr+2; endcr+=(1+rel[stcr-1]); esc=0;17*wd1=0; *wd2=0; p=wd1+mwdl; q=p+dim;18while (++p<=q) *p=0;19p=wd2+mwdl; q=p+dim;20while (++p<=q) *p=0;21p=wd2+mwdl; s=rel+endcr+1; t=s+ *s; necr=endcr+ *s+1;22while (++s<t) {p[*s]= *(s+1); s++; }23if (mult==0 && ccos>1) action(p,def[ccos]);24fcos=ccos; bcos=ccos; compfsc=1;25for (i=stcr;i<=endcr;i++)26{ k=imcos[rel[i]][fcos];27if (k==0) { compfsc=0; break;}28if (concat(wd1,coeff[rel[i]][fcos])== -1) return(-1);29fcos=k;30}31if (compfsc)32{ if (fcos!=bcos) esc=coinc(fcos,bcos);33else if (conch) if (concheck()== -1) return(-1);34if (esc== -1) return(-1);35if (esc==0) endcr=necr;36return(0);37}38stcr=i;39for (i=endcr;i>=stcr;i--)40{ l=rel[i]; m=invg[l]; k=imcos[m][bcos];41if (k==0)42{ if (i==stcr)43{ k=imcos[l][fcos];44if (k==0)45{ imcos[l][fcos]=bcos; imcos[m][bcos]=fcos;46if (ainvb(wd1,wd2,wd3)== -1) return(-1);47if (*wd3>2) reduce(wd3);48if (comp(wd3,coeff[l]+fcos)== -1) return(-1);49invwd(wd3,wd2);50if (comp(wd2,coeff[m]+bcos)== -1) return(-1);51}52else53{ if (concat(wd1,coeff[l][fcos])== -1) return(-1);54if (k!=bcos) esc=coinc(k,bcos);55else if (conch) if (concheck()== -1) return(-1);56if (esc== -1) return(-1);57}58if (esc==0) endcr=necr;59return(0);60}61if (lkah || nfree==0)62{ fullsc=0; if (esc==0) endcr=necr; return(0); }63for (j=0;j<ng;j++) imcos[j][nfree]=0;64cind++;65if (mult==0)66{ tmalloc(def[nfree],short,def[bcos][0]+2);67def[nfree][0]=def[bcos][0]+1; def[nfree][1]=l;68for (j=1;j<=def[bcos][0];j++) def[nfree][j+1]=def[bcos][j];69}70imcos[m][bcos]=nfree; imcos[l][nfree]=bcos; bcos=nfree;71bpt[nfree]=lastd; fpt[lastd]=nfree; lastd=nfree;72nfree=fpt[nfree]; fpt[lastd]=0;73}74else75{ if (concat(wd2,coeff[m][bcos])== -1) return(-1); bcos=k;}76}77if (fcos!=bcos) esc=coinc(fcos,bcos);78else if (conch) if (concheck()== -1) return(-1);79if (esc== -1) return(-1);80if (esc==0) endcr=necr;81return(0);82}8384int85coinc (int c1, int c2)86{ short lc,hc,qh,qt,i,j,y,fhc,bhc,lim,him,ret; short *ocend,esc;87esc=0; ocend=cend; lc=1;88while (lc!=c1 && lc!=c2) lc=fpt[lc];89if (lc==c1) { hc=c2; ret=ainvb(wd2,wd1,wd3); }90else { hc=c1; ret=ainvb(wd1,wd2,wd3);}91if (ret== -1) return(-1);92if (hc<=lo) {fprintf(stderr,"Impossible coincidence.\n"); return(-1); }93if (compb(wd3,cco+hc)== -1) return(-1);94qh=0; qt=0;95fhc=fpt[hc]; bhc=bpt[hc]; fpt[bhc]=fhc;96if (fhc==0) lastd=bhc; else bpt[fhc]=bhc;97if (ccos==hc) { ccos=bhc; endcr=endr; esc=1; clsd=0; }98if (lkah && lcl==hc) lcl=bhc;99while (1)100{ fpt[hc]=nfree; nfree=hc; cind--; nelim++;101for (i=0;i<ng;i++)102{ him=imcos[i][hc];103if (him!=0)104{ expand(wd1,coeff[i][hc]);105j=invg[i]; lim=imcos[i][lc];106if (him==hc)107{ him=lc; if (concat(wd1,cco[hc])== -1) return(-1);}108else imcos[j][him]=0;109if (lim==0)110{ imcos[i][lc]=him;111if (ainvb(wd3,wd1,wd2)== -1) return(-1);112if (*wd2>2) reduce(wd2);113if (comp(wd2,coeff[i]+lc)== -1) return(-1);114}115else116{ expand(wd2,coeff[i][lc]);117if (lim==hc)118{ imcos[i][lc]=lc; lim=lc;119if (concat(wd2,cco[hc])== -1) return(-1);120if (*wd2>2) reduce(wd2);121if (comp(wd2,coeff[i]+lc)== -1) return(-1);122}123while (fpt[him]<0)124{ if (concat(wd1,cco[him])== -1) return(-1); him= -fpt[him];}125while (fpt[lim]<0)126{ if (concat(wd2,cco[lim])== -1) return(-1); lim= -fpt[lim];}127if (him!=lim)128{ if (ainvb(wd3,wd1,wd4)== -1) return(-1);129y=1;130while (y!=him && y!=lim) y=fpt[y];131if (y==him)132{ him=lim; lim=y; ret=ainvb(wd2,wd4,wd1); }133else ret=ainvb(wd4,wd2,wd1);134if (ret== -1) return(-1);135if (him<=lo)136{ fprintf(stderr,"Impossible coincidence(q).\n"); return(-1); }137fhc=fpt[him]; bhc=bpt[him]; fpt[bhc]=fhc;138if (fhc==0) lastd=bhc; else bpt[fhc]=bhc;139if (ccos==him) { ccos=bhc; endcr=endr; esc=1; clsd=0; }140if (lkah && lcl==him) lcl=bhc;141if (*wd1>2) reduce(wd1);142if (compb(wd1,cco+him)== -1) return(-1);143fpt[him]= -lim;144if (qh==0) qh=him; else bpt[qt]=him;145qt=him; bpt[qt]=0;146}147}148y=imcos[i][lc];149if (imcos[j][y]==0)150{ imcos[j][y]=lc; expand(wd1,coeff[i][lc]); invwd(wd1,wd2);151if (comp(wd2,coeff[j]+y)== -1) return(-1);152}153}154coeff[i][hc]=0;155}156if (qh==0) break;157hc=qh; qh=bpt[qh]; lc= -fpt[hc]; bpt[hc]=0;158expand(wd3,cco[hc]);159}160cend=ocend;161return(esc);162}163164165