#include "chdecl.h"
void CH_typestate_prereveal(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 c3;
    case 4: goto cb27;
    case 5: goto c28;
    case 6: goto c33;  }
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:
/* initget 4 3.4.2 , 0,0 */
  (*(REF(4).tsdr)->finalize)(REF(4).value,F_DISCARD,sched);
  if ((ch_returncode = init_selector(DEF(4),DEF(3)DOT(4)DOT(2),nil,sched,GET,
    0,0)) != Normal) goto ch_raise_exception;
c3:
/* get_or_err 4 3.4.2 */
  if ((ch_returncode = get_selected_object(DEF(4),DEF(3)DOT(4)DOT(2)
    ,sched)) != Normal) goto ch_raise_exception;
/* position 5 4 */
  ch_frame = get_selector_frame(DEF(4),sched);
  ch_t = ch_frame->inspectee->value.table;
  REF(5).value.integer = ch_frame->rmvcount +
    (*(ch_t->tbls[ORDER_TBL].des->position_of))(ch_t,ORDER_TBL,ch_frame->pos);
  REF(5).tsdr = &dr_integer;
/* lookup_at 6 3.7 =(0) */
  if ( !((ch_t = REF(3)DOT(7).value.table)->size) ) goto ch_notfound;
  (*(REF(6).tsdr)->finalize)(REF(6).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(6).value,0);
  REF(6).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 7 6 */
  REF(7) = REF(6);
/* notequal . 5 7 , 3 */
  if ( REF(5).value.integer != REF(7).value.integer ) goto c3;
/* copy 8 4 */
  if((ch_returncode = (REF(4).tsdr->copy)(& ch_val, REF(4).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(8).tsdr)->finalize)(REF(8).value,F_DISCARD,sched);
  REF(8).value = ch_val;
  REF(8).tsdr = datarepmap[REF(4).tsdr->number];
/* endget 4 3.4.2 */
  end_selector(DEF(4),DEF(3)DOT(4)DOT(2),sched,GET);
/* move 9 8 */
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  REF(9) = REF(8);
  REF(8).tsdr = & dr_bottom;
/* privatize 9.1 */
  if (REF(9)DOT(1).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(9)DOT(1))) != Normal)
       goto ch_raise_exception;
/* size 10 9.1 */
  REF(10).value.integer = REF(9)DOT(1).value.table->size;
  REF(10).tsdr = & dr_integer;
/* isubtract 11 10 =(1) */
  if (!chf_isubtract(DEF(11),REF(10).value.integer,1)) goto ch_depletion;
/* lookup_at 12 9.1 11 */
  if((ch_i = REF(11).value.integer) < 0 || ch_i >= (ch_t = REF(9)DOT(1).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,ch_i);
  REF(12).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 13 9.1 11 */
  if ((ch_returncode = remove_at_func(DEF(13),DEF(9)DOT(1),
    REF(11).value.integer)) != Normal) goto ch_raise_exception;
/* new_table 14 , 1 */
  if ((ch_returncode = che_new_table(DEF(14),QUAL(1),sched)) != Normal) 
     goto ch_raise_exception;
/* new_record 15 , 2 */
  if ((ch_val.record = new_record(2)) == nil) goto ch_depletion;
  (*(REF(15).tsdr)->finalize)(REF(15).value,F_DISCARD,sched);
  REF(15).value = ch_val; REF(15).tsdr = & dr_record;
/* new_table 15.1 , 2 */
  if ((ch_returncode = che_new_table(DEF(15)DOT(1),QUAL(2),sched)) != Normal) 
     goto ch_raise_exception;
/* unite 15.0 16 , 0 */
  if ((ch_returncode = che_unite(DEF(15)DOT(0),DEF(16),sched,0)) != Normal)
     goto ch_raise_exception;
/* copy 17 9 */
  if((ch_returncode = (REF(9).tsdr->copy)(& ch_val, REF(9).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(17).tsdr)->finalize)(REF(17).value,F_DISCARD,sched);
  REF(17).value = ch_val;
  REF(17).tsdr = datarepmap[REF(9).tsdr->number];
/* insert 15.1 17 */
  if ((ch_returncode = insertfunc(DEF(15)DOT(1),DEF(17),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* insert 14 15 */
  if ((ch_returncode = insertfunc(DEF(14),DEF(15),FALSE,0)) != Normal)
     goto ch_raise_exception;
  current->ip = 4;
cb27:
/* call 3.0.4 3.6 9 14 18 , 3 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(3)DOT(0)DOT(4),
          arguments[1] = DEF(3)DOT(6),
          arguments[2] = DEF(9),
          arguments[3] = DEF(14),
          arguments[4] = DEF(18),
          arguments[4+1] = nil,& arguments[0]),QUAL(3),sched)) != Normal)
     goto ch_raise_exception;
  return;
c28:
/* merge 3.8 14 */
  if ((ch_returncode = mergefunc(DEF(3)DOT(8),DEF(14),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* merge 3.9 18 */
  if ((ch_returncode = mergefunc(DEF(3)DOT(9),DEF(18),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* 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);
c33:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
