#include "chdecl.h"
void CH_chcode_chphase2(current, sched, cop)
#define ARGUMENTS 7
#include "chhead.h"
select: switch (SELECTOR) {
    case 0: goto c0;
    case 1: goto cb1;
    case 2: goto c2;
    case 3: goto cb4;
    case 4: goto c5;
    case 5: goto cb21;
    case 6: goto c22;
    case 7: goto c23;
    case 8: goto cb70;
    case 9: goto c71;
    case 10: goto c72;
    case 11: goto c75;
    case 12: goto c103;
    case 13: goto c107;
    case 14: goto cb125;
    case 15: goto c126;
    case 16: goto c128;
    case 17: goto cb144;
    case 18: goto c145;
    case 19: goto cb148;
    case 20: goto c149;
    case 21: goto c153;  }
c0:
/* block , 0 */
  if((ch_returncode = che_block(QUAL(0),sched)) != Normal)
     goto ch_raise_exception;
  current->ip = 1;
cb1:
/* receive 3 0 */
  if ((ch_returncode = che_receive(DEF(3),DEF(0),sched)) != Normal)
     goto ch_raise_exception;
  return;
c2:
/* branch_false 3.0.9.0 , 5 */
  if ( !REF(3)DOT(0)DOT(9)DOT(0).value.boolean ) goto c5;
/* chs_lit 4 , "phase2 " */
  if( !chs_lit(DEF(4),"phase2 ") ) goto ch_depletion;
  current->ip = 3;
cb4:
/* call 3.0.4 4 , 1 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(3)DOT(0)DOT(4),
          arguments[1] = DEF(4),
          arguments[1+1] = nil,& arguments[0]),QUAL(1),sched)) != Normal)
     goto ch_raise_exception;
  return;
c5:
/* discard 4 */
  (*(REF(4).tsdr)->finalize)(REF(4).value,F_DISCARD,sched);
  REF(4).tsdr = & dr_bottom;
/* prog_lit 5 , 2 */
  if ((ch_returncode = che_prog_lit(DEF(5),QUAL(2),sched)) != Normal) 
     goto ch_raise_exception;
/* procedure 6 5 , 3 */
  if ((ch_returncode = che_procedure(DEF(6),DEF(5),QUAL(3),sched)) != Normal)
     goto ch_raise_exception;
/* discard 5 */
  (*(REF(5).tsdr)->finalize)(REF(5).value,F_DISCARD,sched);
  REF(5).tsdr = & dr_bottom;
/* move 7 6 */
  (*(REF(7).tsdr)->finalize)(REF(7).value,F_DISCARD,sched);
  REF(7) = REF(6);
  REF(6).tsdr = & dr_bottom;
/* new_table 8 , 4 */
  if ((ch_returncode = che_new_table(DEF(8),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* ilit 9 , 0 */
  REF(9).value.integer = 0;
  REF(9).tsdr = & dr_integer;
/* boolean 10 , TRUE */
  REF(10).value.boolean = TRUE;
  REF(10).tsdr = & dr_boolean;
/* boolean 11 , FALSE */
  REF(11).value.boolean = FALSE;
  REF(11).tsdr = & dr_boolean;
/* new_record 12 , 5 */
  if ((ch_val.record = new_record(5)) == nil) goto ch_depletion;
  (*(REF(12).tsdr)->finalize)(REF(12).value,F_DISCARD,sched);
  REF(12).value = ch_val; REF(12).tsdr = & dr_record;
/* new_table 12.0 , 4 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(0),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* new_table 12.3 , 4 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(3),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* new_table 12.4 , 5 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(4),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
  current->ip = 5;
cb21:
/* call 7 13 14 , 6 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(7),
          arguments[1] = DEF(13),
          arguments[2] = DEF(14),
          arguments[2+1] = nil,& arguments[0]),QUAL(6),sched)) != Normal)
     goto ch_raise_exception;
  return;
c22:
/* new_table 15 , 5 */
  if ((ch_returncode = che_new_table(DEF(15),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
c23:
/* size 16 3.2 */
  REF(16).value.integer = REF(3)DOT(2).value.table->size;
  REF(16).tsdr = & dr_integer;
/* ige . 9 16 , 128 */
  if ( REF(9).value.integer >= REF(16).value.integer ) goto c128;
/* lookup_at 17 3.2 9 */
  if((ch_i = REF(9).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(2).value
    .table)->size) goto ch_notfound;
  (*(REF(17).tsdr)->finalize)(REF(17).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(17).value,ch_i);
  REF(17).tsdr = qdatarepmap[ch_t->tsdr->number];
/* block , 7 */
  if((ch_returncode = che_block(QUAL(7),sched)) != Normal)
     goto ch_raise_exception;
/* notequal . 17.4 =(0) , 35 */
  if ( REF(17)DOT(4).value.ord_enum != 0 ) goto c35;
/* branch_false 10 , 34 */
  if ( !REF(10).value.boolean ) goto c34;
/* exit , 8 */
  ch_e = handler_type__exit; ch_val = QUAL(8); goto ch_exception;
c34:
/* exit , 9 */
  ch_e = handler_type__exit; ch_val = QUAL(9); goto ch_exception;
c35:
/* noop */
  
/* notequal . 17.4 =(4) , 55 */
  if ( REF(17)DOT(4).value.ord_enum != 4 ) goto c55;
/* notequal . 17.6 =(0) , 42 */
  if ( REF(17)DOT(6).value.integer != 0 ) goto c42;
/* exit , 8 */
  ch_e = handler_type__exit; ch_val = QUAL(8); goto ch_exception;
c42:
/* privatize 3.2 */
  if (REF(3)DOT(2).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(2))) != Normal)
       goto ch_raise_exception;
/* lookup_at 18 3.2 9 */
  if((ch_i = REF(9).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(2).value
    .table)->size) goto ch_notfound;
  (*(REF(18).tsdr)->finalize)(REF(18).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(18).value,ch_i);
  REF(18).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 19 3.2 9 */
  if ((ch_returncode = remove_at_func(DEF(19),DEF(3)DOT(2),
    REF(9).value.integer)) != Normal) goto ch_raise_exception;
/* ordenum_lit 19.4 , 3 */
  REF(19)DOT(4).value.ord_enum = 3;
  REF(19)DOT(4).tsdr = & dr_ord_enumeration;
/* enum_lit 19.0 , 114 */
  REF(19)DOT(0).value.enumeration = 114;
  REF(19)DOT(0).tsdr = & dr_enumeration;
/* ordenum_lit 19.3 , 3 */
  REF(19)DOT(3).value.ord_enum = 3;
  REF(19)DOT(3).tsdr = & dr_ord_enumeration;
/* new_table 19.1 , 4 */
  if ((ch_returncode = che_new_table(DEF(19)DOT(1),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* unite 19.2 20 , 0 */
  if ((ch_returncode = che_unite(DEF(19)DOT(2),DEF(20),sched,0)) != Normal)
     goto ch_raise_exception;
/* insert_at 3.2 19 9 */
  ch_i = REF(9).value.integer;
  if (ch_i < 0 || REF(3)DOT(2).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(2),DEF(19),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
c55:
/* branch_false 10 , 61 */
  if ( !REF(10).value.boolean ) goto c61;
/* boolean 10 , FALSE */
  REF(10).value.boolean = FALSE;
  REF(10).tsdr = & dr_boolean;
/* boolean 11 , TRUE */
  REF(11).value.boolean = TRUE;
  REF(11).tsdr = & dr_boolean;
/* branch , 65 */
   goto c65;
c61:
/* noop */
  
/* notequal . 17.4 =(1) , 65 */
  if ( REF(17)DOT(4).value.ord_enum != 1 ) goto c65;
/* exit , 9 */
  ch_e = handler_type__exit; ch_val = QUAL(9); goto ch_exception;
c65:
/* noop */
  
/* equal . 17.6 =(0) , 75 */
  if ( REF(17)DOT(6).value.integer == 0 ) goto c75;
/* not 21 11 */
  REF(21).value.boolean = !REF(11).value.boolean;
  REF(21).tsdr = & dr_boolean;
/* branch_false 21 , 75 */
  if ( !REF(21).value.boolean ) goto c75;
  current->ip = 8;
cb70:
/* call 3.4 3.2 15 14 22 , 10 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(3)DOT(4),
          arguments[1] = DEF(3)DOT(2),
          arguments[2] = DEF(15),
          arguments[3] = DEF(14),
          arguments[4] = DEF(22),
          arguments[4+1] = nil,& arguments[0]),QUAL(10),sched)) != Normal)
     goto ch_raise_exception;
  return;
c71:
/* call 13 9 17.6 23 , 11 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(13),
          arguments[1] = DEF(9),
          arguments[2] = DEF(17)DOT(6),
          arguments[3] = DEF(23),
          arguments[3+1] = nil,& arguments[0]),QUAL(11),sched)) != Normal)
     goto ch_raise_exception;
  return;
c72:
/* branch_false 23 , 74 */
  if ( !REF(23).value.boolean ) goto c74;
/* exit , 9 */
  ch_e = handler_type__exit; ch_val = QUAL(9); goto ch_exception;
c74:
/* new_table 15 , 5 */
  if ((ch_returncode = che_new_table(DEF(15),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
c75:
/* noop */
  
/* notequal . 17.3 =(1) , 80 */
  if ( REF(17)DOT(3).value.ord_enum != 1 ) goto c80;
/* copy 24 9 */
  REF(24) = REF(9);
/* insert 15 24 */
  if ((ch_returncode = insertfunc(DEF(15),DEF(24),FALSE,0)) != Normal)
     goto ch_raise_exception;
c80:
/* copy 25 9 */
  REF(25) = REF(9);
/* insert 12.3 25 */
  if ((ch_returncode = insertfunc(DEF(12)DOT(3),DEF(25),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* branch_false 11 , 98 */
  if ( !REF(11).value.boolean ) goto c98;
/* notequal . 17.4 =(1) , 90 */
  if ( REF(17)DOT(4).value.ord_enum != 1 ) goto c90;
/* iadd 9 9 =(1) */
  if (!chf_iadd(DEF(9),REF(9).value.integer,1)) goto ch_depletion;
/* exit , 9 */
  ch_e = handler_type__exit; ch_val = QUAL(9); goto ch_exception;
c90:
/* boolean 11 , FALSE */
  REF(11).value.boolean = FALSE;
  REF(11).tsdr = & dr_boolean;
/* privatize 3.2 */
  if (REF(3)DOT(2).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(2))) != Normal)
       goto ch_raise_exception;
/* lookup_at 26 3.2 9 */
  if((ch_i = REF(9).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(2).value
    .table)->size) goto ch_notfound;
  (*(REF(26).tsdr)->finalize)(REF(26).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(26).value,ch_i);
  REF(26).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 19 3.2 9 */
  if ((ch_returncode = remove_at_func(DEF(19),DEF(3)DOT(2),
    REF(9).value.integer)) != Normal) goto ch_raise_exception;
/* ordenum_lit 19.4 , 2 */
  REF(19)DOT(4).value.ord_enum = 2;
  REF(19)DOT(4).tsdr = & dr_ord_enumeration;
/* insert_at 3.2 19 9 */
  ch_i = REF(9).value.integer;
  if (ch_i < 0 || REF(3)DOT(2).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(2),DEF(19),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
c98:
/* noop */
  
/* iadd 9 9 =(1) */
  if (!chf_iadd(DEF(9),REF(9).value.integer,1)) goto ch_depletion;
/* endblock */
  che_endblock(sched);
/* branch , 23 */
   goto c23;
c103:
/* noop */
  
/* iadd 9 9 =(1) */
  if (!chf_iadd(DEF(9),REF(9).value.integer,1)) goto ch_depletion;
/* branch , 23 */
   goto c23;
c107:
/* noop */
  
/* lookup_at 27 12.3 =(0) */
  if ( !((ch_t = REF(12)DOT(3).value.table)->size) ) goto ch_notfound;
  (*(REF(27).tsdr)->finalize)(REF(27).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(27).value,0);
  REF(27).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 12.1 27 */
  if((ch_returncode = (REF(27).tsdr->copy)(& ch_val, REF(27).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(12)DOT(1).tsdr)->finalize)(REF(12)DOT(1).value,F_DISCARD,sched);
  REF(12)DOT(1).value = ch_val;
  REF(12)DOT(1).tsdr = datarepmap[REF(27).tsdr->number];
/* copy 12.2 9 */
  REF(12)DOT(2) = REF(9);
/* size 28 8 */
  REF(28).value.integer = REF(8).value.table->size;
  REF(28).tsdr = & dr_integer;
/* insert 12.0 28 */
  if ((ch_returncode = insertfunc(DEF(12)DOT(0),DEF(28),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* insert 8 12 */
  if ((ch_returncode = insertfunc(DEF(8),DEF(12),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* boolean 10 , TRUE */
  REF(10).value.boolean = TRUE;
  REF(10).tsdr = & dr_boolean;
/* boolean 11 , FALSE */
  REF(11).value.boolean = FALSE;
  REF(11).tsdr = & dr_boolean;
/* new_record 12 , 5 */
  if ((ch_val.record = new_record(5)) == nil) goto ch_depletion;
  (*(REF(12).tsdr)->finalize)(REF(12).value,F_DISCARD,sched);
  REF(12).value = ch_val; REF(12).tsdr = & dr_record;
/* new_table 12.0 , 4 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(0),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* new_table 12.3 , 4 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(3),QUAL(4),sched)) != Normal) 
     goto ch_raise_exception;
/* new_table 12.4 , 5 */
  if ((ch_returncode = che_new_table(DEF(12)DOT(4),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
/* discard 13 */
  (*(REF(13).tsdr)->finalize)(REF(13).value,F_DISCARD,sched);
  REF(13).tsdr = & dr_bottom;
/* discard 14 */
  (*(REF(14).tsdr)->finalize)(REF(14).value,F_DISCARD,sched);
  REF(14).tsdr = & dr_bottom;
  current->ip = 14;
cb125:
/* call 7 13 14 , 6 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(7),
          arguments[1] = DEF(13),
          arguments[2] = DEF(14),
          arguments[2+1] = nil,& arguments[0]),QUAL(6),sched)) != Normal)
     goto ch_raise_exception;
  return;
c126:
/* new_table 15 , 5 */
  if ((ch_returncode = che_new_table(DEF(15),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
/* branch , 23 */
   goto c23;
c128:
/* not 29 10 */
  REF(29).value.boolean = !REF(10).value.boolean;
  REF(29).tsdr = & dr_boolean;
/* branch_false 29 , 138 */
  if ( !REF(29).value.boolean ) goto c138;
/* lookup_at 30 12.3 =(0) */
  if ( !((ch_t = REF(12)DOT(3).value.table)->size) ) goto ch_notfound;
  (*(REF(30).tsdr)->finalize)(REF(30).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(30).value,0);
  REF(30).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 12.1 30 */
  if((ch_returncode = (REF(30).tsdr->copy)(& ch_val, REF(30).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(12)DOT(1).tsdr)->finalize)(REF(12)DOT(1).value,F_DISCARD,sched);
  REF(12)DOT(1).value = ch_val;
  REF(12)DOT(1).tsdr = datarepmap[REF(30).tsdr->number];
/* move 12.2 9 */
  REF(12)DOT(2) = REF(9);
  REF(9).tsdr = & dr_bottom;
/* size 31 8 */
  REF(31).value.integer = REF(8).value.table->size;
  REF(31).tsdr = & dr_integer;
/* insert 12.0 31 */
  if ((ch_returncode = insertfunc(DEF(12)DOT(0),DEF(31),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* insert 8 12 */
  if ((ch_returncode = insertfunc(DEF(8),DEF(12),FALSE,0)) != Normal)
     goto ch_raise_exception;
c138:
/* discard 12 */
  (*(REF(12).tsdr)->finalize)(REF(12).value,F_DISCARD,sched);
  REF(12).tsdr = & dr_bottom;
/* discard 13 */
  (*(REF(13).tsdr)->finalize)(REF(13).value,F_DISCARD,sched);
  REF(13).tsdr = & dr_bottom;
/* discard 14 */
  (*(REF(14).tsdr)->finalize)(REF(14).value,F_DISCARD,sched);
  REF(14).tsdr = & dr_bottom;
/* prog_lit 32 , 12 */
  if ((ch_returncode = che_prog_lit(DEF(32),QUAL(12),sched)) != Normal) 
     goto ch_raise_exception;
/* create 33 32 , 13 */
  if ((ch_returncode = che_create(DEF(33),DEF(32),QUAL(13),sched)) != Normal)
     goto ch_raise_exception;
/* discard 32 */
  (*(REF(32).tsdr)->finalize)(REF(32).value,F_DISCARD,sched);
  REF(32).tsdr = & dr_bottom;
  current->ip = 17;
cb144:
/* call 33 3.0 8 3.2 3.3 , 14 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(33),
          arguments[1] = DEF(3)DOT(0),
          arguments[2] = DEF(8),
          arguments[3] = DEF(3)DOT(2),
          arguments[4] = DEF(3)DOT(3),
          arguments[4+1] = nil,& arguments[0]),QUAL(14),sched)) != Normal)
     goto ch_raise_exception;
  return;
c145:
/* prog_lit 34 , 15 */
  if ((ch_returncode = che_prog_lit(DEF(34),QUAL(15),sched)) != Normal) 
     goto ch_raise_exception;
/* create 35 34 , 13 */
  if ((ch_returncode = che_create(DEF(35),DEF(34),QUAL(13),sched)) != Normal)
     goto ch_raise_exception;
/* discard 34 */
  (*(REF(34).tsdr)->finalize)(REF(34).value,F_DISCARD,sched);
  REF(34).tsdr = & dr_bottom;
  current->ip = 19;
cb148:
/* call 35 3.0 8 3.2 3.3 , 14 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(35),
          arguments[1] = DEF(3)DOT(0),
          arguments[2] = DEF(8),
          arguments[3] = DEF(3)DOT(2),
          arguments[4] = DEF(3)DOT(3),
          arguments[4+1] = nil,& arguments[0]),QUAL(14),sched)) != Normal)
     goto ch_raise_exception;
  return;
c149:
/* move 3.1 8 */
  (*(REF(3)DOT(1).tsdr)->finalize)(REF(3)DOT(1).value,F_DISCARD,sched);
  REF(3)DOT(1) = REF(8);
  REF(8).tsdr = & dr_bottom;
/* return 3 */
  if (ch_caller = do_return(REF(3).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(3).value);
  REF(3).tsdr = & dr_bottom;
/* endblock */
  che_endblock(sched);
c153:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
