int strcmp(char *a, char *b) {
  return 1;
}
int sprintf(char *str, char *patt) {
  return 0;
}
int strlen(char *s) {
  return 0;
}
void fprintf(FILE *file, char *patt) {
}
void exit(int n) {
}
int strcpy(char *a, char *b) {
  return 1;
}
int isalpha(int cond) {
}
int isdigit(int cond) {
}
void ungetc(int c, FILE *f) {
}
int fgetc(FILE *f) {
}
void fflush(FILE *f) {
}
int atoi(char *a) {
}
void assert(int bool) {
}
int strcat(char *a, char *b) {
  return 1;
}
char *strrchr(char *a, int c) {
  return a;
}
int strcasecmp(char *a, char *b) {
  return 1;
}
FILE *fopen(char *f, char *mode) {
  return NULL;
}
char *strerror(int errno) {
  return "err";
}
FILE *stdout;
FILE *stderr;
const int NULL = 0;
const int EOF = -1;
static char prognames[256];
static char *progname;
static char outname[256];
FILE *outfile;
int debug = (0!=0);
int gram[777] = {
    2, 2, 587, 521, 1, 512, 8, 5, 256, 40, 542, 538, 41, 8, 535, 530,
  585, 40, 527, 41, 525, 524, 6, 530, 585, 40, 527, 41, 525, 3, 585, 525,
  524, 1, 518, 1, 519, 1, 520, 3, 40, 582, 41, 3, 8, 535, 530, 585,
   40, 527, 41, 525, 524, 6, 530, 585, 40, 527, 41, 525, 3, 586, 525, 524,
    3, 1, 514, 1, 515, 0, 4, 4, 91, 582, 93, 525, 3, 46, 585, 525,
    4, 45, 62, 585, 525, 0, 2, 4, 256, 40, 542, 41, 6, 536, 530, 585,
   40, 527, 41, 2, 2, 578, 528, 0, 2, 3, 44, 578, 528, 0, 2, 3,
  535, 530, 522, 1, 523, 2, 1, 534, 0, 2, 2, 532, 523, 2, 533, 522,
    5, 1, 514, 1, 515, 2, 536, 534, 1, 38, 1, 256, 11, 1, 514, 1,
  515, 1, 43, 1, 45, 1, 33, 1, 126, 2, 536, 534, 1, 535, 1, 38,
    1, 256, 0, 1, 4, 40, 542, 538, 41, 1, 2, 42, 536, 2, 1, 535,
    0, 1, 2, 42, 538, 2, 1, 537, 0, 3, 1, 257, 1, 258, 0, 5,
    1, 259, 1, 260, 1, 261, 1, 262, 0, 1, 1, 41, 12, 1, 263, 2,
  264, 624, 4, 265, 40, 529, 41, 4, 543, 266, 266, 267, 3, 543, 266, 266,
    3, 543, 266, 267, 2, 543, 266, 2, 543, 267, 3, 543, 268, 267, 2, 543,
  268, 2, 543, 269, 1, 270, 3, 1, 271, 1, 272, 0, 1, 2, 531, 555,
    1, 2, 544, 556, 1, 2, 545, 557, 1, 2, 546, 558, 1, 2, 547, 559,
    1, 2, 548, 560, 1, 2, 549, 561, 1, 2, 550, 562, 1, 2, 551, 563,
    1, 2, 552, 564, 1, 2, 553, 577, 2, 3, 565, 531, 555, 0, 2, 3,
  566, 544, 556, 0, 2, 3, 567, 545, 557, 0, 2, 3, 568, 546, 558, 0,
    2, 3, 569, 547, 559, 0, 2, 3, 570, 548, 560, 0, 2, 3, 572, 549,
  561, 0, 2, 3, 573, 550, 562, 0, 2, 3, 575, 551, 563, 0, 2, 3,
  576, 552, 564, 0, 3, 1, 42, 1, 47, 1, 37, 2, 1, 43, 1, 45,
    2, 2, 60, 60, 2, 62, 62, 4, 2, 60, 61, 1, 60, 2, 62, 61,
    1, 62, 2, 2, 61, 61, 2, 33, 61, 1, 2, 33339, 38, 1, 2, 38,
   38, 1, 1, 94, 1, 2, 33342, 124, 1, 2, 124, 124, 1, 2, 38, 38,
    1, 2, 124, 124, 2, 4, 63, 553, 58, 554, 0, 1, 2, 580, 554, 1,
    2, 61, 61, 2, 4, 529, 33347, 581, 580, 0, 11, 1, 61, 2, 43, 61,
    2, 45, 61, 2, 42, 61, 2, 47, 61, 2, 37, 61, 2, 38, 61, 2,
   94, 61, 2, 124, 61, 3, 60, 60, 61, 3, 62, 62, 61, 1, 2, 578,
  583, 2, 3, 44, 578, 583, 0, 1, 1, 582, 1, 1, 513, 1, 1, 513,
    7, 3, 123, 592, 125, 1, 588, 1, 595, 1, 590, 1, 619, 1, 621, 1,
  622, 3, 3, 585, 58, 587, 4, 273, 589, 58, 587, 3, 274, 58, 587, 1,
    1, 582, 1, 2, 591, 59, 2, 1, 582, 0, 1, 2, 593, 618, 2, 1,
  594, 0, 1, 2, 595, 593, 4, 1, 598, 1, 601, 1, 602, 1, 603, 3,
    1, 598, 1, 601, 1, 603, 2, 2, 596, 597, 0, 1, 5, 264, 623, 123,
  597, 125, 2, 5, 44, 538, 585, 611, 599, 0, 1, 5, 538, 585, 611, 599,
   59, 1, 4, 540, 539, 542, 600, 1, 9, 540, 539, 542, 538, 585, 40, 612,
   41, 604, 1, 8, 540, 539, 542, 538, 585, 605, 607, 59, 2, 1, 59, 3,
  123, 592, 125, 1, 4, 91, 616, 93, 606, 2, 4, 91, 616, 93, 606, 0,
    2, 4, 61, 123, 608, 125, 0, 1, 2, 610, 609, 3, 3, 44, 610, 609,
    1, 44, 0, 2, 1, 589, 3, 123, 608, 125, 2, 2, 61, 578, 0, 2,
    2, 263, 16925, 2, 614, 613, 2, 3, 44, 614, 613, 0, 1, 4, 542, 538,
  585, 615, 2, 4, 91, 616, 93, 615, 0, 2, 1, 589, 0, 1, 2, 587,
  618, 2, 2, 587, 618, 0, 2, 6, 275, 40, 582, 41, 587, 620, 7, 276,
   40, 582, 41, 123, 592, 125, 2, 2, 277, 587, 0, 3, 5, 278, 40, 582,
   41, 587, 7, 279, 587, 278, 40, 582, 41, 59, 9, 280, 40, 591, 59, 591,
   59, 591, 41, 587, 4, 3, 281, 585, 59, 2, 282, 59, 2, 283, 59, 3,
  284, 591, 59, 1, 1, 513, 1, 1, 513,
};
char *keyword[29] = {
  "sizeof", "const", "volatile", "auto",
  "register", "static", "extern", "void",
  "struct", "typeof", "long", "int",
  "short", "char", "FILE", "unsigned",
  "signed", "case", "default", "if",
  "switch", "else", "while", "do",
  "for", "goto", "continue", "break",
  "return",
};
int BIP[9] = {
 0, 1, 2, 3, 4, 5, 6, 7, 8,
};



char *phrasename[113] = {
  "EOD", "TAG", "PPP", "MMM",
  "CHAR", "KEYWORD", "integer-constant", "character-constant",
  "string-constant", "SS", "level14", "level14-lv",
  "opt-post-ppp-or-mmm", "opt-postfix", "function-call", "opt-argument-list",
  "comma-opt-argument-list", "lvalue", "opt-cast", "level13",
  "prefix-operator-lv", "opt-prefix-operator", "cast", "indirectthrough-seq",
  "opt-indirectthrough-seq", "pointerto-seq", "opt-pointerto-seq", "opt-qualifier",
  "opt-scope", "closer", "type", "signed",
  "level12", "level11", "level10", "level9",
  "level8", "level7", "level6", "level5",
  "level4", "level3", "level2", "opt-level12",
  "opt-level11", "opt-level10", "opt-level9", "opt-level8",
  "opt-level7", "opt-level6", "opt-level5", "opt-level4",
  "opt-level3", "level12-op", "level11-op", "level10-op",
  "level9-op", "level8-op", "level7-op", "ANDAND",
  "level6-op", "level5-op", "OROR", "level4-op",
  "level3-op", "opt-conditional", "level1", "equiv",
  "opt-assign-list", "assign-op", "expression", "opt-comma-level0-list",
  "rvalue", "identifier", "identifier-lv", "statement",
  "labeled-statement", "constant-expression", "expression-statement", "opt-expression",
  "compound-statement", "opt-declaration-list", "declaration-list", "declaration",
  "struct-member-declaration", "struct-member-list", "struct-decl", "opt-rest-of-scalar-decl",
  "rest-of-scalar-decl", "scalar-decl", "proc-fn-decl", "array-decl",
  "forward-decl-or-actual-body", "array-bounds", "opt-array-bounds", "opt-array-init",
  "constant-initializer-list", "rest-of-constant-initializer-list", "constant-initializer", "opt-scalar-init",
  "opt-param-list", "opt-rest-of-param-list", "param", "opt-empty-array-bounds",
  "opt-constant-expression", "statement-list", "opt-statement-list", "selection-statement",
  "opt-else-statement", "iteration-statement", "jump-statement", "new-structname",
  "existing-structname",
};


int phrase_start[113 -9] = {
    0, 6, 43, 64, 70, 86, 99,
  104, 110, 117, 121, 128, 140, 163, 169, 173, 177, 181, 185, 191, 201, 204, 246,
  252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 302, 308, 314, 320,
  326, 332, 338, 344, 350, 356, 363, 368, 375, 386, 393, 397, 401, 404, 408, 412,
  416, 420, 427, 431, 435, 442, 477, 481, 487, 490, 493, 496, 513, 527, 530, 534,
  538, 542, 546, 550, 559, 566, 571, 578, 586, 593, 599, 610, 620, 627, 633, 640,
  647, 651, 659, 666, 671, 678, 684, 690, 697, 701, 705, 710, 726, 731, 756, 771,
  774,
};
int bestparse = -1;
char *looking_for = "<UNKNOWN>";
  char stringpool[(16*1024)];
  int nextstring = 0;
  int str_to_pool(char *s)
  {
    int tag;
    for (tag = 0; tag <= nextstring; tag++) {
 if (strcmp(stringpool+tag, s) == 0) {
     return tag;
 }
    }
  }
  struct sourceinfo {
    char *s;
    int l;
    int col;
    int t;
    char *f;
  };
  static struct sourceinfo c[128*1024];
  int nextfree = 0, arraysize = 128*1024;
  char onecharstr[2*256];
  static int A[2*1024*1024];
  int next_free_a = 0, a_size = 2*1024*1024;
  FILE *sourcefile;
  char *curfile;
  int startline = (0==0), whitespace = (0==0), lineno = 1, col = 0, ch, peek;
char *escape(char *s, int t)
{
  static char result[1024];
  char *rslt;
  int quote;
  rslt = result;
  if ((t != 7) && (t != 8)) {
    rslt += sprintf(rslt, "%s", s); return result;
  }
  if (t == 7) quote = '\'';
  if (t == 8) quote = '"';
  rslt += sprintf(rslt, "%c", quote);
  for (;;) {
    int c = *s++;
    if (c == '\n') rslt += sprintf(rslt, "\\n");
    else if (c == '\r') rslt += sprintf(rslt, "\\r");
    else if (c == '\t') rslt += sprintf(rslt, "\\t");
    else if ((c == 0) && (quote == '\'')) rslt += sprintf(rslt, "\\0");
    else if (c == '\\') rslt += sprintf(rslt, "\\\\");
    else if ((c == '"') && (quote == '"')) rslt += sprintf(rslt, "\\\"");
    else if ((c == '\'') && (quote == '\'')) rslt += sprintf(rslt, "\\'");
    else rslt += sprintf(rslt, "%c", c);
    if ((c == 0) || (quote == '\'')) break;
  }
  sprintf(result+strlen(result), "%c", quote);
  return result;
}
void dump_source(void)
{
  int l;
  int line = -1;
  for (l = 0; l < nextfree; l++) {
    if (c[l].t == 0) break;
    if (c[l].l != line) {
      fprintf(stdout, "\n");
      line = c[l].l;
    }
    fprintf(stdout, "%s", escape(c[l].s, c[l].t));
  }
  fprintf(stdout, "\n");
}
void error_line(int target)
{
  int l;
  fprintf(stderr, "Line %d: ", target);
  for (l = 0; l < nextfree; l++) {
    if (c[l].t == 0) break;
    if (c[l].l == target) {
      fprintf(stderr, "%s", escape(c[l].s, c[l].t), c[l].t);
    }
  }
  fprintf(stderr, "\n");
}
void stores(char *s, int lineno, int col, int type, char *fname) {
  int tag;
  if (nextstring + strlen(s) + 1 >= (16*1024)) exit(1);
  strcpy(stringpool+nextstring, s);
  tag = str_to_pool(s);
  if (tag == nextstring) nextstring += strlen(s)+1;
  c[nextfree].s = stringpool+tag; c[nextfree].l = lineno; c[nextfree].col = col;
  c[nextfree].f = fname; c[nextfree].t = type;
  nextfree++;
}
void storec(int ch, int lineno, int col, int type, char *fname) {
  onecharstr[ch*2] = ch; onecharstr[ch*2+1] = '\0';
  stores(&onecharstr[ch*2], lineno, col, type, fname);
}
int mkliteral(char *s)
{
  int tag;
  if (nextstring + strlen(s) + 1 >= (16*1024)) exit(1);
  strcpy(stringpool+nextstring, s);
  tag = str_to_pool(s);
  if (tag == nextstring) nextstring += strlen(s)+1;
  c[nextfree].s = stringpool+tag; c[nextfree].l = -1; c[nextfree].col = -1;
  c[nextfree].f = ""; c[nextfree].t = 6;
  return nextfree++;
}
int iskeyword(char *s) {
  int i;
  for (i = 0; i < 29; i++) if (strcmp(s, keyword[i]) == 0) return (0==0);
  return (0!=0);
}
static int xfgetc(FILE *f);
static void xungetc(int c, FILE *f);
char *wp; int wpstartcol;
void whitedump(char *fname, int col) {
  int tag;
  *wp = '\0';
  tag = str_to_pool(stringpool+nextstring);
  if (tag == nextstring) nextstring += strlen(stringpool+nextstring)+1;
  c[nextfree].s = stringpool+tag; c[nextfree].l = lineno; c[nextfree].col = wpstartcol;
  c[nextfree].f = fname; c[nextfree].t = (-1);
  nextfree++;
  wp = stringpool+nextstring; wpstartcol = col;
}
void line_reconstruction(void)
{
  wp = stringpool+nextstring;
  wpstartcol = col;
  for (;;) {
    ch = xfgetc(sourcefile); if (ch == EOF) break;
    ch &= 255;
    peek = xfgetc(sourcefile); xungetc(peek, sourcefile);
    if (isalpha(ch) || (ch == '_')) {
        int nextfree = 0, strsize = 0, startcol = col;
        char token[4*1024];
        whitespace = (0!=0);
        for (;;) {
          if (isalpha(ch) || isdigit(ch) || (ch == '_')) {
            col++;
            token[nextfree++] = ch;
          } else {
            token[nextfree] = '\0'; xungetc(ch, sourcefile);
            break;
          }
          ch = xfgetc(sourcefile);
        }
        stores(token, lineno, startcol, iskeyword(token) ? 5 : 1, curfile);
    } else if (isdigit(ch)) {
        int nextfree = 0, numsize = 0;
        char number[4*1024];
        whitespace = (0!=0);
        for (;;) {
          if (isdigit(ch)) {
            col++;
            number[nextfree++] = ch;
          } else {
            number[nextfree] = '\0'; xungetc(ch, sourcefile);
            break;
          }
          ch = xfgetc(sourcefile);
        }
        stores(number, lineno, col, 6, curfile);
    } else switch (ch) {
    case '"':
    case '\'':
      {
        int nextfree = 0, strsize = 0, quotech = ch;
        char string[4*1024];
        whitespace = (0!=0);
        col++;
        for (;;) {
          ch = xfgetc(sourcefile);
          col++;
   if (ch == quotech) {
            string[nextfree] = '\0';
            break;
   } else if (ch == '\\') {
            ch = xfgetc(sourcefile); col++;
            if (ch == '\\') { string[nextfree++] = ch;
            } else if (ch == '\'') { string[nextfree++] = '\'';
            } else if (ch == '"') { string[nextfree++] = '"';
            } else if (ch == 'n') { string[nextfree++] = '\n';
            } else if (ch == 'r') { string[nextfree++] = '\r';
            } else if (ch == 't') { string[nextfree++] = '\t';
            } else if (ch == '0') { string[nextfree++] = '\0';
            } else {
       string[nextfree++] = '\\'; string[nextfree++] = ch;
              fprintf(stderr, "? Warning: unknown escape \\%c at line %d\n", ch, lineno);
            }
          } else {
            string[nextfree++] = ch;
          }
        }
        stores(string, lineno, col, (quotech == '\'' ? 7 : 8), curfile);
      }
      break;
    case '/':
      wpstartcol = col;
      col++;
      whitespace = (0!=0);
      if (peek == '/') {
        wp = stringpool+nextstring;
        *wp++ = peek;
        do {*wp++ = (ch = xfgetc(sourcefile));} while (ch != '\n');
        wp -= 1;
        col = 0; whitespace = (0==0);
        whitedump(curfile, col);
        lineno++;
      } else if (peek == '*') {
        wp = stringpool+nextstring;
        *wp++ = '/';
        *wp++ = (ch = xfgetc(sourcefile));
        for (;;) {
          col++;
          *wp++ = (ch = xfgetc(sourcefile)); peek = xfgetc(sourcefile);
          if (ch == '\n') {
            col = 0; lineno++;
            whitedump(curfile, col);
   }
          if ((ch == '*') && (peek == '/')) break;
          xungetc(peek, sourcefile);
        }
        xungetc(peek, sourcefile);
        col += 2;
        *wp++ = '/'; (void)xfgetc(sourcefile);
        peek = xfgetc(sourcefile); xungetc(peek, sourcefile);
        whitedump(curfile, col);
      } else {
        storec(ch, lineno, col, 4, curfile);
      }
      break;
    case '+':
    case '-':
      whitespace = (0!=0);
      if (peek == ch) {
        ch = xfgetc(sourcefile);
        peek = xfgetc(sourcefile); xungetc(peek, sourcefile);
        if (ch == '+')
          stores("++", lineno, col, 2, curfile);
        else
          stores("--", lineno, col, 3, curfile);
        col++;
      } else storec(ch, lineno, col, 4, curfile);
      col++;
      break;
    case '\n': lineno++;
    case '\r': startline = (0==0); col = 0; whitespace = (0==0);
      wp = stringpool+nextstring;
      wpstartcol = col;
      whitedump(curfile, col);
      break;
    case '\t':
    case ' ': col++;
      wp = stringpool+nextstring;
      wpstartcol = col-1;
      *wp++ = ch;
      whitedump(curfile, col);
      break;
    default:
      whitespace = (0!=0);
      storec(ch, lineno, col++, 4, curfile);
    }
  }
  stores("<EOF>", lineno, col, 0, curfile); nextfree--;
}
static char xline[1024];
static int xi = 0, xcur_line = 1;
static void xungetc(int c, FILE *f)
{
    if (xi > 0) {
      xi -= 1;
    } else if (c == '\n') {
      xcur_line -= 1;
      xi = strlen(xline);
    }
    ungetc(c, f);
}
static int xfgetc(FILE *f)
{
  static int last_line = -1;
  int c;
  int ch;
  c = fgetc(f);
  if (c == EOF) return EOF;
  ch = c&255;
  if (ch == '\n') {
    xline[xi] = '\0'; xi = 0;
    if (last_line != xcur_line) {
      last_line = xcur_line;
    }
    xcur_line += 1;
  } else xline[xi++] = ch;
  if (xi == 1023) xi = 1022;
  xline[xi] = '\0';
  return c;
}
int cp = 0;
int ap = 0;
int parse(int pp, int depth)
{
  int saved_cp;
  int saved_ap;
  int i;
  int gp;
  int alts;
  int match;
  char saved_desc[256];
  gp = phrase_start[pp-512-9];
  alts = gram[gp];
  gp++;
  saved_cp = cp;
  saved_ap = ap;
  for (i = 0; i < alts; i++) {
    int each;
    int phrases = gram[gp++];
    int phrase_count;
    int gap = 0;
    cp = saved_cp;
    ap = saved_ap;
    if (ap+3 > next_free_a) next_free_a = ap+3;
    A[ap++] = pp;
    A[ap++] = i;
    for (each = 0; each < phrases; each++) if (gram[gp+each] >= 512) gap++;
    A[ap++] = gap;
    ap = ap+gap;
    if (saved_ap+3+gap > next_free_a) next_free_a = saved_ap+3+gap;
    match = (0==0);
    phrase_count = 0;
    for (each = 0; each < phrases; each++) {
      int phrase = gram[gp+each] & ((1 << 14) - 1);
      int optional_phrase = gram[gp+each] & (1<<14);
      int negated_phrase = gram[gp+each] & (1<<15);
      while (c[cp].t == (-1)) cp += 1;
      if (cp > bestparse) {
        static char s[128];
        if (phrase < 256) {
          sprintf(s, "'%c'", phrase);
        } else if (phrase < 512) {
          sprintf(s, "\"%s\"", keyword[phrase-256]);
        } else if (phrase < 512+9) {
          sprintf(s, "{%s}", phrasename[phrase-512]);
        } else {
          sprintf(s, "<%s>", phrasename[phrase-512]);
        }
        looking_for = s;
        bestparse = cp;
      }
      if (phrase < 256) {
        if ((c[cp].t != 4) || (c[cp].s[0] != phrase)) match = (0!=0); else cp++;
      } else if (phrase < 512) {
        if ((c[cp].t != 5) || (strcmp(keyword[phrase-256], c[cp].s) != 0)) match = (0!=0); else cp++;
      } else if (phrase < 512+9) {
        int where = ap;
        if (c[cp].t != BIP[phrase-512]) {
          match = (0!=0);
 } else {
          A[ap++] = phrase;
          A[ap++] = 1;
          A[ap++] = 1;
          A[ap++] = cp++;
          A[saved_ap+3+phrase_count++] = where;
        }
      } else {
        int where = ap;
        if (negated_phrase) {
          int here = cp;
          if (!parse(phrase, depth+1)) {
            A[saved_ap+3+phrase_count++] = -1;
          } else {
            match = (0!=0);
   }
          cp = here;
 } else if (optional_phrase) {
          int input_stream_pos = cp;
          if (parse(phrase, depth+1)) {
            A[saved_ap+3+phrase_count++] = where;
            cp = input_stream_pos;
          } else {
            match = (0!=0);
   }
        } else {
          if (parse(phrase, depth+1)) {
            A[saved_ap+3+phrase_count++] = where;
          } else {
            match = (0!=0);
   }
        }
      }
      if (!match) break;
    }
    gp += phrases;
    if (match) break;
  }
  return(match);
}
struct operation {
  int AST_Code;
  int Children;
  char *Diag_Name;
  char *C_Name;
  char *Stack_Name;
  int Display_Children;
};
struct operation op[1085 -1000 +2] = {
  {1000, 2, "AST_Add", "+", "ADD", 3},
  {1001, 2, "AST_Sub", "-", "SUB", 3},
  {1002, 2, "AST_Mul", "*", "MUL", 3},
  {1003, 2, "AST_Div", "/", "DIV", 3},
  {1004, 2, "AST_Mod", "%", "MOD", 3},
  {1005, 2, "AST_AddAss", "+=", "ADDI", 3},
  {1006, 2, "AST_SubAss", "-=", "SUBI", 3},
  {1007, 2, "AST_MulAss", "*=", "MULI", 3},
  {1008, 2, "AST_DivAss", "/=", "DIVI", 3},
  {1009, 2, "AST_ModAss", "%=", "MODI", 3},
  {1010, 1, "AST_Post_Inc", "()++", "", 1},
  {1011, 1, "AST_Pre_Inc", "++()", "", 1},
  {1012, 1, "AST_Post_Dec", "()--", "", 1},
  {1013, 1 ,"AST_Pre_Dec", "--()", "", 1},
  {1014, 2, "AST_Idx", "[]", "INDEX    4", 3},
  {1015, 2, "AST_Member", ".", "ADDI", 3},
  {1016, 2, "AST_Ptr", "->", "ADD", 3},
  {1017, 3, "AST_Call", "()", "", 3<<1},
  {1018, 3, "AST_Cond", "( ? : )", "", 7},
  {1019, 1, "AST_Type", "simple type", "", 1},
  {1020, 1, "AST_Return", "return", "RET      0", 0},
  {1021, 2, "AST_ReturnResult", "return ...", "RET      1", 2},
  {1022, 2, "AST_LE", "<=", "CMPLE", 3},
  {1023, 2, "AST_GT", ">", "CMPGT", 3},
  {1024, 2, "AST_LT", "<", "CMPLT", 3},
  {1025, 2, "AST_GE", ">=", "CMPGE", 3},
  {1026, 2, "AST_EQ", "==", "CMPEQ", 3},
  {1027, 2, "AST_NE", "!=", "CMPNE", 3},
  {1028, 3, "AST_IFTHENELSE", "if () ... else ...", "", 7},
  {1029, 2, "AST_IFTHEN", "if () ...", "", 3},
  {1030, 1, "AST_UNeg", "-()", "NEG", 1},
  {1031, 1, "AST_UPos", "+()", "NOOP", 1},
  {1032, 1, "AST_UBitNot", "~()", "NOT", 1},
  {1033, 1, "AST_UBoolNot", "!()", "BNOT", 1},
  {1034, 2, "AST_BoolAnd", "&&", "BAND", 3},
  {1035, 2, "AST_BoolOr", "||", "BOR", 3},
  {1036, 2, "AST_ShortcutBoolAnd", "&&", "", 3},
  {1037, 2, "AST_ShortcutBoolOr", "||", "", 3},
  {1038, 2, "AST_BitAnd", "&", "AND", 3},
  {1039, 2, "AST_BitOr", "|", "OR", 3},
  {1040, 2, "AST_BitAndAss", "&=", "ANDI", 3},
  {1041, 2, "AST_BitOrAss", "|=", "ORI", 3},
  {1042, 2, "AST_BitXor", "^", "XOR", 3},
  {1043, 2, "AST_BitXorAss", "^=", "XORI", 3},
  {1044, 2, "AST_BitLsh", "<<", "LSH", 3},
  {1045, 2, "AST_BitRsh", ">>", "RSH", 3},
  {1046, 2, "AST_BitLshAss", "<<=", "LSHI", 3},
  {1047, 2, "AST_BitRshAss", ">>=", "RSHI", 3},
  {1048, 2, "AST_Const", "Const", "", 0},
  {1049, 2, "AST_Var", "Var", "", 0},
  {1050, 2, "AST_AssignTo", "=", "POPI", 3},
  {1051, 3, "AST_Declare", "Decl", "", 7},
  {1052, 4, "AST_DefProc", "DefProc", "", 7},
  {1053, 3, "AST_DefParam", "DefParam", "", 3},
  {1054, 3, "AST_ReceiveParam", "ReceiveParam", "", 3},
  {1055, 2, "AST_UseParam", "Param", "", 3},
  {1056, 1, "AST_AddressOf", "&", "", 1},
  {1057, 1, "AST_IndirectThrough", "*", "PUSHI", 1},
  {1058, 2, "AST_SizeOf", "sizeof", "", 0},
  {1059, 1, "AST_TypeOf", "typeof", "", 1},
  {1060, 4+3, "AST_C_ForLoop", "for (;;) ...", "", 15<<3},
  {1061, 2+3, "AST_C_While", "while () ...", "", 3<<3},
  {1062, 2+3, "AST_C_DoWhile", "do ... while ();", "", 3<<3},
  {1063, 1, "AST_C_Break", "break", "", 0},
  {1064, 1, "AST_C_Continue", "continue", "", 0},
  {1065, 2, "AST_Cast", "()...", "", 2},
  {1066, 2, "AST_Label", "lab:", "", 2},
  {1067, 3, "AST_Case", "case <n>:", "", 2<<1},
  {1068, 2, "AST_DefaultCase", "default:", "", 0},
  {1069, 1, "AST_Goto", "goto ...", "", 1},
  {1070, 5, "AST_Switch", "switch (...)", "", 3<<3},
  {1071, 1, "AST_Sourceline", "src", "", 1},
  {1072, 1, "AST_LINENO", "Line #", "", 1},
  {1073, 1, "AST_REDIRECT", "REDIR", "", 1},
  {1074, 2, "AST_SEQ", ";", "", 3},
  {1075, 2, "AST_CommaSEQ", ",", "", 3},
  {1076, 1, "AST_LINEAR_BLOB", "BLOB", "", 0},
  {1077, 5, "AST_TYPE_ArrayOf", "[]", "", 3<<3},
  {1078, 3, "AST_TYPE_Struct", "{}", "", 2},
  {1079, 1, "AST_TYPE_PointerTo", "->", "", 1},
  {1080, 2, "AST_TYPE_Atom", "atom", "", 0},
  {1081, 4, "AST_TYPE_StructMember", "stmemb", ".", 7<<1},
  {1082, 3, "AST_Typed_Object", "Obj", "", 5},
  {1083, 1, "AST_TAG", "tag", "tag", 0},
  {1084, 3, "AST_Scope", "scope", "{ { } }", 2<<1},
  {1085, 10, "AST_Dummy", "dummy", "dummy", 0},
  {-1, 0, "ERROR IN op[] ARRAY!"}
};
static int nexttrip = 0;
static int AST[256*1024];
static int latest_line = -1;
void semantic_error(char *s, char *p)
{
  fprintf(stderr, s, p);
  fprintf(stderr, "Text cells used = %d, Code cells used = %d\n\n", nextfree, nexttrip);
  fflush(stderr);
  exit(2);
}
int character_constant(int ap)
{
  return mkbinop(1048, A[ap+4], c[A[ap+4]].s[0]);
}
int integer_constant(int ap)
{
  return mkbinop(1048, A[ap+4], atoi(c[A[ap+4]].s));
}
int string_constant(int ap)
{
  return mkbinop(1048, A[ap+4], A[ap+4]);
}
int mk(int AST_op, int count, int T[]) {
  int trip;
  int parm;
  trip = nexttrip+1;
  AST[trip] = AST_op;
  AST[trip+1] = count;
  if ((AST_op != 1085) && (count != op[AST_op-1000].Children)) fprintf(stderr, "? Internal warning: size mismatch in mk(%d, %d)\n", AST_op, count);
  for (parm = 0; parm < count; parm++) {
    AST[trip+parm+2] = T[parm+1];
  }
  nexttrip += 2+count+1;
  return trip;
}
int mkmonop(int AST_op, int child) {
  int trip;
  trip = nexttrip+1;
  AST[trip] = AST_op;
  AST[trip+1] = 1;
  if (1 != op[AST_op-1000].Children) fprintf(stderr, "? Internal warning: size mismatch in mkmonop(%d)\n", AST_op);
  AST[trip+2] = child;
  nexttrip += 3+1;
  return trip;
}
int mkbinop(int AST_op, int leftchild, int rightchild) {
  int trip;
  trip = nexttrip+1;
  AST[trip] = AST_op;
  AST[trip+1] = 2;
  if (2 != op[AST_op-1000].Children) fprintf(stderr, "? Internal warning: size mismatch in mkbinop(%d)\n", AST_op);
  AST[trip+2] = leftchild;
  AST[trip+3] = rightchild;
  nexttrip += 4+1;
  return trip;
}
int mkterop(int AST_op, int leftchild, int rightchild, int extrachild) {
  int trip;
  trip = nexttrip+1;
  AST[trip] = AST_op;
  AST[trip+1] = 3;
  if (3 != op[AST_op-1000].Children) fprintf(stderr, "? Internal warning: size mismatch in mkterop(%d)\n", AST_op);
  AST[trip+2] = leftchild;
  AST[trip+3] = rightchild;
  AST[trip+4] = extrachild;
  nexttrip += 5+1;
  return trip;
}
int mkconst(int n)
{
  char s[128];
  int trip = nexttrip+1;
  sprintf(s, "%d", n);
  AST[trip] = 1048;
  AST[trip+1] = 2;
  if (2 != op[1048 -1000].Children) fprintf(stderr, "? Internal warning: size mismatch in mkconst(%d)\n", n);
  AST[trip+2] = mkliteral(s);
  AST[trip+3] = n;
  nexttrip += 4+1;
  return trip;
}
void replace(int p, int val)
{
  AST[p] = 1073;
  AST[p+2] = mkconst(val);
  AST[(p)-1] = -1;
}
int DefToReceive(int p)
{
  int T[4];
  if (p == -1) return -1;
  T[1] = AST[(p)+2];
  T[2] = AST[(p)+3];
  T[3] = DefToReceive(AST[(p)+2+(2)]);
  return mk(1054, 3, T);
}
int mktag(char *tag)
{
  return mkmonop(1083, mkliteral(tag));
}
int TypeArrayOf(int child, int index, int lower, int upper)
{
  int T[6];
  T[1] = child;
  T[2] = index;
  T[3] = 0;
  T[4] = upper;
  T[5] = -1;
  return mk(1077, 5, T);
}
int TypeStructMember(int NextMember, int MemberNameTag, int ThisMemberType)
{
  int T[5];
  T[1] = NextMember;
  T[2] = MemberNameTag;
  T[3] = ThisMemberType;
  T[4] = -1;
  return mk(1081, 4, T);
}
int TypeStruct(int StructNameTag, int StructMemberList)
{
  int T[4];
  T[1] = StructNameTag;
  T[2] = StructMemberList;
  T[3] = -1;
  return mk(1078, 3, T);
}
int TypePointerTo(int child)
{
  return mkmonop(1079, child);
}
int TypeAtom(char *signedness, char *size)
{
  int T[4];
  T[1] = 0;
  if (strcmp(size, "int") == 0) {
    T[2] = 4;
  } else if (strcmp(size, "long") == 0) {
    T[2] = 4;
  } else if (strcmp(size, "long long") == 0) {
    T[2] = 8;
  } else if (strcmp(size, "short") == 0) {
    T[2] = 2;
  } else if (strcmp(size, "char") == 0) {
    T[2] = 1;
  } else {
    T[2] = 0;
  }
  return mk(1080, 2, T);
}
int ConstructType(int scope, int qualifier, int type, int pointers, int arrays) {
  int i;
  fprintf(stderr, "ConstructType(%d,%d,%d,%d,%d);\n", scope, qualifier,type,pointers,arrays);
  if ((pointers == -1) && (arrays == -1)) return type;
  if (pointers != -1) {
    int chain = pointers;
    int chainlen = 0;
    assert((chain == -1 ? -1 : AST[chain]) == 1079);
    for (;;) {
      fprintf(stderr, "chain: %d\n", chain);
      if (AST[(chain)+2] == -1) break;
      chain = AST[(chain)+2]; chainlen += 1;
      if (chain == -1) exit(1);
      if (chainlen == 5) exit(1);
    }
    AST[(chain)+2] = type;
    return pointers;
  }
  return type;
}
int current_scope = -1;
void push_scope(int here)
{
  current_scope = here;
}
void pop_scope(void) {
  current_scope = AST[(current_scope)+3];
}
int locate_tag_inner(int p, int tag, int line, char *file)
{
  int t;
  int disp;
  int this;
  int i;
  if ((p == -1 ? -1 : AST[p]) == 1051) {
    if (c[AST[(AST[(p)+2])+2]].s == c[tag].s) {
      return AST[(p)+3];
    }
  } else if ((p == -1 ? -1 : AST[p]) == 1052) {
    if (c[AST[(AST[(p)+3])+2]].s == c[tag].s) {
      return p;
    }
  } else if ((p == -1 ? -1 : AST[p]) == 1054) {
    if (c[AST[(AST[(p)+2])+2]].s == c[tag].s) {
      return AST[(p)+3];
    }
  } else if ((p == -1 ? -1 : AST[p]) == 1078) {
    if (AST[(p)+3] == -1) return -1;
    if (c[AST[(AST[(p)+2])+2]].s == c[tag].s) {
      return p;
    }
  } else if ((p == -1 ? -1 : AST[p]) == 1084) {
    return -1;
  }
  disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
  this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
  for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
    if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
      t = locate_tag_inner(AST[(p)+2+(i)], tag, 119, "nametable.c");
      if (t != -1) return t;
    }
    this = this>>1;
  }
  return -1;
}
int lookup_identifier_inner(int tag, int parent, char *file, int line)
{
  int loops = 0;
  int t;
  int scope = current_scope;
  int current_block = AST[(scope)+2];
  for (;;) {
    loops += 1;
    if (loops == 10) {
      fprintf(stderr, "* Implementation error: max scopes = 10 for now.  Possibly a bad data structure.\n");
      exit(1);
    }
    t = locate_tag_inner(current_block, tag, 168, "nametable.c");
    if (t != -1) return t;
    if (scope == AST[(scope)+3]) break;
    scope = AST[(scope)+3];
    if (scope == -1) break;
    current_block = AST[(scope)+2];
  }
  error_line(c[tag].l); fprintf(stderr, "\"%s\", Line %d: Error: %s not declared\n", c[tag].f, c[tag].l, c[tag].s);
  exit(1);
  return TypeAtom("signed", "int");
}
int get_member_type(int struct_type, int fieldname_tag)
{
  int field;
  assert((struct_type == -1 ? -1 : AST[struct_type]) == 1078);
  if (AST[(struct_type)+3] == -1) {
    fprintf(stderr, "get_member_type() - recursing!\n");exit(1);
    AST[(struct_type)+3] = lookup_identifier_inner(fieldname_tag, struct_type, "nametable.c", 195);
  }
  assert((fieldname_tag == -1 ? -1 : AST[fieldname_tag]) == 1083);
fprintf(stderr, "Looking for member name %s in struct %s (at %d) - type info is at %d\n",
c[AST[(fieldname_tag)+2]].s,
c[AST[(AST[(struct_type)+2])+2]].s,
struct_type,
AST[(struct_type)+3]
);
  field = AST[(struct_type)+3];
  for (;;) {
    if (field == -1) break;
fprintf(stderr, "Examining AST %d (op=%d) - compare @%d vs %s\n",
field, (field == -1 ? -1 : AST[field]),
AST[(field)+3],
c[AST[(fieldname_tag)+2]].s);
    if (c[AST[(AST[(field)+3])+2]].s == c[AST[(fieldname_tag)+2]].s) {
      fprintf(stderr, "Found!  Member Type = AST[%d] = %d\n", AST[(field)+2+(2)], (AST[(field)+2+(2)] == -1 ? -1 : AST[AST[(field)+2+(2)]]));
      return AST[(field)+2+(2)];
    }
    field = AST[(field)+2];
  }
  fprintf(stderr, "* Error: Member %s not found in struct %s\n", c[AST[(fieldname_tag)+2]].s, c[AST[(AST[(struct_type)+2])+2]].s);
  return -1;
}
int DeclName(int declp) {
  for (;;) {
    switch ((declp == -1 ? -1 : AST[declp])) {
      case 1074:
        declp = AST[(declp)+2];
        break;
      case 1051:
        return AST[(declp)+2];
      default:
        fprintf(stderr, "* Internal Error: missing case %d: in DeclName\n", (declp == -1 ? -1 : AST[declp]));
        return -1;
    }
  }
}
int DeclType(int declp) {
  for (;;) {
    switch ((declp == -1 ? -1 : AST[declp])) {
      case 1074:
        declp = AST[(declp)+2];
        break;
      case 1051:
        return AST[(declp)+3];
      default:
        fprintf(stderr, "* Internal Error: missing case %d: in DeclType\n", (declp == -1 ? -1 : AST[declp]));
        return -1;
    }
  }
}
void build_block_scope(int p, int parent_AST_Scope, int this_blocks_AST_Scope)
{
  int i;
  int disp;
  int this;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  if ((p == -1 ? -1 : AST[p]) == 1084) {
    AST[(p)+3] = this_blocks_AST_Scope;
    build_block_scope(AST[(p)+2], this_blocks_AST_Scope , p );
  } else {
    disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
    this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
    for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
      if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
        build_block_scope(AST[(p)+2+(i)], parent_AST_Scope, this_blocks_AST_Scope);
      }
      this = this>>1;
    }
  }
}
int build_ast_inner(int ap, int caller)
{
  int T[100];
  int saved_ap;
  int phrase;
  int alt;
  int phrases;
  int i;
fprintf(stdout, "\"grammar.c\", %d: build_ast(%d);\n", caller, ap);
  saved_ap = ap;
  phrase = A[ap++] & ((1 << 14) - 1);
  alt = A[ap++];
  phrases = A[ap++];
  if ((phrase < 512) || (phrase > 113 +512)) {
    fprintf(stderr, "* Internal error: build_ast(%d) called from line %d - phrase = %d\n",
     ap, caller, phrase); exit(1);
  }
  switch (phrase) {
  case 512:
    return -1;
  case 513:
  case 514:
  case 515:
  case 516:
  case 517:
  case 518:
  case 519:
  case 520:
    if (c[A[ap]].l > latest_line) latest_line = c[A[ap]].l;
    return A[ap];
case 521:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 204);
    T[2] = build_ast_inner(A[ap+1], 205);
    return mkbinop(1074, T[1], T[2]);
  } else {
    return -1;
  }
  return T[0];
case 522:
  if (alt == 0) {
    return -1;
    T[1] = -1;
    T[2] = build_ast_inner(A[ap+1], 231);
  } else if ((alt == 1) || (alt == 2)) {
    if (alt == 1) {
      T[1] = build_ast_inner(A[ap+0], 235);
      T[2] = build_ast_inner(A[ap+1], 236);
      T[3] = build_ast_inner(A[ap+2], 237);
      T[4] = build_ast_inner(A[ap+3], 238);
      T[5] = build_ast_inner(A[ap+4], 239);
      T[6] = build_ast_inner(A[ap+5], 240);
    } else {
      T[1] = -1;
      T[2] = build_ast_inner(A[ap+0], 243);
      T[3] = build_ast_inner(A[ap+1], 244);
      T[4] = build_ast_inner(A[ap+2], 245);
      T[5] = build_ast_inner(A[ap+3], 246);
      T[6] = -1;
    }
    T[0] = mkterop(1017, T[3], T[4], -1);
    if (T[1] != -1) T[0] = mkmonop(T[1], T[0]);
    if (T[5] != -1) {
      T[7] = T[5];
      while (AST[(T[5])+2] != -1) T[5] = AST[(T[5])+2];
      AST[(T[5])+2] = T[0];
      T[0] = T[7];
    }
    if (T[6] != -1) {
      T[7] = T[6];
      while (AST[(T[6])+2] != -1) T[6] = AST[(T[6])+2];
      AST[(T[6])+2] = T[0];
      T[0] = T[7];
    }
    return T[0];
  } else if (alt == 3) {
    T[1] = build_ast_inner(A[ap+0], 272);
    T[2] = build_ast_inner(A[ap+1], 273);
    T[3] = build_ast_inner(A[ap+2], 274);
    if ((T[2] == -1) && (T[3] == -1)) return T[1];
    if (T[2] == -1) return mkmonop(T[3], T[1]);
    T[0] = T[2];
    while (AST[(T[2])+2] != -1) T[2] = AST[(T[2])+2];
    AST[(T[2])+2] = T[1];
    if (T[3] == -1) return T[0];
    return mkmonop(T[3], T[0]);
  } else if (alt == 4) {
    return integer_constant(ap+0);
  } else if (alt == 5) {
    return character_constant(ap+0);
  } else if (alt == 6) {
    return string_constant(ap+0);
  } else {
    return build_ast_inner(A[ap+0], 289);
  }
  case 523:
  if (alt <= 1) {
    if (alt == 0) {
      T[1] = build_ast_inner(A[ap+0], 302);
      T[2] = build_ast_inner(A[ap+1], 303);
      T[3] = build_ast_inner(A[ap+2], 304);
      T[4] = build_ast_inner(A[ap+3], 305);
      T[5] = build_ast_inner(A[ap+4], 306);
      T[6] = build_ast_inner(A[ap+5], 307);
    } else {
      T[1] = -1;
      T[2] = build_ast_inner(A[ap+0], 310);
      T[3] = build_ast_inner(A[ap+1], 311);
      T[4] = build_ast_inner(A[ap+2], 312);
      T[5] = build_ast_inner(A[ap+3], 313);
      T[6] = -1;
    }
    T[0] = mkterop(1017, T[3], T[4], -1);
    if (T[1] != -1) T[0] = mkmonop(T[1], T[0]);
    if (T[5] != -1) {
      T[7] = T[5];
      while (AST[(T[5])+2] != -1) T[5] = AST[(T[5])+2];
      AST[(T[5])+2] = T[0];
      T[0] = T[7];
    }
    if (T[6] != -1) {
      T[7] = T[6];
      while (AST[(T[6])+2] != -1) T[6] = AST[(T[6])+2];
      AST[(T[6])+2] = T[0];
      T[0] = T[7];
    }
    return T[0];
  } else {
    T[1] = build_ast_inner(A[ap+0], 339);
    T[2] = build_ast_inner(A[ap+1], 340);
    T[3] = build_ast_inner(A[ap+2], 341);
    if ((T[2] == -1) && (T[3] == -1)) return T[1];
    if (T[2] == -1) return mkmonop(T[3], T[1]);
    T[0] = T[2];
    while (AST[(T[2])+2] != -1) T[2] = AST[(T[2])+2];
    AST[(T[2])+2] = T[1];
    if (T[3] == -1) return T[0];
    return mkmonop(T[3], T[0]);
  }
case 524:
  if (alt == 0) return 1010;
  if (alt == 1) return 1012;
  return -1;
case 525:
  if (alt == 3) return -1;
  T[1] = build_ast_inner(A[ap+0], 375);
  T[2] = build_ast_inner(A[ap+1], 376);
  if (alt == 0) {
    T[3] = mkbinop(1014, -1, T[1]);
  } else if (alt == 1) {
    T[3] = mkbinop(1015, -1, T[1]);
  } else if (alt == 2) {
    T[3] = mkbinop(1016, -1, T[1]);
  }
  if (T[2] == -1) return T[3];
  T[0] = T[2];
  while (AST[(T[2])+2] != -1) T[2] = AST[(T[2])+2];
  AST[(T[2])+2] = T[3];
  return T[0];
case 526:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 400);
    return mkbinop(1058, T[1], 2);
  } else {
    T[1] = build_ast_inner(A[ap+2], 405);
    T[2] = build_ast_inner(A[ap+3], 406);
    return mkterop(1017, T[1], T[2], -1);
  }
case 527:
case 528:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 421);
    T[2] = build_ast_inner(A[ap+1], 422);
    return mkbinop(1055, T[1], T[2]);
  } else {
    return mkbinop(1055, -1, -1);
  }
case 529:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 437);
    T[2] = build_ast_inner(A[ap+1], 438);
    T[3] = build_ast_inner(A[ap+2], 439);
    T[0] = T[1];
    while (AST[(T[1])+2] != -1) T[1] = AST[(T[1])+2];
    AST[(T[1])+2] = T[3];
    return T[0];
  }
  return build_ast_inner(A[ap+0], 446);
case 530:
  return -1;
case 531:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 459);
    T[2] = build_ast_inner(A[ap+1], 460);
    T[0] = T[1];
    while (AST[(T[0])+2] != -1) T[0] = AST[(T[0])+2];
    AST[(T[0])+2] = T[2];
    return T[1];
  } else {
    T[1] = build_ast_inner(A[ap+0], 466);
    T[2] = build_ast_inner(A[ap+1], 467);
    if (T[1] == -1) return T[2];
    T[0] = T[1];
    while (AST[(T[0])+2] != -1) T[0] = AST[(T[0])+2];
    AST[(T[0])+2] = T[2];
    return T[1];
  }
case 532:
  if (alt == 0) {
    return mkmonop(1011, -1);
  } else if (alt == 1) {
    return mkmonop(1013, -1);
  } else if (alt == 2) {
    T[1] = build_ast_inner(A[ap+0], 489);
    T[2] = build_ast_inner(A[ap+1], 490);
    if (T[1] == -1) return T[2];
    T[0] = T[1];
    while (AST[(T[1])+2] != -1) T[1] = AST[(T[1])+2];
    AST[(T[1])+2] = T[2];
    return T[0];
  } else if (alt == 3) {
    return mkmonop(1056, -1);
  } else {
    return mkbinop(1058, -1, 0);
  }
case 533:
  if (alt == 0) {
    return mkmonop(1011, -1);
  } else if (alt == 1) {
    return mkmonop(1013, -1);
  } else if (alt == 2) {
    return mkmonop(1031, -1);
  } else if (alt == 3) {
    return mkmonop(1030, -1);
  } else if (alt == 4) {
    return mkmonop(1033, -1);
  } else if (alt == 5) {
    return mkmonop(1032, -1);
  } else if (alt == 6) {
    return build_ast_inner(A[ap+0], 532);
  } else if (alt == 7) {
    return build_ast_inner(A[ap+0], 535);
  } else if (alt == 8) {
    return mkmonop(1056, -1);
  } else if (alt == 9) {
    return mkbinop(1058, -1, 1);
  }
  return -1;
case 534:
  T[1] = build_ast_inner(A[ap+0], 556);
  T[2] = build_ast_inner(A[ap+1], 557);
  if (T[2] == -1) return mkbinop(1065, -1, T[1]);
  T[0] = T[2];
  while (AST[(T[2])+2] != -1) T[2] = AST[(T[2])+2];
  AST[(T[2])+2] = T[1];
  return mkbinop(1065, -1, T[0]);
case 535:
  return mkmonop(1057, build_ast_inner(A[ap+0], 575));
case 536:
  if (alt == 0) return build_ast_inner(A[ap+0], 582);
  return -1;
case 537:
  return mkmonop(1079, build_ast_inner(A[ap+0], 591));
case 538:
  if (alt == 0) return build_ast_inner(A[ap+0], 598);
  return -1;
case 539:
  return -1;
case 540:
  return -1;
case 541:
  return -1;
case 542:
  switch (alt) {
  case 0: return TypeAtom("", "void");
  case 1: return TypeStruct(build_ast_inner(A[ap+0], 625), -1);
  case 2: return -1;
  case 3: return TypeAtom("" , "long long");
  case 4: return TypeAtom("" , "long long");
  case 5: return TypeAtom("" , "long");
  case 6: return TypeAtom("" , "long");
  case 7: return TypeAtom("" , "int");
  case 8: return TypeAtom("" , "short");
  case 9: return TypeAtom("" , "short");
  case 10: return TypeAtom("" , "char");
  default: return TypeAtom("", "void");
    return -1;
  }
  if (alt == 0) return 0;
  if (alt == 1) return (1<<16)-1;
  if (alt != 11) T[0] = build_ast_inner(A[ap+0], 652);
  if (alt == 2) return (1<<16)-1;
  if (alt <= 4) return 8+T[0];
  if (alt == 7) return 4+T[0];
  if (alt <= 9) return 2+T[0];
  if (alt <= 10) return 1+T[0];
  return (1<<16)-1;
case 543:
  if (alt == 0) return 1<<16;
  if (alt == 1) return 2<<16;
  return 0;
case 544:
case 545:
case 546:
case 547:
case 548:
case 549:
case 550:
case 551:
case 552:
case 553:
case 554:
  T[1] = build_ast_inner(A[ap+0], 710);
  T[2] = build_ast_inner(A[ap+1], 711);
  if (T[2] == -1) return T[1];
  T[0] = T[2];
  while (AST[(T[0])+2] != -1) T[0] = AST[(T[0])+2];
  AST[(T[0])+2] = T[1];
  return T[2];
case 555:
case 556:
case 557:
case 558:
case 559:
case 560:
case 561:
case 562:
case 563:
case 564:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 773);
    T[2] = build_ast_inner(A[ap+1], 774);
    T[3] = build_ast_inner(A[ap+2], 775);
    if (T[3] == -1) return mkbinop(T[1], -1, T[2]);
    T[0] = T[3];
    while(AST[(T[3])+2] != -1) T[3] = AST[(T[3])+2];
    AST[(T[3])+2] = mkbinop(T[1], -1, T[2]);
    return T[3];
  }
  return -1;
case 565:
  if (alt == 0) {
    return 1002;
  } else if (alt == 1) {
    return 1003;
  } else {
    return 1004;
  }
case 566:
  if (alt == 0) {
    return 1000;
  } else {
    return 1001;
  }
case 567:
  if (alt == 0) {
    return 1044;
  } else {
    return 1045;
  }
case 568:
  if (alt == 0) {
    return 1022;
  } else if (alt == 1) {
    return 1024;
  } else if (alt == 2) {
    return 1025;
  } else {
    return 1023;
  }
case 569:
  if (alt == 0) {
    return 1026;
  } else {
    return 1027;
  }
case 570:
  return 1038;
case 571:
    return -1;
case 572:
  return 1042;
case 573:
  return 1039;
case 574:
  return -1;
case 575:
  return 1034;
case 576:
  return 1035;
case 577:
  if (alt == 0) {
    T[1] = -1;
    T[2] = build_ast_inner(A[ap+0], 900);
    T[3] = build_ast_inner(A[ap+1], 901);
    return mk(1018, 3, T);
  } else {
    return -1;
  }
case 578:
  T[1] = build_ast_inner(A[ap+0], 915);
  T[2] = build_ast_inner(A[ap+1], 916);
  if (T[1] == -1) return T[2];
  T[0] = T[1];
  while (AST[(T[0])+3] != -1) T[0] = AST[(T[0])+3];
  AST[(T[0])+3] = T[2];
  return T[1];
case 579:
  return -1;
case 580:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 936);
    T[2] = -1;
    T[3] = build_ast_inner(A[ap+2], 938);
    T[4] = build_ast_inner(A[ap+3], 939);
    return mkbinop(T[3], T[1], T[4]);
  } else {
    return -1;
  }
case 581:
  if (alt == 0) {
    return 1050;
  } else if (alt == 1) {
    return 1005;
  } else if (alt == 2) {
    return 1006;
  } else if (alt == 3) {
    return 1007;
  } else if (alt == 4) {
    return 1008;
  } else if (alt == 5) {
    return 1009;
  } else if (alt == 6) {
    return 1040;
  } else if (alt == 7) {
    return 1043;
  } else if (alt == 8) {
    return 1041;
  } else if (alt == 9) {
    return 1046;
  } else {
    return 1047;
  }
case 582:
  T[1] = build_ast_inner(A[ap+0], 990);
  T[2] = build_ast_inner(A[ap+1], 991);
  if (T[2] == -1) return T[1];
  return mkbinop(1075, T[1], T[2]);
case 583:
  if (alt == 1) return -1;
  T[1] = build_ast_inner(A[ap+0], 1000);
  T[2] = build_ast_inner(A[ap+1], 1001);
  if (T[2] == -1) return T[1];
  return mkbinop(1075, T[1], T[2]);
case 584:
  return build_ast_inner(A[ap+0], 1010);
case 585:
  T[1] = mkmonop(1083, build_ast_inner(A[ap+0], 1017));
  return T[1];
case 586:
  T[1] = mkmonop(1083, build_ast_inner(A[ap+0], 1026));
  return T[1];
case 587:
  T[1] = build_ast_inner(A[ap+0], 1044);
  return T[1];
case 588:
  if (alt == 0) {
    return mkbinop(1074, mkbinop(1066, build_ast_inner(A[ap+0], 1054), -1),
                            build_ast_inner(A[ap+1], 1055));
  } else if (alt == 1) {
    T[1] = build_ast_inner(A[ap+0], 1057);
    T[2] = -1;
    T[3] = -1;
    return mkbinop(1074, mk(1067, 3, T),
                            build_ast_inner(A[ap+1], 1061));
  }
  return mkbinop(1074, mkbinop(1068, -1, -1),
                          build_ast_inner(A[ap+0], 1064));
case 589:
  T[1] = build_ast_inner(A[ap+0], 1070);
  return T[1];
case 590:
  return build_ast_inner(A[ap+0], 1078);
case 591:
  if (alt == 1) return -1;
  return build_ast_inner(A[ap+0], 1083);
  case 592:
  T[1] = -1;
  T[2] = -1;
  T[3] = 2;
  T[4] = mk(1084, 3, T);
  AST[(T[4])+3] = current_scope;
  T[5] = build_ast_inner(A[ap+0], 1101);
  T[6] = build_ast_inner(A[ap+1], 1102);
  T[7] = mkbinop(1074, T[5], T[6]);
  AST[(T[4])+2] = T[7];
  return T[4];
case 593:
  if (alt == 1) return -1;
  return build_ast_inner(A[ap+0], 1115);
case 594:
  T[1] = build_ast_inner(A[ap+0], 1119);
  T[2] = build_ast_inner(A[ap+1], 1120);
  return mkbinop(1074, T[1], T[2]);
case 595:
  return build_ast_inner(A[ap+0], 1131);
case 596:
  return build_ast_inner(A[ap+0], 1140);
case 597:
  if (alt == 1) return -1;
  T[1] = build_ast_inner(A[ap+0], 1149);
  T[2] = build_ast_inner(A[ap+1], 1150);
  return TypeStructMember(T[2], DeclName(T[1]), DeclType(T[1]));
case 598:
  T[1] = build_ast_inner(A[ap+0], 1170);
  assert((T[1] == -1 ? -1 : AST[T[1]]) == 1083);
  T[2] = build_ast_inner(A[ap+1], 1172);
  return TypeStruct(T[1] , T[2] );
case 599:
  if (alt == 1) return -1;
case 600:
  T[1] = build_ast_inner(A[ap+0], 1185);
  T[2] = build_ast_inner(A[ap+1], 1186);
  T[3] = build_ast_inner(A[ap+2], 1187);
  T[4] = build_ast_inner(A[ap+3], 1189);
  return mkbinop(1074, mk(1085, 3, T), T[4]);
case 601:
  {
    int seq = mkbinop(1074, -1, -1);
    int topseq = seq;
    T[1] = build_ast_inner(A[ap+0], 1198);
    T[2] = build_ast_inner(A[ap+1], 1199);
    T[3] = build_ast_inner(A[ap+2], 1200);
    T[0] = build_ast_inner(A[ap+3], 1201);
    for (;;) {
      assert((T[0] == -1 ? -1 : AST[T[0]]) == 1074);
      T[4] = AST[(AST[(T[0])+2])+2];
      T[5] = AST[(AST[(T[0])+2])+3];
      T[6] = AST[(AST[(T[0])+2])+2+(2)];
      AST[(seq)+2] = mkterop(1051, T[5], T[3] , T[6]);
      AST[(seq)+3] = -1;
      T[0] = AST[(T[0])+3];
      if (T[0] == -1) break;
      AST[(seq)+3] = mkbinop(1074, -1, -1);
      seq = AST[(seq)+3];
    }
    return topseq;
  }
case 602:
  T[1] = build_ast_inner(A[ap+2], 1234);
  T[2] = build_ast_inner(A[ap+4], 1235);
  T[3] = build_ast_inner(A[ap+5], 1236);
  T[4] = build_ast_inner(A[ap+6], 1237);
  if (T[4] == -1) return -1;
  assert((T[4] == -1 ? -1 : AST[T[4]]) == 1084);
  AST[(T[4])+2] = mkbinop(1074, DefToReceive(T[3]), AST[(T[4])+2]);
  return mk(1052, 4, T);
case 603:
  T[1] = build_ast_inner(A[ap+0], 1262);
  T[2] = build_ast_inner(A[ap+1], 1263);
  T[3] = build_ast_inner(A[ap+2], 1264);
  T[4] = build_ast_inner(A[ap+3], 1265);
  T[5] = build_ast_inner(A[ap+4], 1266);
  T[6] = build_ast_inner(A[ap+5], 1267);
  T[7] = build_ast_inner(A[ap+6], 1268);
  return mkterop(1051,
                           T[5],
                ConstructType(T[1], T[2], T[3], T[4], T[6]),
           T[7]);
case 604:
  if (alt == 0) return -1;
  T[1] = build_ast_inner(A[ap+0], 1290);
  assert((T[1] == -1 ? -1 : AST[T[1]]) == 1084);
  AST[(T[1])+2+(2)] = 1;
  return T[1];
case 605:
case 606:
  return -1;
case 607:
  if (alt == 1) return -1;
  return mkbinop(1050, -1, build_ast_inner(A[ap+0], 1312));
case 608:
case 609:
  if (alt >= 1) return -1;
  return mkbinop(1075, build_ast_inner(A[ap+0], 1321), build_ast_inner(A[ap+1], 1321));
case 610:
  return build_ast_inner(A[ap+0], 1326);
case 611:
  if (alt == 1) return -1;
  return mkbinop(1050, -1, build_ast_inner(A[ap+0], 1333));
case 612:
  if (alt == 0) return -1;
  T[1] = build_ast_inner(A[ap+0], 1340);
  T[2] = build_ast_inner(A[ap+1], 1341);
  AST[(T[1])+2+(2)] = T[2];
  return T[1];
case 613:
  if (alt == 1) return -1;
  T[1] = build_ast_inner(A[ap+0], 1348);
  T[2] = build_ast_inner(A[ap+1], 1349);
  AST[(T[1])+2+(2)] = T[2];
  return T[1];
case 614:
  T[1] = build_ast_inner(A[ap+2], 1355);
  T[2] = build_ast_inner(A[ap+0], 1356);
         T[4] = build_ast_inner(A[ap+1], 1357);
         if (T[4] != -1) {
           T[0] = T[4];
           while (AST[(T[4])+2] != -1) T[4] = AST[(T[4])+2];
           AST[(T[4])+2] = T[2];
           T[2] = T[0];
  }
  T[3] = -1;
  return mk(1053, 3, T);
case 615:
  return -1;
case 616:
  if (alt == 1) return -1;
  return build_ast_inner(A[ap+0], 1376);
case 617:
case 618:
  if (alt == 1) return -1;
  T[1] = build_ast_inner(A[ap+0], 1383);
  T[2] = build_ast_inner(A[ap+1], 1384);
  if (T[2] == -1) return T[1];
  return mkbinop(1074, T[1], T[2]);
case 619:
  T[1] = build_ast_inner(A[ap+0], 1391);
  T[2] = build_ast_inner(A[ap+1], 1392);
  if (alt == 0) {
    T[3] = build_ast_inner(A[ap+2], 1394);
    if (T[3] == -1) return mkbinop(1029, T[1], T[2]);
    return mk(1028, 3, T);
  }
  T[3] = -1;
  T[4] = -1;
  T[5] = -1;
  return mk(1070, 5, T);
case 620:
  if (alt == 1) return -1;
  T[1] = build_ast_inner(A[ap+0], 1406);
  return T[1];
case 621:
  T[1] = build_ast_inner(A[ap+0], 1417);
  T[2] = build_ast_inner(A[ap+1], 1418);
  T[3] = -1;
  T[4] = -1;
  T[5] = -1;
  if (alt == 0) {
    return mk(1061, 2+3, T);
  } else if (alt == 1) {
    return mk(1062, 2+3, T);
  } else {
    T[3] = build_ast_inner(A[ap+2], 1428);
    T[4] = build_ast_inner(A[ap+3], 1429);
    T[5] = -1;
    T[6] = -1;
    T[7] = -1;
    return mk(1060, 4+3, T);
  }
case 622:
  if (alt == 0) {
    T[1] = build_ast_inner(A[ap+0], 1461);
    return mkmonop(1069, T[1]);
  } else if (alt == 1) {
    return mkmonop(1064, -1);
  } else if (alt == 2) {
    return mkmonop(1063, -1);
  } else {
    T[1] = build_ast_inner(A[ap+0], 1469);
    if (T[1] == -1) {
      return mkmonop(1020, -1);
    } else{
      return mkbinop(1021, T[1], -1);
    }
  }
case 623:
  T[1] = mkmonop(1083, build_ast_inner(A[ap+0], 1484));
  return T[1];
case 624:
  T[1] = mkmonop(1083, build_ast_inner(A[ap+0], 1498));
  return T[1];
default:
  if ((phrase >= 512) && (phrase < 512+113)) {
    semantic_error("* Missing case label P_%s:\n", phrasename[phrase-512]);
  } else {
    char temp[16];
    sprintf(temp, "%d", phrase);
    semantic_error("* Missing case label P_<<%s>>\n", temp);
  }
  }
  return -1;
}
static char so_temp[1024];
void show_object(int p)
{
  switch ((p == -1 ? -1 : AST[p])) {
  case 1083: strcat(so_temp, c[AST[(p)+2]].s); return;
  case 1014: show_object(AST[(p)+2]); strcat(so_temp, "["); show_object(AST[(p)+3]); strcat(so_temp, "]"); return;
  case 1016: show_object(AST[(p)+2]); strcat(so_temp, "->"); show_object(AST[(p)+3]); return;
  case 1015: show_object(AST[(p)+2]); strcat(so_temp, "."); show_object(AST[(p)+3]); return;
  default: strcat(so_temp, "???"); return;
  }
}
char *so(int p) {
  so_temp[0] = '\0';
  show_object(p);
  return so_temp;
}
int get_lineno(int p) {
  int l;
  int disp;
  int this;
  int i;
  switch ((p == -1 ? -1 : AST[p])) {
  case 1083: return c[AST[(p)+2]].l;
  case 1014:
  case 1016:
  case 1015:
    l = get_lineno(AST[(p)+2]);
    if (l == -1) return get_lineno(AST[(p)+3]);
  default:
     disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
     this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
     for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
       if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
  l = get_lineno(AST[(p)+2+(i)]);
         if (l != -1) return l;
       }
       this = this>>1;
     }
     return -1;
  }
}
int print_all_trips(void)
{
  int ap = 1;
  for (;;) {
    int oper = AST[ap];
    int count = AST[ap+1];
    int child = ap+2;
    int disp = op[oper-1000].Display_Children;
    int this;
    if ((oper >= 1000) && (oper <= 1085)) {
      fprintf(stdout, "%4d: %s", ap, op[oper-1000].Diag_Name);
    } else {
      fprintf(stdout, "%4d: %d", ap, oper );
    }
    if (oper == 1083) {
      if (AST[child] != -1) {
        fprintf(stdout, " \"%s\" (c[%d].s)", c[AST[child]].s, AST[child]);
      } else {
        fprintf(stdout, " %d", AST[child]);
      }
    } else {
      this = 1<<(count-1);
      for (;;) {
        if (child == ap+2+count) break;
        if ((1000 <= AST[child]) && (AST[child] <= 1085) && ((AST[child] == -1 ? -1 : AST[AST[child]]) == 1083)) {
          fprintf(stdout, " \"%s\"", c[AST[(AST[child])+2]].s);
        } else {
          if (disp&this) {
            fprintf(stdout, " [%d]", AST[child]);
          } else {
            fprintf(stdout, " %d", AST[child]);
          }
        }
        this = this >> 1;
        child += 1;
      }
    }
    fprintf(stdout, "  [[typeinfo=%d]]\n", AST[(ap)-1]);
    ap = ap + 2 + AST[ap+1] + 1;
    if (ap >= nexttrip) break;
  }
  fprintf(stdout, "-----------------\n");
}
int show_ast(int ap, int depth, int comefrom)
{
  int oper = AST[ap];
  int count = AST[ap+1];
  int child = ap+2;
  int disp;
  int this;
  if (ap == -1) {
                                            return -1;
  }
  if ((oper < 1000) || (oper > 1085)) {
    fprintf(stderr, "%4d: oper = %d,  count = %d,  Children = %d (came from %4d:)\n",
     ap, oper, count, op[oper-1000].Children, comefrom);
    exit(1);
  } else if (count != op[oper-1000].Children) {
    fprintf(stderr, "%4d: oper = %d (%s),  count = %d,  Children = %d (came from %4d:)\n",
     ap, oper, op[oper-1000].Diag_Name, count, op[oper-1000].Children, comefrom);
    fflush(stderr);
    assert(count == op[oper-1000].Children);
  }
  switch (oper) {
  case 1083:
    fprintf(stdout, "%4d: %s \"%s\"  [[typeinfo=%d]]\n", ap, op[oper-1000].Diag_Name, c[AST[ap+2]].s, AST[(ap)-1]);
    break;
  case 1049:
    fprintf(stdout, "%4d: %s %s %d\n", ap, op[oper-1000].Diag_Name, c[AST[ap+2]].s, AST[ap+3]);
    break;
  case 1048:
    fprintf(stdout, "%4d: %s %s\n", ap, op[oper-1000].Diag_Name, escape(c[AST[ap+2]].s, c[AST[ap+2]].t));
    break;
  default:
    if ((oper < 1000) || (oper > 1085)) {
      fprintf(stderr, "* WARNING: show_ast oper=%d branched via 'default:' - add a case for it.\n", oper);
    } else {
      fprintf(stderr, "* WARNING: show_ast oper=%s branched via 'default:' - add a case for it.\n", op[oper-1000].Diag_Name);
    }
    exit(0);
  case 1000: ;
  case 1001: ;
  case 1002: ;
  case 1003: ;
  case 1004: ;
  case 1005: ;
  case 1006: ;
  case 1007: ;
  case 1008: ;
  case 1009: ;
  case 1010: ;
  case 1011: ;
  case 1012: ;
  case 1013: ;
  case 1014: ;
  case 1015: ;
  case 1016: ;
  case 1017: ;
  case 1018: ;
  case 1019: ;
  case 1020: ;
  case 1021: ;
  case 1022: ;
  case 1023: ;
  case 1024: ;
  case 1025: ;
  case 1026: ;
  case 1027: ;
  case 1028: ;
  case 1029: ;
  case 1070: ;
  case 1030: ;
  case 1031: ;
  case 1032: ;
  case 1033: ;
  case 1034: ;
  case 1035: ;
  case 1036: ;
  case 1037: ;
  case 1038: ;
  case 1039: ;
  case 1040: ;
  case 1041: ;
  case 1042: ;
  case 1043: ;
  case 1044: ;
  case 1045: ;
  case 1046: ;
  case 1047: ;
  case 1050: ;
  case 1051: ;
  case 1052: ;
  case 1053: ;
  case 1054: ;
  case 1055: ;
  case 1056: ;
  case 1057: ;
  case 1060: ;
  case 1061: ;
  case 1062: ;
  case 1063: ;
  case 1064: ;
  case 1065: ;
  case 1058: ;
  case 1067: ;
  case 1068: ;
  case 1066: ;
  case 1069: ;
  case 1071: ;
  case 1072: ;
  case 1073: ;
  case 1076: ;
  case 1074: ;
  case 1075: ;
  case 1077: ;
  case 1078: ;
  case 1079: ;
  case 1080: ;
  case 1081: ;
  case 1084: ;
    disp = op[oper-1000].Display_Children;
    fprintf(stdout, "%4d: %s", ap, op[oper-1000].Diag_Name);
    if (disp == 0) {
      fprintf(stdout, "\n");
      return;
    }
    this = 1<<(count-1);
    for (;;) {
      if (child == ap+2+count) break;
      if (disp&this) fprintf(stdout, " [%d]", AST[child]); else fprintf(stdout, " %d", AST[child]);
      this = this >> 1;
      child += 1;
    }
    fprintf(stdout, "  [[typeinfo=%d]]\n", AST[(ap)-1]);
    this = 1<<(count-1);
    {
      child = ap+2;
      for (;;) {
        if (child == ap+2+count) break;
        if (disp&this) show_ast(AST[child], depth+1, ap);
        this = this >> 1;
        child += 1;
      }
    }
    break;
  }
  fflush(stdout);
  return -1;
}
static char *SPACES =
  "                                                                                        ";
void stack_emit(char *label, char *opcode, char *addressing_mode, char *operand, char *comment)
{
  char line[512];
  char *s;
  int col = 0, spaces;
  sprintf(line, "%s%s", label, SPACES);
  line[9] = ' '; line[10] = '\0';
  sprintf(line+10, "%s%s", opcode, SPACES);
  if (line[19] == ' ') {
    line[19] = '\0';
    sprintf(line+19, "%s%s ", addressing_mode, operand);
  } else strcat(line, " ");
  if (strlen(line) < 55) {
    strcat(line, SPACES);
    line[54] = ' '; line[55] = '\0';
  }
  strcat(line, "; ");
  strcat(line, comment);
  fprintf(stdout, "%s\n", line);
}
int stack_code(int ap, int thenlab, int elselab, int donelab)
{
  char temp[128];
  char temp2[128];
  int oper;
  int count;
  int disp;
  char *opname;
  char *code;
  int this;
  if ((ap == -1) || AST[ap] == -1) return -1;
  while (AST[ap] == 1073) AST[ap] = AST[(AST[ap])+2];
  if ((ap == -1) || AST[ap] == -1) return -1;
  oper = AST[ap]; count = AST[ap+1];
  if ((oper < 1000) || (oper > 1085)) {
    fprintf(stderr, "* Bad oper %d at switch in genstack.c\n", oper); exit(1);
  }
  disp = op[oper-1000].Display_Children;
  opname = op[oper-1000].Diag_Name;
  code = op[oper-1000].Stack_Name;
  if (count != op[oper-1000].Children) {
    fprintf(stderr, "Oper = %d (%s)\n", oper, opname);
    assert(count == op[oper-1000].Children);
  }
  switch (oper) {
  case 1078:
    return;
  case 1084:
    push_scope(ap);
    stack_code(AST[(ap)+2], -1,-1,-1);
    pop_scope();
    return;
  case 1074:
    stack_code(AST[(ap)+2], -1,-1,-1);
    stack_code(AST[(ap)+3], -1,-1,-1);
    break;
  case 1051:
    break;
  case 1083:
    {
      if ((AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]) == 1077) {
        stack_emit("", "PUSH", "&", c[AST[(ap)+2]].s, "push address of zeroth element of array");
      } else if ((AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]) == -1) {
        stack_emit("", "PUSH", "", c[AST[(ap)+2]].s, "(implied external?)");
      } else {
        sprintf(temp, "[[typeinfo=%d]]", (AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]));
        stack_emit("", "PUSH", "", c[AST[(ap)+2]].s, temp);
      }
    }
    break;
  case 1049:
    if (AST[(ap)+3] == 0) {
      stack_emit("", "PUSH", "", c[AST[(ap)+2]].s, "This code may be replaced under the new type system");
    } else if (AST[(ap)+3] == 1) {
      stack_emit("", "PUSH", "&", c[AST[(ap)+2]].s,"This code may be replaced under the new type system");
    } else {
      fprintf(stderr, "VAR: rightchild(%d) (type) = %d\n", ap, AST[(ap)+3]);
      assert((unsigned int)AST[(ap)+3] <= 1);
    }
    break;
  case 1014: ;
    {int objecttype = AST[(AST[(AST[(ap)+2])-1])+2];
    stack_code(AST[(ap)+2], -1,-1,-1);
    stack_code(AST[(ap)+3], -1,-1,-1);
    if ((objecttype == -1 ? -1 : AST[objecttype]) == 1078) {
      sprintf(temp, "(by size of struct %s)", c[AST[(AST[(objecttype)+2])+2]].s);
    } else {
      sprintf(temp, "(by size of object type %d)", (objecttype == -1 ? -1 : AST[objecttype]));
    }
    sprintf(temp2, "%d", object_sizeof(objecttype));
    stack_emit("", "INDEX", temp2, "", temp);
    }
    break;
  case 1015: ;
    stack_code(AST[(ap)+2], -1,-1,-1);
    stack_code(AST[(ap)+3], -1,-1,-1);
    stack_emit("", "ADD", "", "", "add offset to this member to object base address");
    break;
  case 1016: ;
    stack_code(AST[(ap)+2], -1,-1,-1);
    stack_emit("", "PUSHI", "", "", "dereference pointer to base of struct");
    stack_code(AST[(ap)+3], -1,-1,-1);
    stack_emit("", "ADD", "", "", "add offset to this field in the struct");
    break;
  case 1056:
    ap = AST[(ap)+2];
    if ((ap == -1 ? -1 : AST[ap])==1083) {
      stack_emit("", "PUSH", "&", c[AST[(ap)+2]].s, "AddressOf()");
    } else if ((ap == -1 ? -1 : AST[ap])==1078) {
      stack_emit("", "PUSH", "&", c[AST[(ap)+2]].s, "AddressOf()");
    } else if ((ap == -1 ? -1 : AST[ap])==1057) {
      stack_code(AST[(ap)+2], -1,-1,-1);
    } else if (((ap) == -1 ? -1 : AST[(ap)+1]) == 2) {
      AST[(ap)+2] = mkmonop(1056, AST[(ap)+2]);
      stack_code(ap, -1,-1,-1);
    } else {
      fprintf(stderr, "Internal error, not sure how to handle AddressOf(@ %d:)\n",ap); exit(1);
    }
    break;
  case 1050:
    if ((AST[(ap)+2] == -1 ? -1 : AST[AST[(ap)+2]])==1083) {
      stack_code(AST[(ap)+3], -1,-1,-1);
      ap = AST[(ap)+2];
      if ((AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]) == 1077) {
        stack_emit("", "POPI", "", c[AST[(ap)+2]].s, "store indirect");
      } else if ((AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]) == -1) {
        stack_emit("", "POP", "", c[AST[(ap)+2]].s, "(implied external?)");
      } else {
        sprintf(temp, "[[typeinfo=%d]]", (AST[(ap)-1] == -1 ? -1 : AST[AST[(ap)-1]]));
        stack_emit("", "POP", "", c[AST[(ap)+2]].s, temp);
      }
    } else {
  case 1005:
  case 1006:
  case 1007:
  case 1008:
  case 1009:
  case 1046:
  case 1047:
  case 1040:
  case 1041:
  case 1043:
      stack_emit("", "", "", "", "next is addressof(LHS)");
      stack_code(mkmonop(1056, AST[(ap)+2]), -1,-1,-1);
      stack_code(AST[(ap)+3], -1,-1,-1);
      stack_emit("", code, "", "", "modify TOS-1 with contents of TOS");
    }
    break;
  case 1048:
    stack_emit("", "PUSH", "#", escape(c[AST[(ap)+2]].s, c[AST[(ap)+2]].t), "AST_Const");
    break;
  case 1075:
    stack_code(AST[(ap)+2], -1,-1,-1);
    if (AST[(ap)+3] != -1) {
      stack_emit("", "POP", "", "", "void");
      stack_code(AST[(ap)+3], -1,-1,-1);
    }
    break;
  case 1052: ;
    {
    int params = AST[(ap)+2+(2)];
    stack_emit("", "PROC", c[AST[(AST[(ap)+3])+2]].s, "", "AST_DefProc");
    stack_code(AST[(ap)+2+(2)], -1,-1,-1);
    stack_code(AST[(ap)+2+(2+1)], -1,-1,-1);
                                      stack_emit("", "RET", "", "0", "Return by dropping through end of proc");
    }
    break;
  case 1053:
    break;
  case 1054:
    {
      sprintf(temp, "[[typeinfo=%d]]", (AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]));
      stack_emit("", "PARAM", "", c[AST[(AST[(ap)+2])+2]].s, temp);
      if (AST[(ap)+2+(2)] != -1) stack_code(AST[(ap)+2+(2)], -1,-1,-1);
    }
    break;
  case 1017: ;
    {
      int UseParam;
      int Var;
      int DefProc;
      int count;
      int results;
      char callee[128];
      assert((AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]) == 1055);
      Var = AST[(ap)+2]; UseParam = AST[(ap)+3]; count = 0;
      while ((UseParam == -1 ? -1 : AST[UseParam]) == 1055) { count += 1; UseParam = AST[(UseParam)+3]; }
      DefProc = AST[(ap)+2+(2)];
      assert(DefProc != -1);
      if (AST[(AST[(DefProc)+2])+3] == 0 ) results = 0; else results = 1 ;
      sprintf(callee, "%s,%d,%d", c[AST[(Var)+2]].s, count-1, results);
      stack_emit("", "PRECALL", "", callee, "in case we need to reserve space etc");
      stack_code(AST[(ap)+3], -1,-1,-1);
      sprintf(callee, "%s,%d,%d", c[AST[(Var)+2]].s, count-1, results);
      stack_emit("", "CALL", "", callee, "AST_Call");
    }
    break;
  case 1021:
    stack_code(AST[(ap)+2], -1,-1,-1);
    stack_emit("", "RET", "", "1", "Return a result");
    break;
  case 1020:
    stack_emit("", "RET", "", "0", "Return");
    break;
  case 1066:
    stack_emit(c[AST[(AST[(ap)+2])+2]].s, "", "", "", "AST_Label");
    break;
  case 1069:
    stack_emit("", "B", "", c[AST[(AST[(ap)+2])+2]].s, "AST_Goto");
    break;
  case 1061: ;
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+2)]);
    stack_emit(temp, "", "", "", "START: AST_C_While");
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+1)]);
    stack_emit(temp, "", "", "", "CONTINUE: AST_C_While");
    stack_code(AST[(ap)+2], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+0)]);
    stack_emit("", "BF", "", temp, "");
    stack_code(AST[(ap)+3], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+1)]);
    stack_emit("", "B", "", temp, "LOOP: AST_C_While");
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+0)]);
    stack_emit(temp, "", "", "", "EXIT: AST_C_While");
    break;
  case 1062: ;
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+2)]);
    stack_emit(temp, "", "", "", "START: AST_C_DoWhile");
    stack_code(AST[(ap)+2], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+1)]);
    stack_emit(temp, "", "", "", "CONTINUE: AST_C_DoWhile");
    stack_code(AST[(ap)+3], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+2)]);
    stack_emit("", "BT", "", temp, "LOOP: AST_C_While");
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+0)]);
    stack_emit(temp, "", "", "", "EXIT: AST_C_DoWhile");
    break;
  case 1060:
    stack_code(AST[(ap)+2], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+4)]);
    stack_emit(temp, "", "", "", "START: AST_C_ForLoop");
    stack_code(AST[(ap)+3], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+2)]);
    stack_emit("", "BF", "", temp, "");
    stack_code(AST[(ap)+2+(2+1)], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+3)]);
    stack_emit(temp, "", "", "", "CONTINUE: AST_C_ForLoop");
    stack_code(AST[(ap)+2+(2)], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+4)]);
    stack_emit("", "B", "", temp, "LOOP: AST_C_ForLoop");
    sprintf(temp, "__L%0d", AST[(ap)+2+(2+2)]);
    stack_emit(temp, "", "", "", "EXIT: AST_C_ForLoop");
    break;
  case 1063:
    if (AST[(ap)+2] == -1) {fprintf(stderr, "* ERROR: break (AST %4d:) does not know its jump destination.", ap); exit(1);}
    sprintf(temp, "__L%0d", AST[(ap)+2]);
    stack_emit("", "B", "", temp, "AST_C_Break");
    break;
  case 1064:
    if (AST[(ap)+2] == -1) {fprintf(stderr, "* ERROR: continue (AST %4d:) does not know its jump destination.", ap); exit(1);}
    sprintf(temp, "__L%0d", AST[(ap)+2]);
    stack_emit("", "B", "", temp, "AST_C_Continue");
    break;
  case 1018:
    {
        int cond = AST[(ap)+2];
        int thenpart = AST[(ap)+3];
        int elsepart = AST[(ap)+2+(2)];
 {
 int thenlab = temp_label();
 int donelab = temp_label();
 int elselab = temp_label();
        if (((cond == -1 ? -1 : AST[cond]) < 1022) || ((cond == -1 ? -1 : AST[cond]) > 1027)) {
          if (((cond == -1 ? -1 : AST[cond]) < 1034) || ((cond == -1 ? -1 : AST[cond]) > 1037)) {
            cond = mkbinop(1027, cond, mkconst(0));
   }
        }
 stack_code(cond, thenlab, elselab, thenlab);
        sprintf(temp, "__L%0d", thenlab); stack_emit(temp, "", "", "", "?-lab");
 stack_code(thenpart, -1, -1, -1);
        sprintf(temp, "__L%0d", donelab); stack_emit("", "B", "", temp, "");
        sprintf(temp, "__L%0d", elselab); stack_emit(temp, "", "", "", ":-lab");
 stack_code(elsepart, -1, -1, -1);
        sprintf(temp, "__L%0d", donelab); stack_emit(temp, "", "", "", "donelab");
 }
    }
    break;
  case 1022: ;
  case 1023: ;
  case 1024: ;
  case 1025: ;
  case 1026: ;
  case 1027: ;
    {
      stack_code(AST[(ap)+2], thenlab, elselab, donelab);
      stack_code(AST[(ap)+3], thenlab, elselab, donelab);
      stack_emit("", code, "", "", "");
      if (thenlab != donelab) {
        sprintf(temp, "__L%0d", thenlab);
        stack_emit("", "BT", "", temp, "");
      }
      if (elselab != donelab) {
        sprintf(temp, "__L%0d", elselab);
        stack_emit("", "BF", "", temp, "");
      }
    }
    break;
  case 1034:
  case 1035:
  case 1036:
  case 1037:
    {
      int truelab = thenlab;
      int falselab = elselab;
      int dropthrough = donelab;
      {
      int thenlab;
      int elselab;
      int donelab;
      int nexttestlab = temp_label();
      if (((ap == -1 ? -1 : AST[ap]) == 1034) || ((ap == -1 ? -1 : AST[ap]) == 1036)) {
 thenlab = nexttestlab; elselab = falselab;
      } else {
 thenlab = truelab; elselab = nexttestlab;
      }
      donelab = nexttestlab;
      if (((AST[(ap)+2] == -1 ? -1 : AST[AST[(ap)+2]]) < 1022) || ((AST[(ap)+2] == -1 ? -1 : AST[AST[(ap)+2]]) > 1027)) {
        if (((AST[(ap)+2] == -1 ? -1 : AST[AST[(ap)+2]]) < 1034) || ((AST[(ap)+2] == -1 ? -1 : AST[AST[(ap)+2]]) > 1037)) {
          AST[(ap)+2] = mkbinop(1027, AST[(ap)+2], mkconst(0));
 }
      }
      stack_code(AST[(ap)+2], thenlab, elselab, donelab);
      sprintf(temp, "__L%0d", nexttestlab); stack_emit(temp, "", "", "", "nexttestlab");
      if (((AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]) < 1022) || ((AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]) > 1027)) {
        if (((AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]) < 1034) || ((AST[(ap)+3] == -1 ? -1 : AST[AST[(ap)+3]]) > 1037)) {
          AST[(ap)+3] = mkbinop(1027, AST[(ap)+3], mkconst(0));
 }
      }
      stack_code(AST[(ap)+3], truelab, falselab, dropthrough);
      }
    }
    break;
  case 1029: ;
    {
      int cond = AST[(ap)+2];
      int thenpart = AST[(ap)+3];
      {
 int thenlab = temp_label();
 int donelab = temp_label();
        if (((cond == -1 ? -1 : AST[cond]) < 1022) || ((cond == -1 ? -1 : AST[cond]) > 1027)) {
          if (((cond == -1 ? -1 : AST[cond]) < 1034) || ((cond == -1 ? -1 : AST[cond]) > 1037)) {
            cond = mkbinop(1027, cond, mkconst(0));
   }
        }
 stack_code(cond, thenlab, donelab, thenlab);
        sprintf(temp, "__L%0d", thenlab); stack_emit(temp, "", "", "", "thenlab");
 stack_code(thenpart, -1,-1,-1);
        sprintf(temp, "__L%0d", donelab); stack_emit(temp, "", "", "", "donelab");
     }
    }
    break;
  case 1028: ;
    {
      int cond = AST[(ap)+2];
      int thenpart = AST[(ap)+3];
      int elsepart = AST[(ap)+2+(2)];
      {
 int thenlab = temp_label();
 int donelab = temp_label();
 int elselab = temp_label();
        if (((cond == -1 ? -1 : AST[cond]) < 1022) || ((cond == -1 ? -1 : AST[cond]) > 1027)) {
          if (((cond == -1 ? -1 : AST[cond]) < 1034) || ((cond == -1 ? -1 : AST[cond]) > 1037)) {
            cond = mkbinop(1027, cond, mkconst(0));
   }
        }
 stack_code(cond, thenlab, elselab, thenlab);
        sprintf(temp, "__L%0d", thenlab); stack_emit(temp, "", "", "", "thenlab");
 stack_code(thenpart, -1,-1,-1);
        sprintf(temp, "__L%0d", donelab); stack_emit("", "B", "", temp, "");
        sprintf(temp, "__L%0d", elselab); stack_emit(temp, "", "", "", "elselab");
 stack_code(elsepart, -1,-1,-1);
        sprintf(temp, "__L%0d", donelab); stack_emit(temp, "", "", "", "donelab");
     }
    }
    break;
  case 1070: ;
    {
    int next = AST[(ap)+2+(2+1)];
    int switch_table = temp_label();
    stack_code(AST[(ap)+2], -1,-1,-1);
    sprintf(temp, "__L%0d", switch_table);
    stack_emit("", "SWITCH", "", temp, "special opcodes handle DUP of TOS");
    stack_emit(temp, "", "", "", "jump table start");
    while (next != -1) {
      stack_code(AST[(next)+2], -1,-1,-1);
      sprintf(temp, "__L%0d", AST[(next)+2+(2)]);
      stack_emit("", "CASE", "", temp, "");
      next = AST[(next)+3];
    }
    next = AST[(ap)+2+(2+2)];
    if ((next != -1) && (AST[(next)+3] != -1)) {
      sprintf(temp, "__L%0d", AST[(next)+3]);
      stack_emit("", "DEFAULT", "", temp, "");
    } else {
      stack_emit("", "DEFAULT", "", "__missing_case_label__", "");
    }
    stack_code(AST[(ap)+3], -1,-1,-1);
    sprintf(temp, "__L%0d", AST[(ap)+2+(2)]);
    stack_emit(temp, "", "", "", "breaking from the switch comes here");
    }
    break;
  case 1067: ;
    sprintf(temp, "__L%0d", AST[(ap)+2+(2)]);
    stack_emit(temp, "", "", "", "Case element");
    break;
  case 1068: ;
    sprintf(temp, "__L%0d", AST[(ap)+3]);
    stack_emit(temp, "", "", "", "Default case");
    break;
  default:
    if ((oper < 1000) || (oper > 1085)) {
      fprintf(stderr, "* WARNING: genstack oper=%d branched via 'default:' - add a case for it.\n",
                      oper);
    } else {
      fprintf(stderr, "* WARNING: genstack oper=%s branched via 'default:' - add a case for it.\n",
                       op[oper-1000].Diag_Name);
    }
    exit(0);
  case 1000: ;
  case 1001: ;
  case 1002: ;
  case 1003: ;
  case 1004: ;
  case 1010: ;
  case 1011: ;
  case 1012: ;
  case 1013: ;
  case 1019: ;
  case 1030: ;
  case 1031: ;
  case 1032: ;
  case 1033: ;
  case 1038: ;
  case 1039: ;
  case 1042: ;
  case 1044: ;
  case 1045: ;
  case 1055: ;
  case 1057: ;
  case 1058: ;
  case 1065: ;
  case 1071: ;
  case 1072: ;
  case 1073: ;
  case 1076: ;
    {
      int child = 0;
      if ((count <= 2) && (*code != '\0')) {
        if (count >= 1) stack_code(AST[(ap)+2], -1,-1,-1);
        if (count >= 2) stack_code(AST[(ap)+3], -1,-1,-1);
        stack_emit("", code, "", "", opname); return;
      }
      this = 1<<(count-1);
      for (;;) {
        if (child == count) break;
        if (disp&this) stack_code(AST[(ap)+2+(child)], -1,-1,-1);
        this = this >> 1; child += 1;
      }
      if (oper != 1055) stack_emit("", "", "", "", opname);
    }
    break;
  }
  fflush(stdout);
  return -1;
}
void stack_data(void)
{
}
void Fold(int p)
{
  int op;
  int arity;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  op = (p == -1 ? -1 : AST[p]); arity = ((p) == -1 ? -1 : AST[(p)+1]);
  if (arity == 1) {
    if ((AST[(p)+2] != -1) && ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1048)) {
      switch (op) {
        case 1030: replace(p, -AST[(AST[(p)+2])+3]); return;
        case 1031: replace(p, +AST[(AST[(p)+2])+3]); return;
        case 1032: replace(p, ~AST[(AST[(p)+2])+3]); return;
        case 1033: replace(p, !AST[(AST[(p)+2])+3]); return;
        default:
   return;
      }
    }
  } else if (arity == 2) {
    if (((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1048) && ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1048)) {
    switch (op) {
    case 1000: replace(p, AST[(AST[(p)+2])+3] + AST[(AST[(p)+3])+3]); return;
    case 1001: replace(p, AST[(AST[(p)+2])+3] - AST[(AST[(p)+3])+3]); return;
    case 1002: replace(p, AST[(AST[(p)+2])+3] * AST[(AST[(p)+3])+3]); return;
    case 1003: if (AST[(AST[(p)+3])+3] != 0) replace(p, AST[(AST[(p)+2])+3] / AST[(AST[(p)+3])+3]); return;
    case 1004: if (AST[(AST[(p)+3])+3] != 0) replace(p, AST[(AST[(p)+2])+3] % AST[(AST[(p)+3])+3]); return;
    case 1022: replace(p, AST[(AST[(p)+2])+3] <= AST[(AST[(p)+3])+3]); return;
    case 1023: replace(p, AST[(AST[(p)+2])+3] > AST[(AST[(p)+3])+3]); return;
    case 1024: replace(p, AST[(AST[(p)+2])+3] < AST[(AST[(p)+3])+3]); return;
    case 1025: replace(p, AST[(AST[(p)+2])+3] >= AST[(AST[(p)+3])+3]); return;
    case 1026: replace(p, AST[(AST[(p)+2])+3] == AST[(AST[(p)+3])+3]); return;
    case 1027: replace(p, AST[(AST[(p)+2])+3] != AST[(AST[(p)+3])+3]); return;
    case 1034: replace(p, AST[(AST[(p)+2])+3] && AST[(AST[(p)+3])+3]); return;
    case 1035: replace(p, AST[(AST[(p)+2])+3] || AST[(AST[(p)+3])+3]); return;
    case 1036: replace(p, AST[(AST[(p)+2])+3] && AST[(AST[(p)+3])+3]); return;
    case 1037: replace(p, AST[(AST[(p)+2])+3] || AST[(AST[(p)+3])+3]); return;
    case 1038: replace(p, AST[(AST[(p)+2])+3] & AST[(AST[(p)+3])+3]); return;
    case 1039: replace(p, AST[(AST[(p)+2])+3] | AST[(AST[(p)+3])+3]); return;
    case 1042: replace(p, AST[(AST[(p)+2])+3] ^ AST[(AST[(p)+3])+3]); return;
    case 1044: replace(p, AST[(AST[(p)+2])+3] << AST[(AST[(p)+3])+3]); return;
    case 1045: replace(p, AST[(AST[(p)+2])+3] >> AST[(AST[(p)+3])+3]); return;
    default:
      return;
    }
    }
  } else if (op == 1018) {
    if (((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1048)
     && ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1048)
     && ((AST[(p)+2+(2)] == -1 ? -1 : AST[AST[(p)+2+(2)]]) == 1048)
    ) {
      replace(p, ( AST[(AST[(p)+2])+3] ? AST[(AST[(p)+3])+3] : AST[(AST[(p)+2+(2)])+3])); return;
    }
  }
}
void fold_constant_expressions(int p)
{
  int i;
  int disp;
  int this;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  if (((p == -1 ? -1 : AST[p]) < 1000) || ((p == -1 ? -1 : AST[p]) > 1085)) {
    fprintf(stderr, "* Internal Error: p=%d  astop(p) - %d\n", p, (p == -1 ? -1 : AST[p]));
    exit(1);
  }
  disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
  this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
  for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
    if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
      fold_constant_expressions(AST[(p)+2+(i)]);
      while ((AST[(p)+2+(i)] == -1 ? -1 : AST[AST[(p)+2+(i)]]) == 1073) AST[(p)+2+(i)] = AST[(AST[(p)+2+(i)])+2];
    }
    this = this>>1;
  }
  Fold(p);
}
int object_sizeof(int ast_type)
{
  if ((ast_type == -1 ? -1 : AST[ast_type]) == 1078) return 12;
  if ((ast_type == -1 ? -1 : AST[ast_type]) == 1077) return 120;
  return 4;
}
int derive_type(int p)
{
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  switch ((p == -1 ? -1 : AST[p])) {
    case 1054:
      return AST[(p)+3];
    case 1078:
      if (AST[(p)+3] != -1) return p;
      AST[(p)+3] = AST[(lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 39))+3];
      return p;
    case 1048:
      return TypeAtom("signed", "int");
    case 1083:
      return -1;
    case 1014:
      {
        int objtype;
        int idxtype;
        if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 58);
        if ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1083) AST[(AST[(p)+3])-1] = lookup_identifier_inner(AST[(AST[(p)+3])+2], p, "populate_types.c", 59);
        objtype = AST[(AST[(p)+2])-1];
        idxtype = AST[(AST[(p)+3])-1];
 if ((objtype == -1) || (idxtype == -1)) {
          assert(objtype != -1); assert(idxtype != -1);
 }
        if (((objtype == -1 ? -1 : AST[objtype]) != 1077) && ((objtype == -1 ? -1 : AST[objtype]) != 1079)) {
   error_line(get_lineno(AST[(p)+2]));
          fprintf(stderr, "* Error: indexed object %s is not an array or pointer (found %s)\n",
    so(AST[(p)+2]), op[(objtype == -1 ? -1 : AST[objtype])-1000].Diag_Name); exit(1);
        }
 fprintf(stderr, "Setting TYPEINFO(%d) to cell at %d (type=%d)\n", p, AST[(objtype)+2], (AST[(objtype)+2] == -1 ? -1 : AST[AST[(objtype)+2]]));
        return AST[(objtype)+2];
      }
    case 1015:
      {
        int objtype;
        int fieldtype;
        if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 88);
        objtype = AST[(AST[(p)+2])-1];
        if ((objtype == -1 ? -1 : AST[objtype]) != 1078) {
   error_line(get_lineno(AST[(p)+2]));
          fprintf(stderr, "* Error: AST_Member: object %s is not a struct (appears it is a %d)\n",
                          so(AST[(p)+2]), (objtype == -1 ? -1 : AST[objtype])); exit(1);
        }
        if ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1083) {
          fieldtype = AST[(AST[(p)+3])-1] = get_member_type(objtype , AST[(p)+3] );
 } else {
          fieldtype = AST[(AST[(p)+3])-1];
          fprintf(stderr, "* Internal Error: struct member is not a tag? (got %d)\n", (fieldtype == -1 ? -1 : AST[fieldtype])); exit(1);
 }
        return fieldtype;
      }
    case 1016:
      {
        int objtype;
        int fieldtype;
        if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 118);
        objtype = AST[(AST[(p)+2])-1];
        if ((objtype == -1 ? -1 : AST[objtype]) != 1079) {
   error_line(get_lineno(AST[(p)+2]));
          fprintf(stderr, "* Error: AST_Ptr: object %d is not a pointer to something (appears it is a %d)\n",
                          AST[(p)+2], (objtype == -1 ? -1 : AST[objtype])); exit(1);
        }
        if ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1083) {
          fieldtype = AST[(AST[(p)+3])-1] = get_member_type(AST[(objtype)+2] , AST[(p)+3] );
 } else {
          fieldtype = AST[(AST[(p)+3])-1];
   error_line(get_lineno(AST[(p)+2]));
          fprintf(stderr, "* Internal Error: struct member is not a tag? (got %d)\n", (fieldtype == -1 ? -1 : AST[fieldtype])); exit(1);
 }
        return fieldtype;
      }
    case 1057:
      {
        int objtype;
        if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 144);
        objtype = AST[(AST[(p)+2])-1];
        if ((objtype == -1 ? -1 : AST[objtype]) != 1079) {
   error_line(get_lineno(AST[(p)+2]));
          fprintf(stderr, "* Error: Indirected object %s is not a pointer (got %d)\n",
    so(AST[(p)+2]), (objtype == -1 ? -1 : AST[objtype]));
          exit(1);
 }
        return AST[(objtype)+2];
      }
  case 1017:
    {
      int defproc;
      defproc = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 163);
      AST[(p)+2+(2)] = defproc;
      return AST[(defproc)+2];
    }
    case 1030:
    case 1031:
    case 1032:
    case 1033:
    case 1010:
    case 1011:
    case 1012:
    case 1013:
      if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 179);
      return AST[(AST[(p)+2])-1];
    case 1005:
    case 1006:
    case 1007:
    case 1008:
    case 1009:
    case 1040:
    case 1041:
    case 1043:
    case 1046:
    case 1047:
    case 1050:
    case 1000:
    case 1001:
    case 1002:
    case 1003:
    case 1004:
    case 1022:
    case 1023:
    case 1024:
    case 1025:
    case 1026:
    case 1027:
    case 1034:
    case 1035:
    case 1036:
    case 1037:
    case 1038:
    case 1039:
    case 1042:
    case 1044:
    case 1045:
      if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 226);
      if ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1083) AST[(AST[(p)+3])-1] = lookup_identifier_inner(AST[(AST[(p)+3])+2], p, "populate_types.c", 227);
      return AST[(AST[(p)+2])-1];
    case 1018:
      if ((AST[(p)+2] == -1 ? -1 : AST[AST[(p)+2]]) == 1083) AST[(AST[(p)+2])-1] = lookup_identifier_inner(AST[(AST[(p)+2])+2], p, "populate_types.c", 236);
      if ((AST[(p)+3] == -1 ? -1 : AST[AST[(p)+3]]) == 1083) AST[(AST[(p)+3])-1] = lookup_identifier_inner(AST[(AST[(p)+3])+2], p, "populate_types.c", 237);
      if ((AST[(p)+2+(2)] == -1 ? -1 : AST[AST[(p)+2+(2)]]) == 1083) AST[(AST[(p)+2+(2)])-1] = lookup_identifier_inner(AST[(AST[(p)+2+(2)])+2], p, "populate_types.c", 238);
      return AST[(AST[(p)+3])-1];
    default:
      return -1;
  }
}
void populate_types(int p)
{
  int i;
  int disp;
  int this;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  if ((p == -1 ? -1 : AST[p]) == 1084) {
    push_scope(p);
  }
  disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
  this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
  for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
    if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
      populate_types(AST[(p)+2+(i)]);
    }
    this = this>>1;
  }
  AST[(p)-1] = derive_type(p);
  if ((p == -1 ? -1 : AST[p]) == 1084) {
    pop_scope();
  }
}
int temp_label(void)
{
  static int next = 999;
  next += 1;
  return next;
}
void assign_loop_labels(int p, int break_lab, int continue_lab, int branch_back_lab)
{
  int i;
  int disp;
  int this;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  if ((p == -1 ? -1 : AST[p]) == 1064) {
    AST[(p)+2] = continue_lab;
    return;
  } else if ((p == -1 ? -1 : AST[p]) == 1063) {
    AST[(p)+2] = break_lab;
    return;
  }
  if (((p == -1 ? -1 : AST[p]) == 1061) || ((p == -1 ? -1 : AST[p]) == 1062)) {
    break_lab = AST[(p)+2+(2+0)];
    continue_lab = AST[(p)+2+(2+1)];
    branch_back_lab = AST[(p)+2+(2+2)];
    if (break_lab == -1) AST[(p)+2+(2+0)] = break_lab = temp_label();
    if (continue_lab == -1) AST[(p)+2+(2+1)] = continue_lab = temp_label();
    if (branch_back_lab = -1) AST[(p)+2+(2+2)] = branch_back_lab = temp_label();
    assign_loop_labels(AST[(p)+3], break_lab, continue_lab, branch_back_lab);
  } else if ((p == -1 ? -1 : AST[p]) == 1060) {
    break_lab = AST[(p)+2+(4+0)];
    continue_lab = AST[(p)+2+(4+1)];
    branch_back_lab = AST[(p)+2+(4+2)];
    if (break_lab == -1) AST[(p)+2+(4+0)] = break_lab = temp_label();
    if (continue_lab == -1) AST[(p)+2+(4+1)] = continue_lab = temp_label();
    if (branch_back_lab = -1) AST[(p)+2+(4+2)] = branch_back_lab = temp_label();
    assign_loop_labels(AST[(p)+2+(3)], break_lab, continue_lab, branch_back_lab);
  } else if ((p == -1 ? -1 : AST[p]) == 1070) {
    int case_lab_chain;
    int default_lab;
    break_lab = AST[(p)+2+(2+0)];
    case_lab_chain = AST[(p)+2+(2+1)];
    default_lab = AST[(p)+2+(2+2)];
    if (break_lab == -1) {
      AST[(p)+2+(2)] = break_lab = temp_label();
    }
    assign_loop_labels(AST[(p)+3], break_lab, continue_lab, branch_back_lab);
  }
  disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
  this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
  for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
    if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
      assign_loop_labels(AST[(p)+2+(i)], break_lab, continue_lab, branch_back_lab);
    }
    this = this>>1;
  }
}
void build_switch_table(int p, int enclosing_switch)
{
  int i;
  int disp;
  int this;
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  if ((p == -1 ? -1 : AST[p]) == 1070) {
    build_switch_table(AST[(p)+3], p);
    if (AST[(p)+2+(3)] == -1) {
      if (AST[(p)+2+(4)] == -1) {
        fprintf(stderr, "* Error: switch block does not contain any case statements (or default:)\n");
      } else {
        fprintf(stderr, "? Warning: switch block does not contain any case statements\n");
      }
    }
  } else if ((p == -1 ? -1 : AST[p]) == 1067) {
    if (enclosing_switch == -1) fprintf(stderr, "* ERROR: case with no switch?\n");
    AST[(p)+2+(2)] = temp_label();
    AST[(p)+3] = AST[(enclosing_switch)+2+(2+1)];
    AST[(enclosing_switch)+2+(2+1)] = p;
  } else if ((p == -1 ? -1 : AST[p]) == 1068) {
    if (enclosing_switch == -1) fprintf(stderr, "* ERROR: default with no switch?\n");
    AST[(p)+2] = enclosing_switch;
    AST[(p)+3] = temp_label();
    AST[(enclosing_switch)+2+(2+2)] = p;
  } else {
    disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
    this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
    for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
      if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
        build_switch_table(AST[(p)+2+(i)], enclosing_switch);
      }
      this = this>>1;
    }
  }
}
void check_function_results(int p, int enclosing_defproc, int *resultcount)
{
  if ((p == -1) || ((p == -1 ? -1 : AST[p]) == -1)) return;
  switch ((p == -1 ? -1 : AST[p])) {
  case 1052:
    {
      int count = 0;
      check_function_results(AST[(p)+2+(3)], p, &count);
      if ((count == 0) && (AST[(AST[(p)+2])+3] != 0)) {
        error_line(c[AST[(AST[(p)+3])+2]].l);
        fprintf(stderr, "* Error: non-void function %s does not return a result\n", c[AST[(AST[(p)+3])+2]].s);
      }
    }
    break;
  case 1021:
    *resultcount = 1 + *resultcount;
    break;
  case 1020:
    fprintf(stderr, "Return: proctype=%d\n", AST[(AST[(enclosing_defproc)+2])+3]);
    *resultcount = *resultcount + 1;
    break;
  default:
    break;
  }
  {
    int i;
    int disp;
    int this;
    disp = op[(p == -1 ? -1 : AST[p])-1000].Display_Children;
    this = 1<<(((p) == -1 ? -1 : AST[(p)+1])-1);
    for (i = 0; i < ((p) == -1 ? -1 : AST[(p)+1]); i++) {
      if ((AST[(p)+2+(i)] != -1) && (disp&this)) {
        check_function_results(AST[(p)+2+(i)], enclosing_defproc, resultcount);
      }
      this = this>>1;
    }
  }
}
int main(int argc, char **argv) {
  int opt_3address = (0!=0), opt_debug = (0!=0), opt_stack = (0!=0), opt_c = (0!=0), opt_execute = (0!=0), opt_optimiser = (0!=0);
  char *s;
  strcpy(prognames, argv[0]); progname = prognames;
  if ((s = strrchr(progname, '/')) != NULL) progname = s+1;
  if ((s = strrchr(progname, '\\')) != NULL) progname = s+1;
  if ((s = strrchr(progname, ']')) != NULL) progname = s+1;
  if ((s = strrchr(progname, ';')) != NULL) *s = '\0';
  if (((s = strrchr(progname, '.')) != NULL) && (strcasecmp(s, ".exe") == 0)) *s = '\0';
  if (((s = strrchr(progname, '.')) != NULL) && (strcasecmp(s, ".com") == 0)) *s = '\0';
 moreopt:
  if ((argc >= 2) && (*argv[1] == '-') && (argv[1][2] == '\0') ) {
  if (argv[1][1] == 'O') {
    argv++; argc--; opt_optimiser = (0==0); goto moreopt;
  }
  if (argv[1][1] == 'd') {
    argv++; argc--; debug = (0==0); goto moreopt;
  }
  if (argv[1][1] == '3') {
    argv++; argc--; opt_3address = (0==0); goto moreopt;
  }
  if (argv[1][1] == 's') {
    argv++; argc--; opt_stack = (0==0); goto moreopt;
  }
  if (argv[1][1] == 'c') {
    argv++; argc--; opt_c = (0==0); goto moreopt;
  }
  if (argv[1][1] == 'e') {
    argv++; argc--; opt_execute = (0==0); goto moreopt;
  }
  if (argv[1][1] == 'h') {
      fprintf(stderr, "%s:\n", progname);
      fprintf(stderr, "\t-3\tgenerate low-level 3-address code using c\n");
      fprintf(stderr, "\t-c\tgenerate high-level c translation\n");
      fprintf(stderr, "\t-s\tgenerate stack-based assembly code\n");
      fprintf(stderr, "\t-e\texecute directly\n");
      fprintf(stderr, "\t-d\tdebug\n");
      fprintf(stderr, "\t-h\thelp (this info)\n");
      exit(0);
  }
}
  if (argc != 2) {
    fprintf(stderr, "syntax: %s [-3cdehs] filename\n", progname);
    exit(1);
  }
  if (!(opt_3address || opt_c || opt_execute || opt_stack)) opt_stack = (0==0);
  if (argv[1][0] == '-' && argv[1][1] == '\0') {
    sourcefile = fopen("/dev/null", "r");
  } else {
    sourcefile = fopen(argv[1], "r");
  }
  if (sourcefile == NULL) {
    fprintf(stderr, "%s: %s - %s\n", progname, strerror(errno), argv[1]);
    exit(errno);
  }
  if (opt_execute) {
    outfile = stdout;
  } else {
    char *s;
    sprintf(outname, "%s", argv[1]);
    s = strrchr(outname, '.');
    if (s == NULL) s = outname+strlen(outname);
    if (opt_3address || opt_c) {
      sprintf(s, "%s", ".c");
    } else if (opt_stack) {
      sprintf(s, "%s", ".asm");
    } else {
      fprintf(stderr, "Won't\n"); exit(123);
    }
  }
  curfile = argv[1]; startline = (0==0); whitespace = (0==0);
  line_reconstruction();
  dump_source();
 resume:
  if (!parse(521, 0)) {
    if (bestparse == nextfree) {
      fprintf(stderr, "\"%s\", Line %d, Col %d: Premature end of file while looking for %s\n",
                       argv[1], c[bestparse].l, c[bestparse].col+1, looking_for);
      exit(1);
    } else {
      int i;
      error_line(c[bestparse].l);
      fprintf(stderr, "\"%s\", Line %d, Col %d: Syntax error while looking for %s near ",
                       argv[1], c[bestparse].l, c[bestparse].col+1, looking_for);
      fprintf(stderr, "%s\n", escape(c[i].s,c[i].t));
      exit(1);
    }
  } else {
    int rslt_errs = 0;
    int T[4];
    int program;
    program = build_ast_inner(0, 250);
    T[1] = program;
    T[2] = -1;
    T[3] = 0;
    program = mk(1084, 3, T);
    fflush(stdout);
    print_all_trips();
    fold_constant_expressions(program); while ((program == -1 ? -1 : AST[program]) == 1073) program = AST[(program)+2];
    fprintf(stderr, "assign_loop_labels(%d)\n", program);
    assign_loop_labels(program, -1, -1, -1); while ((program == -1 ? -1 : AST[program]) == 1073) program = AST[(program)+2];
    fprintf(stderr, "build_switch_table()\n");
    build_switch_table(program, -1);
    fprintf(stderr, "build_block_scope()\n");
    build_block_scope(program, -1, -1);
    fprintf(stderr, "populate_types()\n");
    populate_types(program);
    fprintf(stderr, "check_function_results()\n");
    check_function_results(program, -1, &rslt_errs);
    fprintf(stderr, "=============\n");
    show_ast(program, 0, -1);
    fprintf(stderr, "stack_code()\n");
    stack_data(); stack_code(program, -1, -1, -1);
    fprintf(stderr, "\n");
    fflush(stdout);
  }
  exit(0); return(1);
}
