//	This source and compression method apply to GNU General Public License. 
//		Copyright (C) August , 2010 and later by Jasenko Dzinleski 

//		This program is free software; you can redistribute it
//	and/or modify it under the terms of the GNU General Public License as
//	published by the Free Software Foundation; either version 2 of the
//	License, or (at your option) any later version. 

//	This program is distributed in the hope that it will be useful, but
//	WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//	General Public License for more details. 

//	You should have received a copy of the GNU General Public License along
//	with this program; if not, write to the Free Software Foundation, Inc.,
//	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

//
//			
//			written by Dzinleski Jasenko August , 15 , 2010
//			
//
//			to Dusica and Dzinleski Borce
//
//



#include 	<stdio.h>
#include 	<string.h>
#include 	<math.h>

#define		BuffL				64 	//(128)
#define		BtM				8*256
#define		TBEnd				8

int		b12=((0xffff>>4 )<<4 );
int		b11=((0xffff>>5 )<<5 );
int		b10=((0xffff>>6 )<<6 );
int		b09=((0xffff>>7 )<<7 );
int		b08=((0xffff>>8 )<<8 );
int		b07=((0xffff>>9 )<<9 );
int		b06=((0xffff>>10)<<10);
int		b05=((0xffff>>11)<<11);
int		b04=((0xffff>>12)<<12);

char 		infn[256]="CL2001011101AA.CEL";
char		outfn[256]="t_.txt";
char		outxfn[256]="xd.txt";

char		out1fn[256]="1_.mar";
char		out2fn[256]="2_.mar";
char		out3fn[256]="3_.mar";
char		out4fn[256]="4_.mar";

FILE		*f1,*f2,*f3,*f4,*f5,*f6;

int 		ba16[16][16][16][16][3];		int	ba16i=0;

__int64 	fc=0;
int 		bl08[16][256];				int	bl08i=0;

int		mm[16][3];				
int		md[16][30000][2];			
int		mdi[16];

int		ddf[70000][2];				int	ddfi=0;
int		dd[70000][4];				int	ddi=0;
int		ca[BuffL];				int 	cai=0;
bool		br[BtM];				int	bri=0;
bool		bt32_1[32];				int	bt32i_1=0;
bool		bt32_2[32];				int	bt32i_2=0;

__int64	bitc=0,bc=0,fb=0;
int		bytc=0,bytc1=0;

bool		df=false;
bool		nf=false;
bool		o_f=false;

char		c_l[256]="{[--]}{[hh][ee][cc][dd]}{[AZ][az][09][__][  ][..]}";

double 		mult_=1;
char		n_s[256];
char		p_s[256];

int p_format(double in_n,char fm[256],char arr0[256])
{

int		sig;
char		arr1[256];
double 		iv,fv;
__int64	lv,rv;
char		fa[256];int	fai=0;
int		i,j,k,l,m,n,e;


	if(in_n<0){sig=1;in_n*=-1.0;iv=in_n;}else{sig=0;iv=in_n;}

	for(i=0;i<256;++i){fa[i]='\0';}fai=0;
	for(j=0;j<256;++j){arr0[j]='\0';}

	for(i=1;i<12;++i)
	{
		lv=(long)iv/pow(10,i);//printf("%d %d %d\n",lv,i,(long)pow(10,i));
		if(lv==0){e=i-1;break;}
	}
	if(i==12){printf("Overflow...\n");arr0[0]='0';return(0);}

	if(e-1<0)
	{
		rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
		fa[fai]=(char)(48+rv);++fai;

	}else{

	rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
	fa[fai]=(char)(48+rv);++fai;
	rv*=pow(10,e);fv=(long)iv-rv;
	for(i=e-1;i>=0;--i)
	{
		lv=(long)fv/pow(10,i);//printf("!%c",(char)(48+lv));
		fa[fai]=(char)(48+lv);++fai;
		rv+=lv*pow(10,i);fv=iv;fv-=rv;
	}

	}

	//printf("%s\n",fa);

	if(strlen(fm)!=0)
	{

		m=0;l=strlen(fm);
		for(i=strlen(fm)-1;i>=0;--i)
		{if(fm[i]==','||fm[i]=='.'){if(l==strlen(fm)){l=i+1;++m;}else{++m;}}}
		k=(strlen(fm)-((strlen(fm)-l)+m))-strlen(fa);

		if(k>=0)
		{

			j=0;for(i=0;i<k;++i)
			{if(fm[i]=='.'||fm[i]==','){++k;}arr0[j]=fm[i];++j;}n=i;

			for(i=0;i<strlen(fa);++i)
			{
				if(fm[i+n]=='.'||fm[i+n]==','){arr0[j]=fm[i+n];++j;++n;}
				arr0[j]=fa[i];++j;
			}
				
			if(l!=strlen(fm))
			{
				--l;arr0[j]=fm[l];++j;
				for(i=l+1;i<strlen(fm);++i){arr0[j]=fm[i];++j;}

				iv=in_n;
				for(i=0;i<256;++i){fa[i]='\0';}fai=0;

				iv=pow(10,(strlen(fm)-(l+1)))*(iv-(double)((long)iv));

				for(i=1;i<12;++i)
				{
					lv=(long)iv/pow(10,i);//printf("%d %d %d\n",lv,i,(long)pow(10,i));
					if(lv==0){e=i-1;break;}
				}
				if(i==12){printf("Overflow...\n");arr0[0]='0';return(0);}

				if(e-1<0)
				{
					rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
					fa[fai]=(char)(48+rv);++fai;

				}else{

				rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
				fa[fai]=(char)(48+rv);++fai;
				rv*=pow(10,e);fv=(long)iv-rv;
				for(i=e-1;i>=0;--i)
				{
					lv=(long)fv/pow(10,i);//printf("!%c",(char)(48+lv));
					fa[fai]=(char)(48+lv);++fai;
					rv+=lv*pow(10,i);fv=iv;fv-=rv;
				}

				}

				//printf("s\n",fa);

				if((strlen(fm)-(l+1))==strlen(fa))
				{

				for(i=strlen(arr0)-1;i>=0;--i)
				{if(arr0[i]=='.'||arr0[i]==','){j=i;break;}}++j;
				for(i=0;i<strlen(fa);++i){arr0[j]=fa[i];++j;}

				}else{

					k=(strlen(fm)-(l+1))-strlen(fa);
					for(i=strlen(arr0)-1;i>=0;--i)
					{if(arr0[i]=='.'||arr0[i]==','){j=i;break;}}++j;
					for(i=0;i<k;++i){arr0[j]='0';++j;}
					for(i=0;i<strlen(fa);++i){arr0[j]=fa[i];++j;}

				}

			}

		}else{

			k=strlen(fa)-(strlen(fm)-((strlen(fm)-l)+m));
			j=0;for(i=0;i<k;++i){arr0[j]=fa[i];++j;}n=i;
			
			for(i=n;i<strlen(fa);++i)
			{
				if(fm[i-n]=='.'||fm[i-n]==','){arr0[j]=fm[i-n];++j;--n;}
				arr0[j]=fa[i];++j;
			}

			if(l!=strlen(fm))
			{
				--l;arr0[j]=fm[l];++j;
				for(i=l+1;i<strlen(fm);++i){arr0[j]=fm[i];++j;}

				iv=in_n;
				for(i=0;i<256;++i){fa[i]='\0';}fai=0;

				iv=pow(10,(strlen(fm)-(l+1)))*(iv-(double)((long)iv));

				for(i=1;i<12;++i)
				{
					lv=(long)iv/pow(10,i);//printf("%d %d %d\n",lv,i,(long)pow(10,i));
					if(lv==0){e=i-1;break;}
				}
				if(i==12){printf("Overflow...\n");arr0[0]='0';return(0);}

				if(e-1<0)
				{
					rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
					fa[fai]=(char)(48+rv);++fai;

				}else{

				rv=(long)iv/pow(10,e);//printf("!%c",(char)(48+rv));
				fa[fai]=(char)(48+rv);++fai;
				rv*=pow(10,e);fv=(long)iv-rv;
				for(i=e-1;i>=0;--i)
				{
					lv=(long)fv/pow(10,i);//printf("!%c",(char)(48+lv));
					fa[fai]=(char)(48+lv);++fai;
					rv+=lv*pow(10,i);fv=iv;fv-=rv;
				}

				}

				//printf("s\n",fa);

				if((strlen(fm)-(l+1))==strlen(fa))
				{

				for(i=strlen(arr0)-1;i>=0;--i)
				{if(arr0[i]=='.'||arr0[i]==','){j=i;break;}}++j;
				for(i=0;i<strlen(fa);++i){arr0[j]=fa[i];++j;}

				}else{

					k=(strlen(fm)-(l+1))-strlen(fa);
					for(i=strlen(arr0)-1;i>=0;--i)
					{if(arr0[i]=='.'||arr0[i]==','){j=i;break;}}++j;
					for(i=0;i<k;++i){arr0[j]='0';++j;}
					for(i=0;i<strlen(fa);++i){arr0[j]=fa[i];++j;}

				}
				
			}

		}

	}else{

		j=0;for(i=0;i<strlen(fa);++i){arr0[j]=fa[i];++j;}

	}

	for(i=0;i<strlen(arr0);++i){if(arr0[i]=='#'){arr0[i]=' ';}}
	for(i=0;i<strlen(arr0)-1;++i){if((arr0[i]==' ')&&(arr0[i+1]==','||arr0[i+1]=='.')){arr0[i+1]=' ';}}

	if(sig==1)
	{
		for(i=0;i<256;++i){arr1[i]='\0';}
		j=0;arr1[j]='-';++j;
		for(i=0;i<strlen(arr0);++i){arr1[j]=arr0[i];++j;}
		for(i=0;i<256;++i){arr0[i]='\0';}
		j=0;for(i=0;i<strlen(arr1);++i){arr0[j]=arr1[i];++j;}
	}

	//printf("%s\n",arr0);



	return(0);
}

double p_val(char arr0[256])
{

	int	j=0,k=0,l;

	long		fr;
	int		rvi;
	long		rvl;
	__int64	rvd;
	double		rvd_;

	char 		arr1[256];

	for(j=0;j<256;++j){arr1[j]='\0';}
	l=0;for(j=0;j<strlen(arr0);++j){if((arr0[j]>='0'&&arr0[j]<='9')||(arr0[j]=='.'||arr0[j]==',')){arr1[l]=arr0[j];++l;}}

	for(j=0;j<256;++j){arr0[j]='\0';}l=0;for(j=0;j<strlen(arr1);++j){arr0[l]=arr1[j];++l;}

	for(j=0;j<strlen(arr0);++j){if(arr0[j]=='.'){break;}}

	if(j==strlen(arr0))
	{
		rvl=0;l=-1;
		for(j=-1+strlen(arr0);j>=0;--j)
		{
			++l;rvl+=(long)(-48+arr0[j])*pow(10,l);
		}
		rvi=(int)rvl;
		rvd_=(double)rvl;

	}else{

			fr=0;l=-1;
			for(k=-1+strlen(arr0);k>j;--k)
			{
				++l;fr+=(long)(-48+arr0[k])*pow(10,l);
			}

			rvd=0;l=-1;
			for(k=j-1;k>=0;--k)
			{
				++l;rvd+=(__int64)(-48+arr0[k])*pow(10,l);

			}rvd*=(__int64)pow(10,strlen(arr0)-j-1);

			rvd_=(double)(rvd+(__int64)fr)/(__int64)pow(10,strlen(arr0)-j-1);
				
	}

	return(rvd_);
}

void pr32_(long d,bool b_[32],int b_i)
{

	b_i=0;
	if((((((d&0xff000000)>>24)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0xff000000)>>24)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}

	if((((((d&0x00ff0000)>>16)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x00ff0000)>>16)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}

	if((((((d&0x0000ff00)>>8)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if((((((d&0x0000ff00)>>8)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}

	if(((((d&0x000000ff)<<24)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<25)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<26)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<27)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<28)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<29)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<30)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}
	if(((((d&0x000000ff)<<31)>>31)&0x1)==1){b_[b_i]=true;++b_i;}else{b_[b_i]=false;++b_i;}

}

int p_1(int ns)
{

	char		fld[100][256];
	int		fi=0;
	int		fl[100];

	int		fbyte;
	int		ai;

	int		i,j,k,l,m,n,p,q;
	int		a,b,c,d;

	int		b8o,b8e,b16o,b16e;
	int		nH,nL;
	int		mx,mxi;

	b8o=0;
	b8o|=1<<0;
	b8o|=1<<2;
	b8o|=1<<4;
	b8o|=1<<6;

	b8e=0;
	b8e|=1<<1;
	b8e|=1<<3;
	b8e|=1<<5;
	b8e|=1<<7;

	b16o=0;
	b16o|=1<<0;
	b16o|=1<<2;
	b16o|=1<<4;
	b16o|=1<<6;
	b16o|=1<<8;
	b16o|=1<<10;
	b16o|=1<<12;
	b16o|=1<<14;

	b16e=0;
	b16e|=1<<1;
	b16e|=1<<3;
	b16e|=1<<5;
	b16e|=1<<7;
	b16e|=1<<9;
	b16e|=1<<11;
	b16e|=1<<13;
	b16e|=1<<15;

	for(i=0;i<16;++i){for(j=0;j<16;++j){for(k=0;k<16;++k){for(l=0;l<16;++l){
		ba16[i][j][k][l][0]=-1;ba16[i][j][k][l][1]=0;ba16[i][j][k][l][2]=0;
	}}}}

	f1=fopen(infn,"rb");
	while(!feof(f1))
	{
		fi=0;for(i=0;i<100;++i){fl[i]=0;for(j=0;j<256;++j){fld[i][j]='\0';}}
		while(!feof(f1)&&fbyte!=13&&fbyte!=10){if(fbyte==(char)9){++fi;}else{fld[fi][fl[fi]]=fbyte;++fl[fi];}fbyte=getc(f1);}
		while(!feof(f1)&&fbyte==13||fbyte==10){fbyte=getc(f1);}

		//printf(".%d.",fi);

		if(fi==4)
		{

			ai=3;for(i=0;i<256;++i){n_s[i]='\0';}
			for(i=0;i<strlen(fld[ai]);++i){if((fld[ai][i]>='0'&&fld[ai][i]<='9')||fld[ai][i]=='.'||fld[ai][i]=='-'){n_s[i]=fld[ai][i];}}
			n=(long)(((double)mult_)*p_val(n_s));
	
			if(ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]==-1)
			{
				a=n&ns;b=n;
				d=((((b16e&a)>>1)^((b16e&(b&0xffff))>>1))<<1)|((b16o&a)^(b16o&(b&0xffff)));
				ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]=ba16i;
				ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][1]=1;
				ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][2]=d;
				++ba16i;
			}else{
				++ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][1];
			}

		}
	}
	fclose(f1);

	printf("\n%d\n\n",ba16i);
	
	for(i=0;i<16;++i){for(j=0;j<16;++j){
		mx=-1;
		for(k=0;k<16;++k){for(l=0;l<16;++l){
			n=(i<<12)|(j<<8)|(k<<4)|(l<<0);
			if(ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]!=-1)
			{
				if(mx==-1)
				{
					mxi=(i<<12)|(j<<8)|(k<<4)|(l<<0);
					mx=ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][2];
				}else{
					if
					(
						mx<
						ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][2]
					)
					{
						mxi=(i<<12)|(j<<8)|(k<<4)|(l<<0);
						mx=ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][2];
					}
				}
			}	
		}}
		if(mx!=-1)
		{
			if(ddi==0)
			{
				dd[ddi][0]=mxi;dd[ddi][1]=mx;
				dd[ddi][2]=ba16[(mxi&0xf000)>>12][(mxi&0x0f00)>>8][(mxi&0x00f0)>>4][(mxi&0x000f)>>0][1];
				dd[ddi][3]=ba16[(mxi&0xf000)>>12][(mxi&0x0f00)>>8][(mxi&0x00f0)>>4][(mxi&0x000f)>>0][2];
				++ddi;
			}else{
				for(a=0;a<ddi;++a)
				{
					if(dd[a][1]==mx)
					{
						dd[ddi][2]+=ba16[(dd[a][0]&0xf000)>>12][(dd[a][0]&0x0f00)>>8][(dd[a][0]&0x00f0)>>4][(dd[a][0]&0x000f)>>0][1];
						dd[ddi][3]+=ba16[(dd[a][0]&0xf000)>>12][(dd[a][0]&0x0f00)>>8][(dd[a][0]&0x00f0)>>4][(dd[a][0]&0x000f)>>0][2];
						break;
					}
				}
				if(a==ddi)
				{
					dd[ddi][0]=mxi;dd[ddi][1]=mx;
					dd[ddi][2]=ba16[(mxi&0xf000)>>12][(mxi&0x0f00)>>8][(mxi&0x00f0)>>4][(mxi&0x000f)>>0][1];
					dd[ddi][3]=ba16[(mxi&0xf000)>>12][(mxi&0x0f00)>>8][(mxi&0x00f0)>>4][(mxi&0x000f)>>0][2];
					++ddi;
				}
			}
		}
	}}

	for(a=0;a<ddi;++a){printf("%d\t-\t%d\t%e\n",dd[a][0],dd[a][1],((double)dd[a][3]/(double)dd[a][2]));}

	printf("\n%d\n\n",ddi);

	return(0);
}

int main(int argc,char *argv[])
{
	char		fld[100][256];
	int		fi=0;
	int		fl[100];

	int		fbyte;
	int		ai;

	int		i,j,k,l,m,n,p,q;
	int		i_,j_,k_,l_;
	int		a,b,c,d;
	double		ad,bd,cd;
	long		sa,sb;

	int		b8o,b8e,b16o,b16e;
	int		nH,nL;
	int		mx,mxi;

	int		ml=0; 			// 4 + 0,1,2,3 ... - to be determined
	int		ns;

	if(argv[1]!=NULL){strcpy(infn,argv[1]);f1=fopen(infn,"rb");if(f1!=NULL){fclose(f1);}else{return(0);}}else{return(0);}

	b8o=0;
	b8o|=1<<0;
	b8o|=1<<2;
	b8o|=1<<4;
	b8o|=1<<6;

	b8e=0;
	b8e|=1<<1;
	b8e|=1<<3;
	b8e|=1<<5;
	b8e|=1<<7;

	b16o=0;
	b16o|=1<<0;
	b16o|=1<<2;
	b16o|=1<<4;
	b16o|=1<<6;
	b16o|=1<<8;
	b16o|=1<<10;
	b16o|=1<<12;
	b16o|=1<<14;

	b16e=0;
	b16e|=1<<1;
	b16e|=1<<3;
	b16e|=1<<5;
	b16e|=1<<7;
	b16e|=1<<9;
	b16e|=1<<11;
	b16e|=1<<13;
	b16e|=1<<15;

	if(ml==0){p_1(b04);ns=b04;}
	if(ml==1){p_1(b05);ns=b05;}
	if(ml==2){p_1(b06);ns=b06;}
	if(ml==3){p_1(b07);ns=b07;}
	if(ml==4){p_1(b08);ns=b08;}
	if(ml==5){p_1(b09);ns=b09;}
	if(ml==6){p_1(b10);ns=b10;}
	if(ml==7){p_1(b11);ns=b11;}

	for(i=0;i<ddi-1;++i){dd[i][1]=dd[1+i][0]-dd[i][0];}

	for(i=0;i<ddi;++i)
	{
		printf("%d %d %d %d %d %d\t%e\n",dd[i][0],dd[i][1],
		((((dd[i][1]&0xff00)>>8)&0xf0)>>4),
		((((dd[i][1]&0xff00)>>8)&0x0f)>>0),
		((((dd[i][1]&0x00ff)>>0)&0xf0)>>4),
		((((dd[i][1]&0x00ff)>>0)&0x0f)>>0),
		log((double)dd[i][3]/(double)dd[i][2])
		);
	}

	printf("\n");

	f1=fopen(infn,"rb");
	while(!feof(f1))
	{
		fi=0;for(i=0;i<100;++i){fl[i]=0;for(j=0;j<256;++j){fld[i][j]='\0';}}
		while(!feof(f1)&&fbyte!=13&&fbyte!=10){if(fbyte==(char)9){++fi;}else{fld[fi][fl[fi]]=fbyte;++fl[fi];}fbyte=getc(f1);}
		while(!feof(f1)&&fbyte==13||fbyte==10){fbyte=getc(f1);}

		//printf(".%d.",fi);

		if(fi==4)
		{
			ai=3;for(i=0;i<256;++i){n_s[i]='\0';}
			for(i=0;i<strlen(fld[ai]);++i){if((fld[ai][i]>='0'&&fld[ai][i]<='9')||fld[ai][i]=='.'||fld[ai][i]=='-'){n_s[i]=fld[ai][i];}}
			n=(long)(((double)mult_)*p_val(n_s));

			mx=-1;
			for(i=0;i<ddi;++i)
			{
				if(n<=dd[i][0]){d=dd[i][0]-n;if(mx==-1){mx=d;mxi=i;}else{if(mx>d){mx=d;mxi=i;}}}
			}
			if(mx==-1){dd[ddi][0]=n;dd[ddi][1]=0;mx=0;mxi=ddi;++ddi;}

		}
	}
	fclose(f1);

	for(i=0;i<ddi-1;++i){dd[i][1]=dd[1+i][0]-dd[i][0];}

	f2=fopen(outfn,"wb");
	for(i=0;i<ddi;++i)
	{
		p_format(((double)dd[i][0]/(double)mult_),"00000.00000",p_s);
		fprintf(f2,"%s",p_s);
		fprintf(f2,"%c",(char)9);
		p_format(((double)dd[i][1]/(double)mult_),"00000.00000",p_s);
		fprintf(f2,"%s",p_s);
		fprintf(f2,"%c%c",(char)13,(char)10);
	}
	fclose(f2);

	f3=fopen(outxfn,"wb");

	ad=(double)10;bd=1;		
	for(j=0;j<dd[0][1];++j)
	{
		ad+=bd;n=(int)ad;
		sa=0;
		for(k_=0;k_<16;++k_){for(l_=0;l_<16;++l_){
			
			p=(n&0xff00)|(k_<<4)|(l_<<0);
			if(ba16[(p&0xf000)>>12][(p&0x0f00)>>8][(k_&0x00f0)>>4][(l_&0x000f)>>0][0]!=-1)
			{
				a=p&ns;b=p;
				sa+=((((b16e&a)>>1)^((b16e&(b&0xffff))>>1))<<1)|((b16o&a)^(b16o&(b&0xffff)));
			}
		}}

		sb=0;
		for(i_=0;i_<16;++i_){for(j_=0;j_<16;++j_){
			
			p=(i_<<12)|(j_<<8)|(n&0x00ff);
			if(ba16[(i_&0xf000)>>12][(j_&0x0f00)>>8][(p&0x00f0)>>4][(p&0x000f)>>0][0]!=-1)
			{
				a=p&ns;b=p;
				sb+=((((b16e&a)>>1)^((b16e&(b&0xffff))>>1))<<1)|((b16o&a)^(b16o&(b&0xffff)));
			}
		}}

		printf("%d\t%d\t%d\t%d\t%d\t%d\t",(int)((double)ad/(double)mult_),(int)((double)dd[i][1]/(double)mult_),
		((((n&0xff00)>>8)&0xf0)>>4),
		((((n&0xff00)>>8)&0x0f)>>0),
		((((n&0x00ff)>>0)&0xf0)>>4),
		((((n&0x00ff)>>0)&0x0f)>>0));
		
		printf("%c",(char)9);
		if(sa>0&&sb>0)
		{p_format(log((double)sa/(double)sb),"00000.00000",p_s);printf("%s",p_s);}else{printf("0.00000");}
		printf("%c",(char)9);
		if(ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]>0&&sb>0)
		{p_format(log((double)ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]/(double)sb),"00000.00000",p_s);printf("%s\n",p_s);}else{printf("0.00000\n");}

		if(sa>0&&sb>0&&ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]>0)
		{
			p_format(((double)ad/(double)mult_),"00000.00000",p_s);
			fprintf(f3,"%s",p_s);
			fprintf(f3,"%c",(char)9);
			p_format((log((double)sa/(double)sb)-
			log((double)ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]/(double)sb)),"00000.00000",p_s);fprintf(f3,"%s",p_s);
			fprintf(f3,"%c%c",(char)13,(char)10);
		}
	}

	for(i=0;i<ddi-1;++i)
	{
		ad=(double)dd[i][0];bd=1;		
		for(j=0;j<dd[i][1]&&(dd[i][0]+j)<dd[1+i][0];++j)
		{
			ad+=bd;n=(int)ad;
			sa=0;
			for(k_=0;k_<16;++k_){for(l_=0;l_<16;++l_){
			
				p=(n&0xff00)|(k_<<4)|(l_<<0);
				if(ba16[(p&0xf000)>>12][(p&0x0f00)>>8][(k_&0x00f0)>>4][(l_&0x000f)>>0][0]!=-1)
				{
					a=p&ns;b=p;
					sa+=((((b16e&a)>>1)^((b16e&(b&0xffff))>>1))<<1)|((b16o&a)^(b16o&(b&0xffff)));
				}
			}}

			sb=0;
			for(i_=0;i_<16;++i_){for(j_=0;j_<16;++j_){
			
				p=(i_<<12)|(j_<<8)|(n&0x00ff);
				if(ba16[(i_&0xf000)>>12][(j_&0x0f00)>>8][(p&0x00f0)>>4][(p&0x000f)>>0][0]!=-1)
				{
					a=p&ns;b=p;
					sb+=((((b16e&a)>>1)^((b16e&(b&0xffff))>>1))<<1)|((b16o&a)^(b16o&(b&0xffff)));
				}
			}}

			printf("%d\t%d\t%d\t%d\t%d\t%d\t",(int)((double)ad/(double)mult_),(int)((double)dd[i][1]/(double)mult_),
			((((n&0xff00)>>8)&0xf0)>>4),
			((((n&0xff00)>>8)&0x0f)>>0),
			((((n&0x00ff)>>0)&0xf0)>>4),
			((((n&0x00ff)>>0)&0x0f)>>0));
		
			printf("%c",(char)9);
			if(sa>0&&sb>0)
			{p_format(log((double)sa/(double)sb),"00000.00000",p_s);printf("%s",p_s);}else{printf("0.00000");}
			printf("%c",(char)9);
			if(ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]>0&&sb>0)
			{p_format(log((double)ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]/(double)sb),"00000.00000",p_s);printf("%s\n",p_s);}else{printf("0.00000\n");}

			if(sa>0&&sb>0&&ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]>0)
			{
				p_format(((double)ad/(double)mult_),"00000.00000",p_s);
				fprintf(f3,"%s",p_s);
				fprintf(f3,"%c",(char)9);
				p_format((log((double)sa/(double)sb)-
				log((double)ba16[(n&0xf000)>>12][(n&0x0f00)>>8][(n&0x00f0)>>4][(n&0x000f)>>0][0]/(double)sb)),"00000.00000",p_s);fprintf(f3,"%s",p_s);
				fprintf(f3,"%c%c",(char)13,(char)10);
			}
		}
	}
	fclose(f3);

	return(0);

}