

#include "BUILTIN.h"
extern OBJ __ASeq_6;

#include "Nat.h"
extern OBJ _ASeqZip_4(OBJ,OBJ,OBJ);OBJ __ASeqZip_4; /* zip */
extern TUP2 _ASeqZip_5(OBJ,OBJ);OBJ __ASeqZip_5; /* unzip */

extern OBJ _ASeqZip_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=__ASeq_6;
   }else{
    HLT("zip\'SeqZip: second sequence longer than first");}
  }else{
   {OBJ x69=FLD1(x2,1);OBJ x70=FLD1(x2,2);
    if(EXPRD(x2,1)){
     DSPRDF(x2);
    }else{
     COPY(x69,1);COPY(x70,1);
     FRPRD(x2,1);}
    if(ISPRM(x3)){
     HLT("zip\'SeqZip: first sequence longer than second");
    }else{
     {OBJ x71=FLD1(x3,1);OBJ x72=FLD1(x3,2);
      if(EXPRD(x3,1)){
       CPCLS(x1,1);
       {OBJ x76;
	x76=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x1,2))(x1,x69,x71);
	RSOME(x3,*p1);FLD1(*p1,1)=x76;
	x2=x70;x3=x72;p1=&FLD1(*p1,2);continue;}
      }else{
       COPY(x71,1);COPY(x72,1);
       CPCLS(x1,1);
       {OBJ x76;
	x76=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x1,2))(x1,x69,x71);
	FRPRD(x3,1);PRD1(2,*p1);FLD1(*p1,1)=x76;
	x2=x70;x3=x72;p1=&FLD1(*p1,2);continue;}}}}}}
  break;}
 return r;}

extern TUP2 _ASeqZip_5(OBJ x1,OBJ x2) /* unzip */
{TUP2 r;
 if(ISPRM(x2)){
  FRCLS(x1,1);
  r.c1=__ASeq_6;r.c2=__ASeq_6;
 }else{
  {OBJ x28=FLD1(x2,1);OBJ x29=FLD1(x2,2);FLAG x_x2=EXPRD(x2,1);
   if(x_x2){
   }else{
    COPY(x28,1);COPY(x29,1);}
   CPCLS(x1,1);
   {TUP2 x33;OBJ x35;OBJ x36;
    x33=_ASeqZip_5(x1,x29);
    {OBJ t=(*(OBJ(*)(OBJ,OBJ))METHOD(x1,1))(x1,x28);
     x35=FLD1(t,1);
     x36=FLD1(t,2);
     DSPRDF(t);}
    if(x_x2){
     RSOME(x2,r.c2);FLD1(r.c2,1)=x36;FLD1(r.c2,2)=x33.c2;
    }else{
     FRPRD(x2,1);PRD1(2,r.c2);FLD1(r.c2,1)=x36;FLD1(r.c2,2)=x33.c2;}
    PRD1(2,r.c1);FLD1(r.c1,1)=x35;FLD1(r.c1,2)=x33.c1;}}}
 return r;}
extern OBJ _ASeqZip_5_c(OBJ x1,OBJ x2) /* unzip */
{OBJ r;
 {TUP2 t=_ASeqZip_5(x1,x2);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

static OBJ _mt_2_0_1(OBJ t,OBJ t1) 
{OBJ r;
 DPCLS(t,r);
 INCCLS(r,0,1);
 FLDCLS(r,1)=t1;
 return r;}

static OBJ _mt_2_1_1(OBJ t,OBJ t1) 
{OBJ r;
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  COPY(FLDCLS(t,1),1);
  DCCLS(t,1);}
 r=(*(OBJ(*)(OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),t1);
 return r;}
static OBJ _mt_2_1_1_l(OBJ t,OBJ t1) 
{OBJ r;
 r=(*(OBJ(*)(OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),t1);
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  DCCLS(t,1);
  FLDCLS(t,1)=NIL;
  COPY(r,1);LZYCLS(t,r);}
 return r;}

init_ASeqZip()
{
 static int visited=0; if(visited) return; visited=1;
 init_ASeq();
 init_ANat();
 init_AOption();
 CLS(2,_ASeqZip_5_c,__ASeqZip_5);
 CLS(3,_ASeqZip_4,__ASeqZip_4);
 MTH(2,0,1,_mt_2_0_1);LZYMTH(2,0,1,_mt_2_0_1);
 MTH(2,1,1,_mt_2_1_1);LZYMTH(2,1,1,_mt_2_1_1_l);}

