// File: /workspace/github_c_makefile_star2_O1/cbouilla[P]AES-attacks-finder/SysEqLin.c
// Function: Transform2
SysEqLin Transform2(Equation *Eq, int taille, int gen) // Transforme une système d'équations en SysEqLin
{
	Equation *A;
	SysEqLin E;
	int i,*dedans,j,NA;
	A=Linearise(Eq,taille,&NA); // Probablement inutile maintenant
#if DISPLAY_EQUATIONS==1
	for (i = 0; i < NA; i++)
	{
		printf("Eq[%d] : ",i);
		PrintEq(A[i]);
		printf("\n");
	}
#endif
	E=malloc(sizeof(SYSEQLIN));
	E->a=gen*VARIABLES;
	E->b=NA;
	E->gen=gen;
	E->mat=malloc(E->a*sizeof(unsigned char *));
	dedans=malloc(VARIABLES*sizeof(int));
	for (i = 0; i < VARIABLES; i++) dedans[i]=0;
	for (i = 0; i < E->a; i++)
	{
		E->mat[i]=malloc(NA*sizeof(unsigned char));
		for (j = 0; j < NA; j++) E->mat[i][j]=0;
	}
	for (i = 0; i < NA; i++)
	{
		for (j = 0; j < A[i]->nV; j++)
		{
			E->mat[gen*A[i]->var[j]][i]^=A[i]->coefV[j];
			dedans[A[i]->var[j]]=1;
		}
		for (j = 0; j < A[i]->nS; j++)
		{
			E->mat[gen*A[i]->S[j]->var[0]+A[i]->sbox[j]+1][i]^=A[i]->coefS[j];
			dedans[A[i]->S[j]->var[0]]=1;
		}
		freeEq(A[i]);
	}
	free(A);
	E->varligne=malloc(VARIABLES*sizeof(int));
	E->lignevar=malloc(VARIABLES*sizeof(int));
	for (i = 0; i < VARIABLES; i++) E->varligne[i]=i;
	for (i = 0; i < VARIABLES; i++) E->lignevar[i]=i;
	for (i = 0; i < VARIABLES; i++)
	{
		if (dedans[i]==0)
		{
			E->a=E->a-gen;
			PermuterVar(i,E->varligne[E->a/gen],E);
		}
	}
	E->initialise=0;
	return E;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
leaq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0x5afe
movq %rax, %r12
movl $0x40, %edi
callq 0x21d0
movq %rax, %r13
leaq 0x270f5(%rip), %rax     # 0x322b8
movslq (%rax), %rbx
movl %ebx, %r14d
imull %ebp, %r14d
movl %r14d, 0x8(%r13)
movl (%r15), %eax
movl %eax, 0xc(%r13)
movl %ebp, 0xc(%rsp)
movl %ebp, 0x10(%r13)
movslq %r14d, %rdi
shlq $0x3, %rdi
callq 0x21d0
movq %rax, %rbp
movq %r13, 0x20(%rsp)
movq %rax, (%r13)
leaq (,%rbx,4), %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, %r15
movq %rbx, 0x18(%rsp)
testq %rbx, %rbx
jle 0xb222
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2120
movq %r13, 0x10(%rsp)
testl %r14d, %r14d
jle 0xb268
movl %r14d, %r14d
xorl %ebx, %ebx
movslq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, (%rbp,%rbx,8)
testq %r13, %r13
jle 0xb260
xorl %eax, %eax
movq (%rbp,%rbx,8), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
movslq 0x8(%rsp), %rcx
cmpq %rcx, %rax
jl 0xb24a
incq %rbx
cmpq %r14, %rbx
jne 0xb231
cmpl $0x0, 0x8(%rsp)
movl 0xc(%rsp), %ebx
jle 0xb342
xorl %r13d, %r13d
movslq %ebx, %r14
movq (%r12,%r13,8), %rcx
cmpl $0x0, (%rcx)
jle 0xb2c7
xorl %eax, %eax
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rcx
movb (%rcx,%rax), %cl
movslq (%rdx,%rax,4), %rdx
imulq %r14, %rdx
movq (%rbp,%rdx,8), %rdx
xorb %cl, (%rdx,%r13)
movq (%r12,%r13,8), %rcx
movq 0x8(%rcx), %rcx
movslq (%rcx,%rax,4), %rcx
movl $0x1, (%r15,%rcx,4)
incq %rax
movq (%r12,%r13,8), %rcx
movslq (%rcx), %rdx
cmpq %rdx, %rax
jl 0xb288
movq (%r12,%r13,8), %rdi
cmpl $0x0, 0x18(%rdi)
jle 0xb32c
xorl %eax, %eax
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %rdx
movb (%rdx,%rax), %dl
movq (%rcx,%rax,8), %rcx
movq 0x8(%rcx), %rcx
movslq (%rcx), %rcx
imulq %r14, %rcx
movq 0x30(%rdi), %rsi
movzbl (%rsi,%rax), %esi
addq %rcx, %rsi
movq 0x8(%rbp,%rsi,8), %rcx
xorb %dl, (%rcx,%r13)
movq (%r12,%r13,8), %rcx
movq 0x20(%rcx), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x8(%rcx), %rcx
movslq (%rcx), %rcx
movl $0x1, (%r15,%rcx,4)
incq %rax
movq (%r12,%r13,8), %rdi
movslq 0x18(%rdi), %rcx
cmpq %rcx, %rax
jl 0xb2d3
callq 0x484f
incq %r13
movslq 0x8(%rsp), %rax
cmpq %rax, %r13
jl 0xb27d
movq %r12, %rdi
callq 0x2030
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, %r12
movq 0x20(%rsp), %r14
movq %rax, 0x20(%r14)
movq %r13, %rdi
callq 0x21d0
movq %rax, 0x18(%r14)
movq 0x18(%rsp), %rbp
testl %ebp, %ebp
jle 0xb386
xorl %ecx, %ecx
movl %ecx, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0xb37a
testl %ebp, %ebp
jle 0xb397
xorl %ecx, %ecx
movl %ecx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0xb38c
testl %ebp, %ebp
jle 0xb3cb
xorl %r13d, %r13d
cmpl $0x0, (%r15,%r13,4)
jne 0xb3c3
movl 0x8(%r14), %eax
subl %ebx, %eax
movl %eax, 0x8(%r14)
cltd
idivl %ebx
cltq
movl (%r12,%rax,4), %esi
movl %r13d, %edi
movq %r14, %rdx
callq 0xb0e6
incq %r13
cmpq %r13, %rbp
jne 0xb39e
movb $0x0, 0x28(%r14)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq