// File: /workspace/github_c_makefile_star2_O2/cbouilla[P]AES-attacks-finder/Algo.c
// Function: EcrireAlgo
void EcrireAlgo(char *s, Solver b, int *Known, int NKnown, SysEqLin E, string_list_t *variable_names)
{
	Solver *B1,B;
	int N1,i,sur,n,tab;
	char *s1,*s2;
	SysEqLin F;
	unsigned long int mem,mem_max;

	printf("Sart C code generation (may take a long time ...) : \n");
	B1=MakeSolver1(E,&N1);
	while (EnleveFaussesEq(B1,N1,E)==1)
	{
		for (i = 0; i < N1; i++) freeSolver(B1[i]);
		free(B1);
		B1=MakeSolver1(E,&N1);
	}
	for (i = 0; i < N1; i++) freeSolver(B1[i]);
	free(B1);
	F=EsachantX(Known,NKnown,E);
	printf("- Refine solver\n");
	fflush(stdout);
	Solver b1=OptimizeSolver(b,F);
	B=Refine(b1,F);

	FILE *out1,*out2,*outH,*out;

	n=strlen(s)+1+strlen("Programs/.c");
	s1=malloc(n*sizeof(char));
	s2=malloc(n*sizeof(char));
	sprintf(s1,"Programs/%s.c",s);
	sprintf(s2,"Programs/%s.h",s);

	out=fopen(s1,"w+");
	out1=fopen("Programs/debut.c","w+");
	out2=fopen("Programs/fin.c","w+");
	outH=fopen(s2,"w+");
	
	fprintf(outH,"#include <stdint.h>\n\n");

	printf("- Write attacks\n");
	fflush(stdout);
	{
		char *s1_tmp = malloc(30*sizeof(char));
		char *s2_tmp = malloc(30*sizeof(char));
		tab=EcrireAlgo_tmp(s1_tmp,s2_tmp,outH,B,F,0,&sur,&mem,&mem_max,NULL,0);
		copyAlgo(out1,s1_tmp,0);
		copyAlgo(out2,s2_tmp,0);
		remove(s1_tmp);
		remove(s2_tmp);
		free(s1_tmp);
		free(s2_tmp);
	}
	printf("\n");

	fprintf(out,"#include <stdio.h>\n");
	fprintf(out,"#include <stdlib.h>\n");
	fprintf(out,"#include <unistd.h>\n");
	fprintf(out,"#include \"%s.h\"\n\n",s);
	
	fprintf(out,"const unsigned char sbox[256] = {\n");   
    fprintf(out,"	//0     1    2      3     4    5     6     7      8    9     A      B    C     D     E     F   \n"); 
    fprintf(out,"	0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0  \n");  
    fprintf(out,"	0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1   \n"); 
	fprintf(out,"	0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, //2   \n"); 
    fprintf(out,"	0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, //3   \n"); 
    fprintf(out,"	0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, //4   \n"); 
    fprintf(out,"	0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, //5   \n"); 
    fprintf(out,"	0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, //6   \n"); 
    fprintf(out,"	0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, //7   \n"); 
    fprintf(out,"	0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, //8   \n"); 
    fprintf(out,"	0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, //9   \n"); 
    fprintf(out,"	0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, //A   \n"); 
    fprintf(out,"	0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, //B   \n"); 
    fprintf(out,"	0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C   \n"); 
    fprintf(out,"	0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D   \n"); 
    fprintf(out,"	0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E   \n"); 
    fprintf(out,"	0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 \n"); 
	fprintf(out,"	};\n\n"); 

	fprintf(out,"const unsigned char rsbox[256] = { \n");  
    fprintf(out,"	0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,  \n"); 
    fprintf(out,"	0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,  \n"); 
    fprintf(out,"	0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,  \n"); 
    fprintf(out,"	0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,  \n"); 
    fprintf(out,"	0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,  \n"); 
    fprintf(out,"	0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,  \n"); 
    fprintf(out,"	0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,  \n"); 
    fprintf(out,"	0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,  \n"); 
    fprintf(out,"	0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,  \n"); 
    fprintf(out,"	0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,  \n"); 
    fprintf(out,"	0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,  \n"); 
    fprintf(out,"	0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,  \n"); 
    fprintf(out,"	0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,  \n"); 
    fprintf(out,"	0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,  \n"); 
    fprintf(out,"	0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,  \n"); 
    fprintf(out,"	0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d \n"); 
	fprintf(out,"	};\n\n"); 
    
	fprintf(out,"/*const unsigned char Rcon[255] = { \n");   
    fprintf(out,"	0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,    \n"); 
    fprintf(out,"	0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39,    \n"); 
    fprintf(out,"	0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,    \n"); 
    fprintf(out,"	0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,    \n"); 
    fprintf(out,"	0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef,    \n"); 
    fprintf(out,"	0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,    \n"); 
    fprintf(out,"	0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b,    \n"); 
    fprintf(out,"	0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3,    \n"); 
    fprintf(out,"	0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,    \n"); 
    fprintf(out,"	0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20,    \n"); 
    fprintf(out,"	0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35,    \n"); 
    fprintf(out,"	0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,    \n"); 
    fprintf(out,"	0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04,    \n"); 
    fprintf(out,"	0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63,    \n"); 
    fprintf(out,"	0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,    \n"); 
    fprintf(out,"	0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb\n"); 
	fprintf(out,"	};*/\n\n");

	fprintf(out,"#define S(x) sbox[x]\n");
	fprintf(out,"#define R(x) rsbox[x]\n\n");

	fprintf(out,"unsigned char TableMul2_8[256][256];\n\n");
	
	fprintf(out,"void MakeTableMul2_8(void)\n"); 
	fprintf(out,"{\n");
	fprintf(out,"	int a,b;\n");
	fprintf(out,"	unsigned char aa,bb,r,t;\n");
	fprintf(out,"	for (a = 0; a <256 ; a++)\n");
	fprintf(out,"	{\n");
	fprintf(out,"		for (b = a; b < 256 ; b++)\n");
	fprintf(out,"		{\n");
	fprintf(out,"			aa=a;\n");
	fprintf(out,"			bb=b;\n");
	fprintf(out,"			r=0;\n");
	fprintf(out,"			while (aa != 0)\n");
	fprintf(out,"			{\n");
	fprintf(out,"				if ((aa & 1) != 0) r=r^bb;\n");
	fprintf(out,"				t=bb & 0x80;\n");
	fprintf(out,"				bb=bb<<1;\n");
	fprintf(out,"				if (t != 0) bb=bb^0x1b;\n");
	fprintf(out,"				aa=aa>>1;\n");
	fprintf(out,"			}\n");
	fprintf(out,"			TableMul2_8[a][b]=TableMul2_8[b][a]=r;\n");	
	fprintf(out,"		}\n");
	fprintf(out,"	}\n");
	fprintf(out,"}\n\n");

	fprintf(out,"#define Multiply(a,b) TableMul2_8[a][b]\n\n");
	/* blabla
	 *
	 *
	 *
	 *
	 * */
	fprintf(out,"/*unsigned char Inverse(unsigned char a)\n");
	fprintf(out,"{\n");
	fprintf(out,"	static unsigned char TableInverse[256]={0x00,0x01,0x8d,0xf6,0xcb,0x52,0x7b,0xd1,0xe8,0x4f,0x29,0xc0,0xb0,0xe1,0xe5,0xc7,0x74,0xb4,0xaa,0x4b,0x99,0x2b,0x60,0x5f,0x58,0x3f,0xfd,0xcc,0xff,0x40,0xee,0xb2,0x3a,0x6e,0x5a,0xf1,0x55,0x4d,0xa8,0xc9,0xc1,0x0a,0x98,0x15,0x30,0x44,0xa2,0xc2,0x2c,0x45,0x92,0x6c,0xf3,0x39,0x66,0x42,0xf2,0x35,0x20,0x6f,0x77,0xbb,0x59,0x19,0x1d,0xfe,0x37,0x67,0x2d,0x31,0xf5,0x69,0xa7,0x64,0xab,0x13,0x54,0x25,0xe9,0x09,0xed,0x5c,0x05,0xca,0x4c,0x24,0x87,0xbf,0x18,0x3e,0x22,0xf0,0x51,0xec,0x61,0x17,0x16,0x5e,0xaf,0xd3,0x49,0xa6,0x36,0x43,0xf4,0x47,0x91,0xdf,0x33,0x93,0x21,0x3b,0x79,0xb7,0x97,0x85,0x10,0xb5,0xba,0x3c,0xb6,0x70,0xd0,0x06,0xa1,0xfa,0x81,0x82,0x83,0x7e,0x7f,0x80,0x96,0x73,0xbe,0x56,0x9b,0x9e,0x95,0xd9,0xf7,0x02,0xb9,0xa4,0xde,0x6a,0x32,0x6d,0xd8,0x8a,0x84,0x72,0x2a,0x14,0x9f,0x88,0xf9,0xdc,0x89,0x9a,0xfb,0x7c,0x2e,0xc3,0x8f,0xb8,0x65,0x48,0x26,0xc8,0x12,0x4a,0xce,0xe7,0xd2,0x62,0x0c,0xe0,0x1f,0xef,0x11,0x75,0x78,0x71,0xa5,0x8e,0x76,0x3d,0xbd,0xbc,0x86,0x57,0x0b,0x28,0x2f,0xa3,0xda,0xd4,0xe4,0x0f,0xa9,0x27,0x53,0x04,0x1b,0xfc,0xac,0xe6,0x7a,0x07,0xae,0x63,0xc5,0xdb,0xe2,0xea,0x94,0x8b,0xc4,0xd5,0x9d,0xf8,0x90,0x6b,0xb1,0x0d,0xd6,0xeb,0xc6,0x0e,0xcf,0xad,0x08,0x4e,0xd7,0xe3,0x5d,0x50,0x1e,0xb3,0x5b,0x23,0x38,0x34,0x68,0x46,0x03,0x8c,0xdd,0x9c,0x7d,0xa0,0xcd,0x1a,0x41,0x1c};\n");
	fprintf(out,"	return TableInverse[a];\n");
	fprintf(out,"}\n*/");

	fprintf(out,"/* Index variables \n");
	for (i = 0; i < VARIABLES; i++) fprintf(out," * x[%d] = %s\n",i,find_var_name(variable_names,i));
	fprintf(out," **/\n");

	fprintf(out,"void Attack(const unsigned char Known[%d])\n",NKnown);
	fprintf(out,"{\n");
	//fprintf(out,"	unsigned char x[%d];\n",VARIABLES);
	//fprintf(out,"	int i;\n");
	//fprintf(out,"	for (i = 0; i < %d; i++) x[i]=0;\n\n",VARIABLES);
	for (i = 0; i < NKnown; i++) fprintf(out,"	const unsigned char x%d=Known[%d]; /* %s */\n",Known[i],i,find_var_name(variable_names,Known[i]));
	fclose(out1);
	copyAlgo(out,"Programs/debut.c",1);
	out1=fopen("Programs/debut.c","w+");
	fprintf(out1,"printf(\"# Solution found :\\n\");\n");
	for (i = 0; i < VARIABLES; i++) {
	  if(strncmp(find_var_name(variable_names,i), "1", 1)) 
	    fprintf(out1,"printf(\"%s = %%02x\\n\",x%d);\n",find_var_name(variable_names,i),i);
	}
	fprintf(out1,"return ;/*getchar();*/\n");
	fclose(out1);
	copyAlgo(out,"Programs/debut.c",1+tab);
	fclose(out2);
	copyAlgo(out,"Programs/fin.c",1);
	remove("Programs/debut.c");
	remove("Programs/fin.c");
	fprintf(out,"}\n\n");	
	freeSysEq(F);
	printf(" Make a generator for known variables ? (y/n) ");
	char c;
	scanf("%c",&c);
	getchar();
	Solver B_tmp = NULL;
	if (c=='y') B_tmp=SearchAlgo(E,1,1,Known,1,2,variable_names,NULL);
	if (c=='n' || B_tmp==NULL)
	{
		F=ExtraireEX2(Known,NKnown,E);
		B_tmp=SearchAlgo(F,1,1,Known,1,2,variable_names,NULL);
		freeSysEq(F);
	}
	if (B_tmp!=NULL)
	{
		out1=fopen("Programs/debut.c","w+");
		out2=fopen("Programs/fin.c","w+");
		printf("- Write generator\n");
		F=EsachantX(Known,1,E);
		//tab=EcrireAlgo_tmp(out1,out2,outH,B_tmp,F,1,&sur,&mem,&mem_max,NULL,0);
		{
			char *s1_tmp = malloc(30*sizeof(char));
			char *s2_tmp = malloc(30*sizeof(char));
			tab=EcrireAlgo_tmp(s1_tmp,s2_tmp,outH,B_tmp,F,1,&sur,&mem,&mem_max,NULL,0);
			copyAlgo(out1,s1_tmp,0);
			copyAlgo(out2,s2_tmp,0);
			remove(s1_tmp);
			remove(s2_tmp);
			free(s1_tmp);
			free(s2_tmp);
		}
		freeSysEq(F);
		printf("\n");
			
		fprintf(out,"int Generator(unsigned char Known[%d]/*, unsigned char y[%d]*/)\n",NKnown,VARIABLES);
		fprintf(out,"{\n");
		//fprintf(out,"	unsigned char *x = malloc(%d*sizeof(unsigned char));\n",VARIABLES);
		//fprintf(out,"	int i;\n");
		//fprintf(out,"	for (i = 1; i < %d; i++) x[i]=0;\n\n",VARIABLES);
		fprintf(out,"	const unsigned char x0=1;\n");
		fclose(out1);
		copyAlgo(out,"Programs/debut.c",1);
		out1=fopen("Programs/debut.c","w+");
		for (i = 0; i < NKnown; i++) fprintf(out1,"Known[%d]=x%d; /* %s */\n",i,Known[i], find_var_name(variable_names,Known[i]));
		//fprintf(out1,"free(x);\n");
		fprintf(out1,"return 1;\n");
		fclose(out1);
		copyAlgo(out,"Programs/debut.c",1+tab);
		fclose(out2);
		copyAlgo(out,"Programs/fin.c",1);
		//fprintf(out,"	free(x);\n");
		fprintf(out,"	return 0;\n");
		fprintf(out,"}\n\n");

		fprintf(out,"int main(int argc, char** argv)\n");
		fprintf(out,"{\n");
		fprintf(out,"	unsigned char Known[%d];\n",NKnown);
		fprintf(out,"   srand(getpid()); /* Init PRNG */\n");
		fprintf(out,"	MakeTableMul2_8();\n");
		fprintf(out,"	/* assign values */\n");
		//for (i = 0; i < NKnown; i++) fprintf(out,"	Known[%d] = %s;\n",i,find_var_name(variable_names, Known[i]));
		//fprintf(out,"	y[0]=1;\n");
		fprintf(out,"	Generator(Known);\n");
		fprintf(out,"	/* Attack */\n");
		fprintf(out,"	Attack(Known);\n");
		fprintf(out,"	return 0;\n");
		fprintf(out,"}\n");
		freeSolver(B_tmp);
		remove("Programs/debut.c");
		remove("Programs/fin.c");
	}
	else
	{
		fprintf(out,"int main(int argc, char** argv)\n");
		fprintf(out,"{\n");
		fprintf(out,"	unsigned char Known[%d];\n",NKnown);
		fprintf(out,"   srand(getpid()); /* Init PRNG */\n");
		fprintf(out,"	MakeTableMul2_8();\n");
		fprintf(out,"	/* assign values */\n");
		fprintf(out,"	Known[0] = 1;\n");
		for (i = 1; i < NKnown; i++) fprintf(out,"	Known[%d] = (1+rand()%%255) /* %s */;\n",i,find_var_name(variable_names, Known[i]));
		fprintf(out,"	/* Attack */\n");
		fprintf(out,"	Attack(Known);\n");
		fprintf(out,"	return 0;\n");
		fprintf(out,"}\n");
	}
	freeSolver(B);
	fclose(outH);
	fclose(out);
	printf("\nDone\n");
	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r12
movl %ecx, %ebp
movq %rdx, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, 0x38(%rsp)
leaq 0x198d6(%rip), %rdi     # 0x2aaaf
callq 0x2090
leaq 0x24(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x771f
movq %rax, %r15
movl 0x24(%rsp), %esi
movq %rax, %rdi
movq %r12, %rdx
callq 0x8b0c
xorl %ebx, %ebx
cmpl $0x1, %eax
je 0x11215
jmp 0x11235
movq (%r15,%rbx,8), %rdi
callq 0x6852
incq %rbx
movslq 0x24(%rsp), %rax
cmpq %rax, %rbx
jl 0x11209
movq %r15, %rdi
callq 0x2030
jmp 0x111e3
movq (%r15,%rbx,8), %rdi
callq 0x6852
incq %rbx
movslq 0x24(%rsp), %rax
cmpq %rax, %rbx
jl 0x11229
movq %r15, %rdi
callq 0x2030
movq 0x18(%rsp), %rdi
movl %ebp, 0xc(%rsp)
movl %ebp, %esi
movq %r12, 0x30(%rsp)
movq %r12, %rdx
callq 0xb021
movq %rax, %rbx
leaq 0x1987b(%rip), %rdi     # 0x2aae4
callq 0x2090
movq 0x1ed4b(%rip), %rax     # 0x2ffc0
movq (%rax), %rdi
callq 0x21d0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7ea8
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7ac5
movq %rax, 0x48(%rsp)
movq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x20f0
addl $0xc, %eax
movslq %eax, %r14
movq %r14, %rdi
callq 0x21c0
movq %rax, %r13
movq %r14, %rdi
callq 0x21c0
movq %rax, %r15
leaq 0x17975(%rip), %rsi     # 0x28c3d
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2230
leaq 0x1796f(%rip), %rsi     # 0x28c4b
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2230
leaq 0x16fe4(%rip), %rbp     # 0x282d4
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2200
movq %rax, %r14
leaq 0x17954(%rip), %rdi     # 0x28c59
movq %rbp, %rsi
callq 0x2200
movq %rax, 0x40(%rsp)
leaq 0x17951(%rip), %rdi     # 0x28c6a
movq %rbp, %rsi
callq 0x2200
movq %rax, 0x28(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2200
movq %rax, %r12
leaq 0x1793e(%rip), %rdi     # 0x28c79
pushq $0x15
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
movq %rax, %rcx
callq 0x2250
leaq 0x197a0(%rip), %rdi     # 0x2aaf4
callq 0x2090
movq 0x1ec60(%rip), %rax     # 0x2ffc0
movq (%rax), %rdi
callq 0x21d0
pushq $0x1e
popq %r13
movq %r13, %rdi
callq 0x21c0
movq %rax, %rbp
movq %r13, %rdi
callq 0x21c0
movq %rax, %r13
subq $0x8, %rsp
leaq 0x70(%rsp), %r11
leaq 0x78(%rsp), %r10
leaq 0x5c(%rsp), %rax
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, 0x60(%rsp)
movq %r12, %rdx
movq 0x50(%rsp), %rcx
movq %rbx, 0x68(%rsp)
movq %rbx, %r8
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
pushq %r11
pushq %r10
pushq %rax
callq 0xdb0a
addq $0x30, %rsp
movl %eax, 0x50(%rsp)
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xda6a
movq 0x28(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xda6a
movq %rbp, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
callq 0x2030
pushq $0xa
popq %rdi
callq 0x2040
leaq 0x17879(%rip), %rdi     # 0x28c8f
pushq $0x13
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17878(%rip), %rdi     # 0x28ca3
pushq $0x14
popq %rbx
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17875(%rip), %rdi     # 0x28cb8
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17875(%rip), %rsi     # 0x28ccd
movq %r14, %rdi
movq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x2180
leaq 0x17871(%rip), %rdi     # 0x28cdf
pushq $0x22
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1787f(%rip), %rdi     # 0x28d02
pushq $0x61
popq %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x178c8(%rip), %rdi     # 0x28d64
pushq $0x67
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1791b(%rip), %rdi     # 0x28dcc
pushq $0x68
popq %rbp
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1796c(%rip), %rdi     # 0x28e35
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x179c0(%rip), %rdi     # 0x28e9e
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17a14(%rip), %rdi     # 0x28f07
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17a68(%rip), %rdi     # 0x28f70
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17abc(%rip), %rdi     # 0x28fd9
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17b10(%rip), %rdi     # 0x29042
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17b64(%rip), %rdi     # 0x290ab
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17bb8(%rip), %rdi     # 0x29114
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17c0c(%rip), %rdi     # 0x2917d
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17c60(%rip), %rdi     # 0x291e6
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17cb4(%rip), %rdi     # 0x2924f
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17d08(%rip), %rdi     # 0x292b8
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17d5c(%rip), %rdi     # 0x29321
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17db0(%rip), %rdi     # 0x2938a
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17dfd(%rip), %r12     # 0x293ec
pushq $0x5
popq %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17de8(%rip), %rdi     # 0x293f2
pushq $0x24
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17df8(%rip), %rdi     # 0x29417
pushq $0x63
popq %rbp
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17e44(%rip), %rdi     # 0x2947b
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17e93(%rip), %rdi     # 0x294df
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17ee2(%rip), %rdi     # 0x29543
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17f31(%rip), %rdi     # 0x295a7
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17f80(%rip), %rdi     # 0x2960b
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17fcf(%rip), %rdi     # 0x2966f
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1801e(%rip), %rdi     # 0x296d3
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1806d(%rip), %rdi     # 0x29737
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x180bc(%rip), %rdi     # 0x2979b
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1810b(%rip), %rdi     # 0x297ff
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1815a(%rip), %rdi     # 0x29863
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x181a9(%rip), %rdi     # 0x298c7
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x181f8(%rip), %rdi     # 0x2992b
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18247(%rip), %rdi     # 0x2998f
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18296(%rip), %rdi     # 0x299f3
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x182d2(%rip), %rdi     # 0x29a55
pushq $0x25
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x182e3(%rip), %rdi     # 0x29a7b
pushq $0x65
popq %rbp
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18331(%rip), %rdi     # 0x29ae1
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18382(%rip), %rdi     # 0x29b47
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x183d3(%rip), %rdi     # 0x29bad
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18424(%rip), %rdi     # 0x29c13
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18475(%rip), %rdi     # 0x29c79
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x184c6(%rip), %rdi     # 0x29cdf
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18517(%rip), %rdi     # 0x29d45
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18568(%rip), %rdi     # 0x29dab
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x185b9(%rip), %rdi     # 0x29e11
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1860a(%rip), %rdi     # 0x29e77
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1865b(%rip), %rdi     # 0x29edd
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x186ac(%rip), %rdi     # 0x29f43
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x186fd(%rip), %rdi     # 0x29fa9
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1874e(%rip), %rdi     # 0x2a00f
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1879f(%rip), %rdi     # 0x2a075
pushq $0x5a
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187e5(%rip), %rdi     # 0x2a0d0
pushq $0x7
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187d8(%rip), %rdi     # 0x2a0d8
pushq $0x15
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187d9(%rip), %rdi     # 0x2a0ee
pushq $0x17
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187dc(%rip), %rdi     # 0x2a106
pushq $0x26
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187ee(%rip), %rdi     # 0x2a12d
pushq $0x1b
popq %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18885(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187dc(%rip), %rdi     # 0x2a149
pushq $0xa
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187d2(%rip), %rdi     # 0x2a154
pushq $0x1a
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187d8(%rip), %rdi     # 0x2a16f
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18830(%rip), %rdi     # 0x2a1dc
pushq $0x3
popq %rbp
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187c7(%rip), %rdi     # 0x2a18b
pushq $0x1d
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18802(%rip), %rdi     # 0x2a1db
pushq $0x4
popq %r12
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187b7(%rip), %rdi     # 0x2a1a9
pushq $0x9
popq %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187a8(%rip), %rdi     # 0x2a1b3
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1879d(%rip), %rdi     # 0x2a1bd
pushq $0x8
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18791(%rip), %rdi     # 0x2a1c6
pushq $0x13
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18790(%rip), %rdi     # 0x2a1da
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18781(%rip), %rdi     # 0x2a1e0
pushq $0x1f
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1878c(%rip), %rdi     # 0x2a200
pushq $0x11
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18789(%rip), %rdi     # 0x2a212
pushq $0xe
popq %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1877f(%rip), %rdi     # 0x2a221
pushq $0x1c
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18787(%rip), %rdi     # 0x2a23e
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18781(%rip), %rdi     # 0x2a24d
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18772(%rip), %rdi     # 0x2a253
pushq $0x2a
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18758(%rip), %rdi     # 0x2a24e
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18744(%rip), %rdi     # 0x2a24f
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1875e(%rip), %rdi     # 0x2a27e
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1874d(%rip), %rdi     # 0x2a282
pushq $0x29
popq %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1875e(%rip), %rdi     # 0x2a2ac
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1867a(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1875e(%rip), %rdi     # 0x2a2d6
movl $0x52b, %esi            # imm = 0x52B
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18c73(%rip), %rdi     # 0x2a802
pushq $0x19
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18c78(%rip), %rdi     # 0x2a81c
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18c68(%rip), %rdi     # 0x2a821
pushq $0x14
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1e6ea(%rip), %rbx     # 0x302b8
leaq 0x18c61(%rip), %r15     # 0x2a836
xorl %ebp, %ebp
cmpl (%rbx), %ebp
jge 0x11bfd
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xbf23
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2180
incl %ebp
jmp 0x11bd7
leaq 0x18c41(%rip), %rdi     # 0x2a845
pushq $0x5
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18c2e(%rip), %rsi     # 0x2a84b
movq %r14, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2180
leaq 0x185a9(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2250
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
leaq 0x18c22(%rip), %r15     # 0x2a877
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x11c8c
movq 0x18(%rsp), %rax
movl (%rax,%r13,4), %ebp
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xbf23
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2180
incq %r13
jmp 0x11c58
movq 0x40(%rsp), %rdi
callq 0x20e0
leaq 0x16fbc(%rip), %r15     # 0x28c59
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0xda6a
leaq 0x16622(%rip), %rsi     # 0x282d4
movq %r15, %rdi
callq 0x2200
movq %rax, %r15
leaq 0x18be1(%rip), %rdi     # 0x2a8a5
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x2250
leaq 0x18bed(%rip), %r13     # 0x2a8c6
xorl %ebp, %ebp
cmpl (%rbx), %ebp
jge 0x11d12
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xbf23
cmpb $0x31, (%rax)
je 0x11d0e
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xbf23
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2180
incl %ebp
jmp 0x11cdb
leaq 0x18bca(%rip), %rdi     # 0x2a8e3
pushq $0x17
popq %rsi
pushq $0x1
popq %rbp
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2250
movq %r15, %rdi
callq 0x20e0
movl 0x50(%rsp), %edx
incl %edx
leaq 0x16f1a(%rip), %r15     # 0x28c59
movq %r14, %rdi
movq %r15, %rsi
callq 0xda6a
movq 0x28(%rsp), %rdi
callq 0x20e0
leaq 0x16f0f(%rip), %r13     # 0x28c6a
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0xda6a
movq %r15, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
leaq 0x184fe(%rip), %rdi     # 0x2a27e
pushq $0x3
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
movq 0x60(%rsp), %rdi
callq 0xb562
leaq 0x18b5c(%rip), %rdi     # 0x2a8fb
xorl %eax, %eax
callq 0x2110
leaq 0x1585a(%rip), %rdi     # 0x27607
leaq 0xb(%rsp), %r15
movq %r15, %rsi
xorl %eax, %eax
callq 0x2220
callq 0x2170
cmpb $0x79, (%r15)
jne 0x11e06
pushq $0x1
popq %rdx
pushq $0x2
popq %r9
movq 0x30(%rsp), %rdi
movl %edx, %esi
movq 0x18(%rsp), %rcx
movl %edx, %r8d
pushq $0x0
pushq 0x18(%rsp)
callq 0x16021
addq $0x10, %rsp
cmpb $0x6e, 0xb(%rsp)
sete %dl
movq %rax, 0x28(%rsp)
testq %rax, %rax
sete %cl
orb %dl, %cl
cmpb $0x1, %cl
jne 0x11e57
movq 0x18(%rsp), %r13
movq %r13, %rdi
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %rdx
callq 0xace0
movq %rax, %r15
pushq $0x1
popq %rdx
pushq $0x2
popq %r9
movq %rax, %rdi
movl %edx, %esi
movq %r13, %rcx
movl %edx, %r8d
pushq $0x0
pushq 0x18(%rsp)
callq 0x16021
popq %rcx
popq %rdx
movq %rax, %r13
movq %r15, %rdi
callq 0xb562
movq %r13, 0x28(%rsp)
testq %r13, %r13
je 0x12199
leaq 0x16dfb(%rip), %rdi     # 0x28c59
leaq 0x1646f(%rip), %r15     # 0x282d4
movq %r15, %rsi
callq 0x2200
movq %rax, 0x38(%rsp)
leaq 0x16df1(%rip), %rdi     # 0x28c6a
movq %r15, %rsi
callq 0x2200
movq %rax, 0x40(%rsp)
leaq 0x18c77(%rip), %rdi     # 0x2ab04
callq 0x2090
pushq $0x1
popq %rsi
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rdx
callq 0xb021
movq %rax, %rbp
pushq $0x1e
popq %r15
movq %r15, %rdi
callq 0x21c0
movq %rax, %r13
movq %r15, %rdi
callq 0x21c0
movq %rax, %r15
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movq 0x60(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %rbp, %r8
pushq $0x1
popq %r9
pushq $0x0
pushq $0x0
leaq 0x80(%rsp), %rax
pushq %rax
leaq 0x90(%rsp), %rax
pushq %rax
leaq 0x7c(%rsp), %rax
pushq %rax
callq 0xdb0a
addq $0x30, %rsp
movl %eax, 0x30(%rsp)
movq 0x38(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xda6a
movq 0x40(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xda6a
movq %r13, %rdi
callq 0x2070
movq %r15, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2030
movq %r15, %rdi
callq 0x2030
movq %rbp, %rdi
callq 0xb562
pushq $0xa
popq %rdi
callq 0x2040
movl (%rbx), %ecx
leaq 0x189ce(%rip), %rsi     # 0x2a92a
movq %r14, %rdi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2180
leaq 0x1826c(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x189e2(%rip), %rdi     # 0x2a96b
pushq $0x1b
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
movq 0x38(%rsp), %rdi
callq 0x20e0
movq %r14, %rdi
leaq 0x16cae(%rip), %rbx     # 0x28c59
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0xda6a
movq %rbx, %rdi
leaq 0x16314(%rip), %rsi     # 0x282d4
callq 0x2200
movq %rax, %r15
leaq 0x189b8(%rip), %rbx     # 0x2a987
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x12006
movq 0x18(%rsp), %rax
movl (%rax,%r13,4), %ebp
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xbf23
movq %r15, %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2180
incq %r13
jmp 0x11fd2
leaq 0x18993(%rip), %rdi     # 0x2a9a0
pushq $0xa
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r15, %rcx
callq 0x2250
movq %r15, %rdi
callq 0x20e0
movl 0x30(%rsp), %edx
incl %edx
leaq 0x16c26(%rip), %rsi     # 0x28c59
movq %r14, %rdi
callq 0xda6a
movq 0x40(%rsp), %rdi
callq 0x20e0
leaq 0x16c1e(%rip), %r13     # 0x28c6a
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0xda6a
leaq 0x1894a(%rip), %r15     # 0x2a9ab
pushq $0xb
popq %rbp
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18202(%rip), %rdi     # 0x2a27e
pushq $0x3
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18926(%rip), %rdi     # 0x2a9b7
pushq $0x20
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18137(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %r12
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18919(%rip), %rsi     # 0x2a9d8
movq %r14, %rdi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2180
leaq 0x1891f(%rip), %rdi     # 0x2a9f3
pushq $0x24
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1892f(%rip), %rdi     # 0x2aa18
pushq $0x14
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1892f(%rip), %rdi     # 0x2aa2d
pushq $0x15
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18930(%rip), %rdi     # 0x2aa43
pushq $0x13
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1892f(%rip), %rdi     # 0x2aa57
pushq $0xe
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18929(%rip), %rdi     # 0x2aa66
pushq $0x10
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x180ed(%rip), %rdi     # 0x2a250
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
movq 0x28(%rsp), %rdi
callq 0x6852
leaq 0x16ad7(%rip), %rdi     # 0x28c59
callq 0x2070
movq %r13, %rdi
callq 0x2070
movq 0x48(%rsp), %r12
jmp 0x122c2
leaq 0x18817(%rip), %rdi     # 0x2a9b7
pushq $0x20
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18028(%rip), %rdi     # 0x2a1dd
pushq $0x2
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1880e(%rip), %rsi     # 0x2a9d8
movq %r14, %rdi
movl 0xc(%rsp), %ebx
movl %ebx, %edx
xorl %eax, %eax
callq 0x2180
leaq 0x18812(%rip), %rdi     # 0x2a9f3
pushq $0x24
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18822(%rip), %rdi     # 0x2aa18
pushq $0x14
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18822(%rip), %rdi     # 0x2aa2d
pushq $0x15
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x18857(%rip), %rdi     # 0x2aa77
pushq $0xf
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x2250
movslq %ebx, %r15
leaq 0x1884f(%rip), %rbx     # 0x2aa87
movq 0x48(%rsp), %r12
cmpq %r15, %rbp
jge 0x1226b
movq 0x18(%rsp), %rax
movl (%rax,%rbp,4), %esi
movq 0x10(%rsp), %rdi
callq 0xbf23
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2180
incq %rbp
jmp 0x1223d
leaq 0x187e5(%rip), %rdi     # 0x2aa57
pushq $0xe
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x187dc(%rip), %rdi     # 0x2aa66
pushq $0x10
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x1870c(%rip), %rdi     # 0x2a9ab
pushq $0xb
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
leaq 0x17f9c(%rip), %rdi     # 0x2a250
pushq $0x2
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x2250
movq %r12, %rdi
callq 0x6852
movq 0x58(%rsp), %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x20e0
leaq 0x18833(%rip), %rdi     # 0x2ab16
callq 0x2090
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop