/*
**	Code derived from program prettyprint
**	Translated by ptc $Revision: 1.3 $
**	$Id: ptc.c 1.3 1991/03/09 20:57:47 gtoal Exp $
*/
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <ctype.h>
# include "ptcmain.h"
text	input = { stdin, 0, 0, 0, 0};
text	output = { stdout, 0, 0, 0, 1};
/*
**	Definitions for standard types
*/
typedef unsigned char	boolean;
# define false (boolean)0
# define true (boolean)1
static char	*Bools[] = { "false", "true" };
typedef int	integer;
# ifndef Unionoffs
# define Unionoffs(p, m) (((long)(&(p)->m))-((long)(p)))
# endif
# define Claimset() (void)Currset(0, (setptr)0)
# define Newset() Currset(1, (setptr)0)
# define Saveset(s) Currset(2, s)
# define setbits 31
typedef unsigned int	setword;
typedef setword *	setptr;
boolean	Member(unsigned int m, setptr sp),
	Le(setptr p1, setptr p2),
	Ge(setptr p1, setptr p2),
	Eq(setptr p1, setptr p2),
	Ne(setptr p1, setptr p2);
setptr	Union(setptr p1, setptr p2);
setptr	Diff(setptr p1, setptr p2);
setptr	Insmem(unsigned int m, setptr sp);
setptr	Mksubr(unsigned int lo, unsigned int hi, setptr sp);
setptr	Currset(int n, setptr sp);
setptr	Inter(setptr p1, setptr p2);
static setptr	Tmpset;
setptr	Conset[];
void	Setncpy(setptr S1, setptr S2, unsigned int N);
# ifndef SETALIGN
# define SETALIGN(x) Alignset((unsigned int *)(x))
struct Set { unsigned int	S[32+1]; } *Alignset(register unsigned int *Sp);
# endif
# ifndef STRALIGN
# define STRALIGN(x) Alignstr((unsigned char *)(x))
struct String { char	A[127+1]; } *Alignstr(register unsigned char *Cp);
# endif
/*
**	Start of program definitions
*/
# define maxsymbolsize 200
# define maxstacksize 100
# define maxkeylength 10
# define maxlinesize 90
# define slofail1 50
# define slofail2 70
# define indent1 3
# define indent2 1
# define space ' '
static unsigned char	keybefore[]	= "<b>";
static unsigned char	keyafter[]	= "</b>";
static unsigned char	numbefore[]	= "<font color =\"000080\">";
static unsigned char	numafter[]	= "</font>";
static unsigned char	commentbefore[]	= "<font color =\"408080\">";
static unsigned char	commentafter[]	= "</font>";
static unsigned char	stringbefore[]	= "<font color =\"FF0000\">";
static unsigned char	stringafter[]	= "</font>";
typedef enum { progsym, funcsym, procsym, labelsym,
  constsym, typesym, varsym, beginsym,
  repeatsym, recordsym, casesym, casevarsym,
  ofsym, forsym, whilesym, withsym,
  dosym, ifsym, thensym, elsesym,
  endsym, forwardsym, untilsym, becomes,
  opencomment, closecomment, semicolon, colon,
  coloncase, equals, openparen, closeparen,
  period, endoffile, othersym } 	keysymbol;
typedef enum { crsuppress, crbefore, markposition, firstindentbytab,
  blanklinebefore, dindentonkeys, dindent, dindentafter,
  spacebefore, spaceafter, gobblesymbols, indentbytab,
  indenttoclp, crbeforegobble, crnotbegin, crnotiforbegin,
  crafter } 	option;
typedef struct { setword	S[2]; }	optionset;
typedef struct { setword	S[3]; }	keysymset;
typedef struct S68 {
  optionset	optionsselected;
  keysymset	dindentsymbols;
  keysymset	gobbleterminators;
}	tableentry;
typedef struct { tableentry	A[35]; }	optiontable;
typedef struct { unsigned char	A[maxkeylength - 1 + 1]; }	key;
typedef struct { key	A[(int)(untilsym) + 1]; }	keywordtable;
typedef struct { unsigned char	A[2 - 1 + 1]; }	specialchar;
typedef struct { setword	S[2]; }	dblchrset;
typedef struct { specialchar	A[(int)(opencomment) - (int)(becomes) + 1]; }	dblchartable;
typedef struct { unsigned char	A[(int)(period) - (int)(opencomment) + 1]; }	sglchartable;
typedef struct { unsigned char	A[maxsymbolsize - 1 + 1]; }	Y1_string;
typedef struct S62 {
  keysymbol	name;
  Y1_string	valu;
  integer	length;
  integer	spacesbefore;
  integer	actualstartpos;
  integer	crsbefore;
}	Y2_symbol;
typedef struct S62 *	symbolinfo;
typedef enum { letter, digit, blank, quote,
  endofline, filemark, otherchar } 	charname;
typedef struct S67 {
  integer	actuallinepos;
  charname	name;
  unsigned char	valu;
}	charinfo;
typedef struct  {
  keysymbol	indentsymbol;
  integer	prevmargin;
  integer	actualstartpos;
}	stackentry;
typedef struct { stackentry	A[maxstacksize - 1 + 1]; }	symbolstack;
boolean	recordseen;
boolean	formattingrequired;
charinfo	currchar, nextchar;
symbolinfo	currsym, nextsym;
boolean	crpending;
optiontable	ppoption;
keywordtable	keyword;
dblchrset	dblchars;
dblchartable	dblchar;
sglchartable	sglchar;
symbolstack	stack;
integer	top;
keysymbol	lastsymbolpoppedfromstack;
integer	startpos, currlinepos, lastlinestartpos, thislinestartpos, currmargin;
integer	decidlength;
boolean	indecsection;
boolean	gobbling;
integer	gobblestart;
integer	gobbleoffset;

 void
C58_getchar(nextchar, currchar)
  charinfo	*nextchar;
  charinfo	*currchar;
{
  (*currchar) = (*nextchar);
  {
    register struct S67 *W3 = &(*nextchar);

    if (Eofx(input))
      W3->name = filemark;
    else
      if (Eoln(input))
	W3->name = endofline;
      else
	if (Member((unsigned)(Bufx(input)), Conset[0]))
	  W3->name = letter;
	else
	  if (Member((unsigned)(Bufx(input)), Conset[1]))
	    W3->name = digit;
	  else
	    if (Bufx(input) == '\'')
	      W3->name = quote;
	    else
	      if (Bufx(input) == space)
		W3->name = blank;
	      else
		W3->name = otherchar;
    if (Member((unsigned)(W3->name), Conset[2])) {
      thislinestartpos = 0;
      W3->actuallinepos = 0;
      W3->valu = space;
    } else {
      W3->actuallinepos = ((W3->actuallinepos)+1);
      W3->valu = Bufx(input);
    }
    if (W3->name != filemark)
      Getx(input);
  }
}

 void
storenextchar(length, currchar, nextchar, valu)
  integer	*length;
  charinfo	*currchar, *nextchar;
  Y1_string	*valu;
{
  C58_getchar(&(*nextchar), &(*currchar));
  if ((*length) < maxsymbolsize) {
    (*length) = (*length) + 1;
    (*valu).A[(*length) - 1] = (*currchar).valu;
  }
}

 void
skipspaces(currchar, nextchar, spacesbefore, crsbefore)
  charinfo	*currchar, *nextchar;
  integer	*spacesbefore, *crsbefore;
{
  (*spacesbefore) = 0;
  (*crsbefore) = 0;
  while (Member((unsigned)((*nextchar).name), Conset[3])) {
    C58_getchar(&(*nextchar), &(*currchar));
    switch ((int)((*currchar).name)) {
      case blank:
      (*spacesbefore) = (*spacesbefore) + 1;
      break ;
      case endofline:
      (*crsbefore) = (*crsbefore) + 1;
      (*spacesbefore) = 0;
      break ;
      default:
      PTCerror(PTC_E_CASE, __LINE__, 0, 0, 0);
    }
  }
}

 void
checkfordirective(valu)
  Y1_string	valu;
{
  unsigned char	start;
  integer	num;
  integer	index;

  if ((valu.A[1 - 1] == '{') && (valu.A[2 - 1] == '$'))
    start = 3;
  else
    if ((valu.A[1 - 1] == '(') && (valu.A[2 - 1] == '*') && (valu.A[3 - 1] == '$'))
      start = 4;
    else
      start = 1;
  if (((int)(start) > 1) && (Member((unsigned)(valu.A[start - 1]), Conset[4])))
    switch ((int)(valu.A[start - 1])) {
      case 'P':
      if (valu.A[(int)(start) + 1 - 1] == '+')
	formattingrequired = true;
      else
	if (valu.A[(int)(start) + 1 - 1] == '-')
	  formattingrequired = false;
      break ;
      case 'A':
      num = 0;
      index = (int)(start) + 1;
      while (Member((unsigned)(valu.A[index - 1]), Conset[5])) {
	num = num * 10 + ((unsigned)(valu.A[index - 1]) - (unsigned)('0'));
	index = index + 1;
      }
      decidlength = num;
      break ;
      default:
      PTCerror(PTC_E_CASE, __LINE__, 0, 0, 0);
    }
}

 void
getcomment(currchar, nextchar, name, valu, actualstartpos, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*actualstartpos;
  integer	*length;
{
  unsigned char	i;
  unsigned char	from;

  (*name) = opencomment;
  while (!((((*currchar).valu == '*') && ((*nextchar).valu == ')')) || ((*currchar).valu == '}') || ((*nextchar).name == endofline) || ((*nextchar).name == filemark)))
    storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
  if (((*currchar).valu == '}') || (((*currchar).valu == '*') && ((*nextchar).valu == ')'))) {
    if (((*currchar).valu == '*') && ((*nextchar).valu == ')'))
      storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
    (*name) = closecomment;
  }
}

 keysymbol
idtype(valu, length)
  Y1_string	valu;
  integer	length;
{
  register keysymbol	R63;
  register integer	i;
  key	keyvalu;
  boolean	hit;
  keysymbol	thiskey;

  R63 = othersym;
  if (length <= maxkeylength) {
    {
      integer	B4 = 1,
      	B5 = length;

      if (B4 <= B5)
	for (i = B4; ; i++) {
	  if (Member((unsigned)(valu.A[i - 1]), Conset[6]))
	    keyvalu.A[i - 1] = valu.A[i - 1];
	  else
	    keyvalu.A[i - 1] = ((unsigned)(valu.A[i - 1]) - (unsigned)('a')) + (unsigned)('A');
	  if (i == B5) break;
	}
    }
    {
      integer	B6 = length + 1,
      	B7 = maxkeylength;

      if (B6 <= B7)
	for (i = B6; ; i++) {
	  keyvalu.A[i - 1] = space;
	  if (i == B7) break;
	}
    }
    thiskey = progsym;
    hit = false;
    while (!(hit || (thiskey == ((keysymbol)((int)(untilsym)+1)))))
      if (Cmpstr(keyvalu.A, keyword.A[(int)(thiskey)].A) == 0)
	hit = true;
      else
	thiskey = ((keysymbol)((int)(thiskey)+1));
    if (hit)
      R63 = thiskey;
  }
  return R63;
}

 void
getidentifier(currchar, nextchar, name, valu, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*length;
{
  while (Member((unsigned)((*nextchar).name), Conset[7]))
    storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
  (*name) = idtype((*valu), (*length));
  if (Member((unsigned)((*name)), Conset[8]))
    switch ((int)((*name))) {
      case recordsym:
      recordseen = true;
      break ;
      case casesym:
      if (recordseen)
	(*name) = casevarsym;
      break ;
      case endsym:
      recordseen = false;
      break ;
      default:
      PTCerror(PTC_E_CASE, __LINE__, 0, 0, 0);
    }
}

 void
getnumber(currchar, nextchar, name, valu, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*length;
{
  while ((*nextchar).name == digit)
    storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
  (*name) = othersym;
}

 void
getcharliteral(currchar, nextchar, name, valu, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*length;
{
  while ((*nextchar).name == quote) {
    storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
    while (!(Member((unsigned)((*nextchar).name), Conset[9])))
      storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
    if ((*nextchar).name == quote)
      storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
  }
  (*name) = othersym;
}

 keysymbol
chartype(currchar, nextchar)
  charinfo	currchar, nextchar;
{
  register keysymbol	R64;
  specialchar	nexttwochars;
  boolean	hit;
  keysymbol	thischar;

  nexttwochars.A[1 - 1] = currchar.valu;
  nexttwochars.A[2 - 1] = nextchar.valu;
  thischar = becomes;
  hit = false;
  while (!(hit || (thischar == closecomment)))
    if (Cmpstr(nexttwochars.A, dblchar.A[(int)(thischar) - (int)(becomes)].A) == 0)
      hit = true;
    else
      thischar = ((keysymbol)((int)(thischar)+1));
  if (!hit) {
    thischar = opencomment;
    while (!(hit || (((keysymbol)((int)(thischar)-1)) == period)))
      if (currchar.valu == sglchar.A[(int)(thischar) - (int)(opencomment)])
	hit = true;
      else
	thischar = ((keysymbol)((int)(thischar)+1));
  }
  if (hit) {
    if ((thischar == colon) && (stack.A[top - 1].indentsymbol == casesym))
      thischar = coloncase;
    R64 = thischar;
  } else
    R64 = othersym;
  return R64;
}

 void
getspecialchar(currchar, nextchar, name, valu, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*length;
{
  storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
  (*name) = chartype((*currchar), (*nextchar));
  if ((Member((unsigned)((*name)), dblchars.S)) && !(Member((unsigned)((*currchar).valu), Conset[10])))
    storenextchar(&(*length), &(*currchar), &(*nextchar), &(*valu));
}

 void
getnextsymbol(currchar, nextchar, name, valu, actualstartpos, length)
  charinfo	*currchar, *nextchar;
  keysymbol	*name;
  Y1_string	*valu;
  integer	*actualstartpos;
  integer	*length;
{
  (*actualstartpos) = (*nextchar).actuallinepos;
  switch ((int)((*nextchar).name)) {
    case letter:
    getidentifier(&(*currchar), &(*nextchar), &(*name), &(*valu), &(*length));
    break ;
    case digit:
    getnumber(&(*currchar), &(*nextchar), &(*name), &(*valu), &(*length));
    break ;
    case quote:
    getcharliteral(&(*currchar), &(*nextchar), &(*name), &(*valu), &(*length));
    break ;
    case otherchar:
    getspecialchar(&(*currchar), &(*nextchar), &(*name), &(*valu), &(*length));
    if ((*name) == opencomment)
      getcomment(&(*currchar), &(*nextchar), &(*name), &(*valu), &(*actualstartpos), &(*length));
    break ;
    case filemark:
    (*name) = endoffile;
    break ;
    default:
    PTCerror(PTC_E_CASE, __LINE__, 0, 0, 0);
  }
}

 void
getsymbol(nextsym, currsym)
  symbolinfo	*nextsym;
  symbolinfo	*currsym;
{
  symbolinfo	dummy;
  register integer	index;

  dummy = (*currsym);
  (*currsym) = (*nextsym);
  (*nextsym) = dummy;
  if ((*(*currsym)).crsbefore > 0)
    thislinestartpos = (*(*currsym)).spacesbefore;
  if (lastlinestartpos == 0)
    lastlinestartpos = thislinestartpos;
  {
    register struct S62 *W8 = &(*(*nextsym));

    skipspaces(&currchar, &nextchar, &W8->spacesbefore, &W8->crsbefore);
    W8->length = 0;
    if ((*(*currsym)).name == opencomment)
      getcomment(&currchar, &nextchar, &W8->name, &W8->valu, &W8->actualstartpos, &W8->length);
    else
      getnextsymbol(&currchar, &nextchar, &W8->name, &W8->valu, &W8->actualstartpos, &W8->length);
  }
  if (indecsection && ((*(*currsym)).name == othersym) && (Member((unsigned)((*(*nextsym)).name), Conset[11]))) {
    if (((*(*currsym)).length < decidlength) && (decidlength > 0)) {
      {
	integer	B9 = (*(*currsym)).length + 1,
		B10 = decidlength;

	if (B9 <= B10)
	  for (index = B9; ; index++) {
	    (*(*currsym)).valu.A[index - 1] = ' ';
	    if (index == B10) break;
	  }
      }
      (*(*currsym)).length = decidlength;
      (*(*nextsym)).spacesbefore = 1;
    }
  }
}

 void
initialise(topofstack, currlinepos, currmargin, keyword, dblchars, dblchar, sglchar, recordseen, currchar, nextchar, currsym, nextsym, ppoption)
  integer	*topofstack;
  integer	*currlinepos, *currmargin;
  keywordtable	*keyword;
  dblchrset	*dblchars;
  dblchartable	*dblchar;
  sglchartable	*sglchar;
  boolean	*recordseen;
  charinfo	*currchar, *nextchar;
  symbolinfo	*currsym, *nextsym;
  optiontable	*ppoption;
{
  (*topofstack) = 0;
  (*currlinepos) = 0;
  (*currmargin) = 0;
  gobbling = false;
  thislinestartpos = 0;
  lastlinestartpos = 0;
  lastsymbolpoppedfromstack = othersym;
  decidlength = 10;
  formattingrequired = true;
  (void)strncpy((char *)(*keyword).A[(int)(progsym)].A, "PROGRAM   ", sizeof((*keyword).A[(int)(progsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(funcsym)].A, "FUNCTION  ", sizeof((*keyword).A[(int)(funcsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(procsym)].A, "PROCEDURE ", sizeof((*keyword).A[(int)(procsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(labelsym)].A, "LABEL     ", sizeof((*keyword).A[(int)(labelsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(constsym)].A, "CONST     ", sizeof((*keyword).A[(int)(constsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(typesym)].A, "TYPE      ", sizeof((*keyword).A[(int)(typesym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(varsym)].A, "VAR       ", sizeof((*keyword).A[(int)(varsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(beginsym)].A, "BEGIN     ", sizeof((*keyword).A[(int)(beginsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(repeatsym)].A, "REPEAT    ", sizeof((*keyword).A[(int)(repeatsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(recordsym)].A, "RECORD    ", sizeof((*keyword).A[(int)(recordsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(casesym)].A, "CASE      ", sizeof((*keyword).A[(int)(casesym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(casevarsym)].A, "CASE      ", sizeof((*keyword).A[(int)(casevarsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(ofsym)].A, "OF        ", sizeof((*keyword).A[(int)(ofsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(forsym)].A, "FOR       ", sizeof((*keyword).A[(int)(forsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(whilesym)].A, "WHILE     ", sizeof((*keyword).A[(int)(whilesym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(withsym)].A, "WITH      ", sizeof((*keyword).A[(int)(withsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(dosym)].A, "DO        ", sizeof((*keyword).A[(int)(dosym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(ifsym)].A, "IF        ", sizeof((*keyword).A[(int)(ifsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(thensym)].A, "THEN      ", sizeof((*keyword).A[(int)(thensym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(elsesym)].A, "ELSE      ", sizeof((*keyword).A[(int)(elsesym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(endsym)].A, "END       ", sizeof((*keyword).A[(int)(endsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(forwardsym)].A, "FORWARD   ", sizeof((*keyword).A[(int)(forwardsym)].A));
  (void)strncpy((char *)(*keyword).A[(int)(untilsym)].A, "UNTIL     ", sizeof((*keyword).A[(int)(untilsym)].A));
  Setncpy((*dblchars).S, Conset[12], sizeof((*dblchars).S));
  (void)strncpy((char *)(*dblchar).A[(int)(becomes) - (int)(becomes)].A, ":=", sizeof((*dblchar).A[(int)(becomes) - (int)(becomes)].A));
  (void)strncpy((char *)(*dblchar).A[(int)(opencomment) - (int)(becomes)].A, "(*", sizeof((*dblchar).A[(int)(opencomment) - (int)(becomes)].A));
  (*sglchar).A[(int)(opencomment) - (int)(opencomment)] = '{';
  (*sglchar).A[(int)(closecomment) - (int)(opencomment)] = '}';
  (*sglchar).A[(int)(semicolon) - (int)(opencomment)] = ';';
  (*sglchar).A[(int)(colon) - (int)(opencomment)] = ':';
  (*sglchar).A[(int)(coloncase) - (int)(opencomment)] = ':';
  (*sglchar).A[(int)(equals) - (int)(opencomment)] = '=';
  (*sglchar).A[(int)(openparen) - (int)(opencomment)] = '(';
  (*sglchar).A[(int)(closeparen) - (int)(opencomment)] = ')';
  (*sglchar).A[(int)(period) - (int)(opencomment)] = '.';
  (*recordseen) = false;
  C58_getchar(&(*nextchar), &(*currchar));
  (*currsym) = (struct S62 *)malloc((unsigned)(sizeof(*(*currsym))));
  (*nextsym) = (struct S62 *)malloc((unsigned)(sizeof(*(*nextsym))));
  getsymbol(&(*nextsym), &(*currsym));
  {
    register struct S68 *W11 = &(*ppoption).A[(int)(progsym)];

    Setncpy(W11->optionsselected.S, Conset[13], sizeof(W11->optionsselected.S));
    Setncpy(W11->dindentsymbols.S, Conset[14], sizeof(W11->dindentsymbols.S));
    Setncpy(W11->gobbleterminators.S, Conset[15], sizeof(W11->gobbleterminators.S));
  }
  {
    register struct S68 *W12 = &(*ppoption).A[(int)(funcsym)];

    Setncpy(W12->optionsselected.S, Conset[16], sizeof(W12->optionsselected.S));
    Setncpy(W12->dindentsymbols.S, Conset[17], sizeof(W12->dindentsymbols.S));
    Setncpy(W12->gobbleterminators.S, Conset[18], sizeof(W12->gobbleterminators.S));
  }
  {
    register struct S68 *W13 = &(*ppoption).A[(int)(procsym)];

    Setncpy(W13->optionsselected.S, Conset[19], sizeof(W13->optionsselected.S));
    Setncpy(W13->dindentsymbols.S, Conset[20], sizeof(W13->dindentsymbols.S));
    Setncpy(W13->gobbleterminators.S, Conset[21], sizeof(W13->gobbleterminators.S));
  }
  {
    register struct S68 *W14 = &(*ppoption).A[(int)(labelsym)];

    Setncpy(W14->optionsselected.S, Conset[22], sizeof(W14->optionsselected.S));
    Setncpy(W14->dindentsymbols.S, Conset[23], sizeof(W14->dindentsymbols.S));
    Setncpy(W14->gobbleterminators.S, Conset[24], sizeof(W14->gobbleterminators.S));
  }
  {
    register struct S68 *W15 = &(*ppoption).A[(int)(constsym)];

    Setncpy(W15->optionsselected.S, Conset[25], sizeof(W15->optionsselected.S));
    Setncpy(W15->dindentsymbols.S, Conset[26], sizeof(W15->dindentsymbols.S));
    Setncpy(W15->gobbleterminators.S, Conset[27], sizeof(W15->gobbleterminators.S));
  }
  {
    register struct S68 *W16 = &(*ppoption).A[(int)(typesym)];

    Setncpy(W16->optionsselected.S, Conset[28], sizeof(W16->optionsselected.S));
    Setncpy(W16->dindentsymbols.S, Conset[29], sizeof(W16->dindentsymbols.S));
    Setncpy(W16->gobbleterminators.S, Conset[30], sizeof(W16->gobbleterminators.S));
  }
  {
    register struct S68 *W17 = &(*ppoption).A[(int)(varsym)];

    Setncpy(W17->optionsselected.S, Conset[31], sizeof(W17->optionsselected.S));
    Setncpy(W17->dindentsymbols.S, Conset[32], sizeof(W17->dindentsymbols.S));
    Setncpy(W17->gobbleterminators.S, Conset[33], sizeof(W17->gobbleterminators.S));
  }
  {
    register struct S68 *W18 = &(*ppoption).A[(int)(beginsym)];

    Setncpy(W18->optionsselected.S, Conset[34], sizeof(W18->optionsselected.S));
    Setncpy(W18->dindentsymbols.S, Conset[35], sizeof(W18->dindentsymbols.S));
    Setncpy(W18->gobbleterminators.S, Conset[36], sizeof(W18->gobbleterminators.S));
  }
  {
    register struct S68 *W19 = &(*ppoption).A[(int)(repeatsym)];

    Setncpy(W19->optionsselected.S, Conset[37], sizeof(W19->optionsselected.S));
    Setncpy(W19->dindentsymbols.S, Conset[38], sizeof(W19->dindentsymbols.S));
    Setncpy(W19->gobbleterminators.S, Conset[39], sizeof(W19->gobbleterminators.S));
  }
  {
    register struct S68 *W20 = &(*ppoption).A[(int)(recordsym)];

    Setncpy(W20->optionsselected.S, Conset[40], sizeof(W20->optionsselected.S));
    Setncpy(W20->dindentsymbols.S, Conset[41], sizeof(W20->dindentsymbols.S));
    Setncpy(W20->gobbleterminators.S, Conset[42], sizeof(W20->gobbleterminators.S));
  }
  {
    register struct S68 *W21 = &(*ppoption).A[(int)(casesym)];

    Setncpy(W21->optionsselected.S, Conset[43], sizeof(W21->optionsselected.S));
    Setncpy(W21->dindentsymbols.S, Conset[44], sizeof(W21->dindentsymbols.S));
    Setncpy(W21->gobbleterminators.S, Conset[45], sizeof(W21->gobbleterminators.S));
  }
  {
    register struct S68 *W22 = &(*ppoption).A[(int)(casevarsym)];

    Setncpy(W22->optionsselected.S, Conset[46], sizeof(W22->optionsselected.S));
    Setncpy(W22->dindentsymbols.S, Conset[47], sizeof(W22->dindentsymbols.S));
    Setncpy(W22->gobbleterminators.S, Conset[48], sizeof(W22->gobbleterminators.S));
  }
  {
    register struct S68 *W23 = &(*ppoption).A[(int)(ofsym)];

    Setncpy(W23->optionsselected.S, Conset[49], sizeof(W23->optionsselected.S));
    Setncpy(W23->dindentsymbols.S, Conset[50], sizeof(W23->dindentsymbols.S));
    Setncpy(W23->gobbleterminators.S, Conset[51], sizeof(W23->gobbleterminators.S));
  }
  {
    register struct S68 *W24 = &(*ppoption).A[(int)(forsym)];

    Setncpy(W24->optionsselected.S, Conset[52], sizeof(W24->optionsselected.S));
    Setncpy(W24->dindentsymbols.S, Conset[53], sizeof(W24->dindentsymbols.S));
    Setncpy(W24->gobbleterminators.S, Conset[54], sizeof(W24->gobbleterminators.S));
  }
  {
    register struct S68 *W25 = &(*ppoption).A[(int)(whilesym)];

    Setncpy(W25->optionsselected.S, Conset[55], sizeof(W25->optionsselected.S));
    Setncpy(W25->dindentsymbols.S, Conset[56], sizeof(W25->dindentsymbols.S));
    Setncpy(W25->gobbleterminators.S, Conset[57], sizeof(W25->gobbleterminators.S));
  }
  {
    register struct S68 *W26 = &(*ppoption).A[(int)(withsym)];

    Setncpy(W26->optionsselected.S, Conset[58], sizeof(W26->optionsselected.S));
    Setncpy(W26->dindentsymbols.S, Conset[59], sizeof(W26->dindentsymbols.S));
    Setncpy(W26->gobbleterminators.S, Conset[60], sizeof(W26->gobbleterminators.S));
  }
  {
    register struct S68 *W27 = &(*ppoption).A[(int)(dosym)];

    Setncpy(W27->optionsselected.S, Conset[61], sizeof(W27->optionsselected.S));
    Setncpy(W27->dindentsymbols.S, Conset[62], sizeof(W27->dindentsymbols.S));
    Setncpy(W27->gobbleterminators.S, Conset[63], sizeof(W27->gobbleterminators.S));
  }
  {
    register struct S68 *W28 = &(*ppoption).A[(int)(ifsym)];

    Setncpy(W28->optionsselected.S, Conset[64], sizeof(W28->optionsselected.S));
    Setncpy(W28->dindentsymbols.S, Conset[65], sizeof(W28->dindentsymbols.S));
    Setncpy(W28->gobbleterminators.S, Conset[66], sizeof(W28->gobbleterminators.S));
  }
  {
    register struct S68 *W29 = &(*ppoption).A[(int)(thensym)];

    Setncpy(W29->optionsselected.S, Conset[67], sizeof(W29->optionsselected.S));
    Setncpy(W29->dindentsymbols.S, Conset[68], sizeof(W29->dindentsymbols.S));
    Setncpy(W29->gobbleterminators.S, Conset[69], sizeof(W29->gobbleterminators.S));
  }
  {
    register struct S68 *W30 = &(*ppoption).A[(int)(elsesym)];

    Setncpy(W30->optionsselected.S, Conset[70], sizeof(W30->optionsselected.S));
    Setncpy(W30->dindentsymbols.S, Conset[71], sizeof(W30->dindentsymbols.S));
    Setncpy(W30->gobbleterminators.S, Conset[72], sizeof(W30->gobbleterminators.S));
  }
  {
    register struct S68 *W31 = &(*ppoption).A[(int)(endsym)];

    Setncpy(W31->optionsselected.S, Conset[73], sizeof(W31->optionsselected.S));
    Setncpy(W31->dindentsymbols.S, Conset[74], sizeof(W31->dindentsymbols.S));
    Setncpy(W31->gobbleterminators.S, Conset[75], sizeof(W31->gobbleterminators.S));
  }
  {
    register struct S68 *W32 = &(*ppoption).A[(int)(forwardsym)];

    Setncpy(W32->optionsselected.S, Conset[76], sizeof(W32->optionsselected.S));
    Setncpy(W32->dindentsymbols.S, Conset[77], sizeof(W32->dindentsymbols.S));
    Setncpy(W32->gobbleterminators.S, Conset[78], sizeof(W32->gobbleterminators.S));
  }
  {
    register struct S68 *W33 = &(*ppoption).A[(int)(untilsym)];

    Setncpy(W33->optionsselected.S, Conset[79], sizeof(W33->optionsselected.S));
    Setncpy(W33->dindentsymbols.S, Conset[80], sizeof(W33->dindentsymbols.S));
    Setncpy(W33->gobbleterminators.S, Conset[81], sizeof(W33->gobbleterminators.S));
  }
  {
    register struct S68 *W34 = &(*ppoption).A[(int)(becomes)];

    Setncpy(W34->optionsselected.S, Conset[82], sizeof(W34->optionsselected.S));
    Setncpy(W34->dindentsymbols.S, Conset[83], sizeof(W34->dindentsymbols.S));
    Setncpy(W34->gobbleterminators.S, Conset[84], sizeof(W34->gobbleterminators.S));
  }
  {
    register struct S68 *W35 = &(*ppoption).A[(int)(opencomment)];

    Setncpy(W35->optionsselected.S, Conset[85], sizeof(W35->optionsselected.S));
    Setncpy(W35->dindentsymbols.S, Conset[86], sizeof(W35->dindentsymbols.S));
    Setncpy(W35->gobbleterminators.S, Conset[87], sizeof(W35->gobbleterminators.S));
  }
  {
    register struct S68 *W36 = &(*ppoption).A[(int)(closecomment)];

    Setncpy(W36->optionsselected.S, Conset[88], sizeof(W36->optionsselected.S));
    Setncpy(W36->dindentsymbols.S, Conset[89], sizeof(W36->dindentsymbols.S));
    Setncpy(W36->gobbleterminators.S, Conset[90], sizeof(W36->gobbleterminators.S));
  }
  {
    register struct S68 *W37 = &(*ppoption).A[(int)(semicolon)];

    Setncpy(W37->optionsselected.S, Conset[91], sizeof(W37->optionsselected.S));
    Setncpy(W37->dindentsymbols.S, Conset[92], sizeof(W37->dindentsymbols.S));
    Setncpy(W37->gobbleterminators.S, Conset[93], sizeof(W37->gobbleterminators.S));
  }
  {
    register struct S68 *W38 = &(*ppoption).A[(int)(colon)];

    Setncpy(W38->optionsselected.S, Conset[94], sizeof(W38->optionsselected.S));
    Setncpy(W38->dindentsymbols.S, Conset[95], sizeof(W38->dindentsymbols.S));
    Setncpy(W38->gobbleterminators.S, Conset[96], sizeof(W38->gobbleterminators.S));
  }
  {
    register struct S68 *W39 = &(*ppoption).A[(int)(coloncase)];

    Setncpy(W39->optionsselected.S, Conset[97], sizeof(W39->optionsselected.S));
    Setncpy(W39->dindentsymbols.S, Conset[98], sizeof(W39->dindentsymbols.S));
    Setncpy(W39->gobbleterminators.S, Conset[99], sizeof(W39->gobbleterminators.S));
  }
  {
    register struct S68 *W40 = &(*ppoption).A[(int)(equals)];

    Setncpy(W40->optionsselected.S, Conset[100], sizeof(W40->optionsselected.S));
    Setncpy(W40->dindentsymbols.S, Conset[101], sizeof(W40->dindentsymbols.S));
    Setncpy(W40->gobbleterminators.S, Conset[102], sizeof(W40->gobbleterminators.S));
  }
  {
    register struct S68 *W41 = &(*ppoption).A[(int)(openparen)];

    Setncpy(W41->optionsselected.S, Conset[103], sizeof(W41->optionsselected.S));
    Setncpy(W41->dindentsymbols.S, Conset[104], sizeof(W41->dindentsymbols.S));
    Setncpy(W41->gobbleterminators.S, Conset[105], sizeof(W41->gobbleterminators.S));
  }
  {
    register struct S68 *W42 = &(*ppoption).A[(int)(closeparen)];

    Setncpy(W42->optionsselected.S, Conset[106], sizeof(W42->optionsselected.S));
    Setncpy(W42->dindentsymbols.S, Conset[107], sizeof(W42->dindentsymbols.S));
    Setncpy(W42->gobbleterminators.S, Conset[108], sizeof(W42->gobbleterminators.S));
  }
  {
    register struct S68 *W43 = &(*ppoption).A[(int)(period)];

    Setncpy(W43->optionsselected.S, Conset[109], sizeof(W43->optionsselected.S));
    Setncpy(W43->dindentsymbols.S, Conset[110], sizeof(W43->dindentsymbols.S));
    Setncpy(W43->gobbleterminators.S, Conset[111], sizeof(W43->gobbleterminators.S));
  }
  {
    register struct S68 *W44 = &(*ppoption).A[(int)(endoffile)];

    Setncpy(W44->optionsselected.S, Conset[112], sizeof(W44->optionsselected.S));
    Setncpy(W44->dindentsymbols.S, Conset[113], sizeof(W44->dindentsymbols.S));
    Setncpy(W44->gobbleterminators.S, Conset[114], sizeof(W44->gobbleterminators.S));
  }
  {
    register struct S68 *W45 = &(*ppoption).A[(int)(othersym)];

    Setncpy(W45->optionsselected.S, Conset[115], sizeof(W45->optionsselected.S));
    Setncpy(W45->dindentsymbols.S, Conset[116], sizeof(W45->dindentsymbols.S));
    Setncpy(W45->gobbleterminators.S, Conset[117], sizeof(W45->gobbleterminators.S));
  }
}

 boolean
stackempty()
{
  register boolean	R65;

  if (top == 0)
    R65 = true;
  else
    R65 = false;
  return R65;
}

 boolean
stackfull()
{
  register boolean	R66;

  if (top == maxstacksize)
    R66 = true;
  else
    R66 = false;
  return R66;
}

 void
popstack(indentsymbol, actualstartpos, prevmargin)
  keysymbol	*indentsymbol;
  integer	*actualstartpos;
  integer	*prevmargin;
{
  if (!stackempty()) {
    (*indentsymbol) = stack.A[top - 1].indentsymbol;
    (*prevmargin) = stack.A[top - 1].prevmargin;
    (*actualstartpos) = stack.A[top - 1].actualstartpos;
    lastsymbolpoppedfromstack = (*indentsymbol);
    top = top - 1;
  } else {
    (*indentsymbol) = othersym;
    (*prevmargin) = 0;
  }
}

 void
pushstack(indentsymbol, actualstartpos, prevmargin)
  keysymbol	indentsymbol;
  integer	actualstartpos;
  integer	prevmargin;
{
  top = top + 1;
  stack.A[top - 1].indentsymbol = indentsymbol;
  stack.A[top - 1].prevmargin = prevmargin;
  stack.A[top - 1].actualstartpos = actualstartpos;
}

 void
writecrs(numberofcrs, currlinepos)
  integer	numberofcrs;
  integer	*currlinepos;
{
  register integer	i;

  if (numberofcrs > 0) {
    {
      integer	B46 = 1,
      	B47 = numberofcrs;

      if (B46 <= B47)
	for (i = B46; ; i++) {
	  Putchr('\n', output);
	  if (i == B47) break;
	}
    }
    (*currlinepos) = 0;
  }
}

 void
insertcr(currsym)
  symbolinfo	*currsym;
{
# define X48_once 1

  if ((*(*currsym)).crsbefore == 0) {
    writecrs(X48_once, &currlinepos);
    (*(*currsym)).spacesbefore = 0;
  }
# undef X48_once
}

 void
insertblankline(currsym)
  symbolinfo	*currsym;
{
# define X49_once 1
# define twice 2

  if ((*(*currsym)).crsbefore == 0) {
    if (currlinepos == 0)
      writecrs(X49_once, &currlinepos);
    else
      writecrs(twice, &currlinepos);
    (*(*currsym)).spacesbefore = 0;
  } else
    if ((*(*currsym)).crsbefore == 1)
      if (currlinepos > 0)
	writecrs(X49_once, &currlinepos);
# undef X49_once
# undef twice
}

 void
lshifton(dindentsymbols)
  keysymset	dindentsymbols;
{
  keysymbol	indentsymbol;
  integer	actualstartpos;
  Y2_symbol	msg;
  integer	prevmargin;

  if (!stackempty()) {
    do {
      popstack(&indentsymbol, &actualstartpos, &prevmargin);
      if (Member((unsigned)(indentsymbol), dindentsymbols.S)) {
	currmargin = prevmargin;
	lastlinestartpos = 0;
	thislinestartpos = 0;
      }
    } while (!(!(Member((unsigned)(indentsymbol), dindentsymbols.S)) || (stackempty())));
    if (!(Member((unsigned)(indentsymbol), dindentsymbols.S)))
      pushstack(indentsymbol, actualstartpos, prevmargin);
  }
}

 void
lshift()
{
  keysymbol	indentsymbol;
  integer	actualstartpos;
  Y2_symbol	msg;
  integer	prevmargin;

  if (!stackempty()) {
    popstack(&indentsymbol, &actualstartpos, &prevmargin);
    currmargin = prevmargin;
    lastlinestartpos = 0;
    thislinestartpos = 0;
  }
}

 void
insertspace(symbol)
  symbolinfo	*symbol;
{
  if (currlinepos < maxlinesize) {
    Putchr(space, output);
    currlinepos = currlinepos + 1;
    {
      register struct S62 *W50 = &(*(*symbol));

      if ((W50->crsbefore == 0) && (W50->spacesbefore > 0))
	W50->spacesbefore = W50->spacesbefore - 1;
    }
  }
}

 void
movelinepos(newlinepos, currlinepos)
  integer	newlinepos;
  integer	*currlinepos;
{
  register integer	i;

  {
    integer	B51 = (*currlinepos) + 1,
    	B52 = newlinepos;

    if (B51 <= B52)
      for (i = B51; ; i++) {
	Putchr(space, output);
	if (i == B52) break;
      }
  }
  (*currlinepos) = newlinepos;
}

 void
printsymbol(currsym, currlinepos)
  symbolinfo	currsym;
  integer	*currlinepos;
{
  register integer	i;
  boolean	num;
  boolean	extrakey;
  boolean	string;

  num = false;
  extrakey = false;
  string = false;
  {
    register struct S62 *W53 = &(*currsym);

    switch ((int)(W53->name)) {
      case progsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case labelsym:
      break ;
      case beginsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case casesym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case forsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case ifsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case endsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case becomes:
      break ;
      case semicolon:
      break ;
      case openparen:
      break ;
      case endoffile:
      break ;
      case othersym:
      if (Member((unsigned)(W53->valu.A[1 - 1]), Conset[118])) {
	num = true;
	(void)fprintf(output.fp, "%s", numbefore), Putl(output, 0);
      } else
	if (W53->valu.A[1 - 1] == '\'') {
	  string = true;
	  (void)fprintf(output.fp, "%s", stringbefore), Putl(output, 0);
	}
      break ;
      case funcsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case constsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case repeatsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case casevarsym:
      break ;
      case whilesym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case thensym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case forwardsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case opencomment:
      (void)fprintf(output.fp, "%s", commentbefore), Putl(output, 0);
      break ;
      case colon:
      break ;
      case closeparen:
      break ;
      case procsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case typesym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case recordsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case ofsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case withsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case elsesym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case untilsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case closecomment:
      (void)fprintf(output.fp, "%s", commentbefore), Putl(output, 0);
      break ;
      case coloncase:
      break ;
      case period:
      break ;
      case varsym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case dosym:
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
      break ;
      case equals:
      break ;
      default:
      ;
    }
    if ((W53->length == 2) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[119])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[120]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 2) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[121])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[122]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 2) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[123])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[124]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 3) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[125])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[126])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[127]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 3) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[128])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[129])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[130]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 3) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[131])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[132])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[133]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 4) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[134])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[135])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[136])) && (Member((unsigned)(W53->valu.A[4 - 1]), Conset[137]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 5) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[138])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[139])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[140])) && (Member((unsigned)(W53->valu.A[4 - 1]), Conset[141])) && (Member((unsigned)(W53->valu.A[5 - 1]), Conset[142]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 6) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[143])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[144])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[145])) && (Member((unsigned)(W53->valu.A[4 - 1]), Conset[146])) && (Member((unsigned)(W53->valu.A[5 - 1]), Conset[147])) && (Member((unsigned)(W53->valu.A[6 - 1]), Conset[148]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 7) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[149])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[150])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[151])) && (Member((unsigned)(W53->valu.A[4 - 1]), Conset[152])) && (Member((unsigned)(W53->valu.A[5 - 1]), Conset[153])) && (Member((unsigned)(W53->valu.A[6 - 1]), Conset[154])) && (Member((unsigned)(W53->valu.A[7 - 1]), Conset[155]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    if ((W53->length == 7) && (Member((unsigned)(W53->valu.A[1 - 1]), Conset[156])) && (Member((unsigned)(W53->valu.A[2 - 1]), Conset[157])) && (Member((unsigned)(W53->valu.A[3 - 1]), Conset[158])) && (Member((unsigned)(W53->valu.A[4 - 1]), Conset[159])) && (Member((unsigned)(W53->valu.A[5 - 1]), Conset[160])) && (Member((unsigned)(W53->valu.A[6 - 1]), Conset[161])) && (Member((unsigned)(W53->valu.A[7 - 1]), Conset[162]))) {
      extrakey = true;
      (void)fprintf(output.fp, "%s", keybefore), Putl(output, 0);
    }
    {
      integer	B54 = 1,
      	B55 = W53->length;

      if (B54 <= B55)
	for (i = B54; ; i++) {
	  if (W53->valu.A[i - 1] == '<') {
	    (void)fprintf(output.fp, "&lt;"), Putl(output, 0);
	  } else
	    if (W53->valu.A[i - 1] == '>') {
	      (void)fprintf(output.fp, "&gt;"), Putl(output, 0);
	    } else
	      if (W53->valu.A[i - 1] == '&') {
		(void)fprintf(output.fp, "&amp;"), Putl(output, 0);
	      } else {
		Putchr(W53->valu.A[i - 1], output);
	      }
	  if (i == B55) break;
	}
    }
    if (extrakey)
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
    switch ((int)(W53->name)) {
      case progsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case labelsym:
      break ;
      case beginsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case casesym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case forsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case ifsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case endsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case becomes:
      break ;
      case semicolon:
      break ;
      case openparen:
      break ;
      case endoffile:
      break ;
      case othersym:
      if (num)
	(void)fprintf(output.fp, "%s", numafter), Putl(output, 0);
      if (string)
	(void)fprintf(output.fp, "%s", stringafter), Putl(output, 0);
      break ;
      case funcsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case constsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case repeatsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case casevarsym:
      break ;
      case whilesym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case thensym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case forwardsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case opencomment:
      (void)fprintf(output.fp, "%s", commentafter), Putl(output, 0);
      break ;
      case colon:
      break ;
      case closeparen:
      break ;
      case procsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case typesym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case recordsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case ofsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case withsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case elsesym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case untilsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case closecomment:
      (void)fprintf(output.fp, "%s", commentafter), Putl(output, 0);
      break ;
      case coloncase:
      break ;
      case period:
      break ;
      case varsym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case dosym:
      (void)fprintf(output.fp, "%s", keyafter), Putl(output, 0);
      break ;
      case equals:
      break ;
      default:
      ;
    }
    startpos = (*currlinepos);
    (*currlinepos) = (*currlinepos) + W53->length;
  }
}

 void
ppsymbol(currsym)
  symbolinfo	currsym;
{
# define X56_once 1
  integer	newlinepos;

  {
    register struct S62 *W57 = &(*currsym);

    writecrs(W57->crsbefore, &currlinepos);
    if (gobbling && (W57->crsbefore > 0))
      newlinepos = gobblestart + (W57->actualstartpos - gobbleoffset);
    else
      if ((currlinepos + W57->spacesbefore > currmargin) && (W57->crsbefore == 0))
	newlinepos = currlinepos + W57->spacesbefore;
      else
	newlinepos = currmargin;
    if (newlinepos + W57->length > maxlinesize) {
      writecrs(X56_once, &currlinepos);
      if (currmargin + W57->length <= maxlinesize)
	newlinepos = currmargin;
      else
	if (W57->length <= maxlinesize)
	  newlinepos = maxlinesize - W57->length;
	else
	  newlinepos = 0;
    }
    movelinepos(newlinepos, &currlinepos);
    printsymbol(currsym, &currlinepos);
  }
# undef X56_once
}


 void
gobble(terminators, currsym, nextsym)
  keysymset	terminators;
  symbolinfo	*currsym, *nextsym;
{
  keysymbol	startsym;

  startsym = (*(*currsym)).name;
  gobbling = true;
  if (!(Member((unsigned)(startsym), Conset[163]))) {
    gobblestart = startpos;
    gobbleoffset = (*(*currsym)).actualstartpos;
  } else {
    gobblestart = currmargin;
    gobbleoffset = (*(*nextsym)).actualstartpos;
  }
  while (!(Member((unsigned)((*(*nextsym)).name), (Union(terminators.S, Conset[164]))))) {
    getsymbol(&(*nextsym), &(*currsym));
    Claimset();
    ppsymbol((*currsym));
  }
  Claimset();
  gobbling = false;
}

 void
rshift(csym)
  keysymbol	csym;
{
  if (!stackfull())
    pushstack(csym, (*currsym).actualstartpos, currmargin);
  if (currmargin < slofail1)
    currmargin = currmargin + indent1;
  else
    if (currmargin < slofail2)
      currmargin = currmargin + indent2;
  lastlinestartpos = (*nextsym).actualstartpos;
  thislinestartpos = 0;
}

 void
rshifttoclp(csym)
  keysymbol	csym;
{
  if (!stackfull())
    pushstack(csym, (*currsym).actualstartpos, currmargin);
  currmargin = currlinepos;
  lastlinestartpos = 0;
  thislinestartpos = 0;
}

 void
markcurrentposition(csym)
  keysymbol	csym;
{
  if (!stackfull())
    pushstack(csym, (*currsym).actualstartpos, currmargin);
}

 void
crifnot(sym)
  keysymset	sym;
{
  if (Member((unsigned)((*nextsym).name), sym.S)) {
    crpending = false;
    (*nextsym).crsbefore = 0;
    (*nextsym).spacesbefore = 1;
  } else
    if ((*nextsym).crsbefore == 0)
      (*nextsym).crsbefore = 1;
}

int	argc;
unsigned char	**argv;

int main(_ac, _av)
int	_ac;
unsigned char	*_av[];
{

  argc = _ac;
  argv = _av;
  initialise(&top, &currlinepos, &currmargin, &keyword, &dblchars, &dblchar, &sglchar, &recordseen, &currchar, &nextchar, &currsym, &nextsym, &ppoption);
  crpending = false;
  indecsection = false;
  (void)fprintf(output.fp, "<html><body bgcolor=\"FFFFFF\"><pre>"), Putl(output, 0);
  while (((*nextsym).name != endoffile)) {
    getsymbol(&nextsym, &currsym);
    if (Member((unsigned)((*currsym).name), Conset[165]))
      checkfordirective((*currsym).valu);
    if (formattingrequired)
      {
	register struct S68 *W58 = &ppoption.A[(int)((*currsym).name)];

	if (Member((unsigned)((*currsym).name), Conset[166]))
	  indecsection = true;
	else
	  if ((Member((unsigned)((*currsym).name), Conset[167])) && indecsection) {
	    indecsection = false;
	    insertblankline(&currsym);
	    crpending = false;
	  }
	if ((crpending && !(Member((unsigned)(crsuppress), W58->optionsselected.S))) || (Member((unsigned)(crbefore), W58->optionsselected.S))) {
	  insertcr(&currsym);
	  crpending = false;
	}
	if (Member((unsigned)(blanklinebefore), W58->optionsselected.S)) {
	  insertblankline(&currsym);
	  crpending = false;
	}
	if (Member((unsigned)(crsuppress), W58->optionsselected.S)) {
	  (*currsym).crsbefore = 0;
	  (*currsym).spacesbefore = 0;
	}
	if (Member((unsigned)(dindentonkeys), W58->optionsselected.S))
	  lshifton(W58->dindentsymbols);
	if (Member((unsigned)(dindent), W58->optionsselected.S))
	  lshift();
	if (Member((unsigned)(firstindentbytab), W58->optionsselected.S)) {
	  if (Member((unsigned)((*currsym).name), Conset[168]))
	    rshift(ifsym);
	  else
	    if ((Member((unsigned)((*currsym).name), Conset[169])) && (!indecsection))
	      ;
	    else
	      rshift((*currsym).name);
	}
	if (Member((unsigned)(spacebefore), W58->optionsselected.S))
	  insertspace(&currsym);
	ppsymbol(currsym);
	if (Member((unsigned)(spaceafter), W58->optionsselected.S))
	  insertspace(&nextsym);
	if (Member((unsigned)(indentbytab), W58->optionsselected.S)) {
	  if (((*currsym).name == elsesym) && ((*nextsym).name == ifsym))
	    ;
	  else
	    if (((*currsym).name == beginsym) && (Member((unsigned)(stack.A[top - 1].indentsymbol), Conset[170]))) {
	      lshift();
	      rshift(beginsym);
	    } else
	      if (Member((unsigned)((*currsym).name), Conset[171]))
		rshift(ifsym);
	      else
		rshift((*currsym).name);
	}
	if (Member((unsigned)(indenttoclp), W58->optionsselected.S))
	  rshifttoclp((*currsym).name);
	if (Member((unsigned)(markposition), W58->optionsselected.S))
	  markcurrentposition((*currsym).name);
	if (Member((unsigned)(crbeforegobble), W58->optionsselected.S))
	  crifnot(*((keysymset *)SETALIGN(Conset[172])));
	if (Member((unsigned)(gobblesymbols), W58->optionsselected.S))
	  gobble(W58->gobbleterminators, &currsym, &nextsym);
	if (Member((unsigned)(dindentafter), W58->optionsselected.S)) {
	  if ((Member((unsigned)((*currsym).name), Conset[173])) && (!indecsection))
	    ;
	  else
	    lshift();
	}
	if (Member((unsigned)(crnotbegin), W58->optionsselected.S))
	  crifnot(*((keysymset *)SETALIGN(Conset[174])));
	if (Member((unsigned)(crnotiforbegin), W58->optionsselected.S))
	  crifnot(*((keysymset *)SETALIGN(Conset[175])));
	if (Member((unsigned)(crafter), W58->optionsselected.S)) {
	  if (((*currsym).name == endsym) && (Member((unsigned)((*nextsym).name), Conset[176])) && ((*nextsym).crsbefore == 0))
	    ;
	  else
	    crpending = true;
	}
      }
    else
      ppsymbol(currsym);
  }
  if (crpending)
    Putchr('\n', output);
  (void)fprintf(output.fp, "</pre></body></html>"), Putl(output, 0);
  exit(0);
  /* NOTREACHED */
}
# undef maxsymbolsize
# undef maxstacksize
# undef maxkeylength
# undef maxlinesize
# undef slofail1
# undef slofail2
# undef indent1
# undef indent2
# undef space
static setword	Q0[] = {
	1,
	0x03000000
};
static setword	Q1[] = {
	1,
	0x00020080
};
static setword	Q2[] = {
	1,
	0x00000080
};
static setword	Q3[] = {
	1,
	0x03000000
};
static setword	Q4[] = {
	1,
	0x00000080
};
static setword	Q5[] = {
	1,
	0x000C0000
};
static setword	Q6[] = {
	1,
	0x10030000
};
static setword	Q7[] = {
	1,
	0x03000000
};
static setword	Q8[] = {
	1,
	0x000C0000
};
static setword	Q9[] = {
	1,
	0x00000086
};
static setword	Q10[] = {
	1,
	0x00000078
};
static setword	Q11[] = {
	1,
	0x03000000
};
static setword	Q12[] = {
	2,
	0x00000000,	0x00000002
};
static setword	Q13[] = {
	1,
	0x00010000
};
static setword	Q14[] = {
	4,
	0x00000000,	0x00000000,	0x00040000,	0x00040000
};
static setword	Q15[] = {
	4,
	0x00000000,	0x00000000,	0x00000020,	0x00000020
};
static setword	Q16[] = {
	4,
	0x00000000,	0x00000000,	0x00000080,	0x00000080
};
static setword	Q17[] = {
	4,
	0x00000000,	0x00000000,	0x00000020,	0x00000020
};
static setword	Q18[] = {
	4,
	0x00000000,	0x00000000,	0x00100000,	0x00100000
};
static setword	Q19[] = {
	4,
	0x00000000,	0x00000000,	0x00004000,	0x00004000
};
static setword	Q20[] = {
	4,
	0x00000000,	0x00000000,	0x00000200,	0x00000200
};
static setword	Q21[] = {
	4,
	0x00000000,	0x00000000,	0x00004000,	0x00004000
};
static setword	Q22[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q23[] = {
	4,
	0x00000000,	0x00000000,	0x00000020,	0x00000020
};
static setword	Q24[] = {
	4,
	0x00000000,	0x00000000,	0x00001000,	0x00001000
};
static setword	Q25[] = {
	4,
	0x00000000,	0x00000000,	0x00008000,	0x00008000
};
static setword	Q26[] = {
	4,
	0x00000000,	0x00000000,	0x00008000,	0x00008000
};
static setword	Q27[] = {
	4,
	0x00000000,	0x00000000,	0x00000004,	0x00000004
};
static setword	Q28[] = {
	4,
	0x00000000,	0x00000000,	0x00000010,	0x00000010
};
static setword	Q29[] = {
	4,
	0x00000000,	0x00000000,	0x00000020,	0x00000020
};
static setword	Q30[] = {
	4,
	0x00000000,	0x00000000,	0x00000800,	0x00000800
};
static setword	Q31[] = {
	4,
	0x00000000,	0x00000000,	0x00000008,	0x00000008
};
static setword	Q32[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q33[] = {
	4,
	0x00000000,	0x00000000,	0x00010000,	0x00010000
};
static setword	Q34[] = {
	4,
	0x00000000,	0x00000000,	0x02000000,	0x02000000
};
static setword	Q35[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q36[] = {
	4,
	0x00000000,	0x00000000,	0x00040000,	0x00040000
};
static setword	Q37[] = {
	4,
	0x00000000,	0x00000000,	0x00040000,	0x00040000
};
static setword	Q38[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q39[] = {
	4,
	0x00000000,	0x00000000,	0x00040000,	0x00040000
};
static setword	Q40[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q41[] = {
	4,
	0x00000000,	0x00000000,	0x00000100,	0x00000100
};
static setword	Q42[] = {
	4,
	0x00000000,	0x00000000,	0x00000008,	0x00000008
};
static setword	Q43[] = {
	4,
	0x00000000,	0x00000000,	0x00100000,	0x00100000
};
static setword	Q44[] = {
	4,
	0x00000000,	0x00000000,	0x00000020,	0x00000020
};
static setword	Q45[] = {
	4,
	0x00000000,	0x00000000,	0x00080000,	0x00080000
};
static setword	Q46[] = {
	4,
	0x00000000,	0x00000000,	0x00100000,	0x00100000
};
static setword	Q47[] = {
	4,
	0x00000000,	0x00000000,	0x00008000,	0x00008000
};
static setword	Q48[] = {
	4,
	0x00000000,	0x00000000,	0x00004000,	0x00004000
};
static setword	Q49[] = {
	4,
	0x00000000,	0x00000000,	0x00000010,	0x00000010
};
static setword	Q50[] = {
	4,
	0x00000000,	0x00000000,	0x00004000,	0x00004000
};
static setword	Q51[] = {
	4,
	0x00000000,	0x00000000,	0x00000002,	0x00000002
};
static setword	Q52[] = {
	4,
	0x00000000,	0x00000000,	0x00040000,	0x00040000
};
static setword	Q53[] = {
	4,
	0x00000000,	0x00000000,	0x00008000,	0x00008000
};
static setword	Q54[] = {
	4,
	0x00000000,	0x00000000,	0x00008000,	0x00008000
};
static setword	Q55[] = {
	4,
	0x00000000,	0x00000000,	0x00100000,	0x00100000
};
static setword	Q56[] = {
	4,
	0x00000000,	0x00000000,	0x00004000,	0x00004000
};
static setword	Q57[] = {
	4,
	0x00000000,	0x00000000,	0x00000200,	0x00000200
};
static setword	Q58[] = {
	2,
	0x00000000,	0x03FF0000
};
static setword	Q59[] = {
	1,
	0x00000000
};
static setword	Q60[] = {
	1,
	0x00000000
};
static setword	Q61[] = {
	1,
	0x00000000
};
static setword	Q62[] = {
	1,
	0x00000000
};
static setword	Q63[] = {
	1,
	0x00000000
};
static setword	Q64[] = {
	1,
	0x00000000
};
static setword	Q65[] = {
	1,
	0x00000000
};
static setword	Q66[] = {
	1,
	0x00000000
};
static setword	Q67[] = {
	1,
	0x00000001
};
static setword	Q68[] = {
	1,
	0x00000000
};
static setword	Q69[] = {
	1,
	0x00000000
};
static setword	Q70[] = {
	1,
	0x00000000
};
static setword	Q71[] = {
	1,
	0x80000000
};
static setword	Q72[] = {
	1,
	0x00000000
};
static setword	Q73[] = {
	1,
	0x00000400
};
static setword	Q74[] = {
	1,
	0x00000000
};
static setword	Q75[] = {
	1,
	0x00000000
};
static setword	Q76[] = {
	1,
	0x00001300
};
static setword	Q77[] = {
	1,
	0x00000000
};
static setword	Q78[] = {
	1,
	0x00000000
};
static setword	Q79[] = {
	1,
	0x00004800
};
static setword	Q80[] = {
	1,
	0x00000000
};
static setword	Q81[] = {
	1,
	0x00000000
};
static setword	Q82[] = {
	1,
	0x00001200
};
static setword	Q83[] = {
	1,
	0x00000000
};
static setword	Q84[] = {
	1,
	0x380F0000
};
static setword	Q85[] = {
	1,
	0x00010021
};
static setword	Q86[] = {
	1,
	0x00000000
};
static setword	Q87[] = {
	1,
	0x00000000
};
static setword	Q88[] = {
	1,
	0x00000088
};
static setword	Q89[] = {
	1,
	0x00000000
};
static setword	Q90[] = {
	1,
	0x00000000
};
static setword	Q91[] = {
	1,
	0x00000088
};
static setword	Q92[] = {
	1,
	0x04590000
};
static setword	Q93[] = {
	1,
	0x00000000
};
static setword	Q94[] = {
	1,
	0x00000700
};
static setword	Q95[] = {
	1,
	0x04580000
};
static setword	Q96[] = {
	1,
	0x280F0000
};
static setword	Q97[] = {
	1,
	0x00010662
};
static setword	Q98[] = {
	1,
	0x00000000
};
static setword	Q99[] = {
	1,
	0x00000000
};
static setword	Q100[] = {
	1,
	0x00010048
};
static setword	Q101[] = {
	1,
	0x00000000
};
static setword	Q102[] = {
	1,
	0x380F0806
};
static setword	Q103[] = {
	1,
	0x000100A2
};
static setword	Q104[] = {
	1,
	0x00000000
};
static setword	Q105[] = {
	1,
	0x000A0000
};
static setword	Q106[] = {
	1,
	0x00008822
};
static setword	Q107[] = {
	1,
	0x00000000
};
static setword	Q108[] = {
	1,
	0x00000000
};
static setword	Q109[] = {
	1,
	0x00004901
};
static setword	Q110[] = {
	1,
	0x00040000
};
static setword	Q111[] = {
	1,
	0x00080000
};
static setword	Q112[] = {
	1,
	0x00000620
};
static setword	Q113[] = {
	1,
	0x04022080
};
static setword	Q114[] = {
	1,
	0x00000000
};
static setword	Q115[] = {
	1,
	0x00002D01
};
static setword	Q116[] = {
	1,
	0x00010000
};
static setword	Q117[] = {
	1,
	0x00000000
};
static setword	Q118[] = {
	1,
	0x00000600
};
static setword	Q119[] = {
	1,
	0x00010000
};
static setword	Q120[] = {
	1,
	0x00000000
};
static setword	Q121[] = {
	1,
	0x00000600
};
static setword	Q122[] = {
	1,
	0x00010000
};
static setword	Q123[] = {
	1,
	0x00000000
};
static setword	Q124[] = {
	1,
	0x00000600
};
static setword	Q125[] = {
	1,
	0x00000000
};
static setword	Q126[] = {
	1,
	0x00000000
};
static setword	Q127[] = {
	1,
	0x00000101
};
static setword	Q128[] = {
	1,
	0x00001000
};
static setword	Q129[] = {
	1,
	0x00000000
};
static setword	Q130[] = {
	1,
	0x00010600
};
static setword	Q131[] = {
	1,
	0x00001000
};
static setword	Q132[] = {
	1,
	0x00000000
};
static setword	Q133[] = {
	1,
	0x00010604
};
static setword	Q134[] = {
	1,
	0x00000000
};
static setword	Q135[] = {
	1,
	0x00000000
};
static setword	Q136[] = {
	1,
	0x00010800
};
static setword	Q137[] = {
	1,
	0x00000000
};
static setword	Q138[] = {
	1,
	0x00000000
};
static setword	Q139[] = {
	1,
	0x00010800
};
static setword	Q140[] = {
	1,
	0x00000000
};
static setword	Q141[] = {
	1,
	0x0000007E
};
static setword	Q142[] = {
	1,
	0x00010820
};
static setword	Q143[] = {
	1,
	0x00000000
};
static setword	Q144[] = {
	1,
	0x0000003E
};
static setword	Q145[] = {
	1,
	0x00010830
};
static setword	Q146[] = {
	1,
	0x00000000
};
static setword	Q147[] = {
	1,
	0x0000001E
};
static setword	Q148[] = {
	1,
	0x00010830
};
static setword	Q149[] = {
	1,
	0x00000000
};
static setword	Q150[] = {
	1,
	0x0000000E
};
static setword	Q151[] = {
	1,
	0x00010830
};
static setword	Q152[] = {
	1,
	0x00000000
};
static setword	Q153[] = {
	1,
	0x00000006
};
static setword	Q154[] = {
	1,
	0x00010830
};
static setword	Q155[] = {
	1,
	0x00000000
};
static setword	Q156[] = {
	1,
	0x00200078
};
static setword	Q157[] = {
	1,
	0x00000A30
};
static setword	Q158[] = {
	1,
	0x00000000
};
static setword	Q159[] = {
	1,
	0x00200078
};
static setword	Q160[] = {
	1,
	0x00000A30
};
static setword	Q161[] = {
	1,
	0x00000000
};
static setword	Q162[] = {
	1,
	0x00000000
};
static setword	Q163[] = {
	1,
	0x00000210
};
static setword	Q164[] = {
	1,
	0x01800000
};
static setword	Q165[] = {
	1,
	0x28000000
};
static setword	Q166[] = {
	4,
	0x00000000,	0x00000000,	0x00000000,	0x28000000
};
static setword	Q167[] = {
	1,
	0x00000038
};
static setword	Q168[] = {
	1,
	0x00100600
};
static setword	Q169[] = {
	1,
	0x00000003
};
static setword	Q170[] = {
	3,
	0x00000000,	0x00000000,	0x07FFFFFE
};
static setword	Q171[] = {
	2,
	0x00000000,	0x03FF0000
};
static setword	Q172[] = {
	3,
	0x00000000,	0x00000000,	0x00010002
};
static setword	Q173[] = {
	1,
	0x00000014
};
static setword	Q174[] = {
	1,
	0x00000030
};
static setword	Q175[] = {
	2,
	0x00000000,	0x03FF0000
};
static setword	Q176[] = {
	4,
	0x00000000,	0x00000000,	0x07FFFFFE,	0x07FFFFFE
};
setword	*Conset[] = {
	Q176,	Q175,	Q174,	Q173,
	Q172,	Q171,	Q170,	Q169,	Q168,	Q167,
	Q166,	Q165,	Q164,	Q163,	Q162,	Q161,
	Q160,	Q159,	Q158,	Q157,	Q156,	Q155,
	Q154,	Q153,	Q152,	Q151,	Q150,	Q149,
	Q148,	Q147,	Q146,	Q145,	Q144,	Q143,
	Q142,	Q141,	Q140,	Q139,	Q138,	Q137,
	Q136,	Q135,	Q134,	Q133,	Q132,	Q131,
	Q130,	Q129,	Q128,	Q127,	Q126,	Q125,
	Q124,	Q123,	Q122,	Q121,	Q120,	Q119,
	Q118,	Q117,	Q116,	Q115,	Q114,	Q113,
	Q112,	Q111,	Q110,	Q109,	Q108,	Q107,
	Q106,	Q105,	Q104,	Q103,	Q102,	Q101,
	Q100,	Q99,	Q98,	Q97,	Q96,	Q95,
	Q94,	Q93,	Q92,	Q91,	Q90,	Q89,
	Q88,	Q87,	Q86,	Q85,	Q84,	Q83,
	Q82,	Q81,	Q80,	Q79,	Q78,	Q77,
	Q76,	Q75,	Q74,	Q73,	Q72,	Q71,
	Q70,	Q69,	Q68,	Q67,	Q66,	Q65,
	Q64,	Q63,	Q62,	Q61,	Q60,	Q59,
	Q58,	Q57,	Q56,	Q55,	Q54,	Q53,
	Q52,	Q51,	Q50,	Q49,	Q48,	Q47,
	Q46,	Q45,	Q44,	Q43,	Q42,	Q41,
	Q40,	Q39,	Q38,	Q37,	Q36,	Q35,
	Q34,	Q33,	Q32,	Q31,	Q30,	Q29,
	Q28,	Q27,	Q26,	Q25,	Q24,	Q23,
	Q22,	Q21,	Q20,	Q19,	Q18,	Q17,
	Q16,	Q15,	Q14,	Q13,	Q12,	Q11,
	Q10,	Q9,	Q8,	Q7,	Q6,	Q5,
	Q4,	Q3,	Q2,	Q1,	Q0
};

setptr
Union(p1, p2)
	register setptr	p1, p2;
{
	register int		i, j, k;
	register setptr		sp = Newset(),
				p3 = sp;

	j = *p1;
	*p3 = j;
	if (j > *p2)
		j = *p2;
	else
		*p3 = *p2;
	k = *p1 - *p2;
	p1++, p2++, p3++;
	for (i = 0; i < j; i++)
		*p3++ = (*p1++ | *p2++);
	while (k > 0) {
		*p3++ = *p1++;
		k--;
	}
	while (k < 0) {
		*p3++ = *p2++;
		k++;
	}
	return (Saveset(sp));
}

boolean
Member(m, sp)
	register unsigned int	m;
	register setptr	sp;
{
	register unsigned int	i = m / (setbits+1) + 1;

	if ((i <= *sp) && (sp[i] & (1 << (m % (setbits+1)))))
		return (true);
	return (false);
}

# ifndef SETSPACE
# define SETSPACE 256
# endif
setptr
Currset(n,sp)
	int	n;
	setptr	sp;
{
	static setword	Space[SETSPACE];
	static setptr	Top = Space;

	switch (n) {
	  case 0:
		Top = Space;
		return (0);
	  case 1:
		if (&Space[SETSPACE] - Top <= 32) {
			(void)fprintf(stderr, "Set-space exhausted\n");
			exit(1);
		}
		*Top = 0;
		return (Top);
	  case 2:
		if (Top <= &sp[*sp])
			Top = &sp[*sp + 1];
		return (sp);
	}
	/* NOTREACHED */
}

void
Setncpy(S1, S2, N)
	register setptr	S1, S2;
	register unsigned int	N;
{
	register unsigned int	m;

	N /= sizeof(setword);
	*S1++ = --N;
	m = *S2++;
	while (m != 0 && N != 0) {
		*S1++ = *S2++;
		--N;
		--m;
	}
	while (N-- != 0)
		*S1++ = 0;
}

struct Set *
Alignset(Sp)
	register unsigned int	*Sp;
{
	static struct Set	tmp;
	register unsigned int	*tp = tmp.S;
	register int		i = *Sp;

	while (i-- >= 0)
		*tp++ = *Sp++;
	return (&tmp);
}
