#include "chdecl.h"
void CH_codegen_cgtypedstmt(current, sched, cop)
#define ARGUMENTS 6
#include "chhead.h"
select: switch (SELECTOR) {
    case 0: goto c0;
    case 1: goto cb2;
    case 2: goto c3;
    case 3: goto c9;
    case 4: goto cb13;
    case 6: goto cb15;
    case 7: goto c16;
    case 8: goto cb19;
    case 9: goto c20;
    case 10: goto cb21;
    case 11: goto c22;
    case 12: goto c32;
    case 13: goto cb33;
    case 14: goto c34;
    case 15: goto c36;
    case 16: goto c42;
    case 5: goto c44;
    case 17: goto c44;
    case 18: goto c45;
    case 19: goto c47;
    case 20: goto c50;
    case 21: goto c53;
    case 22: goto c55;  }
c0:
/* block , 0 */
  if((ch_returncode = che_block(QUAL(0),sched)) != Normal)
     goto ch_raise_exception;
/* block , 1 */
  if((ch_returncode = che_block(QUAL(1),sched)) != Normal)
     goto ch_raise_exception;
  current->ip = 1;
cb2:
/* receive 3 0 */
  if ((ch_returncode = che_receive(DEF(3),DEF(0),sched)) != Normal)
     goto ch_raise_exception;
  return;
c3:
/* new_inport 4 */
  if ((ch_val.inport = make_inport()) == nil) goto ch_depletion;
  (*(REF(4).tsdr)->finalize)(REF(4).value,F_DISCARD,sched);
  REF(4).value = ch_val; REF(4).tsdr = & dr_inport;
/* connect 3.0 4 */
  if (REF(4).value.inport->refcount == MAXCOUNTER) goto ch_depletion;
  (*(REF(3)DOT(0).tsdr)->finalize)(REF(3)DOT(0).value,F_DISCARD,sched);
  REF(4).value.inport->refcount++;
  REF(3)DOT(0).value.outport = REF(4).value.inport;
  REF(3)DOT(0).tsdr = & dr_outport;
/* new_inport 5 */
  if ((ch_val.inport = make_inport()) == nil) goto ch_depletion;
  (*(REF(5).tsdr)->finalize)(REF(5).value,F_DISCARD,sched);
  REF(5).value = ch_val; REF(5).tsdr = & dr_inport;
/* connect 3.1 5 */
  if (REF(5).value.inport->refcount == MAXCOUNTER) goto ch_depletion;
  (*(REF(3)DOT(1).tsdr)->finalize)(REF(3)DOT(1).value,F_DISCARD,sched);
  REF(5).value.inport->refcount++;
  REF(3)DOT(1).value.outport = REF(5).value.inport;
  REF(3)DOT(1).tsdr = & dr_outport;
/* 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;
/* unite 6 7 , 0 */
  if ((ch_returncode = che_unite(DEF(6),DEF(7),sched,0)) != Normal)
     goto ch_raise_exception;
c9:
/* discard 8 */
  (*(REF(8).tsdr)->finalize)(REF(8).value,F_DISCARD,sched);
  REF(8).tsdr = & dr_bottom;
/* discard 9 */
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  REF(9).tsdr = & dr_bottom;
  current->ip = 4;
cb13:
/* select 4 * 5 * , 2 */
  if ((ch_returncode = che_select((
          arguments[0] = DEF(4),
          arguments[1] = NO_OBJECT,
          arguments[2] = DEF(5),
          arguments[3] = NO_OBJECT,
          arguments[3+1] = nil,& arguments[0]),QUAL(2),sched)) != Normal)
     goto ch_raise_exception;
  if (current->ip == 4) return; else COMPUTE_TARGET;
c15:
  current->ip = 6;
cb15:
/* receive 10 4 */
  if ((ch_returncode = che_receive(DEF(10),DEF(4),sched)) != Normal)
     goto ch_raise_exception;
  return;
c16:
/* new_record 11 , 3 */
  if ((ch_val.record = new_record(3)) == nil) goto ch_depletion;
  (*(REF(11).tsdr)->finalize)(REF(11).value,F_DISCARD,sched);
  REF(11).value = ch_val; REF(11).tsdr = & dr_record;
/* lookup_at 12 10.0.2 =(1) */
  if (1 >= (ch_t = REF(10)DOT(0)DOT(2).value.table)->size) goto ch_notfound;
  (*(REF(12).tsdr)->finalize)(REF(12).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(12).value,1);
  REF(12).tsdr = qdatarepmap[ch_t->tsdr->number];
  current->ip = 8;
cb19:
/* call 10.2.4.6 12 13 , 3 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(10)DOT(2)DOT(4)DOT(6),
          arguments[1] = DEF(12),
          arguments[2] = DEF(13),
          arguments[2+1] = nil,& arguments[0]),QUAL(3),sched)) != Normal)
     goto ch_raise_exception;
  return;
c20:
/* move 8 13 */
  (*(REF(8).tsdr)->finalize)(REF(8).value,F_DISCARD,sched);
  REF(8) = REF(13);
  REF(13).tsdr = & dr_bottom;
  current->ip = 10;
cb21:
/* call 10.2.3.16 8 9 , 4 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(10)DOT(2)DOT(3)DOT(16),
          arguments[1] = DEF(8),
          arguments[2] = DEF(9),
          arguments[2+1] = nil,& arguments[0]),QUAL(4),sched)) != Normal)
     goto ch_raise_exception;
  return;
c22:
/* noop */
  
/* ord_case 14 9.2 */
  REF(14).value.ord_enum = REF(9)DOT(2).value.variant->info.variant_case;
  REF(14).tsdr = & dr_ord_enumeration;
/* find 15 10.2.2.0 10.0.1 , 0 */
  if (findfunc(DEF(15),DEF(10)DOT(2)DOT(2)DOT(0),(
          arguments[0] = DEF(10)DOT(0)DOT(1),& arguments[0]),sched,0
            ) == FAILURE) goto ch_notfound;
/* reveal 15.1 , 1 */
  if (1 != REF(15)DOT(1).value.variant->info.variant_case) goto ch_case_error;
/* find 16 15.1.0 14 , 0 */
  if (findfunc(DEF(16),DEF(15)DOT(1)DOT(0),(
          arguments[0] = DEF(14),& arguments[0]),sched,0) == FAILURE)
             goto ch_notfound;
/* copy 11.0 16.1 */
  if((ch_returncode = (REF(16)DOT(1).tsdr->copy)(& ch_val, REF(16)DOT(1).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(11)DOT(0).tsdr)->finalize)(REF(11)DOT(0).value,F_DISCARD,sched);
  REF(11)DOT(0).value = ch_val;
  REF(11)DOT(0).tsdr = datarepmap[REF(16)DOT(1).tsdr->number];
/* new_table 11.1 , 5 */
  if ((ch_returncode = che_new_table(DEF(11)DOT(1),QUAL(5),sched)) != Normal) 
     goto ch_raise_exception;
/* copy 17 10.0.2 */
  if((ch_returncode = cp_table(& ch_val, REF(10)DOT(0)DOT(2).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(17).tsdr)->finalize)(REF(17).value,F_DISCARD,sched);
  REF(17).value = ch_val;
  REF(17).tsdr = & dr_table;
/* initget 18 17 , 0,0 */
  (*(REF(18).tsdr)->finalize)(REF(18).value,F_DISCARD,sched);
  if ((ch_returncode = init_selector(DEF(18),DEF(17),nil,sched,GET,0,0
    )) != Normal) goto ch_raise_exception;
c32:
/* get_or_goto 18 17 , 36 */
  if ((ch_returncode = get_selected_object(DEF(18),DEF(17),sched)) != Normal)
     goto c36;
  current->ip = 13;
cb33:
/* call 10.2.4.4 18 19 , 6 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(10)DOT(2)DOT(4)DOT(4),
          arguments[1] = DEF(18),
          arguments[2] = DEF(19),
          arguments[2+1] = nil,& arguments[0]),QUAL(6),sched)) != Normal)
     goto ch_raise_exception;
  return;
c34:
/* insert 11.1 19 */
  if ((ch_returncode = insertfunc(DEF(11)DOT(1),DEF(19),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* branch , 32 */
   goto c32;
c36:
/* endget 18 17 */
  end_selector(DEF(18),DEF(17),sched,GET);
/* discard 17 */
  (*(REF(17).tsdr)->finalize)(REF(17).value,F_DISCARD,sched);
  REF(17).tsdr = & dr_bottom;
/* copy 11.2 6 */
  if((ch_returncode = cp_variant(& ch_val, REF(6).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(11)DOT(2).tsdr)->finalize)(REF(11)DOT(2).value,F_DISCARD,sched);
  REF(11)DOT(2).value = ch_val;
  REF(11)DOT(2).tsdr = & dr_variant;
/* insert 10.2.4.3.1 11 */
  if ((ch_returncode = insertfunc(DEF(10)DOT(2)DOT(4)DOT(3)DOT(1),DEF(11)
    ,FALSE,0)) != Normal) goto ch_raise_exception;
/* branch , 45 */
   goto c45;
c42:
/* exit , 7 */
  ch_e = handler_type__exit; ch_val = QUAL(7); goto ch_exception;
c14:
c44:
/* exit , 8 */
  ch_e = handler_type__exit; ch_val = QUAL(8); goto ch_exception;
c45:
/* return 10 */
  if (ch_caller = do_return(REF(10).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(10).value);
  REF(10).tsdr = & dr_bottom;
/* branch , 9 */
   goto c9;
c47:
/* endblock */
  che_endblock(sched);
/* branch , 53 */
   goto c53;
c50:
/* chs_lit 20 , "CantHappen exit taken in cgtypedstmt" */
  if( !chs_lit(DEF(20),"CantHappen exit taken in cgtypedstmt") )
     goto ch_depletion;
/* print 20 */
  re_print(stderr, 0, DEF(20)); fflush(stderr);
/* discard 20 */
  (*(REF(20).tsdr)->finalize)(REF(20).value,F_DISCARD,sched);
  REF(20).tsdr = & dr_bottom;
c53:
/* endblock */
  che_endblock(sched);
c55:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
