// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %r8, %r13
movl %ecx, %r15d
movq %rdx, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x19f62(%rip), %rdi     # 0x2cb0f
callq 0x2090
leaq 0x8(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x834c
movq %rax, %rbp
movl (%r14), %esi
movq %rax, %rdi
movq %r13, %rdx
callq 0x9803
cmpl $0x1, %eax
jne 0x12c27
leaq 0x8(%rsp), %r14
cmpl $0x0, 0x8(%rsp)
jle 0x12bfd
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rdi
callq 0x7447
incq %rbx
movslq 0x8(%rsp), %rax
cmpq %rax, %rbx
jl 0x12be6
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
movq %r14, %rsi
callq 0x834c
movq %rax, %rbp
movl 0x8(%rsp), %esi
movq %rax, %rdi
movq %r13, %rdx
callq 0x9803
cmpl $0x1, %eax
je 0x12bdd
movq %r12, 0x38(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x12c4c
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rdi
callq 0x7447
incq %rbx
movslq 0x8(%rsp), %rax
cmpq %rax, %rbx
jl 0x12c35
movq %rbp, %rdi
callq 0x2030
movq 0x20(%rsp), %rdi
movl %r15d, 0xc(%rsp)
movl %r15d, %esi
movq %r13, 0x28(%rsp)
movq %r13, %rdx
callq 0xc29a
movq %rax, %rbx
leaq 0x19ecc(%rip), %rdi     # 0x2cb44
callq 0x2090
movq 0x1f33c(%rip), %rax     # 0x31fc0
movq (%rax), %rdi
callq 0x21e0
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x8b14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x86e8
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x20f0
addl $0xc, %eax
movslq %eax, %r14
movq %r14, %rdi
callq 0x21d0
movq %rax, %r13
movq %r14, %rdi
callq 0x21d0
movq %rax, %r15
leaq 0x17fc4(%rip), %rsi     # 0x2ac9d
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2240
leaq 0x17fbe(%rip), %rsi     # 0x2acab
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2240
leaq 0x17633(%rip), %rbp     # 0x2a334
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rax, %r14
leaq 0x17fa3(%rip), %rdi     # 0x2acb9
movq %rbp, %rsi
callq 0x2210
movq %rax, 0x18(%rsp)
leaq 0x17fa0(%rip), %rdi     # 0x2acca
movq %rbp, %rsi
callq 0x2210
movq %rax, %r12
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rax, %r13
leaq 0x17f8f(%rip), %rdi     # 0x2acd9
movl $0x15, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2260
leaq 0x19df1(%rip), %rdi     # 0x2cb54
callq 0x2090
movq 0x1f251(%rip), %rax     # 0x31fc0
movq (%rax), %rdi
callq 0x21e0
movl $0x1e, %edi
callq 0x21d0
movq %rax, %rbp
movl $0x1e, %edi
callq 0x21d0
movq %rax, %r15
subq $0x8, %rsp
leaq 0x70(%rsp), %r11
leaq 0x78(%rsp), %r10
leaq 0x54(%rsp), %rax
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, 0x60(%rsp)
movq %r13, %rdx
movq 0x38(%rsp), %rcx
movq %rbx, 0x48(%rsp)
movq %rbx, %r8
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
pushq %r11
pushq %r10
pushq %rax
callq 0xf1b8
addq $0x30, %rsp
movl %eax, 0x48(%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xf118
movq %r12, 0x60(%rsp)
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xf118
movq %rbp, %rdi
callq 0x2070
movq %r15, %rdi
callq 0x2070
movq %rbp, %rdi
callq 0x2030
movq %r15, %rdi
callq 0x2030
movl $0xa, %edi
callq 0x2040
leaq 0x17ec5(%rip), %rdi     # 0x2acef
movl $0x13, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17ec0(%rip), %rdi     # 0x2ad03
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17ebc(%rip), %rdi     # 0x2ad18
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17eb8(%rip), %rsi     # 0x2ad2d
movq %r14, %rdi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2190
leaq 0x17eb4(%rip), %rdi     # 0x2ad3f
movl $0x22, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17ebe(%rip), %rdi     # 0x2ad62
movl $0x61, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17f07(%rip), %rdi     # 0x2adc4
movl $0x67, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17f56(%rip), %rdi     # 0x2ae2c
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17fa6(%rip), %rdi     # 0x2ae95
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x17ff6(%rip), %rdi     # 0x2aefe
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18046(%rip), %rdi     # 0x2af67
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18096(%rip), %rdi     # 0x2afd0
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x180e6(%rip), %rdi     # 0x2b039
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18136(%rip), %rdi     # 0x2b0a2
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18186(%rip), %rdi     # 0x2b10b
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x181d6(%rip), %rdi     # 0x2b174
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18226(%rip), %rdi     # 0x2b1dd
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18276(%rip), %rdi     # 0x2b246
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x182c6(%rip), %rdi     # 0x2b2af
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18316(%rip), %rdi     # 0x2b318
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18366(%rip), %rdi     # 0x2b381
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x183b6(%rip), %rdi     # 0x2b3ea
movl $0x61, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x183ff(%rip), %r15     # 0x2b44c
movl $0x5, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x183e9(%rip), %rdi     # 0x2b452
movl $0x24, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x183f5(%rip), %rdi     # 0x2b477
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18440(%rip), %rdi     # 0x2b4db
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1848b(%rip), %rdi     # 0x2b53f
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x184d6(%rip), %rdi     # 0x2b5a3
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18521(%rip), %rdi     # 0x2b607
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1856c(%rip), %rdi     # 0x2b66b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x185b7(%rip), %rdi     # 0x2b6cf
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18602(%rip), %rdi     # 0x2b733
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1864d(%rip), %rdi     # 0x2b797
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18698(%rip), %rdi     # 0x2b7fb
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x186e3(%rip), %rdi     # 0x2b85f
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1872e(%rip), %rdi     # 0x2b8c3
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18779(%rip), %rdi     # 0x2b927
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x187c4(%rip), %rdi     # 0x2b98b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1880f(%rip), %rdi     # 0x2b9ef
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1885a(%rip), %rdi     # 0x2ba53
movl $0x61, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movl $0x5, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x1888e(%rip), %rdi     # 0x2bab5
movl $0x25, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1889b(%rip), %rdi     # 0x2badb
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x188e8(%rip), %rdi     # 0x2bb41
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18935(%rip), %rdi     # 0x2bba7
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18982(%rip), %rdi     # 0x2bc0d
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x189cf(%rip), %rdi     # 0x2bc73
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18a1c(%rip), %rdi     # 0x2bcd9
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18a69(%rip), %rdi     # 0x2bd3f
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ab6(%rip), %rdi     # 0x2bda5
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b03(%rip), %rdi     # 0x2be0b
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b50(%rip), %rdi     # 0x2be71
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b9d(%rip), %rdi     # 0x2bed7
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18bea(%rip), %rdi     # 0x2bf3d
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c37(%rip), %rdi     # 0x2bfa3
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c84(%rip), %rdi     # 0x2c009
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cd1(%rip), %rdi     # 0x2c06f
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d1e(%rip), %rdi     # 0x2c0d5
movl $0x5a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d60(%rip), %rdi     # 0x2c130
movl $0x7, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d4f(%rip), %rdi     # 0x2c138
movl $0x15, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d4c(%rip), %rdi     # 0x2c14e
movl $0x17, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d4b(%rip), %rdi     # 0x2c166
movl $0x26, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d59(%rip), %rdi     # 0x2c18d
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18df0(%rip), %r15     # 0x2c23d
movl $0x2, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x18d40(%rip), %rdi     # 0x2c1a9
movl $0xa, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d32(%rip), %rdi     # 0x2c1b4
movl $0x1a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d34(%rip), %rdi     # 0x2c1cf
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d88(%rip), %rdi     # 0x2c23c
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d1e(%rip), %rdi     # 0x2c1eb
movl $0x1d, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d55(%rip), %rdi     # 0x2c23b
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d0a(%rip), %rdi     # 0x2c209
movl $0x9, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cfb(%rip), %rdi     # 0x2c213
movl $0x9, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cec(%rip), %rdi     # 0x2c21d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cdc(%rip), %rdi     # 0x2c226
movl $0x13, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cd7(%rip), %rdi     # 0x2c23a
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cc4(%rip), %rdi     # 0x2c240
movl $0x1f, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ccb(%rip), %rdi     # 0x2c260
movl $0x11, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cc4(%rip), %rdi     # 0x2c272
movl $0xe, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cba(%rip), %rdi     # 0x2c281
movl $0x1c, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cbe(%rip), %rdi     # 0x2c29e
movl $0xe, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18cb4(%rip), %rdi     # 0x2c2ad
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ca1(%rip), %rdi     # 0x2c2b3
movl $0x2a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c83(%rip), %rdi     # 0x2c2ae
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c6b(%rip), %rdi     # 0x2c2af
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c81(%rip), %rdi     # 0x2c2de
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c6c(%rip), %rdi     # 0x2c2e2
movl $0x29, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c7d(%rip), %rdi     # 0x2c30c
movl $0x29, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movl $0x2, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x18c79(%rip), %rdi     # 0x2c336
movl $0x52b, %esi            # imm = 0x52B
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1918c(%rip), %rdi     # 0x2c862
movl $0x19, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1918d(%rip), %rdi     # 0x2c87c
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19179(%rip), %rdi     # 0x2c881
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1eb97(%rip), %rbx     # 0x322b8
cmpl $0x0, (%rbx)
movq 0x38(%rsp), %r13
jle 0x13756
leaq 0x19164(%rip), %r15     # 0x2c896
xorl %ebp, %ebp
movq %r13, %rdi
movl %ebp, %esi
callq 0xd2a9
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2190
incl %ebp
cmpl (%rbx), %ebp
jl 0x13734
leaq 0x19148(%rip), %rdi     # 0x2c8a5
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19135(%rip), %rsi     # 0x2c8ab
movq %r14, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x18ab0(%rip), %rdi     # 0x2c23d
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq %r14, %r15
movl %ebp, %r14d
testl %ebp, %ebp
movq 0x20(%rsp), %r12
jle 0x137e3
movq %r13, %rbx
xorl %r13d, %r13d
movl (%r12,%r13,4), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0xd2a9
movq %r15, %rdi
leaq 0x1910b(%rip), %rsi     # 0x2c8d7
movl %ebp, %edx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2190
incq %r13
cmpq %r13, %r14
jne 0x137b4
movq %r14, 0x50(%rsp)
movq 0x18(%rsp), %rdi
callq 0x20e0
leaq 0x174c0(%rip), %rbx     # 0x2acb9
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0xf118
leaq 0x16b24(%rip), %rsi     # 0x2a334
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0x190e3(%rip), %rdi     # 0x2c905
movl $0x20, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2260
leaq 0x1ea7d(%rip), %r12     # 0x322b8
cmpl $0x0, (%r12)
movq %r15, %r14
jle 0x1388a
leaq 0x190da(%rip), %rbp     # 0x2c926
xorl %r13d, %r13d
movq 0x38(%rsp), %rdi
movl %r13d, %esi
callq 0xd2a9
cmpb $0x31, (%rax)
je 0x13881
movq 0x38(%rsp), %rdi
movl %r13d, %esi
callq 0xd2a9
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2190
incl %r13d
cmpl (%r12), %r13d
jl 0x1384f
leaq 0x190b2(%rip), %rdi     # 0x2c943
movl $0x17, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2260
movq %rbx, %rdi
callq 0x20e0
movl 0x48(%rsp), %edx
incl %edx
leaq 0x17401(%rip), %r15     # 0x2acb9
movq %r14, %rdi
movq %r15, %rsi
callq 0xf118
movq 0x60(%rsp), %rdi
callq 0x20e0
leaq 0x173f6(%rip), %r13     # 0x2acca
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xf118
movq %r15, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
leaq 0x189e3(%rip), %rdi     # 0x2c2de
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq 0x40(%rsp), %rdi
callq 0xc82d
leaq 0x1903d(%rip), %rdi     # 0x2c95b
xorl %eax, %eax
callq 0x2110
leaq 0x15d3b(%rip), %rdi     # 0x29667
leaq 0x7(%rsp), %r15
movq %r15, %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
cmpb $0x79, (%r15)
movq 0x38(%rsp), %r13
movq 0x20(%rsp), %rbx
jne 0x13999
movq 0x28(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x2, %r9d
pushq $0x0
pushq %r13
callq 0x17eff
addq $0x10, %rsp
cmpb $0x6e, 0x7(%rsp)
sete %dl
movq %rax, 0x18(%rsp)
testq %rax, %rax
sete %cl
orb %dl, %cl
cmpb $0x1, %cl
jne 0x13b52
movq %rbx, %rdi
movl 0xc(%rsp), %ebp
movl %ebp, %esi
movq 0x28(%rsp), %rdx
callq 0xbf32
movq %rax, %r15
movq %rax, %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
movl $0x2, %r9d
pushq $0x0
pushq %r13
callq 0x17eff
addq $0x10, %rsp
movq %rax, %rbx
movq %r15, %rdi
callq 0xc82d
movq %rbx, 0x18(%rsp)
testq %rbx, %rbx
je 0x139fc
movq %r14, 0x10(%rsp)
movq 0x20(%rsp), %rbx
jmp 0x13b57
leaq 0x19014(%rip), %rdi     # 0x2ca17
movl $0x1, %ebx
movl $0x20, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1881c(%rip), %rdi     # 0x2c23d
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ffe(%rip), %rsi     # 0x2ca38
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x19006(%rip), %rdi     # 0x2ca53
movl $0x24, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19012(%rip), %rdi     # 0x2ca78
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1900e(%rip), %rdi     # 0x2ca8d
movl $0x15, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1903f(%rip), %rdi     # 0x2cad7
movl $0xf, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
cmpl $0x2, %ebp
movq 0x20(%rsp), %r12
movq %r14, %rbp
movq 0x50(%rsp), %r14
jl 0x13ae9
leaq 0x19024(%rip), %r15     # 0x2cae7
movl (%r12,%rbx,4), %esi
movq %r13, %rdi
callq 0xd2a9
movq %rbp, %rdi
movq %r15, %rsi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2190
incq %rbx
cmpq %rbx, %r14
jne 0x13ac3
leaq 0x18fc7(%rip), %rdi     # 0x2cab7
movl $0xe, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18fbd(%rip), %rdi     # 0x2cac6
movl $0x10, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18ee9(%rip), %rdi     # 0x2ca0b
movl $0xb, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18775(%rip), %rdi     # 0x2c2b0
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
jmp 0x13ed8
movq %r14, 0x10(%rsp)
leaq 0x1715b(%rip), %rdi     # 0x2acb9
leaq 0x167cf(%rip), %r14     # 0x2a334
movq %r14, %rsi
callq 0x2210
movq %rax, %r15
leaq 0x17153(%rip), %rdi     # 0x2acca
movq %r14, %rsi
callq 0x2210
movq %rax, %r14
leaq 0x18fdb(%rip), %rdi     # 0x2cb64
callq 0x2090
movq %rbx, %rdi
movl $0x1, %esi
movq 0x28(%rsp), %rdx
callq 0xc29a
movq %rax, %rbx
movl $0x1e, %edi
callq 0x21d0
movq %rax, %rbp
movl $0x1e, %edi
callq 0x21d0
movq %rax, %r13
subq $0x8, %rsp
movq %rbp, %rdi
movq %rax, %rsi
movq 0x60(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbx, %r8
movl $0x1, %r9d
pushq $0x0
pushq $0x0
leaq 0x80(%rsp), %rax
pushq %rax
leaq 0x90(%rsp), %rax
pushq %rax
leaq 0x74(%rsp), %rax
pushq %rax
callq 0xf1b8
addq $0x30, %rsp
movl %eax, 0x40(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xf118
movq %r14, 0x28(%rsp)
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf118
movq %rbp, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0xc82d
movl $0xa, %edi
callq 0x2040
movl (%r12), %ecx
leaq 0x18d2b(%rip), %rsi     # 0x2c98a
movq 0x10(%rsp), %r14
movq %r14, %rdi
movl 0xc(%rsp), %ebx
movl %ebx, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x185c2(%rip), %rdi     # 0x2c23d
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d37(%rip), %rdi     # 0x2c9cb
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq %r15, %rdi
callq 0x20e0
movq %r14, %rdi
leaq 0x17001(%rip), %r14     # 0x2acb9
movq %r14, %rsi
movl $0x1, %edx
callq 0xf118
movq %r14, %rdi
leaq 0x16665(%rip), %rsi     # 0x2a334
callq 0x2210
movq %rax, %r15
testl %ebx, %ebx
movq 0x38(%rsp), %r12
movq 0x50(%rsp), %r14
jle 0x13d1f
leaq 0x18cfb(%rip), %rbx     # 0x2c9e7
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movl (%rax,%r13,4), %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xd2a9
movq %r15, %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2190
incq %r13
cmpq %r13, %r14
jne 0x13cef
leaq 0x18cda(%rip), %rdi     # 0x2ca00
movl $0xa, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2260
movq %r15, %rdi
callq 0x20e0
movl 0x40(%rsp), %edx
incl %edx
leaq 0x16f6c(%rip), %r12     # 0x2acb9
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xf118
movq 0x28(%rsp), %rdi
callq 0x20e0
leaq 0x16f5c(%rip), %rbx     # 0x2acca
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0xf118
leaq 0x18c86(%rip), %r13     # 0x2ca0b
movl $0xb, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rcx
callq 0x2260
leaq 0x1853d(%rip), %rdi     # 0x2c2de
movl $0x3, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c5d(%rip), %rdi     # 0x2ca17
movl $0x20, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x1846a(%rip), %rdi     # 0x2c23d
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c4c(%rip), %rsi     # 0x2ca38
movq %rbp, %rdi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2190
leaq 0x18c52(%rip), %rdi     # 0x2ca53
movl $0x24, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c5e(%rip), %rdi     # 0x2ca78
movl $0x14, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c5a(%rip), %rdi     # 0x2ca8d
movl $0x15, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c57(%rip), %rdi     # 0x2caa3
movl $0x13, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c52(%rip), %rdi     # 0x2cab7
movl $0xe, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18c48(%rip), %rdi     # 0x2cac6
movl $0x10, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
movl $0xb, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rcx
callq 0x2260
leaq 0x18404(%rip), %rdi     # 0x2c2b0
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
movq 0x18(%rsp), %rdi
callq 0x7447
movq %r12, %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2070
movq 0x30(%rsp), %rdi
callq 0x7447
movq 0x58(%rsp), %rdi
callq 0x20e0
movq %rbp, %rdi
callq 0x20e0
leaq 0x18c7b(%rip), %rdi     # 0x2cb76
callq 0x2090
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop