// File: /workspace/github_c_makefile_star2_O3/cbouilla[P]AES-attacks-finder/Solver.c
// Function: ExtraireEquationUnion
Equation * ExtraireEquationUnion(Solver B, SysEqLin E, int *taille) // Renvoi les equations de E(X1 u X2) - (E(X1) + E(X2)).
{
	// Attention : les équation sont de la forme Eq[i] = Eq[i + *taille], Eq[i] est en les variables X2

	/* A améliorer, elle est beaucoup trop lente et c'est la fonction la plus utilisée dans l'écriture du code C. */

	
	
	const int a=E->gen*VARIABLES;

	__restrict SysEqLin F = ExtraireEX2(B->var,B->Nvar,E);

	unsigned char ** __restrict m1=malloc(a*sizeof(unsigned char *));
	unsigned char ** __restrict m2=malloc(a*sizeof(unsigned char *));
	unsigned char ** __restrict m3=malloc(a*sizeof(unsigned char *));
	int i;
	for (i = 0; i < a; i++)
	{
		m1[i]=malloc(F->b*sizeof(unsigned char));
		m2[i]=malloc(F->b*sizeof(unsigned char));
		m3[i]=malloc(F->b*sizeof(unsigned char));
	}

	int b1=ExtraireEX(m1,B->fils1->var,B->fils1->Nvar,F);
	int b2=ExtraireEX(m2,B->fils2->var,B->fils2->Nvar,F);	
	
	int b3=Somme(m3,m1,b1,m2,a,b2);
	//b1=ExtraireEX(m1,B->var,B->Nvar,E);
	
	b2=Supplementaire(m2,m3,b3,F->mat,a,F->b);
	for (i = 0; i < a; i++)
	{
		free(m1[i]);
		free(m3[i]);
	}
	free(m1);
	free(m3);
	__restrict SysEqLin G=malloc(sizeof(SYSEQLIN));
	G->mat=m2;
	G->gen=F->gen;
	G->a=F->a;
	G->b=b2;
	//->lignevar=malloc((VARIABLES)*sizeof(int));
	//for (i = 0; i < VARIABLES; i++) F->lignevar[i]=E->lignevar[i];
	G->lignevar=F->lignevar;
	Equation * __restrict Eq=ConversionSys2(B->fils2->var,B->fils2->Nvar,G);
	//free(F->lignevar);
	for (i = 0; i < a; i++) free(m2[i]);
	free(m2);
	freeSysEq(F);
	free(G);
	*taille=b2;
	return Eq;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x20(%rsp)
movq %rsi, %rdx
movq %rdi, %rcx
leaq 0x28c7b(%rip), %rax     # 0x322b8
movl (%rax), %ebp
imull 0x10(%rsi), %ebp
movq (%rdi), %rdi
movq %rcx, 0x18(%rsp)
movl 0x8(%rcx), %esi
callq 0xbf32
movq %rax, 0x10(%rsp)
movslq %ebp, %r12
leaq (,%r12,8), %rbx
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r13
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r15
movq %rbx, %rdi
callq 0x21d0
movq %rax, %rbx
movl %ebp, 0xc(%rsp)
movl %ebp, %r14d
testl %r12d, %r12d
jle 0x96c8
movq 0x10(%rsp), %rax
movslq 0xc(%rax), %r12
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x21d0
movq %rax, (%r13,%rbp,8)
movq %r12, %rdi
callq 0x21d0
movq %rax, (%r15,%rbp,8)
movq %r12, %rdi
callq 0x21d0
movq %rax, (%rbx,%rbp,8)
incq %rbp
cmpq %rbp, %r14
jne 0x969b
movq 0x18(%rsp), %r12
movq 0x20(%r12), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
movq %r13, %rdi
movq 0x10(%rsp), %rbp
movq %rbp, %rcx
callq 0xb7c5
movl %eax, 0x8(%rsp)
movq 0x28(%r12), %rax
movq (%rax), %rsi
movl 0x8(%rax), %edx
movq %r15, %rdi
movq %rbp, %rcx
callq 0xb7c5
movq %rbx, %rdi
movq %r13, %rsi
movl 0x8(%rsp), %edx
movq %r15, %rcx
movl 0xc(%rsp), %r12d
movl %r12d, %r8d
movl %eax, %r9d
callq 0x3a5c
movq (%rbp), %rcx
movl 0xc(%rbp), %r9d
movq %r15, %rdi
movq %rbx, %rsi
movl %eax, %edx
movl %r12d, %r8d
callq 0x405a
movl %eax, 0x8(%rsp)
testl %r12d, %r12d
jle 0x975e
xorl %r12d, %r12d
movq (%r13,%r12,8), %rdi
callq 0x2030
movq (%rbx,%r12,8), %rdi
callq 0x2030
incq %r12
cmpq %r12, %r14
jne 0x9743
movq %r13, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movl $0x40, %edi
callq 0x21d0
movq %rax, %rbx
movq %r15, (%rax)
movl 0x10(%rbp), %eax
movl %eax, 0x10(%rbx)
movl 0x8(%rbp), %eax
movl %eax, 0x8(%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rbx)
movq 0x18(%rbp), %rax
movq %rax, 0x18(%rbx)
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movq %rbx, %rdx
callq 0xc630
movq %rax, %r12
cmpl $0x0, 0xc(%rsp)
jle 0x97ce
xorl %r13d, %r13d
movq (%r15,%r13,8), %rdi
callq 0x2030
incq %r13
cmpq %r13, %r14
jne 0x97bd
movq %r15, %rdi
callq 0x2030
movq %rbp, %rdi
callq 0xc82d
movq %rbx, %rdi
callq 0x2030
movq 0x20(%rsp), %rax
movl 0x8(%rsp), %ecx
movl %ecx, (%rax)
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq