// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/Equation.c
// Function: RemonteSysEq
Equation * RemonteSysEq(Equation *E, int N, int *N1, int *Known, int Nconnu)
{
	Equation *Eq,*Eq2,tmp,tmp1;
	int *V,*F,*F1,n,n1,n2,i,j,k,pos1,pos2;
	Eq=malloc(N*sizeof(Equation));
	for (i = 0; i < N; i++) Eq[i]=copyEq(E[i]);
	Eq2=malloc(N*sizeof(Equation));
	pos1=0;
	pos2=N-1;
	F=malloc(Nconnu*sizeof(int));
	for (i = 0; i < Nconnu; i++) F[i]=Known[i];	
	n=Nconnu;
	for (i = 0; i < N; i++)
	{
		V=VarsDedans(Eq[i],&n1);
		Tri(V,n1);
		/*
		printf("V : ");
		PrintListe(V,n1);
		printf("F : ");
		PrintListe(F,n);
		*/
		for (j = n1-1; j >= 0; j--)
		{
			if (SearchElement(V[j],F,n)==-1 && apparaitEq(Eq[i],V[j])==1)
			{
				tmp=inverseEq(Eq[i],V[j]);
				/*
				  printf("%d = ",V[j]);
				  PrintEq(tmp);
				  printf("\n");
				  getchar();
				*/
				for (k = i+1; k < N; k++)
				{
					tmp1=remplaceEq(Eq[k],V[j],tmp);
					freeEq(Eq[k]);
					Eq[k]=tmp1;
				}
				Eq2[pos2--]=copyEq(Eq[i]);
				break;
			}
		}
		if (j==-1) Eq2[pos1++]=copyEq(Eq[i]);
		F1=UnionListesTriees(F,n,V,n1,&n2);
		free(F);
		free(V);
		F=F1;
		n=n2;	
	}
	*N1=pos1;
	for (i = 0; i < N; i++) freeEq(Eq[i]);
	free(Eq);
	return Eq2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x30(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7d89
movq -0x8(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x59c0
movq %rax, %rdx
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7d56
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x38(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x80(%rbp)
movslq -0x24(%rbp), %rdi
shlq $0x2, %rdi
callq 0x21c0
movq %rax, -0x58(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7deb
movq -0x20(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x58(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7dc2
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7fb7
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x68(%rbp), %rsi
callq 0x7b30
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movl -0x68(%rbp), %esi
callq 0x2e10
movl -0x68(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x74(%rbp)
jl 0x7f3e
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x58(%rbp), %rsi
movl -0x64(%rbp), %edx
callq 0x2b60
cmpl $-0x1, %eax
jne 0x7f2e
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x6c40
cmpl $0x1, %eax
jne 0x7f2e
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x71b0
movq %rax, -0x40(%rbp)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7f02
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq -0x40(%rbp), %rdx
callq 0x6e70
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5900
movq -0x48(%rbp), %rdx
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x7eaa
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x59c0
movq %rax, %rdx
movq -0x38(%rbp), %rax
movl -0x80(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x80(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x7f3e
jmp 0x7f30
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x7e32
cmpl $-0x1, -0x74(%rbp)
jne 0x7f6e
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x59c0
movq %rax, %rdx
movq -0x38(%rbp), %rax
movl -0x7c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x7c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x58(%rbp), %rdi
movl -0x64(%rbp), %esi
movq -0x50(%rbp), %rdx
movl -0x68(%rbp), %ecx
leaq -0x6c(%rbp), %r8
callq 0x24e0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x2030
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7df8
movl -0x7c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x7feb
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5900
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7fc7
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x38(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)