#include "chdecl.h"
void CH_chcode_chupstate(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 c7;
    case 4: goto cb46;
    case 5: goto c47;
    case 6: goto c50;  }
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:
/* ilit 4 , 0 */
  REF(4).value.integer = 0;
  REF(4).tsdr = & dr_integer;
/* new_table 5 , 1 */
  if ((ch_returncode = che_new_table(DEF(5),QUAL(1),sched)) != Normal) 
     goto ch_raise_exception;
/* copy 6 3.0 */
  if((ch_returncode = cp_table(& ch_val, REF(3)DOT(0).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(6).tsdr)->finalize)(REF(6).value,F_DISCARD,sched);
  REF(6).value = ch_val;
  REF(6).tsdr = & dr_table;
/* initget 7 6 , 0,0 */
  (*(REF(7).tsdr)->finalize)(REF(7).value,F_DISCARD,sched);
  if ((ch_returncode = init_selector(DEF(7),DEF(6),nil,sched,GET,0,0
    )) != Normal) goto ch_raise_exception;
c7:
/* get_or_goto 7 6 , 40 */
  if ((ch_returncode = get_selected_object(DEF(7),DEF(6),sched)) != Normal)
     goto c40;
/* position 8 7 */
  ch_frame = get_selector_frame(DEF(7),sched);
  ch_t = ch_frame->inspectee->value.table;
  REF(8).value.integer = ch_frame->rmvcount +
    (*(ch_t->tbls[ORDER_TBL].des->position_of))(ch_t,ORDER_TBL,ch_frame->pos);
  REF(8).tsdr = &dr_integer;
/* oele 9 7.4 =(2) */
  REF(9).value.boolean = (REF(7)DOT(4).value.ord_enum <= 2);
/* equal 10 7.4 =(4) */
  REF(10).value.boolean = (REF(7)DOT(4).value.ord_enum == 4);
  REF(10).tsdr = & dr_boolean;
/* equal 11 7.0 =(113) */
  REF(11).value.boolean = (REF(7)DOT(0).value.enumeration == 113);
  REF(11).tsdr = & dr_boolean;
/* and 12 10 11 */
  REF(12).value.boolean = REF(10).value.boolean&REF(11).value.boolean;
  REF(12).tsdr = & dr_boolean;
/* or 13 9 12 */
  REF(13).value.boolean = REF(9).value.boolean|REF(12).value.boolean;
  REF(13).tsdr = & dr_boolean;
/* branch_false 13 , 27 */
  if ( !REF(13).value.boolean ) goto c27;
/* privatize 3.0 */
  if (REF(3)DOT(0).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(0))) != Normal)
       goto ch_raise_exception;
/* lookup_at 14 3.0 8 */
  if((ch_i = REF(8).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(0).value
    .table)->size) goto ch_notfound;
  (*(REF(14).tsdr)->finalize)(REF(14).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(14).value,ch_i);
  REF(14).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 15 3.0 8 */
  if ((ch_returncode = remove_at_func(DEF(15),DEF(3)DOT(0),
    REF(8).value.integer)) != Normal) goto ch_raise_exception;
/* copy 15.5 4 */
  REF(15)DOT(5) = REF(4);
/* insert_at 3.0 15 8 */
  ch_i = REF(8).value.integer;
  if (ch_i < 0 || REF(3)DOT(0).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(0),DEF(15),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
/* iadd 4 4 =(1) */
  if (!chf_iadd(DEF(4),REF(4).value.integer,1)) goto ch_depletion;
c27:
/* noop */
  
/* oege . 7.3 =(2) , 7 */
  if ( REF(7)DOT(3).value.ord_enum >= 2 ) goto c7;
/* notequal . 7.3 =(0) , 35 */
  if ( REF(7)DOT(3).value.ord_enum != 0 ) goto c35;
/* insert 5 8 */
  if ((ch_returncode = insertfunc(DEF(5),DEF(8),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* branch , 7 */
   goto c7;
c35:
/* noop */
  
/* notequal . 7.4 =(0) , 7 */
  if ( REF(7)DOT(4).value.ord_enum != 0 ) goto c7;
/* insert 5 8 */
  if ((ch_returncode = insertfunc(DEF(5),DEF(8),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* branch , 7 */
   goto c7;
c40:
/* endget 7 6 */
  end_selector(DEF(7),DEF(6),sched,GET);
/* discard 6 */
  (*(REF(6).tsdr)->finalize)(REF(6).value,F_DISCARD,sched);
  REF(6).tsdr = & dr_bottom;
/* prog_lit 16 , 2 */
  if ((ch_returncode = che_prog_lit(DEF(16),QUAL(2),sched)) != Normal) 
     goto ch_raise_exception;
/* procedure 17 16 , 3 */
  if ((ch_returncode = che_procedure(DEF(17),DEF(16),QUAL(3)
    ,sched)) != Normal) goto ch_raise_exception;
/* discard 16 */
  (*(REF(16).tsdr)->finalize)(REF(16).value,F_DISCARD,sched);
  REF(16).tsdr = & dr_bottom;
/* move 18 17 */
  (*(REF(18).tsdr)->finalize)(REF(18).value,F_DISCARD,sched);
  REF(18) = REF(17);
  REF(17).tsdr = & dr_bottom;
  current->ip = 4;
cb46:
/* call 3.1 3.0 5 18 19 , 4 */
  if ((ch_returncode = che_call((
          arguments[0] = DEF(3)DOT(1),
          arguments[1] = DEF(3)DOT(0),
          arguments[2] = DEF(5),
          arguments[3] = DEF(18),
          arguments[4] = DEF(19),
          arguments[4+1] = nil,& arguments[0]),QUAL(4),sched)) != Normal)
     goto ch_raise_exception;
  return;
c47:
/* 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);
c50:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
