// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq 0x1b635(%rip), %rdi     # 0x36ddf
movb $0x0, %al
callq 0x2100
movq -0x30(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0xb340
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0xd9c0
cmpl $0x1, %eax
jne 0x1b81e
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1b802
movq -0x40(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x93b0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1b7de
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x30(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0xb340
movq %rax, -0x40(%rbp)
jmp 0x1b7c2
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1b849
movq -0x40(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x93b0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1b825
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x11aa0
movq %rax, -0x78(%rbp)
leaq 0x1b5a8(%rip), %rdi     # 0x36e15
movb $0x0, %al
callq 0x2100
movq 0x2174d(%rip), %rax     # 0x3cfc8
movq (%rax), %rdi
callq 0x21d0
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xc050
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xb980
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20e0
addq $0x1, %rax
addq $0xb, %rax
movl %eax, -0x58(%rbp)
movslq -0x58(%rbp), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, -0x68(%rbp)
movslq -0x58(%rbp), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1b536(%rip), %rsi     # 0x36e26
movb $0x0, %al
callq 0x2230
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1b52e(%rip), %rsi     # 0x36e34
movb $0x0, %al
callq 0x2230
movq -0x68(%rbp), %rdi
leaq 0x1ab5e(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0xb0(%rbp)
leaq 0x1b517(%rip), %rdi     # 0x36e42
leaq 0x1ab44(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0x98(%rbp)
leaq 0x1b50e(%rip), %rdi     # 0x36e53
leaq 0x1ab2a(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0xa0(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x1ab13(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
leaq 0x1b4e5(%rip), %rsi     # 0x36e62
movb $0x0, %al
callq 0x2180
leaq 0x1b4ed(%rip), %rdi     # 0x36e78
movb $0x0, %al
callq 0x2100
movq 0x2162f(%rip), %rax     # 0x3cfc8
movq (%rax), %rdi
callq 0x21d0
movl $0x1e, %edi
callq 0x21c0
movq %rax, -0xb8(%rbp)
movl $0x1e, %edi
callq 0x21c0
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x78(%rbp), %r8
xorl %r9d, %r9d
leaq -0x54(%rbp), %r11
leaq -0x80(%rbp), %r10
leaq -0x88(%rbp), %rax
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0x16640
movl %eax, -0x5c(%rbp)
movq -0x98(%rbp), %rdi
movq -0xb8(%rbp), %rsi
xorl %edx, %edx
callq 0x16590
movq -0xa0(%rbp), %rdi
movq -0xc0(%rbp), %rsi
xorl %edx, %edx
callq 0x16590
movq -0xb8(%rbp), %rdi
callq 0x2060
movq -0xc0(%rbp), %rdi
callq 0x2060
movq -0xb8(%rbp), %rdi
callq 0x2030
movq -0xc0(%rbp), %rdi
callq 0x2030
leaq 0x1b45b(%rip), %rdi     # 0x36ed7
movb $0x0, %al
callq 0x2100
movq -0xb0(%rbp), %rdi
leaq 0x1b3f8(%rip), %rsi     # 0x36e89
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b3f7(%rip), %rsi     # 0x36e9d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b3f7(%rip), %rsi     # 0x36eb2
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1b3f3(%rip), %rsi     # 0x36ec7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b3f0(%rip), %rsi     # 0x36ed9
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b3fe(%rip), %rsi     # 0x36efc
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b44b(%rip), %rsi     # 0x36f5e
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b49e(%rip), %rsi     # 0x36fc6
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b4f2(%rip), %rsi     # 0x3702f
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b546(%rip), %rsi     # 0x37098
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b59a(%rip), %rsi     # 0x37101
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b5ee(%rip), %rsi     # 0x3716a
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b642(%rip), %rsi     # 0x371d3
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b696(%rip), %rsi     # 0x3723c
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b6ea(%rip), %rsi     # 0x372a5
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b73e(%rip), %rsi     # 0x3730e
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b792(%rip), %rsi     # 0x37377
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b7e6(%rip), %rsi     # 0x373e0
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b83a(%rip), %rsi     # 0x37449
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b88e(%rip), %rsi     # 0x374b2
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b8e2(%rip), %rsi     # 0x3751b
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b936(%rip), %rsi     # 0x37584
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b983(%rip), %rsi     # 0x375e6
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b974(%rip), %rsi     # 0x375ec
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b984(%rip), %rsi     # 0x37611
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b9d3(%rip), %rsi     # 0x37675
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1ba22(%rip), %rsi     # 0x376d9
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1ba71(%rip), %rsi     # 0x3773d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bac0(%rip), %rsi     # 0x377a1
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bb0f(%rip), %rsi     # 0x37805
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bb5e(%rip), %rsi     # 0x37869
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bbad(%rip), %rsi     # 0x378cd
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bbfc(%rip), %rsi     # 0x37931
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bc4b(%rip), %rsi     # 0x37995
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bc9a(%rip), %rsi     # 0x379f9
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bce9(%rip), %rsi     # 0x37a5d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bd38(%rip), %rsi     # 0x37ac1
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bd87(%rip), %rsi     # 0x37b25
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bdd6(%rip), %rsi     # 0x37b89
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1be25(%rip), %rsi     # 0x37bed
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b809(%rip), %rsi     # 0x375e6
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1be5d(%rip), %rsi     # 0x37c4f
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1be6e(%rip), %rsi     # 0x37c75
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bebf(%rip), %rsi     # 0x37cdb
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bf10(%rip), %rsi     # 0x37d41
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bf61(%rip), %rsi     # 0x37da7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bfb2(%rip), %rsi     # 0x37e0d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c003(%rip), %rsi     # 0x37e73
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c054(%rip), %rsi     # 0x37ed9
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c0a5(%rip), %rsi     # 0x37f3f
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c0f6(%rip), %rsi     # 0x37fa5
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c147(%rip), %rsi     # 0x3800b
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c198(%rip), %rsi     # 0x38071
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c1e9(%rip), %rsi     # 0x380d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c23a(%rip), %rsi     # 0x3813d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c28b(%rip), %rsi     # 0x381a3
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c2dc(%rip), %rsi     # 0x38209
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c32d(%rip), %rsi     # 0x3826f
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c373(%rip), %rsi     # 0x382ca
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c366(%rip), %rsi     # 0x382d2
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c367(%rip), %rsi     # 0x382e8
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c36a(%rip), %rsi     # 0x38300
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c37c(%rip), %rsi     # 0x38327
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c417(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c36e(%rip), %rsi     # 0x38343
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c364(%rip), %rsi     # 0x3834e
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c36a(%rip), %rsi     # 0x38369
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c3c2(%rip), %rsi     # 0x383d6
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c35c(%rip), %rsi     # 0x38385
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c397(%rip), %rsi     # 0x383d5
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c350(%rip), %rsi     # 0x383a3
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c345(%rip), %rsi     # 0x383ad
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c33a(%rip), %rsi     # 0x383b7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c32e(%rip), %rsi     # 0x383c0
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c32d(%rip), %rsi     # 0x383d4
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c31e(%rip), %rsi     # 0x383da
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c329(%rip), %rsi     # 0x383fa
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c326(%rip), %rsi     # 0x3840c
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c320(%rip), %rsi     # 0x3841b
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c328(%rip), %rsi     # 0x38438
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c322(%rip), %rsi     # 0x38447
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c313(%rip), %rsi     # 0x3844d
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c2f9(%rip), %rsi     # 0x38448
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c2e5(%rip), %rsi     # 0x38449
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c2ff(%rip), %rsi     # 0x38478
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c2ee(%rip), %rsi     # 0x3847c
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c303(%rip), %rsi     # 0x384a6
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c21f(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c303(%rip), %rsi     # 0x384d0
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c81a(%rip), %rsi     # 0x389fc
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c81f(%rip), %rsi     # 0x38a16
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c80f(%rip), %rsi     # 0x38a1b
movb $0x0, %al
callq 0x2180
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
leaq 0x210a4(%rip), %rcx     # 0x3d2c8
cmpl (%rcx), %eax
jge 0x1c274
movq -0xb0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq -0x38(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x12fc0
movq -0xf0(%rbp), %rdi
movl -0xe4(%rbp), %edx
movq %rax, %rcx
leaq 0x1c7ce(%rip), %rsi     # 0x38a30
movb $0x0, %al
callq 0x2180
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c21a
movq -0xb0(%rbp), %rdi
leaq 0x1c7bd(%rip), %rsi     # 0x38a3f
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x1c7ab(%rip), %rsi     # 0x38a45
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c128(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1c330
movq -0xb0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xf8(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0xf4(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x12fc0
movq -0x100(%rbp), %rdi
movl -0xf8(%rbp), %edx
movl -0xf4(%rbp), %ecx
movq %rax, %r8
leaq 0x1c753(%rip), %rsi     # 0x38a71
movb $0x0, %al
callq 0x2180
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c2bd
movq -0x98(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
leaq 0x1aaf8(%rip), %rsi     # 0x36e42
movl $0x1, %edx
callq 0x16590
leaq 0x1aae7(%rip), %rdi     # 0x36e42
leaq 0x1a114(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
leaq 0x1c723(%rip), %rsi     # 0x38a9f
movb $0x0, %al
callq 0x2180
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
leaq 0x20f34(%rip), %rcx     # 0x3d2c8
cmpl (%rcx), %eax
jge 0x1c3ff
movq -0x38(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x12fc0
movq %rax, %rdi
leaq 0x18daa(%rip), %rsi     # 0x35158
movl $0x1, %edx
callq 0x2070
cmpl $0x0, %eax
je 0x1c3f2
movq -0x98(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x38(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x12fc0
movq -0x108(%rbp), %rdi
movq %rax, %rdx
movl -0x50(%rbp), %ecx
leaq 0x1c6d5(%rip), %rsi     # 0x38ac0
movb $0x0, %al
callq 0x2180
jmp 0x1c3f4
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c38a
movq -0x98(%rbp), %rdi
leaq 0x1c6d0(%rip), %rsi     # 0x38add
movb $0x0, %al
callq 0x2180
movq -0x98(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
movl -0x5c(%rbp), %edx
addl $0x1, %edx
leaq 0x1aa0e(%rip), %rsi     # 0x36e42
callq 0x16590
movq -0xa0(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
leaq 0x1aa00(%rip), %rsi     # 0x36e53
movl $0x1, %edx
callq 0x16590
leaq 0x1a9de(%rip), %rdi     # 0x36e42
callq 0x2060
leaq 0x1a9e3(%rip), %rdi     # 0x36e53
callq 0x2060
movq -0xb0(%rbp), %rdi
leaq 0x1bff5(%rip), %rsi     # 0x38478
movb $0x0, %al
callq 0x2180
movq -0x78(%rbp), %rdi
callq 0x12220
leaq 0x1c65b(%rip), %rdi     # 0x38af5
movb $0x0, %al
callq 0x2100
leaq 0x194fb(%rip), %rdi     # 0x359a3
leaq -0xc1(%rbp), %rsi
movb $0x0, %al
callq 0x2220
callq 0x2170
movq $0x0, -0xd0(%rbp)
movsbl -0xc1(%rbp), %eax
cmpl $0x79, %eax
jne 0x1c50b
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movl $0x1, %r8d
movl $0x2, %r9d
xorl %edx, %edx
movl %r8d, %esi
movl %r8d, %edx
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x23800
movq %rax, -0xd0(%rbp)
movsbl -0xc1(%rbp), %eax
cmpl $0x6e, %eax
je 0x1c521
cmpq $0x0, -0xd0(%rbp)
jne 0x1c577
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x115e0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movl $0x1, %r8d
movl $0x2, %r9d
xorl %edx, %edx
movl %r8d, %esi
movl %r8d, %edx
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x23800
movq %rax, -0xd0(%rbp)
movq -0x78(%rbp), %rdi
callq 0x12220
cmpq $0x0, -0xd0(%rbp)
je 0x1c96e
leaq 0x1a8b6(%rip), %rdi     # 0x36e42
leaq 0x19ee3(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0x98(%rbp)
leaq 0x1a8ad(%rip), %rdi     # 0x36e53
leaq 0x19ec9(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0xa0(%rbp)
leaq 0x1c564(%rip), %rdi     # 0x38b24
movb $0x0, %al
callq 0x2100
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rdx
movl $0x1, %esi
callq 0x11aa0
movq %rax, -0x78(%rbp)
movl $0x1e, %edi
callq 0x21c0
movq %rax, -0xd8(%rbp)
movl $0x1e, %edi
callq 0x21c0
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq -0x78(%rbp), %r8
movl $0x1, %r9d
leaq -0x54(%rbp), %r11
leaq -0x80(%rbp), %r10
leaq -0x88(%rbp), %rax
xorl %ebx, %ebx
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0x16640
movl %eax, -0x5c(%rbp)
movq -0x98(%rbp), %rdi
movq -0xd8(%rbp), %rsi
xorl %edx, %edx
callq 0x16590
movq -0xa0(%rbp), %rdi
movq -0xe0(%rbp), %rsi
xorl %edx, %edx
callq 0x16590
movq -0xd8(%rbp), %rdi
callq 0x2060
movq -0xe0(%rbp), %rdi
callq 0x2060
movq -0xd8(%rbp), %rdi
callq 0x2030
movq -0xe0(%rbp), %rdi
callq 0x2030
movq -0x78(%rbp), %rdi
callq 0x12220
leaq 0x1a80e(%rip), %rdi     # 0x36ed7
movb $0x0, %al
callq 0x2100
movq -0xb0(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x20be7(%rip), %rax     # 0x3d2c8
movl (%rax), %ecx
leaq 0x1c44d(%rip), %rsi     # 0x38b37
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bcd8(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c464(%rip), %rsi     # 0x38b78
movb $0x0, %al
callq 0x2180
movq -0x98(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
leaq 0x1a70d(%rip), %rsi     # 0x36e42
movl $0x1, %edx
callq 0x16590
leaq 0x1a6fc(%rip), %rdi     # 0x36e42
leaq 0x19d29(%rip), %rsi     # 0x36476
callq 0x2200
movq %rax, -0x98(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1c7d3
movq -0x98(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x10c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x12fc0
movq -0x118(%rbp), %rdi
movl -0x110(%rbp), %edx
movl -0x10c(%rbp), %ecx
movq %rax, %r8
leaq 0x1c3d3(%rip), %rsi     # 0x38b94
movb $0x0, %al
callq 0x2180
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1c760
movq -0x98(%rbp), %rdi
leaq 0x1c3cc(%rip), %rsi     # 0x38bad
movb $0x0, %al
callq 0x2180
movq -0x98(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
movl -0x5c(%rbp), %edx
addl $0x1, %edx
leaq 0x1a63a(%rip), %rsi     # 0x36e42
callq 0x16590
movq -0xa0(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
leaq 0x1a62c(%rip), %rsi     # 0x36e53
movl $0x1, %edx
callq 0x16590
movq -0xb0(%rbp), %rdi
leaq 0x1c379(%rip), %rsi     # 0x38bb8
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bc24(%rip), %rsi     # 0x38478
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c35b(%rip), %rsi     # 0x38bc4
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bb59(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x1c34f(%rip), %rsi     # 0x38be5
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c355(%rip), %rsi     # 0x38c00
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c365(%rip), %rsi     # 0x38c25
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c365(%rip), %rsi     # 0x38c3a
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c366(%rip), %rsi     # 0x38c50
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c365(%rip), %rsi     # 0x38c64
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c35f(%rip), %rsi     # 0x38c73
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c28f(%rip), %rsi     # 0x38bb8
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1bb0c(%rip), %rsi     # 0x3844a
movb $0x0, %al
callq 0x2180
movq -0xd0(%rbp), %rdi
callq 0x93b0
leaq 0x1a4ea(%rip), %rdi     # 0x36e42
callq 0x2060
leaq 0x1a4ef(%rip), %rdi     # 0x36e53
callq 0x2060
jmp 0x1cabb
movq -0xb0(%rbp), %rdi
leaq 0x1c248(%rip), %rsi     # 0x38bc4
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1ba46(%rip), %rsi     # 0x383d7
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x1c23c(%rip), %rsi     # 0x38be5
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c242(%rip), %rsi     # 0x38c00
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c252(%rip), %rsi     # 0x38c25
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c252(%rip), %rsi     # 0x38c3a
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c287(%rip), %rsi     # 0x38c84
movb $0x0, %al
callq 0x2180
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1ca67
movq -0xb0(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x11c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x12fc0
movq -0x128(%rbp), %rdi
movl -0x11c(%rbp), %edx
movq %rax, %rcx
leaq 0x1c23f(%rip), %rsi     # 0x38c94
movb $0x0, %al
callq 0x2180
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1ca0b
movq -0xb0(%rbp), %rdi
leaq 0x1c1ef(%rip), %rsi     # 0x38c64
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c1e9(%rip), %rsi     # 0x38c73
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1c119(%rip), %rsi     # 0x38bb8
movb $0x0, %al
callq 0x2180
movq -0xb0(%rbp), %rdi
leaq 0x1b996(%rip), %rsi     # 0x3844a
movb $0x0, %al
callq 0x2180
movq -0x48(%rbp), %rdi
callq 0x93b0
movq -0xa8(%rbp), %rdi
callq 0x20d0
movq -0xb0(%rbp), %rdi
callq 0x20d0
leaq 0x1c1d9(%rip), %rdi     # 0x38cbc
movb $0x0, %al
callq 0x2100
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop