// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %r8, %r13
movl %ecx, 0x10(%rsp)
movq %rdx, %r12
movq %rsi, 0x18(%rsp)
movq %rdi, 0x30(%rsp)
leaq 0x1a261(%rip), %rdi     # 0x2caaf
callq 0x2090
leaq 0x14(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x8010
movq %rax, %rbp
movl (%r14), %esi
movq %rax, %rdi
movq %r13, %rdx
callq 0x9530
cmpl $0x1, %eax
jne 0x128c8
leaq 0x14(%rsp), %r14
cmpl $0x0, 0x14(%rsp)
jle 0x1289e
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rdi
callq 0x7060
incq %rbx
movslq 0x14(%rsp), %rax
cmpq %rax, %rbx
jl 0x12887
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
movq %r14, %rsi
callq 0x8010
movq %rax, %rbp
movl 0x14(%rsp), %esi
movq %rax, %rdi
movq %r13, %rdx
callq 0x9530
cmpl $0x1, %eax
je 0x1287e
movq %r15, 0x20(%rsp)
cmpl $0x0, 0x14(%rsp)
jle 0x128ed
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rdi
callq 0x7060
incq %rbx
movslq 0x14(%rsp), %rax
cmpq %rax, %rbx
jl 0x128d6
movq %rbp, %rdi
callq 0x2030
movq %r12, 0x60(%rsp)
movq %r12, %rdi
movl 0x10(%rsp), %esi
movq %r13, 0x28(%rsp)
movq %r13, %rdx
callq 0xbed5
movq %rax, %rbx
leaq 0x1a1cc(%rip), %rdi     # 0x2cae4
callq 0x2090
movq 0x1f69c(%rip), %rax     # 0x31fc0
movq (%rax), %rdi
callq 0x21e0
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x87d3
movq %rax, %rdi
movq %rbx, %rsi
callq 0x83a5
movq %rax, 0x58(%rsp)
movq 0x30(%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 0x182c4(%rip), %rsi     # 0x2ac3d
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2240
leaq 0x182be(%rip), %rsi     # 0x2ac4b
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2240
leaq 0x17933(%rip), %rbp     # 0x2a2d4
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rax, %r14
leaq 0x182a3(%rip), %rdi     # 0x2ac59
movq %rbp, %rsi
callq 0x2210
movq %rax, 0x18(%rsp)
leaq 0x182a0(%rip), %rdi     # 0x2ac6a
movq %rbp, %rsi
callq 0x2210
movq %rax, %r12
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2210
movq %rax, %r13
leaq 0x1828f(%rip), %rdi     # 0x2ac79
movl $0x15, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2260
leaq 0x1a0f1(%rip), %rdi     # 0x2caf4
callq 0x2090
movq 0x1f5b1(%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, 0x58(%rsp)
movq %r13, %rdx
movq 0x60(%rsp), %rcx
movq %rbx, 0x40(%rsp)
movq %rbx, %r8
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
pushq %r11
pushq %r10
pushq %rax
callq 0xee5c
addq $0x30, %rsp
movl %eax, 0x48(%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xedbc
movq %r12, 0x40(%rsp)
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xedbc
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 0x181c5(%rip), %rdi     # 0x2ac8f
movl $0x13, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x181c0(%rip), %rdi     # 0x2aca3
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x181bc(%rip), %rdi     # 0x2acb8
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x181b8(%rip), %rsi     # 0x2accd
movq %r14, %rdi
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x2190
leaq 0x181b4(%rip), %rdi     # 0x2acdf
movl $0x22, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x181be(%rip), %rdi     # 0x2ad02
movl $0x61, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18207(%rip), %rdi     # 0x2ad64
movl $0x67, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18256(%rip), %rdi     # 0x2adcc
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x182a6(%rip), %rdi     # 0x2ae35
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x182f6(%rip), %rdi     # 0x2ae9e
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18346(%rip), %rdi     # 0x2af07
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18396(%rip), %rdi     # 0x2af70
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x183e6(%rip), %rdi     # 0x2afd9
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18436(%rip), %rdi     # 0x2b042
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18486(%rip), %rdi     # 0x2b0ab
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x184d6(%rip), %rdi     # 0x2b114
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18526(%rip), %rdi     # 0x2b17d
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18576(%rip), %rdi     # 0x2b1e6
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x185c6(%rip), %rdi     # 0x2b24f
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18616(%rip), %rdi     # 0x2b2b8
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18666(%rip), %rdi     # 0x2b321
movl $0x68, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x186b6(%rip), %rdi     # 0x2b38a
movl $0x61, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x186ff(%rip), %r15     # 0x2b3ec
movl $0x5, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x186e9(%rip), %rdi     # 0x2b3f2
movl $0x24, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x186f5(%rip), %rdi     # 0x2b417
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18740(%rip), %rdi     # 0x2b47b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1878b(%rip), %rdi     # 0x2b4df
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x187d6(%rip), %rdi     # 0x2b543
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18821(%rip), %rdi     # 0x2b5a7
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1886c(%rip), %rdi     # 0x2b60b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x188b7(%rip), %rdi     # 0x2b66f
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18902(%rip), %rdi     # 0x2b6d3
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1894d(%rip), %rdi     # 0x2b737
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18998(%rip), %rdi     # 0x2b79b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x189e3(%rip), %rdi     # 0x2b7ff
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18a2e(%rip), %rdi     # 0x2b863
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18a79(%rip), %rdi     # 0x2b8c7
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ac4(%rip), %rdi     # 0x2b92b
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b0f(%rip), %rdi     # 0x2b98f
movl $0x63, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b5a(%rip), %rdi     # 0x2b9f3
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 0x18b8e(%rip), %rdi     # 0x2ba55
movl $0x25, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18b9b(%rip), %rdi     # 0x2ba7b
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18be8(%rip), %rdi     # 0x2bae1
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c35(%rip), %rdi     # 0x2bb47
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18c82(%rip), %rdi     # 0x2bbad
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ccf(%rip), %rdi     # 0x2bc13
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d1c(%rip), %rdi     # 0x2bc79
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18d69(%rip), %rdi     # 0x2bcdf
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18db6(%rip), %rdi     # 0x2bd45
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18e03(%rip), %rdi     # 0x2bdab
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18e50(%rip), %rdi     # 0x2be11
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18e9d(%rip), %rdi     # 0x2be77
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18eea(%rip), %rdi     # 0x2bedd
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f37(%rip), %rdi     # 0x2bf43
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f84(%rip), %rdi     # 0x2bfa9
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fd1(%rip), %rdi     # 0x2c00f
movl $0x65, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1901e(%rip), %rdi     # 0x2c075
movl $0x5a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19060(%rip), %rdi     # 0x2c0d0
movl $0x7, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1904f(%rip), %rdi     # 0x2c0d8
movl $0x15, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1904c(%rip), %rdi     # 0x2c0ee
movl $0x17, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1904b(%rip), %rdi     # 0x2c106
movl $0x26, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19059(%rip), %rdi     # 0x2c12d
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x190f0(%rip), %r15     # 0x2c1dd
movl $0x2, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x2260
leaq 0x19040(%rip), %rdi     # 0x2c149
movl $0xa, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19032(%rip), %rdi     # 0x2c154
movl $0x1a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19034(%rip), %rdi     # 0x2c16f
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19088(%rip), %rdi     # 0x2c1dc
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1901e(%rip), %rdi     # 0x2c18b
movl $0x1d, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19055(%rip), %rdi     # 0x2c1db
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1900a(%rip), %rdi     # 0x2c1a9
movl $0x9, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18ffb(%rip), %rdi     # 0x2c1b3
movl $0x9, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fec(%rip), %rdi     # 0x2c1bd
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fdc(%rip), %rdi     # 0x2c1c6
movl $0x13, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fd7(%rip), %rdi     # 0x2c1da
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fc4(%rip), %rdi     # 0x2c1e0
movl $0x1f, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fcb(%rip), %rdi     # 0x2c200
movl $0x11, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fc4(%rip), %rdi     # 0x2c212
movl $0xe, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fba(%rip), %rdi     # 0x2c221
movl $0x1c, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fbe(%rip), %rdi     # 0x2c23e
movl $0xe, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fb4(%rip), %rdi     # 0x2c24d
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fa1(%rip), %rdi     # 0x2c253
movl $0x2a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f83(%rip), %rdi     # 0x2c24e
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f6b(%rip), %rdi     # 0x2c24f
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f81(%rip), %rdi     # 0x2c27e
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f6c(%rip), %rdi     # 0x2c282
movl $0x29, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f7d(%rip), %rdi     # 0x2c2ac
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 0x18f79(%rip), %rdi     # 0x2c2d6
movl $0x52b, %esi            # imm = 0x52B
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1948c(%rip), %rdi     # 0x2c802
movl $0x19, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1948d(%rip), %rdi     # 0x2c81c
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19479(%rip), %rdi     # 0x2c821
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x1eef7(%rip), %rbx     # 0x322b8
cmpl $0x0, (%rbx)
movq 0x20(%rsp), %r12
jle 0x133f6
leaq 0x19464(%rip), %r15     # 0x2c836
xorl %ebp, %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xced1
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2190
incl %ebp
cmpl (%rbx), %ebp
jl 0x133d4
leaq 0x19448(%rip), %rdi     # 0x2c845
movl $0x5, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19435(%rip), %rsi     # 0x2c84b
movq %r14, %rdi
movl 0x10(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x18db0(%rip), %rdi     # 0x2c1dd
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq %r14, %r15
movl %ebp, %r14d
testl %ebp, %ebp
movq 0x60(%rsp), %rbx
jle 0x13480
xorl %r13d, %r13d
movl (%rbx,%r13,4), %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xced1
movq %r15, %rdi
leaq 0x1940e(%rip), %rsi     # 0x2c877
movl %ebp, %edx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x2190
incq %r13
cmpq %r13, %r14
jne 0x13451
movq %r14, 0x30(%rsp)
movq 0x18(%rsp), %rdi
callq 0x20e0
leaq 0x177c3(%rip), %r14     # 0x2ac59
movq %r15, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xedbc
leaq 0x16e27(%rip), %rsi     # 0x2a2d4
movq %r14, %rdi
callq 0x2210
movq %rax, %r14
leaq 0x193e6(%rip), %rdi     # 0x2c8a5
movl $0x20, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2260
leaq 0x1ede0(%rip), %rax     # 0x322b8
cmpl $0x0, (%rax)
movq %rbx, %r12
movq %rax, %rbx
movq %r15, 0x18(%rsp)
jle 0x1352c
leaq 0x193d7(%rip), %rbp     # 0x2c8c6
xorl %r13d, %r13d
movq 0x20(%rsp), %rdi
movl %r13d, %esi
callq 0xced1
cmpb $0x31, (%rax)
je 0x13524
movq 0x20(%rsp), %rdi
movl %r13d, %esi
callq 0xced1
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2190
incl %r13d
cmpl (%rbx), %r13d
jl 0x134f2
leaq 0x193b0(%rip), %rdi     # 0x2c8e3
movl $0x17, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq %r14, %rdi
callq 0x20e0
movl 0x48(%rsp), %edx
incl %edx
leaq 0x176ff(%rip), %r15     # 0x2ac59
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xedbc
movq 0x40(%rsp), %rdi
callq 0x20e0
leaq 0x176ef(%rip), %r13     # 0x2ac6a
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xedbc
movq %r15, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
leaq 0x18cdc(%rip), %rdi     # 0x2c27e
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq 0x38(%rsp), %rdi
callq 0xc453
leaq 0x19336(%rip), %rdi     # 0x2c8fb
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x2110
leaq 0x16031(%rip), %rdi     # 0x29607
leaq 0xf(%rsp), %r15
movq %r15, %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
cmpb $0x79, (%r15)
jne 0x13625
movq 0x28(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r12, %rcx
movl $0x1, %r8d
movl $0x2, %r9d
pushq $0x0
movq 0x28(%rsp), %r13
pushq %r13
callq 0x17c7e
addq $0x10, %rsp
movq %rax, %r14
jmp 0x1362a
movq 0x20(%rsp), %r13
cmpb $0x6e, 0xf(%rsp)
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x13687
movq %r12, %rdi
movl 0x10(%rsp), %esi
movq 0x28(%rsp), %rdx
callq 0xbb8a
movq %rax, %r15
movq %rax, %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r12, %rcx
movl $0x1, %r8d
movl $0x2, %r9d
pushq $0x0
pushq %r13
callq 0x17c7e
addq $0x10, %rsp
movq %rax, %r14
movq %r15, %rdi
callq 0xc453
testq %r14, %r14
je 0x13a1a
leaq 0x175c2(%rip), %rdi     # 0x2ac59
leaq 0x16c36(%rip), %r15     # 0x2a2d4
movq %r15, %rsi
callq 0x2210
movq %rax, 0x38(%rsp)
leaq 0x175b8(%rip), %rdi     # 0x2ac6a
movq %r15, %rsi
callq 0x2210
movq %rax, 0x20(%rsp)
leaq 0x1943e(%rip), %rdi     # 0x2cb04
callq 0x2090
movq %r12, %rdi
movl $0x1, %esi
movq 0x28(%rsp), %rdx
callq 0xbed5
movq %rax, %r15
movl $0x1e, %edi
callq 0x21d0
movq %rax, %rbp
movl $0x1e, %edi
callq 0x21d0
movq %r13, %r12
movq %rax, %r13
subq $0x8, %rsp
movq %rbp, %rdi
movq %rax, %rsi
movq 0x58(%rsp), %rdx
movq %r14, 0x30(%rsp)
movq %r14, %rcx
movq %r15, %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 0xee5c
addq $0x30, %rsp
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xedbc
movq 0x20(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xedbc
movq %rbp, %rdi
callq 0x2070
movq %r13, %rdi
callq 0x2070
movq %rbp, %rdi
callq 0x2030
movq %r13, %rdi
callq 0x2030
movq %r15, %rdi
callq 0xc453
movl $0xa, %edi
callq 0x2040
movl (%rbx), %ecx
leaq 0x1918b(%rip), %rsi     # 0x2c92a
movq 0x18(%rsp), %r14
movq %r14, %rdi
movl 0x10(%rsp), %ebx
movl %ebx, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x18a22(%rip), %rdi     # 0x2c1dd
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x19197(%rip), %rdi     # 0x2c96b
movl $0x1b, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
movq 0x38(%rsp), %rdi
callq 0x20e0
movq %r14, %rdi
leaq 0x1745f(%rip), %r14     # 0x2ac59
movq %r14, %rsi
movl $0x1, %edx
callq 0xedbc
movq %r14, %rdi
leaq 0x16ac3(%rip), %rsi     # 0x2a2d4
callq 0x2210
movq %rax, %r15
testl %ebx, %ebx
movq 0x30(%rsp), %r14
jle 0x1385c
leaq 0x1915e(%rip), %rbx     # 0x2c987
xorl %r13d, %r13d
movq 0x60(%rsp), %rax
movl (%rax,%r13,4), %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xced1
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 0x1382c
leaq 0x1913d(%rip), %rdi     # 0x2c9a0
movl $0xa, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2260
movq %r15, %rdi
callq 0x20e0
movl 0x40(%rsp), %edx
incl %edx
leaq 0x173cf(%rip), %r12     # 0x2ac59
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xedbc
movq 0x20(%rsp), %rdi
callq 0x20e0
leaq 0x173bf(%rip), %rbx     # 0x2ac6a
movq %rbp, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0xedbc
leaq 0x190e9(%rip), %r13     # 0x2c9ab
movl $0xb, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rcx
callq 0x2260
leaq 0x189a0(%rip), %rdi     # 0x2c27e
movl $0x3, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190c0(%rip), %rdi     # 0x2c9b7
movl $0x20, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x188cd(%rip), %rdi     # 0x2c1dd
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190af(%rip), %rsi     # 0x2c9d8
movq %rbp, %rdi
movl 0x10(%rsp), %edx
xorl %eax, %eax
callq 0x2190
leaq 0x190b5(%rip), %rdi     # 0x2c9f3
movl $0x24, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190c1(%rip), %rdi     # 0x2ca18
movl $0x14, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190bd(%rip), %rdi     # 0x2ca2d
movl $0x15, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190ba(%rip), %rdi     # 0x2ca43
movl $0x13, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190b5(%rip), %rdi     # 0x2ca57
movl $0xe, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x190ab(%rip), %rdi     # 0x2ca66
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 0x18867(%rip), %rdi     # 0x2c250
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
movq 0x28(%rsp), %rdi
callq 0x7060
movq %r12, %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2070
jmp 0x13b6f
leaq 0x18f96(%rip), %rdi     # 0x2c9b7
movl $0x1, %ebx
movl $0x20, %esi
movl $0x1, %edx
movq 0x18(%rsp), %r14
movq %r14, %rcx
callq 0x2260
leaq 0x18799(%rip), %rdi     # 0x2c1dd
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f7b(%rip), %rsi     # 0x2c9d8
movq %r14, %rdi
movl 0x10(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x18f7f(%rip), %rdi     # 0x2c9f3
movl $0x24, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f8b(%rip), %rdi     # 0x2ca18
movl $0x14, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18f87(%rip), %rdi     # 0x2ca2d
movl $0x15, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
leaq 0x18fb8(%rip), %rdi     # 0x2ca77
movl $0xf, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x2260
cmpl $0x2, %ebp
movq %r14, %rbp
movq 0x30(%rsp), %r14
jl 0x13b0b
leaq 0x18fa2(%rip), %r15     # 0x2ca87
movl (%r12,%rbx,4), %esi
movq %r13, %rdi
callq 0xced1
movq %rbp, %rdi
movq %r15, %rsi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2190
incq %rbx
cmpq %rbx, %r14
jne 0x13ae5
leaq 0x18f45(%rip), %rdi     # 0x2ca57
movl $0xe, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18f3b(%rip), %rdi     # 0x2ca66
movl $0x10, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x18e67(%rip), %rdi     # 0x2c9ab
movl $0xb, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
leaq 0x186f3(%rip), %rdi     # 0x2c250
movl $0x2, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2260
movq 0x58(%rsp), %rdi
callq 0x7060
movq 0x50(%rsp), %rdi
callq 0x20e0
movq %rbp, %rdi
callq 0x20e0
leaq 0x18f84(%rip), %rdi     # 0x2cb16
callq 0x2090
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop