

#include "BUILTIN.h"

#include "Nat.h"
extern OBJ __AVoid_2;
extern OBJ __ASeq_6;
extern OBJ _ASeq_14(OBJ,OBJ);extern OBJ __ASeq_14;
extern OBJ _ASeq_26(OBJ,OBJ);extern OBJ __ASeq_26;
extern OBJ _ASeqMap_3(OBJ,OBJ);extern OBJ __ASeqMap_3;

#include "Com.h"
extern OBJ _ACom_AcontCom(OBJ);OBJ __ACom_AcontCom; /* contCom */
extern OBJ _ACom_AcontCom_(OBJ);OBJ __ACom_AcontCom_; /* contCom? */
extern OBJ _ACom_Acont(OBJ);OBJ __ACom_Acont; /* cont */
extern OBJ _ACom_Achoice(OBJ);OBJ __ACom_Achoice; /* choice */
extern OBJ _ACom_Achoice_(OBJ);OBJ __ACom_Achoice_; /* choice? */
extern OBJ _ACom_Aalts(OBJ);OBJ __ACom_Aalts; /* alts */
extern OBJ _ACom_Asequence(OBJ,OBJ);OBJ __ACom_Asequence; /* sequence */
extern OBJ _ACom_Asequence_(OBJ);OBJ __ACom_Asequence_; /* sequence? */
extern OBJ _ACom_Aconts(OBJ);OBJ __ACom_Aconts; /* conts */
extern OBJ _ACom_Aproc(OBJ);OBJ __ACom_Aproc; /* proc */
extern OBJ _ACom_Afail(OBJ);OBJ __ACom_Afail; /* fail */
extern OBJ _ACom_Afail_(OBJ);OBJ __ACom_Afail_; /* fail? */
extern OBJ _ACom_Aerror(OBJ);OBJ __ACom_Aerror; /* error */
extern OBJ _ACom_Aokay(OBJ);OBJ __ACom_Aokay; /* okay */
extern OBJ _ACom_Aokay_(OBJ);OBJ __ACom_Aokay_; /* okay? */
extern OBJ _ACom_Adata(OBJ);OBJ __ACom_Adata; /* data */
extern OBJ _ACom_Ayield(OBJ);OBJ __ACom_Ayield; /* yield */
extern OBJ _ACom_Aexit(OBJ);OBJ __ACom_Aexit; /* exit */
extern OBJ _ACom_Asucceed(OBJ);OBJ __ACom_Asucceed; /* succeed */
extern OBJ _ACom_Abreak(OBJ);OBJ __ACom_Abreak; /* break */
extern OBJ _ACom_AEXEC(OBJ);OBJ __ACom_AEXEC; /* EXEC */
extern OBJ _ACom_Acall(OBJ);OBJ __ACom_Acall; /* call */
extern OBJ _ACom_AfollowedBy(OBJ,OBJ);OBJ __ACom_AfollowedBy; /* followedBy */
extern OBJ _ACom_AsequenceCompose(OBJ,OBJ);OBJ __ACom_AsequenceCompose; /* sequenceCompose */
extern OBJ _ACom_AchoiceCompose(OBJ,OBJ);OBJ __ACom_AchoiceCompose; /* choiceCompose */
extern OBJ _ACom_AexecCom(OBJ);OBJ __ACom_AexecCom; /* execCom */
extern OBJ _ACom_AyieldProc(OBJ,OBJ);OBJ __ACom_AyieldProc; /* yieldProc */
extern OBJ _ACom_AexitProc(OBJ,OBJ);OBJ __ACom_AexitProc; /* exitProc */
extern OBJ _ACom_Amonitor(OBJ);OBJ __ACom_Amonitor; /* monitor */
extern OBJ _ACom_AsequenceCompose_L50(OBJ,OBJ);OBJ __ACom_AsequenceCompose_L50; /* sequenceCompose'50 */

#include "Com.hc.c"

extern OBJ _ACom_AcontCom(OBJ x1) /* contCom */
{OBJ r;
 r=x1;
 return r;}

extern OBJ _ACom_AcontCom_(OBJ x1) /* contCom? */
{OBJ r;
 FRCLS(x1,1);
 r=__ABUILTIN_5;
 return r;}

extern OBJ _ACom_Acont(OBJ x1) /* cont */
{OBJ r;
 r=x1;
 return r;}

extern OBJ _ACom_Achoice(OBJ x1) /* choice */
{OBJ r;
 PRD(1,1,r);FLD(r,1)=x1;
 return r;}

extern OBJ _ACom_Achoice_(OBJ x1) /* choice? */
{OBJ r;
 if(ISTGPRD(x1,1)){
  if(EXPRD(x1,1)){
   FREE(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_5;
 }else{
  if(EXPRD(x1,1)){
   DSPRD(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_3;}
 return r;}

extern OBJ _ACom_Aalts(OBJ x1) /* alts */
{OBJ r;
 if(ISTGPRD(x1,1)){
  {OBJ x2=FLD(x1,1);
   if(EXPRD(x1,1)){
    r=x2;
    DSPRDF(x1);
   }else{
    COPY(x2,1);
    r=x2;
    FRPRD(x1,1);}}
 }else{
  HLT("Com at <unknown> : undefined selection alts\'Com:com->seq");}
 return r;}

extern OBJ _ACom_Asequence(OBJ x1,OBJ x2) /* sequence */
{OBJ r;
 PRD(2,0,r);FLD(r,1)=x1;FLD(r,2)=x2;
 return r;}

extern OBJ _ACom_Asequence_(OBJ x1) /* sequence? */
{OBJ r;
 if(ISTGPRD(x1,0)){
  if(EXPRD(x1,1)){
   DSPRD(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_5;
 }else{
  if(EXPRD(x1,1)){
   FREE(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_3;}
 return r;}

extern OBJ _ACom_Aconts(OBJ x1) /* conts */
{OBJ r;
 if(ISTGPRD(x1,0)){
  {OBJ x3=FLD(x1,2);
   if(EXPRD(x1,1)){
    r=x3;
    FRCLS(FLD(x1,1),1);DSPRDF(x1);
   }else{
    COPY(x3,1);
    r=x3;
    FRPRD(x1,1);}}
 }else{
  HLT("Com at <unknown> : undefined selection conts\'Com:com->seq");}
 return r;}

extern OBJ _ACom_Aproc(OBJ x1) /* proc */
{OBJ r;
 if(ISTGPRD(x1,0)){
  {OBJ x2=FLD(x1,1);
   if(EXPRD(x1,1)){
    r=x2;
    FREE(FLD(x1,2),1);DSPRDF(x1);
   }else{
    CPCLS(x2,1);
    r=x2;
    FRPRD(x1,1);}}
 }else{
  HLT("Com at <unknown> : undefined selection proc\'Com:com->void->ans");}
 return r;}

extern OBJ _ACom_Afail(OBJ x1) /* fail */
{OBJ r;
 PRD(1,1,r);FLD(r,1)=x1;
 return r;}

extern OBJ _ACom_Afail_(OBJ x1) /* fail? */
{OBJ r;
 if(ISTGPRD(x1,1)){
  if(EXPRD(x1,1)){
   FRPRD(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_5;
 }else{
  if(EXPRD(x1,1)){
   FREE(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_3;}
 return r;}

extern OBJ _ACom_Aerror(OBJ x1) /* error */
{OBJ r;
 if(ISTGPRD(x1,1)){
  {OBJ x2=FLD(x1,1);
   if(EXPRD(x1,1)){
    r=x2;
    DSPRDF(x1);
   }else{
    CPPRD(x2,1);
    r=x2;
    FRPRD(x1,1);}}
 }else{
  HLT("Com at <unknown> : undefined selection error\'Com:ans->denotation");}
 return r;}

extern OBJ _ACom_Aokay(OBJ x1) /* okay */
{OBJ r;
 PRD(1,0,r);FLD(r,1)=x1;
 return r;}

extern OBJ _ACom_Aokay_(OBJ x1) /* okay? */
{OBJ r;
 if(ISTGPRD(x1,0)){
  if(EXPRD(x1,1)){
   FREE(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_5;
 }else{
  if(EXPRD(x1,1)){
   FRPRD(FLD(x1,1),1);DSPRDF(x1);
  }else{
   DCPRD(x1,1);}
  r=__ABUILTIN_3;}
 return r;}

extern OBJ _ACom_Adata(OBJ x1) /* data */
{OBJ r;
 if(ISTGPRD(x1,0)){
  {OBJ x2=FLD(x1,1);
   if(EXPRD(x1,1)){
    r=x2;
    DSPRDF(x1);
   }else{
    COPY(x2,1);
    r=x2;
    FRPRD(x1,1);}}
 }else{
  HLT("Com at <unknown> : undefined selection data\'Com:ans->data");}
 return r;}

extern OBJ _ACom_Ayield(OBJ x1) /* yield */
{OBJ r;
 CPCLS(__ACom_AyieldProc,1);
 {OBJ x2;
  x2=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AyieldProc,1))(__ACom_AyieldProc,x1);
  PRD(2,0,r);FLD(r,1)=x2;FLD(r,2)=__ASeq_6;}
 return r;}

extern OBJ _ACom_Aexit(OBJ x1) /* exit */
{OBJ r;
 CPCLS(__ACom_AexitProc,1);
 {OBJ x2;
  x2=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AexitProc,1))(__ACom_AexitProc,x1);
  PRD(2,0,r);FLD(r,1)=x2;FLD(r,2)=__ASeq_6;}
 return r;}

extern OBJ _ACom_Asucceed(OBJ x1) /* succeed */
{OBJ r;
 CPCLS(__ACom_AyieldProc,1);
 {OBJ x2;OBJ x3;
  PRD(1,0,x2);FLD(x2,1)=x1;
  x3=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AyieldProc,1))(__ACom_AyieldProc,x2);
  PRD(2,0,r);FLD(r,1)=x3;FLD(r,2)=__ASeq_6;}
 return r;}

extern OBJ _ACom_Abreak(OBJ x1) /* break */
{OBJ r;
 CPCLS(__ACom_AyieldProc,1);
 {OBJ x2;OBJ x3;
  PRD(1,1,x2);FLD(x2,1)=x1;
  x3=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AyieldProc,1))(__ACom_AyieldProc,x2);
  PRD(2,0,r);FLD(r,1)=x3;FLD(r,2)=__ASeq_6;}
 return r;}

extern OBJ _ACom_Acall(OBJ x1) /* call */
{OBJ r;
 PRD(2,0,r);FLD(r,1)=x1;FLD(r,2)=__ASeq_6;
 return r;}

extern OBJ _ACom_AfollowedBy(OBJ x1,OBJ x2) /* followedBy */
{OBJ r;
 {OBJ x3;
  PRD1(2,x3);FLD1(x3,1)=x2;FLD1(x3,2)=__ASeq_6;
  if(ISTGPRD(x1,0)){
   {OBJ x4;OBJ x5=FLD(x1,2);
    if(EXPRD(x1,1)){
     {
      RPRD(x1,r);
      FLD(r,2)=_ASeq_26(x5,x3);}
    }else{
     x4=FLD(x1,1);CPCLS(x4,1);COPY(x5,1);
     {
      FRPRD(x1,1);PRD(2,0,r);FLD(r,1)=x4;
      FLD(r,2)=_ASeq_26(x5,x3);}}}
  }else{
   {OBJ x7=FLD(x1,1);
    if(EXPRD(x1,1)){
     CPCLS(__ACom_AsequenceCompose_L50,1);
     {OBJ x8;
      x8=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x3);
      RPRD(x1,r);
      FLD(r,1)=_ASeqMap_3(x8,x7);}
    }else{
     COPY(x7,1);
     CPCLS(__ACom_AsequenceCompose_L50,1);
     {OBJ x8;
      x8=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x3);
      FRPRD(x1,1);PRD(1,1,r);
      FLD(r,1)=_ASeqMap_3(x8,x7);}}}}}
 return r;}

extern OBJ _ACom_AsequenceCompose(OBJ x1,OBJ x2) /* sequenceCompose */
{OBJ r;
 if(ISTGPRD(x1,0)){
  {OBJ x38;OBJ x39=FLD(x1,2);
   if(EXPRD(x1,1)){
    {
     RPRD(x1,r);
     FLD(r,2)=_ASeq_26(x39,x2);}
   }else{
    x38=FLD(x1,1);CPCLS(x38,1);COPY(x39,1);
    {
     FRPRD(x1,1);PRD(2,0,r);FLD(r,1)=x38;
     FLD(r,2)=_ASeq_26(x39,x2);}}}
 }else{
  {OBJ x42=FLD(x1,1);
   if(EXPRD(x1,1)){
    CPCLS(__ACom_AsequenceCompose_L50,1);
    {OBJ x43;
     x43=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x2);
     RPRD(x1,r);
     FLD(r,1)=_ASeqMap_3(x43,x42);}
   }else{
    COPY(x42,1);
    CPCLS(__ACom_AsequenceCompose_L50,1);
    {OBJ x43;
     x43=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x2);
     FRPRD(x1,1);PRD(1,1,r);
     FLD(r,1)=_ASeqMap_3(x43,x42);}}}}
 return r;}

extern OBJ _ACom_AchoiceCompose(OBJ x1,OBJ x2) /* choiceCompose */
{OBJ r;
 if(ISTGPRD(x1,1)){
  {OBJ x33=FLD(x1,1);FLAG x_x1=EXPRD(x1,1);
   if(x_x1){
   }else{
    COPY(x33,1);}
   if(ISTGPRD(x2,1)){
    {OBJ x46=FLD(x2,1);
     if(EXPRD(x2,1)){
      if(x_x1){
       DSPRDF(x1);
      }else{
       FRPRD(x1,1);}
      {
       RPRD(x2,r);
       FLD(r,1)=_ASeq_26(x33,x46);}
     }else{
      COPY(x46,1);
      if(x_x1){
       DSPRDF(x1);
      }else{
       FRPRD(x1,1);}
      {
       FRPRD(x2,1);PRD(1,1,r);
       FLD(r,1)=_ASeq_26(x33,x46);}}}
   }else{
    {OBJ x50;
     PRD1(2,x50);FLD1(x50,1)=x2;FLD1(x50,2)=x33;
     if(x_x1){
      RPRD(x1,r);FLD(r,1)=x50;
     }else{
      FRPRD(x1,1);PRD(1,1,r);FLD(r,1)=x50;}}}}
 }else{
  if(ISTGPRD(x2,1)){
   {OBJ x65=FLD(x2,1);
    if(EXPRD(x2,1)){
     {OBJ x66;
      PRD1(2,x66);FLD1(x66,1)=x1;FLD1(x66,2)=x65;
      RPRD(x2,r);FLD(r,1)=x66;}
    }else{
     COPY(x65,1);
     {OBJ x66;
      PRD1(2,x66);FLD1(x66,1)=x1;FLD1(x66,2)=x65;
      FRPRD(x2,1);PRD(1,1,r);FLD(r,1)=x66;}}}
  }else{
   {
    PRD(1,1,r);
    FLD(r,1)=_ASeq_14(x1,x2);}}}
 return r;}

extern OBJ _ACom_AexecCom(register OBJ x1) /* execCom */
{OBJ r;
 for(;;){
  if(ISTGPRD(x1,0)){
   {OBJ x73=FLD(x1,1);OBJ x74=FLD(x1,2);
    if(EXPRD(x1,1)){
     DSPRDF(x1);
    }else{
     CPCLS(x73,1);COPY(x74,1);
     FRPRD(x1,1);}
    if(ISPRM(x74)){
     {OBJ x75;
      x75=(*(OBJ(*)(OBJ,OBJ))METHOD(x73,1))(x73,__AVoid_2);
      ACom_Amonitor(x75,r);}
    }else{
     {OBJ x76=FLD1(x74,1);OBJ x77=FLD1(x74,2);
      if(EXPRD(x74,1)){
       DSPRDF(x74);
      }else{
       CPCLS(x76,1);COPY(x77,1);
       FRPRD(x74,1);}
      CPCLS(__ACom_Acont,1);
      {OBJ x79;OBJ x80;OBJ x81;OBJ x88;
       x79=(*(OBJ(*)(OBJ,OBJ))METHOD(x73,1))(x73,__AVoid_2);
       ACom_Amonitor(x79,x80);
       x81=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ACom_Acont,2))(__ACom_Acont,x76,x80);
       if(ISTGPRD(x81,0)){
	{OBJ x82;OBJ x83=FLD(x81,2);
	 if(EXPRD(x81,1)){
	  {
	   RPRD(x81,x88);
	   FLD(x88,2)=_ASeq_26(x83,x77);}
	 }else{
	  x82=FLD(x81,1);CPCLS(x82,1);COPY(x83,1);
	  {
	   FRPRD(x81,1);PRD(2,0,x88);FLD(x88,1)=x82;
	   FLD(x88,2)=_ASeq_26(x83,x77);}}}
       }else{
	{OBJ x85=FLD(x81,1);
	 if(EXPRD(x81,1)){
	  CPCLS(__ACom_AsequenceCompose_L50,1);
	  {OBJ x86;
	   x86=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x77);
	   RPRD(x81,x88);
	   FLD(x88,1)=_ASeqMap_3(x86,x85);}
	 }else{
	  COPY(x85,1);
	  CPCLS(__ACom_AsequenceCompose_L50,1);
	  {OBJ x86;
	   x86=(*(OBJ(*)(OBJ,OBJ))METHOD(__ACom_AsequenceCompose_L50,1))(__ACom_AsequenceCompose_L50,x77);
	   FRPRD(x81,1);PRD(1,1,x88);
	   FLD(x88,1)=_ASeqMap_3(x86,x85);}}}}
       x1=x88;continue;}}}}
  }else{
   HLT("<execution>\'Com: choice command only allowed as behavior of agent");}
  break;}
 return r;}

extern OBJ _ACom_AsequenceCompose_L50(OBJ x1,OBJ x2) /* sequenceCompose'50 */
{OBJ r;
 {OBJ x12;OBJ x7;
  if(ISTGPRD(x2,0)){
   {OBJ x17=FLD(x2,1);OBJ x18=FLD(x2,2);
    if(EXPRD(x2,1)){
     x7=x17;x12=x18;
     DSPRDF(x2);
    }else{
     CPCLS(x17,1);COPY(x18,1);
     x7=x17;x12=x18;
     FRPRD(x2,1);}}
  }else{
   HLT("Com at <unknown> : undefined selection conts\'Com:com->seq");}
  PRD(2,0,r);FLD(r,1)=x7;
  FLD(r,2)=_ASeq_26(x12,x1);}
 return r;}

static OBJ _mt_1_0_2(OBJ t,OBJ t1,OBJ t2) 
{OBJ r;
 {OBJ t3;
  DCCLS(t,1);
  t3=(*(OBJ(*)(OBJ))ENTRY(t))(t1);
  r=(*(OBJ(*)(OBJ,OBJ))METHOD(t3,1))(t3,t2);}
 return r;}

init_ACom()
{
 static int visited=0; if(visited) return; visited=1;
 init_ANat();
 init_AVoid();
 init_ASeq();
 init_AOption();
 init_ASeqMap();
 CLS(1,_ACom_30,__ACom_30);
 CLS(2,_ACom_29,__ACom_29);
 CLS(2,_ACom_28,__ACom_28);
 CLS(2,_ACom_27,__ACom_27);
 CLS(1,_ACom_26,__ACom_26);
 CLS(1,_ACom_25,__ACom_25);
 CLS(1,_ACom_24,__ACom_24);
 CLS(1,_ACom_23,__ACom_23);
 CLS(1,_ACom_22,__ACom_22);
 CLS(1,_ACom_21,__ACom_21);
 CLS(1,_ACom_19,__ACom_19);
 CLS(2,_ACom_50,__ACom_50);
 CLS(1,_ACom_18,__ACom_18);
 CLS(1,_ACom_17,__ACom_17);
 CLS(1,_ACom_49,__ACom_49);
 CLS(1,_ACom_16,__ACom_16);
 CLS(2,_ACom_48,__ACom_48);
 CLS(1,_ACom_15,__ACom_15);
 CLS(2,_ACom_47,__ACom_47);
 CLS(1,_ACom_14,__ACom_14);
 CLS(1,_ACom_12,__ACom_12);
 CLS(1,_ACom_11,__ACom_11);
 CLS(1,_ACom_10,__ACom_10);
 CLS(2,_ACom_9,__ACom_9);
 CLS(1,_ACom_8,__ACom_8);
 CLS(1,_ACom_7,__ACom_7);
 CLS(1,_ACom_6,__ACom_6);
 CLS(1,_ACom_4,__ACom_4);
 CLS(1,_ACom_3,__ACom_3);
 CLS(1,_ACom_2,__ACom_2);
 MTH(1,0,2,_mt_1_0_2);LZYMTH(1,0,2,_mt_1_0_2);
 init_const_ACom();}

