#include "chdecl.h"
void CH_chcode_chimprove_select(current, sched, cop)
#define ARGUMENTS 5
#include "chhead.h"
select: switch (SELECTOR) {
    case 0: goto c0;
    case 1: goto cb2;
    case 2: goto c3;
    case 3: goto c15;
    case 4: goto c39;
    case 5: goto c74;
    case 6: goto c79;
    case 7: goto c82;
    case 8: goto c101;
    case 9: goto c102;
    case 10: goto c106;  }
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:
/* size 4 3.3 */
  REF(4).value.integer = REF(3)DOT(3).value.table->size;
  REF(4).tsdr = & dr_integer;
/* isubtract 5 4 =(1) */
  if (!chf_isubtract(DEF(5),REF(4).value.integer,1)) goto ch_depletion;
/* lookup_at 6 3.3 5 */
  if((ch_i = REF(5).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(3).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,ch_i);
  REF(6).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 7 6 */
  REF(7) = REF(6);
/* lookup_at 8 3.1 7 */
  if((ch_i = REF(7).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(1).value
    .table)->size) goto ch_notfound;
  (*(REF(8).tsdr)->finalize)(REF(8).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(8).value,ch_i);
  REF(8).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 9 8.1 */
  if((ch_returncode = cp_table(& ch_val, REF(8)DOT(1).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  REF(9).value = ch_val;
  REF(9).tsdr = & dr_table;
/* reveal 8.2 , 11 */
  if (11 != REF(8)DOT(2).value.variant->info.variant_case) goto ch_case_error;
/* copy 10 8.2.0 */
  if((ch_returncode = cp_table(& ch_val, REF(8)DOT(2)DOT(0).value)) != Normal)
     goto ch_raise_exception;
  (*(REF(10).tsdr)->finalize)(REF(10).value,F_DISCARD,sched);
  REF(10).value = ch_val;
  REF(10).tsdr = & dr_table;
/* block , 2 */
  if((ch_returncode = che_block(QUAL(2),sched)) != Normal)
     goto ch_raise_exception;
c15:
/* noop */
  
/* ile . 5 =(0) , 79 */
  if ( REF(5).value.integer <= 0 ) goto c79;
/* isubtract 5 5 =(1) */
  if (!chf_isubtract(DEF(5),REF(5).value.integer,1)) goto ch_depletion;
/* lookup_at 11 3.3 5 */
  if((ch_i = REF(5).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(3).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];
/* copy 12 11 */
  REF(12) = REF(11);
/* lookup_at 13 3.1 12 */
  if((ch_i = REF(12).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(1).value
    .table)->size) goto ch_notfound;
  (*(REF(13).tsdr)->finalize)(REF(13).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(13).value,ch_i);
  REF(13).tsdr = qdatarepmap[ch_t->tsdr->number];
/* find 14 3.0.11 13.0 , 0 */
  if (findfunc(DEF(14),DEF(3)DOT(0)DOT(11),(
          arguments[0] = DEF(13)DOT(0),& arguments[0]),sched,0) == FAILURE)
             goto ch_notfound;
/* equal . 14.6 =(2) , 30 */
  if ( REF(14)DOT(6).value.enumeration == 2 ) goto c30;
/* exit , 3 */
  ch_e = handler_type__exit; ch_val = QUAL(3); goto ch_exception;
c30:
/* case 15 13.2 */
  REF(15).value.enumeration = REF(13)DOT(2).value.variant->info.variant_case;
  REF(15).tsdr = & dr_enumeration;
/* notequal . 15 =(0) , 74 */
  if ( REF(15).value.enumeration != 0 ) goto c74;
/* lookup_at 16 13.1 =(0) */
  if ( !((ch_t = REF(13)DOT(1).value.table)->size) ) goto ch_notfound;
  (*(REF(16).tsdr)->finalize)(REF(16).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(16).value,0);
  REF(16).tsdr = qdatarepmap[ch_t->tsdr->number];
/* copy 17 16 */
  REF(17) = REF(16);
/* initget 18 9 , 0,0 */
  (*(REF(18).tsdr)->finalize)(REF(18).value,F_DISCARD,sched);
  if ((ch_returncode = init_selector(DEF(18),DEF(9),nil,sched,GET,0,0
    )) != Normal) goto ch_raise_exception;
c39:
/* get_or_err 18 9 */
  if ((ch_returncode = get_selected_object(DEF(18),DEF(9),sched)) != Normal)
     goto ch_raise_exception;
/* notequal . 18 17 , 39 */
  if ( REF(18).value.integer != REF(17).value.integer ) goto c39;
/* position 19 18 */
  ch_frame = get_selector_frame(DEF(18),sched);
  ch_t = ch_frame->inspectee->value.table;
  REF(19).value.integer = ch_frame->rmvcount +
    (*(ch_t->tbls[ORDER_TBL].des->position_of))(ch_t,ORDER_TBL,ch_frame->pos);
  REF(19).tsdr = &dr_integer;
/* endget 18 9 */
  end_selector(DEF(18),DEF(9),sched,GET);
/* isubtract 20 19 =(1) */
  if (!chf_isubtract(DEF(20),REF(19).value.integer,1)) goto ch_depletion;
/* privatize 10 */
  if (REF(10).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(10))) != Normal)
       goto ch_raise_exception;
/* idivide 21 20 =(2) */
  REF(21).value.integer = REF(20).value.integer/2;
  REF(21).tsdr = & dr_integer;
/* lookup_at 22 10 21 */
  if((ch_i = REF(21).value.integer) < 0 || ch_i >= (ch_t = REF(10).value
    .table)->size) goto ch_notfound;
  (*(REF(22).tsdr)->finalize)(REF(22).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(22).value,ch_i);
  REF(22).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 23 10 21 */
  if ((ch_returncode = remove_at_func(DEF(23),DEF(10),REF(21).value.integer
    )) != Normal) goto ch_raise_exception;
/* privatize 9 */
  if (REF(9).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(9))) != Normal)
       goto ch_raise_exception;
/* lookup_at 24 9 20 */
  if((ch_i = REF(20).value.integer) < 0 || ch_i >= (ch_t = REF(9).value
    .table)->size) goto ch_notfound;
  (*(REF(24).tsdr)->finalize)(REF(24).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(24).value,ch_i);
  REF(24).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 25 9 20 */
  if ((ch_returncode = remove_at_func(DEF(25),DEF(9),REF(20).value.integer
    )) != Normal) goto ch_raise_exception;
/* privatize 9 */
  if (REF(9).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(9))) != Normal)
       goto ch_raise_exception;
/* lookup_at 26 9 20 */
  if((ch_i = REF(20).value.integer) < 0 || ch_i >= (ch_t = REF(9).value
    .table)->size) goto ch_notfound;
  (*(REF(26).tsdr)->finalize)(REF(26).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(26).value,ch_i);
  REF(26).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 25 9 20 */
  if ((ch_returncode = remove_at_func(DEF(25),DEF(9),REF(20).value.integer
    )) != Normal) goto ch_raise_exception;
/* privatize 3.1 */
  if (REF(3)DOT(1).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(1))) != Normal)
       goto ch_raise_exception;
/* lookup_at 27 3.1 12 */
  if((ch_i = REF(12).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(1).value
    .table)->size) goto ch_notfound;
  (*(REF(27).tsdr)->finalize)(REF(27).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(27).value,ch_i);
  REF(27).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 28 3.1 12 */
  if ((ch_returncode = remove_at_func(DEF(28),DEF(3)DOT(1),
    REF(12).value.integer)) != Normal) goto ch_raise_exception;
/* unite 28.2 23 , 2 */
  if ((ch_returncode = che_unite(DEF(28)DOT(2),DEF(23),sched,2)) != Normal)
     goto ch_raise_exception;
/* insert_at 3.1 28 12 */
  ch_i = REF(12).value.integer;
  if (ch_i < 0 || REF(3)DOT(1).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(1),DEF(28),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
/* privatize 3.2 */
  if (REF(3)DOT(2).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(2))) != Normal)
       goto ch_raise_exception;
/* lookup_at 29 3.2 17 */
  if((ch_i = REF(17).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(2).value
    .table)->size) goto ch_notfound;
  (*(REF(29).tsdr)->finalize)(REF(29).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(29).value,ch_i);
  REF(29).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 30 3.2 17 */
  if ((ch_returncode = remove_at_func(DEF(30),DEF(3)DOT(2),
    REF(17).value.integer)) != Normal) goto ch_raise_exception;
/* isubtract 30.2 30.2 =(1) */
  if (!chf_isubtract(DEF(30)DOT(2),REF(30)DOT(2).value.integer,1))
     goto ch_depletion;
/* isubtract 30.3 30.3 =(2) */
  if (!chf_isubtract(DEF(30)DOT(3),REF(30)DOT(3).value.integer,2))
     goto ch_depletion;
/* insert_at 3.2 30 17 */
  ch_i = REF(17).value.integer;
  if (ch_i < 0 || REF(3)DOT(2).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(2),DEF(30),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
c74:
/* noop */
  
/* equal . 13.6 =(0) , 15 */
  if ( REF(13)DOT(6).value.integer == 0 ) goto c15;
/* exit , 3 */
  ch_e = handler_type__exit; ch_val = QUAL(3); goto ch_exception;
c79:
/* endblock */
  che_endblock(sched);
/* branch , 82 */
   goto c82;
c82:
/* size 31 9 */
  REF(31).value.integer = REF(9).value.table->size;
  REF(31).tsdr = & dr_integer;
/* notequal . 31 =(0) , 87 */
  if ( REF(31).value.integer != 0 ) goto c87;
/* exit , 4 */
  ch_e = handler_type__exit; ch_val = QUAL(4); goto ch_exception;
c87:
/* equal . 9 8.1 , 96 */
  if ( eq_table(REF(9).value,REF(8)DOT(1).value) ) goto c96;
/* privatize 3.1 */
  if (REF(3)DOT(1).value.table->refcount != 1)
    if ((ch_returncode = doCopyOnWrite(DEF(3)DOT(1))) != Normal)
       goto ch_raise_exception;
/* lookup_at 32 3.1 7 */
  if((ch_i = REF(7).value.integer) < 0 || ch_i >= (ch_t = REF(3)DOT(1).value
    .table)->size) goto ch_notfound;
  (*(REF(32).tsdr)->finalize)(REF(32).value,F_DISCARD,sched);
  (*(ch_t->tbls[ORDER_TBL].des->lookup_at))
    (ch_t, ORDER_TBL, & REF(32).value,ch_i);
  REF(32).tsdr = qdatarepmap[ch_t->tsdr->number];
/* remove_at 28 3.1 7 */
  if ((ch_returncode = remove_at_func(DEF(28),DEF(3)DOT(1),
    REF(7).value.integer)) != Normal) goto ch_raise_exception;
/* move 28.1 9 */
  (*(REF(28)DOT(1).tsdr)->finalize)(REF(28)DOT(1).value,F_DISCARD,sched);
  REF(28)DOT(1) = REF(9);
  REF(9).tsdr = & dr_bottom;
/* unite 28.2 10 , 11 */
  if ((ch_returncode = che_unite(DEF(28)DOT(2),DEF(10),sched,11)) != Normal)
     goto ch_raise_exception;
/* insert_at 3.1 28 7 */
  ch_i = REF(7).value.integer;
  if (ch_i < 0 || REF(3)DOT(1).value.table->size < ch_i) goto ch_range_error;
  if ((ch_returncode = insertfunc(DEF(3)DOT(1),DEF(28),TRUE, ch_i)) != Normal)
     goto ch_raise_exception;
c96:
/* discard 9 */
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  REF(9).tsdr = & dr_bottom;
/* discard 10 */
  (*(REF(10).tsdr)->finalize)(REF(10).value,F_DISCARD,sched);
  REF(10).tsdr = & dr_bottom;
/* 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);
/* branch , 102 */
   goto c102;
c101:
/* return_exception 3 , 5 */
  if (ch_caller = do_return(REF(3).value)) {
    raise_user(QUAL(5),ch_caller); 
    sched->wakeup_proc(sched,ch_caller);}
  else rem_return_exception(DEF(3),QUAL(5));
  REF(3).tsdr = & dr_bottom;
c102:
/* discard 9 */
  (*(REF(9).tsdr)->finalize)(REF(9).value,F_DISCARD,sched);
  REF(9).tsdr = & dr_bottom;
/* discard 10 */
  (*(REF(10).tsdr)->finalize)(REF(10).value,F_DISCARD,sched);
  REF(10).tsdr = & dr_bottom;
/* endblock */
  che_endblock(sched);
c106:
/* endprocess */
  che_endprocess(sched); return;
#include "chtail.h"
