#include "chdecl.h"
void CH_cache_defmodcache(current, sched, cop)
#define ARGUMENTS 5
#include "chhead.h"
select: switch (SELECTOR) {
    case 0: goto c0;
    case 1: goto cb1;
    case 2: goto c2;
    case 3: goto c8;
    case 4: goto cb8;
    case 5: goto c9;
    case 6: goto c10;
    case 7: goto c26;
    case 8: goto c30;
    case 9: goto c35;
    case 10: goto c37;  }
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:
/* 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;
/* 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;
/* new_table 5 , 1 */
  if ((ch_returncode = che_new_table(DEF(5),QUAL(1),sched)) != Normal) 
     goto ch_raise_exception;
c6:
/* noop */
  
c8:
  current->ip = 4;
cb8:
/* receive 6 4 */
  if ((ch_returncode = che_receive(DEF(6),DEF(4),sched)) != Normal)
     goto ch_raise_exception;
  return;
c9:
/* new_table 7 , 1 */
  if ((ch_returncode = che_new_table(DEF(7),QUAL(1),sched)) != Normal) 
     goto ch_raise_exception;
c10:
/* size 8 6.0.0 */
  REF(8).value.integer = REF(6)DOT(0)DOT(0).value.table->size;
  REF(8).tsdr = & dr_integer;
/* equal . 8 =(0) , 30 */
  if ( REF(8).value.integer == 0 ) goto c30;
/* privatize 6.0.0 */
  if (REF(6)DOT(0)DOT(0).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(6)DOT(0)DOT(0))) != Normal)
       goto ch_raise_exception;
/* initget 9 6.0.0 , 0,0 */
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  if ((ch_returncode = init_selector(DEF(9),DEF(6)DOT(0)DOT(0),nil,sched,GET,
    0,0)) != Normal) goto ch_raise_exception;
/* get_or_err 9 6.0.0 */
  if ((ch_returncode = get_selected_object(DEF(9),DEF(6)DOT(0)DOT(0)
    ,sched)) != Normal) goto ch_raise_exception;
/* remove 10 9 6.0.0 */
  if ((ch_returncode = che_remove(DEF(10),DEF(9),DEF(6)DOT(0)DOT(0)
    ,sched)) != Normal) goto ch_raise_exception;
/* endget 9 6.0.0 */
  end_selector(DEF(9),DEF(6)DOT(0)DOT(0),sched,GET);
/* block , 2 */
  if((ch_returncode = che_block(QUAL(2),sched)) != Normal)
     goto ch_raise_exception;
/* find 11 5 10.0 , 0 */
  if (findfunc(DEF(11),DEF(5),(
          arguments[0] = DEF(10)DOT(0),& arguments[0]),sched,0) == FAILURE)
             goto ch_notfound;
/* discard 10 */
  (*(REF(10).tsdr)->finalize)(REF(10).value,F_DISCARD,sched);
  REF(10).tsdr = & dr_bottom;
/* copy 12 11 */
  if((ch_returncode = (REF(11).tsdr->copy)(& ch_val, REF(11).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(12).tsdr)->finalize)(REF(12).value,F_DISCARD,sched);
  REF(12).value = ch_val;
  REF(12).tsdr = datarepmap[REF(11).tsdr->number];
/* insert 7 12 */
  if ((ch_returncode = insertfunc(DEF(7),DEF(12),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* endblock */
  che_endblock(sched);
/* branch , 10 */
   goto c10;
c26:
/* copy 13 10 */
  if((ch_returncode = (REF(10).tsdr->copy)(& ch_val, REF(10).value
    )) != Normal) goto ch_raise_exception;
  (*(REF(13).tsdr)->finalize)(REF(13).value,F_DISCARD,sched);
  REF(13).value = ch_val;
  REF(13).tsdr = datarepmap[REF(10).tsdr->number];
/* insert 5 13 */
  if ((ch_returncode = insertfunc(DEF(5),DEF(13),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* insert 7 10 */
  if ((ch_returncode = insertfunc(DEF(7),DEF(10),FALSE,0)) != Normal)
     goto ch_raise_exception;
/* branch , 10 */
   goto c10;
c30:
/* move 6.0.0 7 */
  (*(REF(6)DOT(0)DOT(0).tsdr)->finalize)(REF(6)DOT(0)DOT(0).value
    ,F_DISCARD,sched);
  REF(6)DOT(0)DOT(0) = REF(7);
  REF(7).tsdr = & dr_bottom;
/* wrap 14 6.0 , 3 */
  if ((ch_returncode = che_wrap(DEF(14),DEF(6)DOT(0),QUAL(3)
    ,sched)) != Normal) goto ch_raise_exception;
/* unwrap 6.0 14 , 3 */
  if ((ch_returncode = che_unwrap(DEF(6)DOT(0),DEF(14),QUAL(3)
    ,sched)) != Normal) goto ch_raise_exception;
/* return 6 */
  if (ch_caller = do_return(REF(6).value)) {
    if (ch_caller->type < CProcess) ch_caller->ip++;
      sched->wakeup_proc(sched, ch_caller);}
  else rem_return(REF(6).value);
  REF(6).tsdr = & dr_bottom;
/* branch , 6 */
   goto c6;
c35:
/* endblock */
  che_endblock(sched);
c37:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
