// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/EquationAES.c
// Function: MakeEquations
Equation * MakeEquations(int Nk, int Tours, int Final, int Messages, int *N)
{
	int NombreEtat,NombreCstRonde,NombreEqKS,NombreEqMC,NombreEqSS,NombreEqAK;
	Equation *Eq;
	int i,j,pos,taille,state,key;
	
	NombreEtat=Tours+Final+1+Messages*(2*Tours+Final+2);
	NombreCstRonde=Tours+Final;
	VARIABLES=16*NombreEtat+NombreCstRonde;
	NombreEqKS=((Tours+Final+1)*4-Nk)*4;
	NombreEqMC=16*Tours*Messages;
	NombreEqSS=16*(Tours+Final)*Messages;
	NombreEqAK=16*Messages;
	taille=NombreEqKS+NombreEqMC+NombreEqSS+NombreEqAK;
	printf("taille = %d, Variables = %d\n",taille,VARIABLES);
	Eq=malloc(taille*sizeof(Equation));
	pos=MakeKS(Eq,Nk,Tours,Final);
	state=(Tours+Final+1);
	for (i = 0; i < Messages; i++)
	{
		key=0;
		for (j = 0; j < Tours; j++)
		{
			pos+=MakeSS(Eq+pos,key,state,state+1);
			state++;
			pos+=MakeMC(Eq+pos,state,state+1);
			state++;
			key++;
		}
		for (j = 0; j < Final; j++)
		{
			pos+=MakeSS(Eq+pos,key,state,state+1);
			state++;
			key++;
		}
		pos+=MakeAK(Eq+pos,key,state,state+1);
		state+=2;
	}
	/*for (i = 0; i < pos; i++)
	{
		printf("Eq[%d] : ",i);
		PrintEq(Eq[i]);
		printf("\n");
	}
	getchar();
	*/
	*N=taille;
	return Eq;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
addl $0x1, %eax
movl -0x10(%rbp), %ecx
movl -0x8(%rbp), %edx
shll %edx
addl -0xc(%rbp), %edx
addl $0x2, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
shll $0x4, %eax
addl -0x20(%rbp), %eax
movl %eax, 0x34929(%rip)     # 0x3d2c8
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
addl $0x1, %eax
shll $0x2, %eax
subl -0x4(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
shll $0x4, %eax
imull -0x10(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
shll $0x4, %eax
imull -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x10(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
addl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %esi
movl 0x348d6(%rip), %edx     # 0x3d2c8
leaq 0x2c768(%rip), %rdi     # 0x35161
movb $0x0, %al
callq 0x2100
movslq -0x48(%rbp), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x4(%rbp), %esi
movl -0x8(%rbp), %edx
movl -0xc(%rbp), %ecx
callq 0x81d0
movl %eax, -0x44(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x8b59
movl $0x0, -0x50(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8aca
movq -0x38(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
callq 0x8810
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x4c(%rbp), %esi
movl -0x4c(%rbp), %edx
addl $0x1, %edx
callq 0x85e0
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x8a53
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x8b1c
movq -0x38(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
callq 0x8810
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x8ad1
movq -0x38(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
callq 0x84d0
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8a39
movl -0x48(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)