// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/EquationAES.c
// Function: MakeEquations2
Equation * MakeEquations2(int Nk, int Tours, int Final, int Messages, int *N)
{
  Equation *Eq,*Eq2,tmp1,tmp2;/*,tmp3;*/
	int i,j,dec,pos;
	/*int t;*/
	Eq=MakeEquations(Nk,Tours,Final,Messages,N);
	*N=*N+(Messages-1)*15;
	Eq2=malloc((*N+1)*sizeof(Equation));
	dec=(Tours+Final+1)*16;
	pos=0;
	for (i = 1; i < 16; i++)
	{
		for (j = 1; j < Messages; j++)
		{
			tmp1=varEq(dec+i);
			tmp2=varEq((2*(Tours+Final)+1)*16*j+dec+i);
			Eq2[pos++]=addEq(tmp1,tmp2);
			freeEq(tmp1);
			freeEq(tmp2);
		}
	}
	for (i = 0; i < *N-(Messages-1)*15; i++) Eq2[pos++]=Eq[i];
	free(Eq);
	/*for (i = dec; i < 176; i++)
	{
		printf("%d / %d\n",i-dec,176-dec);
		tmp1=varEq(i);
		tmp2=varEq(i+176-dec);
		Eq2[*N]=addEq(tmp1,tmp2);
		t=SimplifySysEq(Eq2,*N+1);
		if (t<=*N)
		{
			freeEq(tmp1);
			tmp1=varEq(i);
			for (j = 0; j < *N; j++)
			{
				tmp3=remplaceEq(Eq2[j],i+176-dec,tmp1);
				freeEq(Eq2[j]);
				Eq2[j]=tmp3;
			}
			*N=SimplifySysEq(Eq2,t);
		}
		else freeEq(Eq2[*N]);
		freeEq(tmp1);
		freeEq(tmp2);
		tmp3=varEq(i);
		tmp1=appliqueS(tmp3,0);
		freeEq(tmp3);
		tmp3=varEq(i+176-dec);
		tmp2=appliqueS(tmp3,0);
		freeEq(tmp3);
		Eq2[*N]=addEq(tmp1,tmp2);
		t=SimplifySysEq(Eq2,*N+1);
		if (t<=*N)
		{
			freeEq(tmp1);
			tmp1=varEq(i);
			for (j = 0; j < *N; j++)
			{
				tmp3=remplaceEq(Eq2[j],i+176-dec,tmp1);
				freeEq(Eq2[j]);
				Eq2[j]=tmp3;
			}
			*N=SimplifySysEq(Eq2,t);
		}
		else freeEq(Eq2[*N]);
		freeEq(tmp1);
		freeEq(tmp2);
		tmp3=varEq(i);
		tmp1=appliqueS(tmp3,1);
		freeEq(tmp3);
		tmp3=varEq(i+176-dec);
		tmp2=appliqueS(tmp3,1);
		freeEq(tmp3);
		Eq2[*N]=addEq(tmp1,tmp2);
		t=SimplifySysEq(Eq2,*N+1);
		if (t<=*N)
		{
			freeEq(tmp1);
			tmp1=varEq(i);
			for (j = 0; j < *N; j++)
			{
				tmp3=remplaceEq(Eq2[j],i+176-dec,tmp1);
				freeEq(Eq2[j]);
				Eq2[j]=tmp3;
			}
			*N=SimplifySysEq(Eq2,t);
		}
		else freeEq(Eq2[*N]);
		freeEq(tmp1);
		freeEq(tmp2);
	}*/
	return Eq2;
}

// 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 -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movq -0x18(%rbp), %r8
callq 0x8950
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movl -0x10(%rbp), %eax
subl $0x1, %eax
imull $0xf, %eax, %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
addl $0x1, %eax
shll $0x4, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x1, -0x3c(%rbp)
cmpl $0x10, -0x3c(%rbp)
jge 0x907a
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x906a
movl -0x44(%rbp), %edi
addl -0x3c(%rbp), %edi
callq 0x5da0
movq %rax, -0x30(%rbp)
movl -0x8(%rbp), %edi
addl -0xc(%rbp), %edi
shll %edi
addl $0x1, %edi
shll $0x4, %edi
imull -0x40(%rbp), %edi
addl -0x44(%rbp), %edi
addl -0x3c(%rbp), %edi
callq 0x5da0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6900
movq %rax, %rdx
movq -0x28(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x48(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x38(%rbp), %rdi
callq 0x5900
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x8fef
jmp 0x906c
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8fde
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
movl -0x10(%rbp), %edx
subl $0x1, %edx
imull $0xf, %edx, %edx
subl %edx, %ecx
cmpl %ecx, %eax
jge 0x90c6
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x48(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x9081
movq -0x20(%rbp), %rdi
callq 0x2030
movq -0x28(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)