

#include "BUILTIN.h"
extern OBJ __ATree_7;

#include "Nat.h"
extern OBJ _ATreeZip_4(OBJ,OBJ,OBJ);OBJ __ATreeZip_4; /* zip */
extern TUP2 _ATreeZip_5(OBJ,OBJ);OBJ __ATreeZip_5; /* unzip */

extern OBJ _ATreeZip_4(register OBJ x1,register OBJ x2,register OBJ x3) /* zip */
{OBJ r;OBJ* p1=&r;
 for(;;){
  if(ISPRM(x2)){
   FRCLS(x1,1);
   if(ISPRM(x3)){
    *p1=__ATree_7;
   }else{
    HLT("zip\'TreeZip: second tree bigger than first");}
  }else{
   {OBJ x102=FLD1(x2,1);OBJ x103=FLD1(x2,2);OBJ x104=FLD1(x2,3);
    if(EXPRD(x2,1)){
     DSPRDF(x2);
    }else{
     COPY(x102,1);COPY(x103,1);COPY(x104,1);
     FRPRD(x2,1);}
    if(ISPRM(x3)){
     HLT("zip\'TreeZip: first tree bigger than second");
    }else{
     {OBJ x105=FLD1(x3,1);OBJ x106=FLD1(x3,2);OBJ x107=FLD1(x3,3);
      if(EXPRD(x3,1)){
       CPCLS(x1,2);
       {OBJ x112;OBJ x111;
	x112=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x1,2))(x1,x102,x105);
	x111=_ATreeZip_4(x1,x103,x106);
	RSOME(x3,*p1);FLD1(*p1,1)=x112;FLD1(*p1,2)=x111;
	x2=x104;x3=x107;p1=&FLD1(*p1,3);continue;}
      }else{
       COPY(x105,1);COPY(x106,1);COPY(x107,1);
       CPCLS(x1,2);
       {OBJ x112;OBJ x111;
	x112=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x1,2))(x1,x102,x105);
	x111=_ATreeZip_4(x1,x103,x106);
	FRPRD(x3,1);PRD1(3,*p1);FLD1(*p1,1)=x112;FLD1(*p1,2)=x111;
	x2=x104;x3=x107;p1=&FLD1(*p1,3);continue;}}}}}}
  break;}
 return r;}

extern TUP2 _ATreeZip_5(OBJ x1,OBJ x2) /* unzip */
{TUP2 r;
 if(ISPRM(x2)){
  FRCLS(x1,1);
  r.c1=__ATree_7;r.c2=__ATree_7;
 }else{
  {OBJ x41=FLD1(x2,1);OBJ x42=FLD1(x2,2);OBJ x43=FLD1(x2,3);FLAG x_x2=EXPRD(x2,1);
   if(x_x2){
   }else{
    COPY(x41,1);COPY(x42,1);COPY(x43,1);}
   CPCLS(x1,2);
   {TUP2 x47;TUP2 x50;OBJ x52;OBJ x53;
    x47=_ATreeZip_5(x1,x43);
    x50=_ATreeZip_5(x1,x42);
    {OBJ t=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x41);
     x52=FLD1(t,1);
     x53=FLD1(t,2);
     DSPRDF(t);}
    if(x_x2){
     RSOME(x2,r.c2);FLD1(r.c2,1)=x53;FLD1(r.c2,2)=x50.c2;FLD1(r.c2,3)=x47.c2;
    }else{
     FRPRD(x2,1);PRD1(3,r.c2);FLD1(r.c2,1)=x53;FLD1(r.c2,2)=x50.c2;FLD1(r.c2,3)=x47.c2;}
    PRD1(3,r.c1);FLD1(r.c1,1)=x52;FLD1(r.c1,2)=x50.c1;FLD1(r.c1,3)=x47.c1;}}}
 return r;}
extern OBJ _ATreeZip_5_c(OBJ x1,OBJ x2) /* unzip */
{OBJ r;
 {TUP2 t=_ATreeZip_5(x1,x2);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

init_ATreeZip()
{
 static int visited=0; if(visited) return; visited=1;
 init_ATree();
 init_ANat();
 init_AOption();
 init_ASeq();
 init_ARelCmp();
 CLS(2,_ATreeZip_5_c,__ATreeZip_5);
 CLS(3,_ATreeZip_4,__ATreeZip_4);}

