# include "lbc2.hh"

value     v[5];
gate_list gts;
var_list  vrs;
int       i;

frame M;

PUBLIC void
c0 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    b = mkhd (b, 1);
    gts = b->fth->gte;
    gts[1] = TRUE;
    gts[2] = TRUE;
    gts[3] = TRUE;
    gts[4] = TRUE;
    gts[5] = TRUE;
    M = b->frm;

    mkps (b, 2, 3);
    c0 (b->sons);
    b = b->sons->bth;
    goto again;
  }
  case 2: {
    M->ent = 0;
    M->but = 1;
    c1 (b);
    break;
  }
  case 3: {
    M->ent = 0;
    M->but = 2;
    c2 (b);
    break;
  }
  }
}

PUBLIC void
c1 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkdis (b, 1, 4);
    c1 (b->sons);
    b = b->sons->bth;
    goto again;
  }
  case 1: {
    mkpe (b, 2, 3);
    gts = b->gte;
    gts[2] = TRUE;
    c1 (b->sons);
    b = b->sons->bth;
    goto again;
  }
  case 2: {
    M->ent = 0;
    M->but = 3;
    c3 (b);
    break;
  }
  case 3: {
    push_gte (2);
    b = mkre (b, 1);
    M->ent = 0;
    M->but = 4;
    c4 (b);
    break;
  }
  case 4: {
    mkad (b, 5, 5, 0, 0, -1, 0);
    break;
  }
  case 5: {
    M->ent = 0;
    goto again;
  }
  }
}

PUBLIC void
c3 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkad (b, 1, 1, 0, 0, -1, 0);
    break;
  }
  case 1: {
    mkmo (0);
    mkad (b, 2, 2, 1, 1, -1, 0);
    break;
  }
  case 2: {
    mkmo (1);
    mkad (b, 3, 2, 1, 1, -1, 0);
    break;
  }
  case 3: {
    mkmo (2);
    mkad (b, 4, 2, 1, 1, -1, 0);
    break;
  }
  case 4: {
    mkmo (3);
    mkad (b, 5, 2, 1, 1, -1, 0);
    break;
  }
  case 5: {
    mkch (b, 6, 8);
    c3 (b->sons);
    b = b->sons->bth;
    goto again;
  }
  case 6: {
    mki (b, 7, 0);
    break;
  }
  case 7: {
    push_gte (4);
    b = mkre (b, 1);
    for (i = 0; i < 4; i++)
      if (M->rav[i] != NULL) {
        ud_free (TSsorts[3][i], M->rav[i]);
        M->rav[i] = NULL;
      }
    M->ent = 0;
    M->but = 5;
    c5 (b);
    break;
  }
  case 8: {
    mki (b, 9, 0);
    break;
  }
  case 9: {
    push_gte (3);
    b = mkre (b, 1);
    for (i = 0; i < 4; i++)
      if (M->rav[i] != NULL) {
        ud_free (TSsorts[3][i], M->rav[i]);
        M->rav[i] = NULL;
      }
    M->ent = 0;
    M->but = 5;
    c5 (b);
    break;
  }
  }
}

PUBLIC void
c5 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkad (b, 1, 1, 0, 0, -1, 0);
    break;
  }
  case 1: {
    M->ent = 0;
    goto again;
  }
  }
}

PUBLIC void
c4 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkmo (0);
    mkad (b, 1, 1, 1, 1, 0, 0);
    break;
  }
  case 1: {
    if (M->rav[0] != NULL) {
      ud_free (2, M->rav[0]);
      M->rav[0] = NULL;
    }
    M->ent = 0;
    M->but = 6;
    c6 (b);
    break;
  }
  }
}

PUBLIC void
c6 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkmo (0);
    mkad (b, 1, 1, 1, 1, -1, 0);
    break;
  }
  case 1: {
    if (M->rav[0] != NULL) {
      ud_free (2, M->rav[0]);
      M->rav[0] = NULL;
    }
    M->ent = 0;
    goto again;
  }
  }
}

PUBLIC void
c2 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    b = mken (b, 1, 2, 0);
    vrs = b->fth->rav;
    goto again;
  }
  case 1: {
    M->ent = 0;
    M->but = 7;
    c7 (b);
    break;
  }
  case 2: {
    b = mken (b, 3, 4, 0);
    vrs = b->fth->rav;
    goto again;
  }
  case 3: {
    M->ent = 0;
    M->but = 8;
    c8 (b);
    break;
  }
  case 4: {
    b = mken (b, 5, 6, 0);
    vrs = b->fth->rav;
    goto again;
  }
  case 5: {
    M->ent = 0;
    M->but = 9;
    c9 (b);
    break;
  }
  case 6: {
    mki (b, 7, 0);
    break;
  }
  case 7: {
#line 95 "scnry2.lot"
printf ("test suite complete!\n");
    mkst (b);
    break;
  }
  }
}

PUBLIC void
c7 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkad (b, 1, 1, 0, 0, -1, 0);
    break;
  }
  case 1: {
    mkso ((udatum)g4 ());
    mkad (b, 2, 2, 1, 1, -1, 0);
    break;
  }
  case 2: {
    mkso ((udatum)g5 ());
    mkad (b, 3, 2, 1, 1, -1, 0);
    break;
  }
  case 3: {
    mkso ((udatum)g6 ());
    mkad (b, 4, 2, 1, 1, -1, 0);
    break;
  }
  case 4: {
    mkad (b, 5, 5, 0, 0, -1, 0);
    break;
  }
  case 5: {
    mki (b, 6, 0);
    break;
  }
  case 6: {
#line 106 "scnry2.lot"
printf ("test1: passed successfully\n");
    mkex (b, 0, 0, 0);
    break;
  }
  }
}

PUBLIC void
c8 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkad (b, 1, 1, 0, 0, -1, 0);
    break;
  }
  case 1: {
    mkso ((udatum)g4 ());
    mkad (b, 2, 2, 1, 1, -1, 0);
    break;
  }
  case 2: {
    mkso ((udatum)g5 ());
    mkad (b, 3, 2, 1, 1, -1, 0);
    break;
  }
  case 3: {
    mkso ((udatum)g6 ());
    mkad (b, 4, 2, 1, 1, -1, 0);
    break;
  }
  case 4: {
    mkso ((udatum)g7 ());
    mkad (b, 5, 2, 1, 1, -1, 0);
    break;
  }
  case 5: {
    mkch (b, 6, 10);
    c8 (b->sons);
    b = b->sons->bth;
    goto again;
  }
  case 6: {
    mkad (b, 7, 3, 0, 0, -1, 0);
    break;
  }
  case 7: {
    mki (b, 8, 0);
    break;
  }
  case 8: {
#line 118 "scnry2.lot"
printf ("test2: passed successfully\n");
    mkad (b, 9, 5, 0, 0, -1, 0);
    break;
  }
  case 9: {
    mkex (b, 0, 0, 0);
    break;
  }
  case 10: {
    mkad (b, 11, 4, 0, 0, -1, 0);
    break;
  }
  case 11: {
    mki (b, 12, 0);
    break;
  }
  case 12: {
#line 123 "scnry2.lot"
printf ("test2: failed; retry\n");
    mkad (b, 13, 5, 0, 0, -1, 0);
    break;
  }
  case 13: {
    M->ent = 0;
    goto again;
  }
  }
}

PUBLIC void
c9 (b)
  board b;
{
  again: 
  M = b->frm;

  switch (M->ent) {
  case 0: {
    mkad (b, 1, 1, 0, 0, -1, 0);
    break;
  }
  case 1: {
    mkso ((udatum)g3 ());
    mkad (b, 2, 2, 1, 1, -1, 0);
    break;
  }
  case 2: {
    mki (b, 3, 0);
    break;
  }
  case 3: {
#line 133 "scnry2.lot"
printf ("test3: passed incorrectly\n");
    mkad (b, 4, 5, 0, 0, -1, 0);
    break;
  }
  case 4: {
    mkex (b, 0, 0, 0);
    break;
  }
  }
}

PUBLIC int
t000 (M)
  frame M;
{
  static value x2 = NULL;
  if (x2 == NULL)
    x2 = ud_const (1, (udatum)(g1 ()));
  if (xto[0] == NULL) return PRD_NRDY;
  return ud_gequal (1, x2, (udatum)(g13 (kd_copy ((kdatum)xto[0]))), 3);
}


char*  TSprocesses[]= {""};

char** TSgates[]= {TSprocesses};

char** TSvariables[]= {TSprocesses};

static int TSsort0[]= { NULL }; /* scnry2 */

static int TSsort1[]= { NULL }; /* office */

static int TSsort2[]= { NULL }; /* tests */

static int TSsort3[]= { /* phone_set */
  2, 2, 2, 2, 0
  };

static int TSsort4[]= { /* national_call */
  2, 0
  };

static int TSsort5[]= { NULL }; /* forever */

static int TSsort6[]= { /* dont_care */
  2, 0
  };

static int TSsort7[]= { NULL }; /* test1 */

static int TSsort8[]= { NULL }; /* test2 */

static int TSsort9[]= { NULL }; /* test3 */

int*  TSsorts[]= {
  TSsort0, TSsort1, TSsort2, TSsort3, TSsort4, 
  TSsort5, TSsort6, TSsort7, TSsort8, TSsort9
  };

int TSsizes[]= {
  0, 1
  };

static int TSsbe0[] = { NULL };
static int TSsbe1[] = { 2 };

int *TSsbes[]= {
  TSsbe0, TSsbe1
  };

eval_f TSevals[]= { NULL };

int specpar = 0;
int max_accepted = 1;
int max_gte = 6;
int max_val = 5;
int max_exp = 2;
boolean g_flag = FALSE;

predicate ftbl[]= {
  t000
  };

coroutine ctbl[]= { c0, c1, c2, c3, c4, c5, c6, c7, c8, c9 };

