

#include "BUILTIN.h"

#include "Array.h"

#include "Nat.h"
extern OBJ _AArrayFilter_2(OBJ,OBJ);OBJ __AArrayFilter_2; /* | */
extern TUP2 _AArrayFilter_3(OBJ,OBJ);OBJ __AArrayFilter_3; /* partition */
extern OBJ _AArrayFilter_4(OBJ,OBJ);OBJ __AArrayFilter_4; /* take */
extern OBJ _AArrayFilter_5(OBJ,OBJ);OBJ __AArrayFilter_5; /* drop */
extern TUP2 _AArrayFilter_6(OBJ,OBJ);OBJ __AArrayFilter_6; /* split */
extern OBJ _AArrayFilter_7(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __AArrayFilter_7; /* copyP */
extern TUP2 _AArrayFilter_8(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __AArrayFilter_8; /* copyP,1 */
extern OBJ _AArrayFilter_9(OBJ,OBJ,OBJ);OBJ __AArrayFilter_9; /* take,1 */
extern OBJ _AArrayFilter_10(OBJ,OBJ,OBJ);OBJ __AArrayFilter_10; /* drop,1 */

extern OBJ _AArrayFilter_2(OBJ x1,OBJ x2) /* | */
{OBJ r;
 CPPRD(x2,1);
 {OBJ x3;
  AArray_17(x2,x3);
  if(ISTGPRM(x3,1)){
   FRCLS(x1,1);
   FRPRD(x2,1);
   CPPRD(__AArray_5,1);
   r=__AArray_5;
  }else{
   CPPRD(x2,2);
   {OBJ x4;OBJ x5;OBJ x6;
    AArray_16(x2,x4);
    AArray_15(x2,__ANat_5,x5);
    AArray_3(x4,x5,x6);
    r=_AArrayFilter_7(x1,x2,__ANat_5,x6,__ANat_5);}}}
 return r;}

extern TUP2 _AArrayFilter_3(OBJ x1,OBJ x2) /* partition */
{TUP2 r;
 CPPRD(x2,1);
 {OBJ x3;
  AArray_17(x2,x3);
  if(ISTGPRM(x3,1)){
   FRCLS(x1,1);
   FRPRD(x2,1);
   CPPRD(__AArray_5,2);
   r.c1=__AArray_5;r.c2=__AArray_5;
  }else{
   CPPRD(x2,2);
   {OBJ x4;OBJ x5;OBJ x6;
    AArray_16(x2,x4);
    AArray_15(x2,__ANat_5,x5);
    AArray_3(x4,x5,x6);
    CPPRD(x6,1);
    r=_AArrayFilter_8(x1,x2,__ANat_5,x6,__ANat_5,x6,__ANat_5);}}}
 return r;}
extern OBJ _AArrayFilter_3_c(OBJ x1,OBJ x2) /* partition */
{OBJ r;
 {TUP2 t=_AArrayFilter_3(x1,x2);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

extern OBJ _AArrayFilter_4(OBJ x1,OBJ x2) /* take */
{OBJ r;
 CPPRD(x2,1);
 {OBJ x3;
  AArray_17(x2,x3);
  if(ISTGPRM(x3,1)){
   FRCLS(x1,1);
   FRPRD(x2,1);
   CPPRD(__AArray_5,1);
   r=__AArray_5;
  }else{
   CPCLS(x1,1);
   CPPRD(x2,1);
   {OBJ x4;OBJ x5;
    AArray_15(x2,__ANat_5,x4);
    x5=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x4);
    if(ISTGPRM(x5,1)){
     r=_AArrayFilter_9(x1,x2,__ANat_8);
    }else{
     FRCLS(x1,1);
     FRPRD(x2,1);
     CPPRD(__AArray_5,1);
     r=__AArray_5;}}}}
 return r;}

extern OBJ _AArrayFilter_5(OBJ x1,OBJ x2) /* drop */
{OBJ r;
 CPPRD(x2,1);
 {OBJ x3;
  AArray_17(x2,x3);
  if(ISTGPRM(x3,1)){
   FRCLS(x1,1);
   FRPRD(x2,1);
   CPPRD(__AArray_5,1);
   r=__AArray_5;
  }else{
   r=_AArrayFilter_10(x1,x2,__ANat_5);}}
 return r;}

extern TUP2 _AArrayFilter_6(OBJ x1,OBJ x2) /* split */
{TUP2 r;
 CPCLS(x1,1);
 CPPRD(x2,1);
 r.c1=_AArrayFilter_4(x1,x2);
 r.c2=_AArrayFilter_5(x1,x2);
 return r;}
extern OBJ _AArrayFilter_6_c(OBJ x1,OBJ x2) /* split */
{OBJ r;
 {TUP2 t=_AArrayFilter_6(x1,x2);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

extern OBJ _AArrayFilter_7(register OBJ x1,register OBJ x2,register OBJ x3,register OBJ x4,register OBJ x5) /* copyP */
{OBJ r;
 for(;;){
  CPPRD(x2,1);
  {OBJ x6;OBJ x7;
   AArray_16(x2,x6);
   ANat_76(x3,x6,x7);
   if(ISTGPRM(x7,1)){
    FRCLS(x1,1);
    FRPRD(x2,1);
    AArray_11(x4,x5,x6,r);
   }else{
    CPCLS(x1,1);
    CPPRD(x2,1);
    {OBJ x8;OBJ x9;OBJ x10;OBJ x14;OBJ x15;
     AArray_15(x2,x3,x8);
     COPY(x8,1);
     ANat_2(x3,x9);
     x10=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x8);
     if(ISTGPRM(x10,1)){
      ANat_2(x5,x15);
      AArray_7(x5,x8,x4,x14);
     }else{
      FREE(x8,1);
      x14=x4;x15=x5;}
     x3=x9;x4=x14;x5=x15;continue;}}}
  break;}
 return r;}

extern TUP2 _AArrayFilter_8(register OBJ x1,register OBJ x2,register OBJ x3,register OBJ x4,register OBJ x5,register OBJ x6,register OBJ x7) /* copyP,1 */
{TUP2 r;
 for(;;){
  CPPRD(x2,1);
  {OBJ x8;OBJ x9;
   AArray_16(x2,x8);
   ANat_76(x3,x8,x9);
   if(ISTGPRM(x9,1)){
    FRCLS(x1,1);
    FRPRD(x2,1);
    CPPRD(x4,1);
    CPPRD(x6,1);
    {OBJ x10;OBJ x11;
     AArray_16(x4,x10);
     AArray_16(x6,x11);
     AArray_11(x4,x5,x10,r.c1);
     AArray_11(x6,x7,x11,r.c2);}
   }else{
    CPCLS(x1,1);
    CPPRD(x2,1);
    {OBJ x14;OBJ x15;OBJ x16;OBJ x22;OBJ x23;OBJ x24;OBJ x25;
     AArray_15(x2,x3,x14);
     COPY(x14,1);
     ANat_2(x3,x15);
     x16=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x14);
     if(ISTGPRM(x16,1)){
      ANat_2(x5,x23);
      AArray_7(x5,x14,x4,x22);
      x24=x6;x25=x7;
     }else{
      ANat_2(x7,x25);
      AArray_7(x7,x14,x6,x24);
      x22=x4;x23=x5;}
     x3=x15;x4=x22;x5=x23;x6=x24;x7=x25;continue;}}}
  break;}
 return r;}
extern OBJ _AArrayFilter_8_c(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6,OBJ x7) /* copyP,1 */
{OBJ r;
 {TUP2 t=_AArrayFilter_8(x1,x2,x3,x4,x5,x6,x7);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

extern OBJ _AArrayFilter_9(register OBJ x1,register OBJ x2,register OBJ x3) /* take,1 */
{OBJ r;
 for(;;){
  CPPRD(x2,1);
  {OBJ x4;OBJ x5;
   AArray_16(x2,x4);
   ANat_76(x3,x4,x5);
   if(ISTGPRM(x5,1)){
    FRCLS(x1,1);
    r=x2;
   }else{
    CPCLS(x1,1);
    CPPRD(x2,1);
    {OBJ x6;OBJ x7;
     AArray_15(x2,x3,x6);
     x7=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x6);
     if(ISTGPRM(x7,1)){
      {OBJ x8;
       ANat_2(x3,x8);
       x3=x8;continue;}
     }else{
      FRCLS(x1,1);
      AArray_11(x2,x3,x4,r);}}}}
  break;}
 return r;}

extern OBJ _AArrayFilter_10(register OBJ x1,register OBJ x2,register OBJ x3) /* drop,1 */
{OBJ r;
 for(;;){
  CPPRD(x2,1);
  {OBJ x4;OBJ x5;
   AArray_16(x2,x4);
   ANat_76(x3,x4,x5);
   if(ISTGPRM(x5,1)){
    FRCLS(x1,1);
    FRPRD(x2,1);
    CPPRD(__AArray_5,1);
    r=__AArray_5;
   }else{
    CPCLS(x1,1);
    CPPRD(x2,1);
    {OBJ x6;OBJ x7;
     AArray_15(x2,x3,x6);
     x7=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x6);
     if(ISTGPRM(x7,1)){
      {OBJ x8;
       ANat_2(x3,x8);
       x3=x8;continue;}
     }else{
      FRCLS(x1,1);
      {OBJ x9;
       ANat_81(x3,__ANat_5,x9);
       if(ISTGPRM(x9,1)){
	{OBJ x10;
	 ANat_4(x3,x10);
	 AArray_11(x2,__ANat_5,x10,r);}
       }else{
	r=x2;}}}}}}
  break;}
 return r;}

static OBJ _mt_5_0_5(OBJ t,OBJ t1,OBJ t2,OBJ t3,OBJ t4,OBJ t5) 
{OBJ r;
 DCCLS(t,1);
 r=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ,OBJ))ENTRY(t))(t1,t2,t3,t4,t5);
 return r;}

static OBJ _mt_7_0_7(OBJ t,OBJ t1,OBJ t2,OBJ t3,OBJ t4,OBJ t5,OBJ t6,OBJ t7) 
{OBJ r;
 DCCLS(t,1);
 r=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ))ENTRY(t))(t1,t2,t3,t4,t5,t6,t7);
 return r;}

init_AArrayFilter()
{
 static int visited=0; if(visited) return; visited=1;
 init_AArray();
 init_ANat();
 CLS(3,_AArrayFilter_10,__AArrayFilter_10);
 CLS(3,_AArrayFilter_9,__AArrayFilter_9);
 CLS(7,_AArrayFilter_8_c,__AArrayFilter_8);
 CLS(5,_AArrayFilter_7,__AArrayFilter_7);
 CLS(2,_AArrayFilter_6_c,__AArrayFilter_6);
 CLS(2,_AArrayFilter_5,__AArrayFilter_5);
 CLS(2,_AArrayFilter_4,__AArrayFilter_4);
 CLS(2,_AArrayFilter_3_c,__AArrayFilter_3);
 CLS(2,_AArrayFilter_2,__AArrayFilter_2);
 MTH(5,0,5,_mt_5_0_5);LZYMTH(5,0,5,_mt_5_0_5);
 MTH(7,0,7,_mt_7_0_7);LZYMTH(7,0,7,_mt_7_0_7);}

