#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <unistd.h>
#include <math.h>
#include <sys/types.h>
#include <regex.h>
#define RANDU (urand96(DGLSystem::xnum))
#define RANDD (erand96(DGLSystem::xnum))
#define RANDI (nrand96(DGLSystem::xnum))
#define RANDSI (jrand96(DGLSystem::xnum))
#define RAND1(x) (((x)<=1)?0:(nrand96(DGLSystem::xnum)%(x)))
#define RAND2(x,y) (((x)>(y))?0:((nrand96(DGLSystem::xnum)%((y)-(x)+1))+(x)))
#define STGTYP
namespace DGLSystem
{   
   enum CmdType
   {
      CmdNone,
      CmdOther,
      CmdDD,
      CmdCount,
      CmdReload,
      CmdDump,
      CmdRestart,
      CmdEOC,
      CmdStart,
      CmdEnd,
      CmdIncr,
      CmdKey,
      CmdWeight,
      CmdProb,
      CmdNext,
      CmdPrev,
      CmdFirst,
      CmdLast,
      CmdReset,
      CmdFcount,
      CmdField,
      CmdSave,
      CmdNew,
      CmdDelete,
      CmdOpen,
      CmdReopen,
      CmdSet,
      CmdTell,
      CmdClose
   };
   CmdType whatcmd(unsigned char *xinstr);
   class CmdParm
   {
   public:
      CmdParm()
      {
         Next = NULL;
         Value = new char[1];
         Value[0] = '\0';
      }
      CmdParm(const CmdParm &x)
      {
         Next = NULL;
         Value = new char[strlen(x.Value)+1];
         strcpy(Value,x.Value);
      }
      ~CmdParm()
      {
         delete [] Value;
      }
      CmdParm &operator=(const CmdParm &x)
      {
         delete [] Value;
         Value = new char[strlen(x.Value)+1];
         strcpy(Value,x.Value);
      }
      char *GetValue(void)
      {
         return Value;
      }
      void SetValue(char *NewValue)
      {
         delete [] Value;
         Value = new char[strlen(NewValue)+1];
         strcpy(NewValue,Value);
      }
      CmdParm *GetNext(void)
      {
         return Next;
      }
      void SetNext(CmdParm *NewNext)
      {
         Next = NewNext;
      }
      char *Value;
      CmdParm *Next;
   };
   class Command
   {
   public:
      Command()
      {
         Count = 0;
         Head = NULL;
         Tail = NULL;
         Type = CmdNone;
         Text = NULL;
         TextLen = 0;
         SeqPtr = NULL;
      }
      Command(const Command &x)
      {
         Count = x.Count;
         Head = x.Duplicate();
         Tail = Head;
         if (Head != NULL)
         {
            while (Tail->Next != NULL)
            {
               Tail = Tail->Next;
            }
         }
         Type = x.Type;
         if (x.Text == NULL)
         {
            Text = NULL;
            TextLen = 0;
         }
         else
         {
            Text = (char *)malloc(strlen(x.Text+1));
            strcpy(Text,x.Text);
            TextLen = x.TextLen;
         }
         SeqPtr = NULL;
      }
      ~Command()
      {
         Clear();
      }
      Command &operator=(const Command &x)
      {
         Clear();
         Count = x.Count;
         Head = x.Duplicate();
         Tail = Head;
         if (Head != NULL)
         {
            while (Tail->Next != NULL)
            {
               Tail = Tail->Next;
            }
         }
         Type = x.Type;
         if (x.Text == NULL)
         {
            Text = NULL;
            TextLen = 0;
         }
         else
         {
            Text = (char *)malloc(strlen(x.Text+1));
            strcpy(Text,x.Text);
            TextLen = x.TextLen;
         }
         SeqPtr = NULL;
         return *this;
      }
      void Clear(void)
      {
         while (Head != NULL)
         {
            CmdParm * temp = Head;
            Head = Head->Next;
            delete temp;
         }
         Tail = NULL;
         Count = 0;
         if (Text != NULL)
         {
            free(Text);
         }
         Text = NULL;
         TextLen = 0;
      }
      CmdParm *Duplicate(void) const
      {
         CmdParm * NewHead = NULL, *NewTail = NULL;
   
         for (CmdParm * temp = Head ; temp ; temp = temp->Next)
         {
            CmdParm * Newtemp = new CmdParm(*temp);
            if (NewHead == NULL)
            {
               NewHead = Newtemp;
            }
            else
            {
               NewTail->Next = Newtemp;
            }
            NewTail = Newtemp;
         }
         return NewHead;
      }
      void Append(CmdParm *Item)
      {
         if (Head == NULL)
         {
            Head = Item;
         }
         else
         {
            Tail->Next = Item;
         }
         Item->Next = NULL;
         Count++;
         Tail = Item;
      }
      CmdType GetType(void)
      {
         return Type;
      }
      void SetType(CmdType NewType)
      {
         Type = NewType;
      }
      int GetCount(void)
      {
         return Count;
      }
      char *FirstParm(void)
      {
         SeqPtr = Head;
         if (SeqPtr != NULL)
         {
            return SeqPtr->GetValue();
         }
         else
         {
            return NULL;
         }
      }
      char *NextParm(void)
      {
         if (SeqPtr != NULL)
         {
            SeqPtr = SeqPtr->Next;
         }
         if (SeqPtr != NULL)
         {
            return SeqPtr->GetValue();
         }
         else
         {
            return NULL;
         }
      }
      CmdParm *SeqPtr;
      CmdType Type;
      int Count;
      CmdParm * Head;
      CmdParm * Tail;
      char *Text;
      int TextLen;
   };
}

namespace DGLSystem {

typedef struct rsav
{
   struct rsav *next;
   char *Value;
   int Start;
   int End;
   int Length;
}
RSAV;

typedef struct TNSAV
{
   struct TNSAV *next;
   char *Name;
   int Count;
}
TNSAV;

typedef struct stak
{
   struct stak *next;
   char *val;
   int length;
}
STAK;

typedef struct istak
{
   struct istak *next;
   int val;
}
ISTAK;

typedef struct fstak
{
   struct fstak *next;
   double val;
}
FSTAK;

typedef struct kstak
{
   struct kstak *next;
   char *key;
   char *val;
   int length;
}
KSTAK;
typedef struct rstakblok
{
   struct rstakblok *down;
   struct rstakblok *right;
   int current;
   int limit;
}
RSTAK;


typedef struct statevx
{
   struct statevx *next;
   int size;
   int *i;
}
STATEVX;

typedef struct statev
{
   struct statev *next;
   char *name;
   int size;
   int vnxt;
   int type;
   union
   {
      char *c;
      int *i;
      STATEVX *x;
      struct statev *v;
      STAK *k;
      int ii;
      RSTAK *r;
   }
   val;
}
STATEV;

}
#define main_TABLE 1
#define main_WIDTH 2
#define b_TABLE 1
#define b_WIDTH 2
long long nrand96(unsigned int *s);
unsigned long long urand96(unsigned int *s);
long long jrand96(unsigned int *s);
double erand96(unsigned int *s);
void DGLI(const char *);
void DGLS(const char *);
namespace DGLProductions
{
STGTYP void main_select(void);
STGTYP void main_assign(const char *,int);
STGTYP void G_select(void);
STGTYP void q_select(void);
STGTYP void q_assign(const char *,int);
STGTYP void b_select(void);
STGTYP void b_assign(const char *,int);
}
char *DGL(void);
namespace DGLSystem
{
STGTYP void PQSort(int *,int *,int);
STGTYP CmdType whatcmd(unsigned char *);
STGTYP Command * CommandParser(char *,int);
STGTYP double zignor(void);
STGTYP double zignorfix(int in_point,int in_index);
STGTYP double zigexp(void);
STGTYP double zigexpfix(int in_point,int in_index);
STGTYP int * MakeDST(int n);
STGTYP int * MakeDST(int n,int *List);
STGTYP void MakeStatic(int size, int Curr, int N, int *Tree);
STGTYP void FileParser(const char * FileName,int *Count,char ***Items);
STGTYP void WFileParser(const char * FileName,int *Count,char ***Items,int **Weights);
STGTYP RSTAK *rs_left=NULL,*rs_above=NULL;
STGTYP RSTAK *advcopy(RSTAK *),*readadv(FILE *);
STGTYP void MakeGraphical(void);
STGTYP void initvar(void);
STGTYP int ckstamp(FILE *ifile,const char *istamp);
STGTYP void Begsav(void);
STGTYP int Lensav(void);
STGTYP char *Endsav(void);
STGTYP void BegSect(int);
STGTYP void EndSect(void);
STGTYP void BegFile(FILE *);
STGTYP void EndFile(void);
STGTYP void savecc(char inchar);
STGTYP void outcc(char incc);
STGTYP void outadj(int insiz);
STGTYP void outstr(const char *instr,int len);
STGTYP void xtos(long value,char *output,int size);
STGTYP char *getstr(FILE *ifile,int outok);
STGTYP char *getstr2(int len,FILE *ifile);
STGTYP void getstate(FILE *ifile);
STGTYP void putstate(FILE *ifile);
STGTYP void interpret(const char *instr);
STGTYP STATEV *svsav(const char *iname,int ilen);
STGTYP void advprint(RSTAK *,FILE *);
STGTYP void interp2(const char *instr,int inlen);
STGTYP void (*(getsel(const char *instr,int inlen)))();
STGTYP void (*(getvar(const char *instr,int inlen)))(const char *,int);
STGTYP char **getkey(const char *instr,int inlen);
STGTYP int advance(RSTAK *istak);
STGTYP void advfree(RSTAK *istak);
STGTYP void ClearChain(RSTAK *istak);
STGTYP char *getstr2(int len,FILE *ifile);
STGTYP STATEV *svcopy(STATEV *ival);
STGTYP void svrstr(STATEV *ival,const char *inid);
STGTYP void svfree(STATEV *ival);
STGTYP void prsvar(STATEV *ival,FILE *ofile);
STGTYP STATEV *rdsvar(FILE *ifile);
STGTYP int perm1(int *vec,int size);
STGTYP int tailok(int *vec,int start,int size);
STGTYP void reverse(int *vec,int start,int size,int point);
STGTYP int comb1(int *vec,int size,int sels);
}

namespace DGLProductions
{
STGTYP int main_size = 1;
STGTYP const char *main_table[] =
{
     "%G",
};


STGTYP int q_min=1,q_max=10;
STGTYP int b_size = 1;
STGTYP const char *b_table[] =
{
     "30",
};


}
/* Dump of Search file */
/* Dump of Search file ended */

class Edge
{
public:
   Edge *Next;
   int Vertex;
   void Randomize(void) {}
};
Edge **G;

namespace DGLSystem
{
   unsigned int xnum[3] = {0xa1579c23,0x0846ebdf,0xa40b3c26};
}

namespace DGLSystem {
STGTYP int stop_run;
STGTYP int GblRepCnt = 0;
STGTYP int saving = 0;
STGTYP int InSection = 0;
STGTYP int InFile = 0;
STGTYP int FileLevel = 0;
}
STGTYP int argc;
STGTYP char **argv;
namespace DGLSystem {
STGTYP char **SectTable = NULL,tc;


STGTYP int SectTableLength = 0;
}
namespace DGLSystem {
typedef struct savstack
{
   struct savstack *next;
   int OldLvl;
}
SAVSTACK;
STGTYP SAVSTACK *SvStak = NULL;
typedef struct filestack
{
   struct filestack *next;
   FILE *f;
   int OldLvl;
}
FILESTACK;
STGTYP FILESTACK *FStak = NULL;
typedef struct sectstack
{
   struct sectstack *next;
   int ID;
   int OldLvl;
}
SECTSTACK;
STGTYP SECTSTACK *SStak = NULL;
STGTYP FILE *CurrSection = NULL,*TFile,*TFile2;


typedef struct savbloc
{
   struct savbloc *vnext;
   struct savbloc *hnext;
   struct savbloc *hend;
   int chars;
   char data[100];
}
SAVBLOC;
STGTYP SAVBLOC *hsav = NULL;


STGTYP const char *TimeStamp="Sun Dec  2 18:05:19 2018";


}
int main(int largc,char *largv[])
{
   const char *startsym = "%{main}";
   int repcnt,trepcnt,i;
   FILE *numfil;
   char *filnam;

   argc = largc;
   argv = largv;
   filnam = (char *)malloc(strlen(argv[0])+6);
   if (filnam == NULL)
   {
      fprintf(stderr,"Out of memory space\n");
      exit(100);
   }
   strcpy(filnam,argv[0]);
   strcat(filnam,".rand");
   numfil=fopen(filnam,"r");
   if (numfil != NULL && DGLSystem::ckstamp(numfil,DGLSystem::TimeStamp))
   {
      for (i=0 ; i<3 ; i++)
      {
         fscanf(numfil,"%u ",&DGLSystem::xnum[i]);
      }
   }
   if (numfil != NULL)
   {
      fclose(numfil);
   }
   DGLSystem::stop_run = 0;
   repcnt = 1;
   DGLSystem::GblRepCnt = 1;
   if (argc > 1)
   {
      trepcnt = strtol(argv[1],NULL,0);
      if (trepcnt > 0)
      {
         repcnt = trepcnt;
         DGLSystem::GblRepCnt = trepcnt;
      }
   }
   while(repcnt>0 && !DGLSystem::stop_run)
   {
      DGLSystem::interpret(startsym);
      repcnt--;
   }
   numfil = fopen(filnam,"w");
   if (numfil != NULL)
   {
      fprintf(numfil,"%s\n",DGLSystem::TimeStamp);
      for (i=0 ; i<3 ; i++)
      {
      fprintf(numfil,"%u ",DGLSystem::xnum[i]);
      }
      putc('\n',numfil);
      fclose(numfil);
   }
   for (i=0 ; i<DGLSystem::SectTableLength ; i++)
   {
      DGLSystem::TFile = fopen(DGLSystem::SectTable[i],"r");
      DGLSystem::tc = getc(DGLSystem::TFile);
      while (!feof(DGLSystem::TFile))
      {
         putc(DGLSystem::tc,stdout);
         DGLSystem::tc = getc(DGLSystem::TFile);
      }
      fclose(DGLSystem::TFile);
      unlink(DGLSystem::SectTable[i]);
   }
   return 0;
}



STGTYP int DGLSystem::ckstamp(FILE *ifile,const char *istamp)
{
   const char *xc;
   char tc;

   for (xc=istamp ; *xc != '\0' ; xc++)
   {
      tc = getc(ifile);
      if (tc != *xc)
      {
	 return 0;
      }
   }
   tc = getc(ifile);
   if (tc != '\n')
   {
      return 0;
   }
   return 1;
}



STGTYP void DGLSystem::Begsav()
{
   SAVBLOC *temp;
   SAVSTACK *sstemp;

   sstemp = (SAVSTACK *)malloc(sizeof(SAVSTACK));

   if (sstemp == NULL)
   {
      fprintf(stderr,"Variable evaluation abort (No Storage)\n");
      exit(100);
   }
   sstemp->OldLvl = DGLSystem::saving;
   sstemp->next = DGLSystem::SvStak;
   DGLSystem::SvStak = sstemp;
   DGLSystem::FileLevel++;
   DGLSystem::saving = DGLSystem::FileLevel;
   temp = (SAVBLOC *)malloc(sizeof(SAVBLOC));
   if (temp == NULL)
   {
      fprintf(stderr,"Variable evaluation abort (No Storage)\n");
      exit(100);
   }
   temp->hnext = NULL;
   temp->hend = temp;
   temp->chars = 0;
   temp->vnext = hsav;
   hsav = temp;
}

STGTYP void DGLSystem::BegSect(int SectID)
{
   SECTSTACK *TStak;
   if (DGLSystem::InSection)
   {
      fclose(DGLSystem::CurrSection);
   }
   TStak = (SECTSTACK *)malloc(sizeof(SECTSTACK));
   if (TStak == NULL)
   {
      fprintf(stderr,"Variable evaluation abort (No Storage)\n");
      exit(100);
   }
   TStak->OldLvl = DGLSystem::InSection;
   TStak->next = DGLSystem::SStak;
   DGLSystem::SStak = TStak;
   DGLSystem::FileLevel++;
   DGLSystem::InSection = DGLSystem::FileLevel;
   TStak->ID = SectID;
   DGLSystem::CurrSection = fopen(DGLSystem::SectTable[SectID],"a");
}

STGTYP void DGLSystem::BegFile(FILE *fp)
{
   FILESTACK *TStak;
   TStak = (FILESTACK *)malloc(sizeof(FILESTACK));
   if (TStak == NULL)
   {
      fprintf(stderr,"Variable evaluation abort (No Storage)\n");
      exit(100);
   }
   TStak->OldLvl = DGLSystem::InFile;
   DGLSystem::FileLevel++;
   DGLSystem::InFile = DGLSystem::FileLevel;
   TStak->next = DGLSystem::FStak;
   DGLSystem::FStak = TStak;
   TStak->f = fp;
}

STGTYP int DGLSystem::Lensav()
{
   SAVBLOC *temp;
   int tlen;

   tlen = 0;
   for (temp = hsav ; temp != NULL ; temp=temp->hnext)
   {
      tlen += temp->chars;
   }
   return tlen;
}


STGTYP char *DGLSystem::Endsav()
{
   SAVSTACK *sstemp;
   SAVBLOC *temp1,*temp2;
   int tlen;
   char *rv,*tstr;

   DGLSystem::saving = DGLSystem::SvStak->OldLvl;
   sstemp = DGLSystem::SvStak;
   DGLSystem::SvStak = DGLSystem::SvStak->next;
   free(sstemp);
   DGLSystem::FileLevel--;
   temp1 = hsav;
   hsav = temp1->vnext;
   tlen = 0;
   for (temp2 = temp1 ; temp2 != NULL ; temp2=temp2->hnext)
   {
      tlen += temp2->chars;
   }
   rv = (char *)malloc(tlen+1);
   if (rv == NULL)
   {
      fprintf(stderr,"Variable evaluation abort (No Storage)\n");
      exit(100);
   }
   tstr=rv;
   for (temp2 = temp1 ; temp2 != NULL ; )
   {
      memcpy(tstr,temp2->data,temp2->chars);
      tstr += temp2->chars;
      temp1 = temp2;
      temp2=temp2->hnext;
      free(temp1);
   }
   *tstr = '\0';
   return(rv);
}


STGTYP void DGLSystem::EndSect(void)
{
   SECTSTACK *TStak;
   DGLSystem::FileLevel--;
   DGLSystem::InSection = DGLSystem::SStak->OldLvl;
   fclose(DGLSystem::CurrSection);
   TStak = DGLSystem::SStak;
   DGLSystem::SStak = DGLSystem::SStak->next;
   free(TStak);
   if (DGLSystem::InSection)
   {
      DGLSystem::CurrSection = fopen(DGLSystem::SectTable[DGLSystem::SStak->ID],"a");
   }
}


STGTYP void DGLSystem::EndFile(void)
{
   FILESTACK *TStak;
   DGLSystem::FileLevel--;
   DGLSystem::InFile = DGLSystem::FStak->OldLvl;
   TStak = DGLSystem::FStak;
   DGLSystem::FStak = DGLSystem::FStak->next;
   free(TStak);
}


STGTYP void DGLSystem::savecc(char inchar)
{
   SAVBLOC *temp1,*temp2;

   temp1 = hsav->hend;
   if (temp1->chars >= 100)
   {
      temp2 = (SAVBLOC *)malloc(sizeof(SAVBLOC));
      if (temp2 == NULL)
      {
	 fprintf(stderr,"Variable evaluation abort (No Storage)\n");
	 exit(100);
      }
      temp1->hnext = temp2;
      temp2->hnext = NULL;
      temp2->vnext = temp1->vnext;
      temp2->chars = 0;
      temp2->hend = NULL;
      hsav->hend = temp2;
      temp1 = temp2;
   }
   temp1->data[temp1->chars] = inchar;
   temp1->chars++;
}



STGTYP void DGLSystem::outcc(char incc)
{
   if (DGLSystem::FileLevel)
   {
      if (DGLSystem::InSection == DGLSystem::FileLevel)
      {
         putc(incc,DGLSystem::CurrSection);
      }
      else if (DGLSystem::saving == DGLSystem::FileLevel)
      {
         savecc(incc);
      }
      else
      {
         putc(incc,DGLSystem::FStak->f);
      }
   }
   else
   {
      putc(incc,stdout);
   }
}


STGTYP void DGLSystem::outadj(int insiz)
{
   int adjval;

   if (DGLSystem::saving)
   {
      adjval = hsav->hend->chars%insiz;
      if (adjval > 0)
      {
	 for ( ; adjval < insiz ; adjval++)
	 {
	    savecc(0);
	 }
      }
   }
}


STGTYP void DGLSystem::outstr(const char *instr,int len)
{
   int i;
   const char *wkstr;

   if (DGLSystem::FileLevel)
   {
      if (DGLSystem::InSection == DGLSystem::FileLevel)
      {
         fwrite(instr,1,len,DGLSystem::CurrSection);
      }
      else if (DGLSystem::saving == DGLSystem::FileLevel)
      {
         for (i=0,wkstr=instr ; i<len ; i++,wkstr++)
         {
	      savecc(*wkstr);
         }
      }
      else
      {
         fwrite(instr,1,len,DGLSystem::FStak->f);
      }
   }
   else
   {
      fwrite(instr,1,len,stdout);
   }
}


   STGTYP void DGLSystem::xtos(long value,char *output,int size)
   {
      int work,negative,swork,len;
      char iwork[32],*x,*owork;
      
      iwork[31] = '\0';
      if (value == 0)
      {
	 iwork[30] = '0';
	 x = iwork+30;
	 len = 1;
      }
      else if (value == 0x80000000)
      {
         strcpy(iwork+20,"-2147483648");
         x=iwork+20;
         len=11;
      }
      else
      {
	 len = 0;
	 if (value < 0)
	 {
	    negative = 1;
	    work = -value;
	 }
	 else
	 {
	    negative = 0;
	    work = value;
	 }
	 x = iwork+31;
	 while (work > 0)
	 {
	    x--;
	    *x = (work % 10) + '0';
	    work /= 10;
	    len++;
	 }
	 if (negative)
	 {
	    x--;
	    *x = '-';
	    len++;
	 }
      }
      if (size == 0)
      {
	 swork = 0;
      }
      else
      {
	 swork = len - size;
      }
      if (swork < 0)
      {
	 if (negative)
	 {
	    x++;
	 }
	 while(swork < 0)
	 {
	    x--;
	    *x = '0';
	    swork++;
	 }
	 if (negative)
	 {
	    x--;
	    *x = '-';
	 }
      }
      for (owork=output,x += swork ; *x ; x++,owork++)
      {
	 *owork = *x;
      }
      *owork = '\0';
   }



bool MakeGraphical(int *List, int Len)
{
   int *A = new int[Len];
   int *B = new int[Len];
   bool Good = false;
   while (!Good)
   {
      Good = true;
      A[0] = List[0];
      for (int i = 1; i < Len; i++)
      {
         A[i] = A[i - 1] + List[i];
      }
      for (int i = 0; i < Len - 1; i++)
      {
         B[i] = 0;
         for (int j = i + 1; j < Len; j++)
         {
            if (i + 1 < List[j])
            {
               B[i] += i + 1;
            }
            else
            {
               B[i] += List[j];
            }
         }
         B[i] += i*(i + 1);
      }
      for (int i = 0; i < Len - 1; i++)
      {
         if (A[i] > B[i])
         {
            Good = false;
            List[i]+=2;
            int j;
            int X = List[i];
            for (j=i-1 ; j>=0 && List[j] < X ; j--)
            {
               List[j+1] = List[j];
            }
            List[j+1] = X;
            break;
         }
      }
   }
}
namespace DGLSystem {
STGTYP int Barrier_Level = 0;

STGTYP int Barrier_Abort = -1;

STGTYP int Barrier_Stop = 0;

}
STGTYP void DGLSystem::interpret(const char *instr)
{
   interp2(instr,strlen(instr));
}


STGTYP void DGLSystem::interp2(const char *instr,int inlen)
{
   const char *wkstr,*idstart,*idend,*varstart,*flagptr,*idstrt;
   char savstr[61],*dashptr;
   int repcnt,begcnt,endcnt,outlen,icntlen,idlen,varlen,idstrtlen;
   int Current_Barrier = DGLSystem::Barrier_Level;
   void (*selrtn)(),(*varassg)(const char *,int);
   int charcount;

   for (wkstr = instr,charcount = inlen ; charcount>0 ; )
   {
      flagptr = (char *)memchr(wkstr,'%',inlen-(wkstr-instr));
      if (flagptr == NULL)
      {
	 outlen = inlen-(wkstr-instr);
      }
      else
      {
	 outlen = flagptr-wkstr;
      }
      if (outlen > 0)
      {
	 outstr(wkstr,outlen);
	 wkstr += outlen;
      }
      charcount -= outlen;
      idstrt = wkstr;
      idstrtlen = charcount;
      if (flagptr != NULL)
      {
	 wkstr++;
	 charcount--;
	 if (charcount <= 0)
	 {
	    outcc('%');
	    return;
	 }
	 icntlen = strspn(wkstr,"0123456789-.");
	 if (icntlen >= charcount)
	 {
	    outstr(idstrt,idstrtlen);
	    return;
	 }
	 if (icntlen > 0)
	 {
	    if (icntlen < 60)
	    {
	       memcpy(savstr,wkstr,icntlen);
	       savstr[icntlen] = '\0';
	    }
	    else
	    {
	       memcpy(savstr,wkstr,60);
	       savstr[60] = '\0';
	    }
	    wkstr += icntlen;
	    dashptr = strchr(savstr,'-');
	    if (dashptr == NULL)
	    {
	       dashptr = strchr(savstr,'.');
	    }
	    if (dashptr != NULL)
	    {
	       *dashptr = '\0';
	       begcnt = atoi(savstr);
	       endcnt = atoi(dashptr+1);
	       repcnt = RAND2(begcnt,endcnt);
	    }
	    else
	    {
	       repcnt = atoi(savstr);
	    }
	 }
	 else
	 {
	    repcnt = 1;
	 }
	 charcount -= icntlen;
	 if (*wkstr == '{')
	 {
	    wkstr++;
	    charcount--;
	    if (charcount <= 0)
	    {
	       outstr(idstrt,idstrtlen);
	       return;
	    }
	    idstart = wkstr;
	    idend = (char *)memchr(wkstr,'}',inlen-(wkstr-instr));
	    if (idend == NULL)
	    {
	       idlen = inlen-(wkstr-instr);
	       wkstr += idlen;
	       idend = wkstr;
	       charcount = 0;
	    }
	    else
	    {
	       idlen = idend - idstart;
	       wkstr = idend + 1;
	       charcount -= idlen + 1;
	    }
	    varstart = (char *)memchr(idstart,'.',idlen);
	    if (varstart == NULL)
	    {
	       varlen = 0;
	    }
	    else
	    {
	       varstart++;
	       if (varstart <= idend)
	       {
		  varlen = idend - varstart;
	          idlen = varstart - idstart - 1;
	       }
	       else
	       {
		  varstart = NULL;
		  varlen = 0;
	       }
	    }
	 }
	 else
	 {
	    idstart = wkstr;
	    idlen = 1;
	    wkstr++;
	    charcount--;
	    varstart = NULL;
	    varlen = 0;
	 }
	 if (varlen > 0)
	 {
	    varassg = getvar(varstart,varlen);
	    if (varassg == NULL)
	    {
	       while (repcnt > 0)
	       {
		  outstr(idstart,idlen+varlen+1);
		  repcnt--;
	       }
	    }
	    else
	    {
	       while (repcnt > 0)
	       {
		  (*varassg)(idstart,idlen);
		  repcnt--;
	       }
	    }
	 }
	 else
	 {
	    selrtn = getsel(idstart,idlen);
	    if (selrtn == NULL)
	    {
	       while (repcnt > 0)
	       {
		  outstr(idstart,idlen);
		  repcnt--;
	       }
	    }
	    else
	    {
	       while (repcnt > 0)
	       {
		  (*selrtn)();
	          repcnt--;
	       }
          }
	 }
      }
      if (DGLSystem::Barrier_Abort == Current_Barrier)
      {
         return;
      }
      else if (DGLSystem::Barrier_Abort > Current_Barrier)
      {
         DGLSystem::Barrier_Abort = -1;
      }
   }
}



STGTYP void (*(DGLSystem::getsel(const char *instr,int inlen)))()
{

   if (inlen > 1) goto lab0;
   if (inlen != 1)
   {
      return NULL;
   }
   if (instr[0] > 'G') goto lab1;
   if (
       instr[0] == 'G'
      )
   {
      return DGLProductions::G_select;
   }
   else
   {
      return NULL;
   }
lab1:
   if (instr[0] > 'b') goto lab2;
   if (
       instr[0] == 'b'
      )
   {
      return DGLProductions::b_select;
   }
   else
   {
      return NULL;
   }
lab2:
   if (
       instr[0] == 'q'
      )
   {
      return DGLProductions::q_select;
   }
   else
   {
      return NULL;
   }
lab0:
   if (inlen != 4)
   {
      return NULL;
   }
   if (
       instr[0] == 'm'
    && instr[1] == 'a'
    && instr[2] == 'i'
    && instr[3] == 'n'
      )
   {
      return DGLProductions::main_select;
   }
   else
   {
      return NULL;
   }
}


STGTYP void (*(DGLSystem::getvar(const char *instr,int inlen)))(const char *,int)
{

   if (inlen > 1) goto lab3;
   if (inlen != 1)
   {
      return NULL;
   }
   if (instr[0] > 'b') goto lab4;
   if (
       instr[0] == 'b'
      )
   {
      return DGLProductions::b_assign;
   }
   else
   {
      return NULL;
   }
lab4:
   if (
       instr[0] == 'q'
      )
   {
      return DGLProductions::q_assign;
   }
   else
   {
      return NULL;
   }
lab3:
   if (inlen != 4)
   {
      return NULL;
   }
   if (
       instr[0] == 'm'
    && instr[1] == 'a'
    && instr[2] == 'i'
    && instr[3] == 'n'
      )
   {
      return DGLProductions::main_assign;
   }
   else
   {
      return NULL;
   }
}


STGTYP char **DGLSystem::getkey(const char *instr,int inlen)
{
   return NULL;
}


STGTYP void DGLProductions::main_select()
{
   DGLSystem::interpret(DGLProductions::main_table[RAND1(1)]);
}



STGTYP void DGLProductions::main_assign(const char *ival,int ilen)
{
   int lcl_index;
   int lcl_len;
   void (*selrtn)();
   DGLSystem::Command * cmd;
   char *lcl_value;

   selrtn = DGLSystem::getsel(ival,ilen);
   DGLSystem::Begsav();
   if (selrtn == NULL)
   {
      DGLSystem::outstr(ival,ilen);
   }
   else
   {
      (*selrtn)();
   }
   lcl_len = DGLSystem::Lensav();
   lcl_value = DGLSystem::Endsav();
   cmd = DGLSystem::CommandParser(lcl_value,lcl_len);
   if (cmd->Type == DGLSystem::CmdCount)
   {
      DGLSystem::interpret("1");
   }
   else
   {
      lcl_index = strtol(lcl_value,NULL,0);
   DGLSystem::interpret(DGLProductions::main_table[lcl_index%1]);
   }
   delete cmd;
   free(lcl_value);
}



STGTYP void DGLProductions::G_select(void)
{
   int TempDeg;
   char * lcl_value;
   int TotalVertices,EdgePoints,IsOdd,*Degree,X,Y;
   void (*selrtn)();
   int *Used,Remain,LRemain,Offset;

   Edge **TempAdj,*TempEdge,*TempEdge2;
   DGLSystem::Begsav();
   DGLSystem::interpret("%b");
   lcl_value = DGLSystem::Endsav();
   TotalVertices = strtol(lcl_value,NULL,0);
   free(lcl_value);
   if (TotalVertices <= 0)
   {
      TempAdj = NULL;
      TotalVertices = 0;
   }
   else
   {
      EdgePoints = 0;
      Degree = new int[TotalVertices];
      for (int i=0 ; i<TotalVertices ; i++)
      {
         DGLSystem::Begsav();
   DGLSystem::interpret("%q");
         lcl_value = DGLSystem::Endsav();
         TempDeg = strtol(lcl_value,NULL,0);
         free(lcl_value);
         Degree[i] = TempDeg;
         EdgePoints += TempDeg;
      }
      IsOdd = EdgePoints%2;
      if (IsOdd)
      {
         int *TDegree;
         TDegree = new int[TotalVertices+1];
         for (int i=0 ; i<TotalVertices ; i++)
         {
            TDegree[i] = Degree[i];
         }
         delete [] Degree;
         Degree = TDegree;
         Degree[TotalVertices] = 1;
         EdgePoints++;
         TotalVertices++;
      }
   }
   TempAdj = new Edge *[TotalVertices];
   for (int i=0 ; i<TotalVertices ; i++)
   {
      TempAdj[i] = NULL;
   }
   int TotalDeg = 0;
   for (int i=0 ; i<TotalVertices ; i++)
   {
      if (Degree[i] <= 0)
      {
         Degree[i] = 1;
      }
      if (Degree[i] >= TotalVertices)
      {
         Degree[i] = TotalVertices - 1;
      }
      TotalDeg += Degree[i];
   }
   if (TotalDeg&1)
   {
      Degree[0]++;
   }
   for (int i=1 ; i<TotalVertices ; i++)
   {
      int j;
      int X=Degree[i];
      for (j=i-1 ; j<=0 && X>Degree[j] ; j--)
      {
         Degree[j+1] = Degree[j];
      }
      Degree[j+1] = X;
   }
   MakeGraphical(Degree,TotalVertices);
   for (int i=0 ; i<TotalVertices-1 ; i++)
   {
      int j = i+1;
      while (Degree[i] > 0)
      {
         for ( ;
         j<TotalVertices && Degree[j] == 0;
         j++);
         if (j<TotalVertices)
         {
            TempEdge = new Edge;
            TempEdge->Randomize();
            TempEdge->Next = TempAdj[i];
            TempEdge->Vertex = j;
            TempAdj[i] = TempEdge;
            TempEdge2 = TempEdge;
            TempEdge = new Edge;
            *TempEdge = *TempEdge2;
            TempEdge->Next = TempAdj[j];
            TempEdge->Vertex = i;
            TempAdj[j] = TempEdge;
            Degree[i]--;
            Degree[j]--;
            j++;
         }
         else
         {
            Degree[i] = 0;
         }
      }
   }
  delete [] Degree;
   G = TempAdj;
}
STGTYP void DGLProductions::q_select()
{
   char work[32];
   char *i;

   DGLSystem::xtos(RAND2(DGLProductions::q_min,DGLProductions::q_max),work,0);
   for (i=work ; *i ; i++)
   {
      DGLSystem::outcc(*i);
   }
}


STGTYP void DGLProductions::q_assign(const char *ival,int ilen)
{
   void (*selrtn)();
   DGLSystem::Command * cmd;

   int lcl_index,lcl_len;

   char *lcl_value,CVal[30];

   DGLSystem::Begsav();
   selrtn = DGLSystem::getsel(ival,ilen);
   if (selrtn == NULL)
   {
      DGLSystem::outstr(ival,ilen);
   }
   else
   {
      (*selrtn)();
   }
   lcl_len = DGLSystem::Lensav();
   lcl_value = DGLSystem::Endsav();
   cmd = DGLSystem::CommandParser(lcl_value,lcl_len);
   if (cmd->Type == DGLSystem::CmdCount)
   {
      sprintf(CVal,"%d",DGLProductions::q_max);
      DGLSystem::interpret(CVal);
   }
   else if (cmd->Type == DGLSystem::CmdStart)
   {
      if (cmd->Count <= 0)
      {
         sprintf(CVal,"%d",DGLProductions::q_min);
         DGLSystem::interpret(CVal);
      }
      else
      {
         lcl_index = strtol(cmd->Head->Value,NULL,0);
         DGLProductions::q_min = lcl_index;
      }
   }
   else if (cmd->Type == DGLSystem::CmdEnd)
   {
      if (cmd->Count <= 0)
      {
         sprintf(CVal,"%d",DGLProductions::q_max);
         DGLSystem::interpret(CVal);
      }
      else
      {
         lcl_index = strtol(cmd->Head->Value,NULL,0);
         DGLProductions::q_max = lcl_index;
      }
   }
   else
   {
      lcl_index = strtol(lcl_value,NULL,0);
   DGLProductions::q_max = lcl_index;
   }
   delete cmd;
   free(lcl_value);
}



STGTYP void DGLProductions::b_select()
{
   DGLSystem::interpret(DGLProductions::b_table[RAND1(1)]);
}



STGTYP void DGLProductions::b_assign(const char *ival,int ilen)
{
   int lcl_index;
   int lcl_len;
   void (*selrtn)();
   DGLSystem::Command * cmd;
   char *lcl_value;

   selrtn = DGLSystem::getsel(ival,ilen);
   DGLSystem::Begsav();
   if (selrtn == NULL)
   {
      DGLSystem::outstr(ival,ilen);
   }
   else
   {
      (*selrtn)();
   }
   lcl_len = DGLSystem::Lensav();
   lcl_value = DGLSystem::Endsav();
   cmd = DGLSystem::CommandParser(lcl_value,lcl_len);
   if (cmd->Type == DGLSystem::CmdCount)
   {
      DGLSystem::interpret("1");
   }
   else
   {
      lcl_index = strtol(lcl_value,NULL,0);
   DGLSystem::interpret(DGLProductions::b_table[lcl_index%1]);
   }
   delete cmd;
   free(lcl_value);
}




// product:
//                 m1   m0
//            s2   s1   s0
//               s0m1 s0m0
//          s1m1 s1m0
//     s2m1 s2m0
//                 a1   a0
//     
// The product s2m1 is not used. It is truncated by the mod 2^96 computation.
// Word 0 is the low-order 32 bits of s0m0.
// Word 1 is the low-order bits of s0m1+s1m0+(the high-order bits of s0m0.
// Word 2 is the low-order bits of s0m2+s1m1+s2m0 + the high-order bits of the Word 1 computation.

/* The following are from Knuth */
/* Multiplier = 6364136223846793005 = 0x5851F42D 0x4C957F2D */
/* Adder = 1442695040888963407 = 0x14057B7E 0xF767814F */
long long nrand96(unsigned int *s)
{
   unsigned long long m0 = 0x4C957F2D;
   unsigned long long m1 = 0x5851F42D;
   unsigned long long a0 = 0xF767814F;
   unsigned long long a1 = 0x14057B7E;
   unsigned long long s0m0,s0m1;
   unsigned long long s1m1,s1m0;
   unsigned long long s2m0,w1;
   s0m0 = (s[0]*m0)+a0;
   s0m1 = (s[0]*m1)+a1;
   s1m0 = s[1]*m0;
   s1m1 = s[1]*m1;
   s2m0 = s[2]*m0;
   s[0] = (unsigned int)(s0m0&0xffffffffULL);
   w1 = s0m0+s0m1+(s0m0>>32);
   s[1] = (unsigned int)(w1&0xffffffffULL);
   s[2] = (unsigned int)((s1m1+s2m0+(w1>>32))&0xffffffffULL);
   return (long long)((((unsigned long long)s[2])<<31)+(((unsigned long long)s[1])>>1));
}
unsigned long long urand96(unsigned int *s)
{
   unsigned long long m0 = 0x4C957F2D;
   unsigned long long m1 = 0x5851F42D;
   unsigned long long a0 = 0xF767814F;
   unsigned long long a1 = 0x14057B7E;
   unsigned long long s0m0,s0m1;
   unsigned long long s1m1,s1m0;
   unsigned long long s2m0,w1;
   s0m0 = (s[0]*m0)+a0;
   s0m1 = (s[0]*m1)+a1;
   s1m0 = s[1]*m0;
   s1m1 = s[1]*m1;
   s2m0 = s[2]*m0;
   s[0] = (unsigned int)(s0m0&0xffffffffULL);
   w1 = s0m0+s0m1+(s0m0>>32);
   s[1] = (unsigned int)(w1&0xffffffffULL);
   s[2] = (unsigned int)((s1m1+s2m0+(w1>>32))&0xffffffffULL);
   return (((unsigned long long)s[2])<<32)+((unsigned long long)s[1]);
}
long long jrand96(unsigned int *s)
{
   unsigned long long m0 = 0x4C957F2D;
   unsigned long long m1 = 0x5851F42D;
   unsigned long long a0 = 0xF767814F;
   unsigned long long a1 = 0x14057B7E;
   unsigned long long s0m0,s0m1;
   unsigned long long s1m1,s1m0;
   unsigned long long s2m0,w1;
   s0m0 = (s[0]*m0)+a0;
   s0m1 = (s[0]*m1)+a1;
   s1m0 = s[1]*m0;
   s1m1 = s[1]*m1;
   s2m0 = s[2]*m0;
   s[0] = (unsigned int)(s0m0&0xffffffffULL);
   w1 = s0m0+s0m1+(s0m0>>32);
   s[1] = (unsigned int)(w1&0xffffffffULL);
   s[2] = (unsigned int)((s1m1+s2m0+(w1>>32))&0xffffffffULL);
   return (long long)((((unsigned long long)s[2])<<32)+((unsigned long long)s[1]));
}
double erand96(unsigned int *s)
{
   return 0.5 + ((long long)urand96(s) * 5.4210108624275221700372640043497e-20);
}
DGLSystem::Command *DGLSystem::CommandParser(char *Cmd,int CmdLen)
{
   Command * rv = new Command;
   if (Cmd == NULL || CmdLen < 2)
   {
      return rv;
   }
   if (Cmd[0] != '$')
   {
      return rv;
   }
   if (Cmd[1] == '$')
   {
      rv->Type = CmdDD;
      rv->Text = (char *)malloc(CmdLen);
      strncpy(rv->Text,Cmd+1,CmdLen-1);
      rv->Text[CmdLen-1] = '\0';
      rv->TextLen = CmdLen-1;
      return rv;
   }
   char *NameStart = Cmd+1;
   char *ParmStart = NULL;
   int NameLen = 0;
   int i;
   for (i=1 ; i<CmdLen ; i++)
   {
      if (Cmd[i] == '(')
      {
         break;
      }
      NameLen++;
   }
   if (NameLen < 1)
   {
      return rv;
   }
   char * NameText = new char [NameLen+1];
   strncpy(NameText,Cmd+1,NameLen);
   NameText[NameLen] = '\0';
   if (i<CmdLen)
   {
      ParmStart = Cmd+1+NameLen+1;
   }
   rv->Type = whatcmd((unsigned char *)NameText);
   if (ParmStart)
   {
      char * tc = ParmStart;
      char * ParmEnd = Cmd + CmdLen;
      while (tc < ParmEnd && *tc != ')')
      {
         for ( ;
              tc < ParmEnd && *tc != ')' && *tc != ',' ;
              tc++);
         int tparmlen = tc-ParmStart;
         CmdParm * tparm = new CmdParm;
         delete tparm->Value;
         tparm->Value = new char[tparmlen+1];
         strncpy(tparm->Value,ParmStart,tparmlen);
         tparm->Value[tparmlen] = '\0';
         if (rv->Head == NULL)
         {
            rv->Head = tparm;
         }
         else
         {
            rv->Tail->Next = tparm;
         }
         rv->Tail = tparm;
         rv->Count++;
         if (*tc != ')')
         {
            ParmStart = tc+1;
            tc++;
         }
      }
   }
   return rv;
}


STGTYP unsigned char ultab[256] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
};

STGTYP DGLSystem::CmdType DGLSystem::whatcmd(register unsigned char *xinstr)
{
   unsigned char yinstr[9];
   register unsigned char *instr=yinstr;

   register unsigned char *ultptr=ultab;

   instr[0] = ultptr[xinstr[0]];
   instr[1] = ultptr[xinstr[1]];
   instr[2] = ultptr[xinstr[2]];
   instr[3] = ultptr[xinstr[3]];
   instr[4] = ultptr[xinstr[4]];
   instr[5] = ultptr[xinstr[5]];
   instr[6] = ultptr[xinstr[6]];
   instr[7] = ultptr[xinstr[7]];
   instr[8] = ultptr[xinstr[8]];
   if (instr[0] > 'l') goto lab0;
   if (instr[0] > 'e') goto lab1;
   if (instr[0] > 'c') goto lab2;
   if (instr[0] != 'c') return CmdOther;
   if (instr[1] > 'l') goto lab3;
   if (
       instr[1] == 'l' &&
       instr[2] == 'o' &&
       instr[3] == 's' &&
       instr[4] == 'e' &&
       instr[5] == '\0'
      )
   {
      return CmdClose;
   }
   else
   {
      return CmdOther;
   }
lab3:
   if (
       instr[1] == 'o' &&
       instr[2] == 'u' &&
       instr[3] == 'n' &&
       instr[4] == 't' &&
       instr[5] == '\0'
      )
   {
      return CmdCount;
   }
   else
   {
      return CmdOther;
   }
lab2:
   if (instr[0] > 'd') goto lab4;
   if (instr[0] != 'd') return CmdOther;
   if (instr[1] > 'e') goto lab5;
   if (
       instr[1] == 'e' &&
       instr[2] == 'l' &&
       instr[3] == 'e' &&
       instr[4] == 't' &&
       instr[5] == 'e' &&
       instr[6] == '\0'
      )
   {
      return CmdDelete;
   }
   else
   {
      return CmdOther;
   }
lab5:
   if (
       instr[1] == 'u' &&
       instr[2] == 'm' &&
       instr[3] == 'p' &&
       instr[4] == '\0'
      )
   {
      return CmdDump;
   }
   else
   {
      return CmdOther;
   }
lab4:
   if (instr[0] != 'e') return CmdOther;
   if (instr[1] > 'n') goto lab6;
   if (
       instr[1] == 'n' &&
       instr[2] == 'd' &&
       instr[3] == '\0'
      )
   {
      return CmdEnd;
   }
   else
   {
      return CmdOther;
   }
lab6:
   if (
       instr[1] == 'o' &&
       instr[2] == 'c' &&
       instr[3] == '\0'
      )
   {
      return CmdEOC;
   }
   else
   {
      return CmdOther;
   }
lab1:
   if (instr[0] > 'i') goto lab7;
   if (instr[0] > 'f') goto lab8;
   if (instr[0] != 'f') return CmdOther;
   if (instr[1] > 'c') goto lab9;
   if (
       instr[1] == 'c' &&
       instr[2] == 'o' &&
       instr[3] == 'u' &&
       instr[4] == 'n' &&
       instr[5] == 't' &&
       instr[6] == '\0'
      )
   {
      return CmdFcount;
   }
   else
   {
      return CmdOther;
   }
lab9:
   if (instr[1] != 'i') return CmdOther;
   if (instr[2] > 'e') goto lab10;
   if (
       instr[2] == 'e' &&
       instr[3] == 'l' &&
       instr[4] == 'd' &&
       instr[5] == '\0'
      )
   {
      return CmdField;
   }
   else
   {
      return CmdOther;
   }
lab10:
   if (
       instr[2] == 'r' &&
       instr[3] == 's' &&
       instr[4] == 't' &&
       instr[5] == '\0'
      )
   {
      return CmdFirst;
   }
   else
   {
      return CmdOther;
   }
lab8:
   if (
       instr[0] == 'i' &&
       instr[1] == 'n' &&
       instr[2] == 'c' &&
       instr[3] == 'r' &&
       instr[4] == '\0'
      )
   {
      return CmdIncr;
   }
   else
   {
      return CmdOther;
   }
lab7:
   if (instr[0] > 'k') goto lab11;
   if (
       instr[0] == 'k' &&
       instr[1] == 'e' &&
       instr[2] == 'y' &&
       instr[3] == '\0'
      )
   {
      return CmdKey;
   }
   else
   {
      return CmdOther;
   }
lab11:
   if (
       instr[0] == 'l' &&
       instr[1] == 'a' &&
       instr[2] == 's' &&
       instr[3] == 't' &&
       instr[4] == '\0'
      )
   {
      return CmdLast;
   }
   else
   {
      return CmdOther;
   }
lab0:
   if (instr[0] > 'p') goto lab12;
   if (instr[0] > 'n') goto lab13;
   if (instr[0] != 'n') return CmdOther;
   if (instr[1] != 'e') return CmdOther;
   if (instr[2] > 'w') goto lab14;
   if (
       instr[2] == 'w' &&
       instr[3] == '\0'
      )
   {
      return CmdNew;
   }
   else
   {
      return CmdOther;
   }
lab14:
   if (
       instr[2] == 'x' &&
       instr[3] == 't' &&
       instr[4] == '\0'
      )
   {
      return CmdNext;
   }
   else
   {
      return CmdOther;
   }
lab13:
   if (instr[0] > 'o') goto lab15;
   if (
       instr[0] == 'o' &&
       instr[1] == 'p' &&
       instr[2] == 'e' &&
       instr[3] == 'n' &&
       instr[4] == '\0'
      )
   {
      return CmdOpen;
   }
   else
   {
      return CmdOther;
   }
lab15:
   if (instr[0] != 'p') return CmdOther;
   if (instr[1] != 'r') return CmdOther;
   if (instr[2] > 'e') goto lab16;
   if (
       instr[2] == 'e' &&
       instr[3] == 'v' &&
       instr[4] == '\0'
      )
   {
      return CmdPrev;
   }
   else
   {
      return CmdOther;
   }
lab16:
   if (
       instr[2] == 'o' &&
       instr[3] == 'b' &&
       instr[4] == '\0'
      )
   {
      return CmdProb;
   }
   else
   {
      return CmdOther;
   }
lab12:
   if (instr[0] > 's') goto lab17;
   if (instr[0] > 'r') goto lab18;
   if (instr[0] != 'r') return CmdOther;
   if (instr[1] != 'e') return CmdOther;
   if (instr[2] > 'l') goto lab19;
   if (
       instr[2] == 'l' &&
       instr[3] == 'o' &&
       instr[4] == 'a' &&
       instr[5] == 'd' &&
       instr[6] == '\0'
      )
   {
      return CmdReload;
   }
   else
   {
      return CmdOther;
   }
lab19:
   if (instr[2] > 'o') goto lab20;
   if (
       instr[2] == 'o' &&
       instr[3] == 'p' &&
       instr[4] == 'e' &&
       instr[5] == 'n' &&
       instr[6] == '\0'
      )
   {
      return CmdReopen;
   }
   else
   {
      return CmdOther;
   }
lab20:
   if (instr[2] != 's') return CmdOther;
   if (instr[3] > 'e') goto lab21;
   if (
       instr[3] == 'e' &&
       instr[4] == 't' &&
       instr[5] == '\0'
      )
   {
      return CmdReset;
   }
   else
   {
      return CmdOther;
   }
lab21:
   if (
       instr[3] == 't' &&
       instr[4] == 'a' &&
       instr[5] == 'r' &&
       instr[6] == 't' &&
       instr[7] == '\0'
      )
   {
      return CmdRestart;
   }
   else
   {
      return CmdOther;
   }
lab18:
   if (instr[0] != 's') return CmdOther;
   if (instr[1] > 'a') goto lab22;
   if (
       instr[1] == 'a' &&
       instr[2] == 'v' &&
       instr[3] == 'e' &&
       instr[4] == '\0'
      )
   {
      return CmdSave;
   }
   else
   {
      return CmdOther;
   }
lab22:
   if (instr[1] > 'e') goto lab23;
   if (
       instr[1] == 'e' &&
       instr[2] == 't' &&
       instr[3] == '\0'
      )
   {
      return CmdSet;
   }
   else
   {
      return CmdOther;
   }
lab23:
   if (
       instr[1] == 't' &&
       instr[2] == 'a' &&
       instr[3] == 'r' &&
       instr[4] == 't' &&
       instr[5] == '\0'
      )
   {
      return CmdStart;
   }
   else
   {
      return CmdOther;
   }
lab17:
   if (instr[0] > 't') goto lab24;
   if (
       instr[0] == 't' &&
       instr[1] == 'e' &&
       instr[2] == 'l' &&
       instr[3] == 'l' &&
       instr[4] == '\0'
      )
   {
      return CmdTell;
   }
   else
   {
      return CmdOther;
   }
lab24:
   if (
       instr[0] == 'w' &&
       instr[1] == 'e' &&
       instr[2] == 'i' &&
       instr[3] == 'g' &&
       instr[4] == 'h' &&
       instr[5] == 't' &&
       instr[6] == '\0'
      )
   {
      return CmdWeight;
   }
   else
   {
      return CmdOther;
   }
}
