

#include "BUILTIN.h"
extern OBJ _AMapByOS_32(OBJ,OBJ,OBJ,OBJ);extern OBJ __AMapByOS_32;

#include "Nat.h"
extern OBJ __ASeq_6;
extern OBJ _ASeq_52(OBJ,OBJ);extern OBJ __ASeq_52;
extern OBJ _AMapByOSReduce_6(OBJ,OBJ,OBJ,OBJ);extern OBJ __AMapByOSReduce_6;
extern OBJ _AMapByOSInvert_5(OBJ,OBJ,OBJ);OBJ __AMapByOSInvert_5; /* invert */
extern OBJ _AMapByOSInvert_6(OBJ,OBJ,OBJ,OBJ);OBJ __AMapByOSInvert_6; /* invert'6 */

extern OBJ _AMapByOSInvert_5(OBJ x1,OBJ x2,OBJ x3) /* invert */
{OBJ r;
 CPCLS(__AMapByOSInvert_6,1);
 COPY(x3,1);
 {OBJ x4;OBJ x5;OBJ x6;OBJ x7;OBJ x8;
  x4=_ASeq_52(x3,__ANat_5);
  x5=(*(OBJ(*)(OBJ,OBJ))METHOD(__AMapByOSInvert_6,1))(__AMapByOSInvert_6,x2);
  x6=_AMapByOSReduce_6(x1,x5,__ASeq_6,x3);
  COPY(x6,1);
  x7=_ASeq_52(x6,__ANat_5);
  ANat_76(x4,x7,x8);
  if(ISTGPRM(x8,1)){
   r=x6;
  }else{
   HLT("invert\'MapByOSInvert: mapping not injective");}}
 return r;}

extern OBJ _AMapByOSInvert_6(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* invert'6 */
{OBJ r;
 r=_AMapByOS_32(x1,x3,x2,x4);
 return r;}

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

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

init_AMapByOSInvert()
{
 static int visited=0; if(visited) return; visited=1;
 init_AMapByOS();
 init_ANat();
 init_AOption();
 init_ASet();
 init_ASeq();
 init_APair();
 init_AMapByOSReduce();
 init_ASeqMap();
 CLS(4,_AMapByOSInvert_6,__AMapByOSInvert_6);
 CLS(3,_AMapByOSInvert_5,__AMapByOSInvert_5);
 MTH(3,0,2,_mt_3_0_2);LZYMTH(3,0,2,_mt_3_0_2);
 MTH(3,2,1,_mt_3_2_1);LZYMTH(3,2,1,_mt_3_2_1_l);}

