

#include "BUILTIN.h"
extern OBJ _ABSTree_2(OBJ,OBJ,OBJ,OBJ);extern OBJ __ABSTree_2;
extern OBJ _ABSTree_6(OBJ,OBJ);extern OBJ __ABSTree_6;
extern OBJ _ABSTree_23(OBJ,OBJ,OBJ);extern OBJ __ABSTree_23;
extern OBJ _ABSTree_44(OBJ,OBJ);extern OBJ __ABSTree_44;

#include "Nat.h"
extern OBJ __ATree_7;
extern OBJ _AOptionMap_3(OBJ,OBJ);extern OBJ __AOptionMap_3;

#include "Denotation.h"
extern OBJ _ATreeIndex_8(OBJ,OBJ);extern OBJ __ATreeIndex_8;
extern OBJ __ATreeIndex_30;
extern OBJ __ATreeIndex_34;
extern OBJ _AIndexingOfTrees_6(OBJ);extern OBJ __AIndexingOfTrees_6;
extern OBJ _AIndexingOfTrees_7(OBJ);extern OBJ __AIndexingOfTrees_7;
extern OBJ _AIndexingOfTrees_8(OBJ);extern OBJ __AIndexingOfTrees_8;
extern OBJ _AIndexingOfTrees_9(OBJ);extern OBJ __AIndexingOfTrees_9;

#include "Char.h"

#include "Int.h"
extern TUP2 _ABSTreeIndex_3(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_3; /* step */
extern OBJ _ABSTreeIndex_4(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_4; /* ! */
extern OBJ _ABSTreeIndex_5(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_5; /* !? */
extern OBJ _ABSTreeIndex_6(OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_6; /* upd */
extern OBJ _ABSTreeIndex_7(OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_7; /* upd,1 */
extern OBJ _ABSTreeIndex_8(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_8; /* !,1 */
extern OBJ _ABSTreeIndex_9(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_9; /* !?,1 */
extern OBJ _ABSTreeIndex_10(OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_10; /* repl */
extern OBJ _ABSTreeIndex_11(OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_11; /* repl,1 */
extern OBJ _ABSTreeIndex_12(OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_12; /* insert */
extern OBJ _ABSTreeIndex_13(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_13; /* delete */
extern OBJ _ABSTreeIndex_14(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_14; /* repl,2 */
OBJ __ABSTreeIndex_15; /* repl,2'15 */
extern OBJ _ABSTreeIndex_16(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_16; /* upd'16 */
OBJ __ABSTreeIndex_17; /* upd'17 */
extern OBJ _ABSTreeIndex_18(OBJ,OBJ,OBJ);OBJ __ABSTreeIndex_18; /* upd,1'18 */
extern OBJ _ABSTreeIndex_19(OBJ,OBJ);OBJ __ABSTreeIndex_19; /* repl'19 */
extern OBJ _ABSTreeIndex_20(OBJ,OBJ);OBJ __ABSTreeIndex_20; /* insert'20 */
OBJ __ABSTreeIndex_21; /* insert'21 */
extern OBJ _ABSTreeIndex_22(OBJ);OBJ __ABSTreeIndex_22; /* delete'22 */

extern TUP2 _ABSTreeIndex_3(OBJ x1,OBJ x2,OBJ x3) /* step */
{TUP2 r;
 FRCLS(x1,1);
 if(ISPRM(x2)){
  HLT("step\'BSTreeIndex: cannot step from empty tree");
 }else{
  {OBJ x33=FLD1(x2,2);OBJ x34=FLD1(x2,3);
   COPY(x33,1);COPY(x34,1);
   {OBJ x35;
    ANat_6(x3,x35);
    if(ISTGPRM(x35,1)){
     FREE(x33,1);
     FREE(x34,1);
     r.c1=x2;r.c2=__ANat_5;
    }else{
     if(EXPRD(x2,1)){
      DSPRD(x2);
     }else{
      DCPRD(x2,1);}
     {OBJ x37;
      x37=_AIndexingOfTrees_6(x3);
      if(ISTGPRM(x37,1)){
       r.c1=x33;
       FREE(x34,1);
       r.c2=_AIndexingOfTrees_8(x3);
      }else{
       FREE(x33,1);
       {OBJ x39;
	x39=_AIndexingOfTrees_7(x3);
	if(ISTGPRM(x39,1)){
	 r.c1=x34;
	 r.c2=_AIndexingOfTrees_9(x3);
	}else{
	 HLT("BSTreeIndex at <28,8-30,33> : missing else in step\'BSTreeIndex:bstree**nat->bstree**nat");}}}}}}}}
 return r;}
extern OBJ _ABSTreeIndex_3_c(OBJ x1,OBJ x2,OBJ x3) /* step */
{OBJ r;
 {TUP2 t=_ABSTreeIndex_3(x1,x2,x3);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

extern OBJ _ABSTreeIndex_4(OBJ x1,OBJ x2,OBJ x3) /* ! */
{OBJ r;
 CPCLS(x1,1);
 {OBJ x4;OBJ x6;
  x4=_ABSTreeIndex_9(x1,x2,x3);
  if(ISPRM(x4)){
   HLT("!\'BSTreeIndex: index does not exist");
  }else{
   {OBJ x5=FLD1(x4,1);
    if(EXPRD(x4,1)){
     x6=x5;
     DSPRDF(x4);
    }else{
     COPY(x5,1);
     x6=x5;
     FRPRD(x4,1);}}}
  r=_ABSTree_6(x1,x6);}
 return r;}

extern OBJ _ABSTreeIndex_5(OBJ x1,OBJ x2,OBJ x3) /* !? */
{OBJ r;
 CPCLS(__ABSTree_6,1);
 CPCLS(x1,1);
 {OBJ x4;OBJ x5;
  x4=(*(OBJ(*)(OBJ,OBJ))METHOD(__ABSTree_6,1))(__ABSTree_6,x1);
  x5=_ABSTreeIndex_9(x1,x2,x3);
  r=_AOptionMap_3(x4,x5);}
 return r;}

extern OBJ _ABSTreeIndex_6(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* upd */
{OBJ r;
 CPCLS(__ABSTreeIndex_16,1);
 CPPRD(__ABSTreeIndex_17,1);
 CPCLS(x1,1);
 {OBJ x5;
  x5=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ABSTreeIndex_16,2))(__ABSTreeIndex_16,x1,x3);
  r=_ABSTreeIndex_14(x1,__ABSTreeIndex_17,x4,x2,x5);}
 return r;}

extern OBJ _ABSTreeIndex_7(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* upd,1 */
{OBJ r;
 CPPRD(__ABSTreeIndex_17,1);
 CPCLS(__ABSTreeIndex_18,1);
 CPCLS(x1,1);
 {OBJ x5;
  x5=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ABSTreeIndex_18,2))(__ABSTreeIndex_18,x1,x3);
  r=_ABSTreeIndex_14(x1,__ABSTreeIndex_17,x4,x2,x5);}
 return r;}

extern OBJ _ABSTreeIndex_8(OBJ x1,OBJ x2,OBJ x3) /* !,1 */
{OBJ r;
 {OBJ x4;
  x4=_ABSTreeIndex_9(x1,x2,x3);
  if(ISPRM(x4)){
   HLT("!\'BSTreeIndex: index does not exist");
  }else{
   {OBJ x8=FLD1(x4,1);
    if(EXPRD(x4,1)){
     r=x8;
     DSPRDF(x4);
    }else{
     COPY(x8,1);
     r=x8;
     FRPRD(x4,1);}}}}
 return r;}

extern OBJ _ABSTreeIndex_9(OBJ x1,OBJ x2,OBJ x3) /* !?,1 */
{OBJ r;
 CPCLS(__ABSTree_44,1);
 {OBJ x4;OBJ x5;
  x4=(*(OBJ(*)(OBJ,OBJ))METHOD(__ABSTree_44,1))(__ABSTree_44,x1);
  x5=_ATreeIndex_8(x2,x3);
  r=_AOptionMap_3(x4,x5);}
 return r;}

extern OBJ _ABSTreeIndex_10(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* repl */
{OBJ r;
 CPCLS(__ABSTreeIndex_19,1);
 CPPRD(__ATreeIndex_30,1);
 {OBJ x5;
  x5=(*(OBJ(*)(OBJ,OBJ))METHOD(__ABSTreeIndex_19,1))(__ABSTreeIndex_19,x4);
  r=_ABSTreeIndex_14(x1,__ATreeIndex_30,x2,x3,x5);}
 return r;}

extern OBJ _ABSTreeIndex_11(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* repl,1 */
{OBJ r;
 CPPRD(__ATreeIndex_30,1);
 r=_ABSTreeIndex_14(x1,__ATreeIndex_30,x2,x3,x4);
 return r;}

extern OBJ _ABSTreeIndex_12(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* insert */
{OBJ r;
 CPCLS(__ABSTreeIndex_20,1);
 CPPRD(__ABSTreeIndex_21,1);
 {OBJ x5;
  x5=(*(OBJ(*)(OBJ,OBJ))METHOD(__ABSTreeIndex_20,1))(__ABSTreeIndex_20,x4);
  r=_ABSTreeIndex_14(x1,__ABSTreeIndex_21,x2,x3,x5);}
 return r;}

extern OBJ _ABSTreeIndex_13(OBJ x1,OBJ x2,OBJ x3) /* delete */
{OBJ r;
 CPCLS(__ABSTreeIndex_22,1);
 CPPRD(__ATreeIndex_34,1);
 r=_ABSTreeIndex_14(x1,__ATreeIndex_34,x2,x3,__ABSTreeIndex_22);
 return r;}

extern OBJ _ABSTreeIndex_14(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* repl,2 */
{OBJ r;
 if(ISPRM(x3)){
  FRCLS(x1,1);
  {OBJ x39;
   ANat_6(x4,x39);
   if(ISTGPRM(x39,1)){
    FRPRD(x2,1);
    r=(*(OBJ(*)(OBJ,OBJ))METHOD(x5,1))(x5,__ATree_7);
   }else{
    FRCLS(x5,1);
    CPPRD(__ABSTreeIndex_15,1);
    {OBJ x40;
     ADenotation_4(x2,__ABSTreeIndex_15,x40);
     ABUILTIN_12(x40,r);}}}
 }else{
  {OBJ x42=FLD1(x3,2);OBJ x43=FLD1(x3,3);
   COPY(x42,1);COPY(x43,1);
   CPCLS(x1,1);
   CPPRD(x3,1);
   {OBJ x44;OBJ x45;
    x44=_ABSTree_6(x1,x3);
    ANat_6(x4,x45);
    if(ISTGPRM(x45,1)){
     FRCLS(x1,1);
     FRPRD(x2,1);
     FREE(x42,1);
     FREE(x43,1);
     FREE(x44,1);
     r=(*(OBJ(*)(OBJ,OBJ))METHOD(x5,1))(x5,x3);
    }else{
     if(EXPRD(x3,1)){
      DSPRD(x3);
     }else{
      DCPRD(x3,1);}
     {OBJ x47;
      x47=_AIndexingOfTrees_6(x4);
      if(ISTGPRM(x47,1)){
       CPCLS(x1,1);
       {OBJ x48;OBJ x49;
	x48=_AIndexingOfTrees_8(x4);
	x49=_ABSTreeIndex_14(x1,x2,x42,x48,x5);
	r=_ABSTree_2(x1,x44,x49,x43);}
      }else{
       {OBJ x50;
	x50=_AIndexingOfTrees_7(x4);
	if(ISTGPRM(x50,1)){
	 CPCLS(x1,1);
	 {OBJ x51;OBJ x52;
	  x51=_AIndexingOfTrees_9(x4);
	  x52=_ABSTreeIndex_14(x1,x2,x43,x51,x5);
	  r=_ABSTree_2(x1,x44,x42,x52);}
	}else{
	 HLT("BSTreeIndex at <92,8-94,37> : missing else in repl\'BSTreeIndex:denotation**bstree**nat**(bstree->bstree)->bstree");}}}}}}}}
 return r;}

extern OBJ _ABSTreeIndex_16(OBJ x1,OBJ x2,OBJ x3) /* upd'16 */
{OBJ r;
 if(ISPRM(x3)){
  HLT("upd\'BSTreeIndex: cannot update empty tree");
 }else{
  r=_ABSTree_23(x1,x3,x2);}
 return r;}

extern OBJ _ABSTreeIndex_18(OBJ x1,OBJ x2,OBJ x3) /* upd,1'18 */
{OBJ r;
 if(ISPRM(x3)){
  HLT("upd\'BSTreeIndex: cannot update empty tree");
 }else{
  CPCLS(x1,1);
  CPPRD(x3,1);
  {OBJ x13;OBJ x14;
   x13=_ABSTree_6(x1,x3);
   x14=(*(OBJ(*)(OBJ,OBJ))METHOD(x2,1))(x2,x13);
   r=_ABSTree_23(x1,x3,x14);}}
 return r;}

extern OBJ _ABSTreeIndex_19(OBJ x1,OBJ x2) /* repl'19 */
{OBJ r;
 FREE(x2,1);
 r=x1;
 return r;}

extern OBJ _ABSTreeIndex_20(OBJ x1,OBJ x2) /* insert'20 */
{OBJ r;
 if(ISPRM(x2)){
  r=x1;
 }else{
  HLT("insert\'BSTreeIndex: must replace an empty tree");}
 return r;}

extern OBJ _ABSTreeIndex_22(OBJ x1) /* delete'22 */
{OBJ r;
 FREE(x1,1);
 r=__ATree_7;
 return r;}

init_ABSTreeIndex()
{
 static int visited=0; if(visited) return; visited=1;
 init_ABSTree();
 init_ANat();
 init_AOption();
 init_ASeq();
 init_ATree();
 init_APair();
 init_AOptionMap();
 init_ADenotation();
 init_ACompose();
 init_ATreeIndex();
 init_AIndexingOfTrees();
 init_AChar();
 init_ARelCmp();
 init_AInt();
 CLS(1,_ABSTreeIndex_22,__ABSTreeIndex_22);
 DEN("insert",__ABSTreeIndex_21);
 CLS(2,_ABSTreeIndex_20,__ABSTreeIndex_20);
 CLS(2,_ABSTreeIndex_19,__ABSTreeIndex_19);
 CLS(3,_ABSTreeIndex_18,__ABSTreeIndex_18);
 DEN("upd",__ABSTreeIndex_17);
 CLS(3,_ABSTreeIndex_16,__ABSTreeIndex_16);
 DEN("\'BSTreeIndex: index does not exist",__ABSTreeIndex_15);
 CLS(5,_ABSTreeIndex_14,__ABSTreeIndex_14);
 CLS(3,_ABSTreeIndex_13,__ABSTreeIndex_13);
 CLS(4,_ABSTreeIndex_12,__ABSTreeIndex_12);
 CLS(4,_ABSTreeIndex_11,__ABSTreeIndex_11);
 CLS(4,_ABSTreeIndex_10,__ABSTreeIndex_10);
 CLS(3,_ABSTreeIndex_9,__ABSTreeIndex_9);
 CLS(3,_ABSTreeIndex_8,__ABSTreeIndex_8);
 CLS(4,_ABSTreeIndex_7,__ABSTreeIndex_7);
 CLS(4,_ABSTreeIndex_6,__ABSTreeIndex_6);
 CLS(3,_ABSTreeIndex_5,__ABSTreeIndex_5);
 CLS(3,_ABSTreeIndex_4,__ABSTreeIndex_4);
 CLS(3,_ABSTreeIndex_3_c,__ABSTreeIndex_3);}

