#include "chdecl.h"
void CH_cwd(current, sched, cop)
#define ARGUMENTS 6
#include "chhead.h"
select: switch (SELECTOR) {
    case 0: goto c0;
    case 1: goto cb3;
    case 2: goto c4;
    case 5: goto c8;
    case 3: goto c10;
    case 4: goto cb10;
    case 6: goto cb12;
    case 7: goto c13;
    case 8: goto cb16;
    case 9: goto c17;
    case 10: goto c31;
    case 11: goto c33;  }
c0:
/* block , 0 */
  if((ch_returncode = che_block(QUAL(0),sched)) != Normal)
     goto ch_raise_exception;
/* new_inport 3 */
  if ((ch_val.inport = make_inport()) == nil) goto ch_depletion;
  (*(REF(3).tsdr)->finalize)(REF(3).value,F_DISCARD,sched);
  REF(3).value = ch_val; REF(3).tsdr = & dr_inport;
/* 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;
  current->ip = 1;
cb3:
/* receive 5 0 */
  if ((ch_returncode = che_receive(DEF(5),DEF(0),sched)) != Normal)
     goto ch_raise_exception;
  return;
c4:
/* copy 6 5.0 */
  if((ch_returncode = cp_table(& ch_val, REF(5)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;
/* connect 5.2 4 */
  if (REF(4).value.inport->refcount == MAXCOUNTER) goto ch_depletion;
  (*(REF(5)DOT(2).tsdr)->finalize)(REF(5)DOT(2).value,F_DISCARD,sched);
  REF(4).value.inport->refcount++;
  REF(5)DOT(2).value.outport = REF(4).value.inport;
  REF(5)DOT(2).tsdr = & dr_outport;
/* connect 5.1 3 */
  if (REF(3).value.inport->refcount == MAXCOUNTER) goto ch_depletion;
  (*(REF(5)DOT(1).tsdr)->finalize)(REF(5)DOT(1).value,F_DISCARD,sched);
  REF(3).value.inport->refcount++;
  REF(5)DOT(1).value.outport = REF(3).value.inport;
  REF(5)DOT(1).tsdr = & dr_outport;
/* return 5 */
  if (ch_caller = do_return(REF(5).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(5).value);
  REF(5).tsdr = & dr_bottom;
c11:
c8:
/* noop */
  
c10:
  current->ip = 4;
cb10:
/* select 4 * 3 * , 1 */
  if ((ch_returncode = che_select((
          arguments[0] = DEF(4),
          arguments[1] = NO_OBJECT,
          arguments[2] = DEF(3),
          arguments[3] = NO_OBJECT,
          arguments[3+1] = nil,& arguments[0]),QUAL(1),sched)) != Normal)
     goto ch_raise_exception;
  if (current->ip == 4) return; else COMPUTE_TARGET;
c12:
  current->ip = 6;
cb12:
/* receive 7 4 */
  if ((ch_returncode = che_receive(DEF(7),DEF(4),sched)) != Normal)
     goto ch_raise_exception;
  return;
c13:
/* copy 7.0 6 */
  if((ch_returncode = cp_table(& ch_val, REF(6).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(7)DOT(0).tsdr)->finalize)(REF(7)DOT(0).value,F_DISCARD,sched);
  REF(7)DOT(0).value = ch_val;
  REF(7)DOT(0).tsdr = & dr_table;
/* return 7 */
  if (ch_caller = do_return(REF(7).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(7).value);
  REF(7).tsdr = & dr_bottom;
/* branch , 8 */
   goto c8;
c16:
  current->ip = 8;
cb16:
/* receive 8 3 */
  if ((ch_returncode = che_receive(DEF(8),DEF(3),sched)) != Normal)
     goto ch_raise_exception;
  return;
c17:
/* copy 6 8.0 */
  if((ch_returncode = cp_table(& ch_val, REF(8)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;
/* privatize 6 */
  if (REF(6).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(6))) != Normal)
       goto ch_raise_exception;
/* size 9 6 */
  REF(9).value.integer = REF(6).value.table->size;
  REF(9).tsdr = & dr_integer;
/* isubtract 10 9 =(1) */
  if (!chf_isubtract(DEF(10),REF(9).value.integer,1)) goto ch_depletion;
/* lookup_at 11 6 10 */
  if((ch_i = REF(10).value.integer) < 0 || ch_i >= (ch_t = REF(6).value
    .table)->size) goto ch_notfound;
  (*(REF(11).tsdr)->finalize)(REF(11).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(11).value,ch_i);
  REF(11).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 12 6 10 */
  if ((ch_returncode = remove_at_func(DEF(12),DEF(6),REF(10).value.integer
    )) != Normal) goto ch_raise_exception;
/* equal . 12 =(47) , 28 */
  if ( REF(12).value.ord_enum == 47 ) goto c28;
/* insert 6 12 */
  if ((ch_returncode = insertfunc(DEF(6),DEF(12),FALSE,0)) != Normal)
     goto ch_raise_exception;
c28:
/* return 8 */
  if (ch_caller = do_return(REF(8).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(8).value);
  REF(8).tsdr = & dr_bottom;
/* branch , 8 */
   goto c8;
c31:
/* endblock */
  che_endblock(sched);
c33:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
