// File: /workspace/github_c_makefile_star2_O3/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
movq %rsp, %rbx
movq %rbx, %rdx
callq 0x5e74
movq %rax, %r12
movl $0x40, %edi
callq 0x21d0
movq %rax, %r13
leaq 0x26dec(%rip), %rax     # 0x322b8
movslq (%rax), %r15
movl %r15d, %r14d
movq %r15, 0x8(%rsp)
imull %ebp, %r14d
movl %r14d, 0x8(%r13)
movl (%rbx), %ebx
movl %ebx, 0xc(%r13)
movl %ebp, 0x4(%rsp)
movl %ebp, 0x10(%r13)
movslq %r14d, %rdi
shlq $0x3, %rdi
callq 0x21d0
movq %rax, %rbp
movq %r13, 0x18(%rsp)
movq %rax, (%r13)
leaq (,%r15,4), %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, %r15
cmpq $0x0, 0x8(%rsp)
jle 0xb52d
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2120
movq %r13, 0x10(%rsp)
testl %r14d, %r14d
jle 0xb578
movl %r14d, %eax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movslq %ebx, %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, (%rbp,%r14,8)
testl %r13d, %r13d
jle 0xb56e
xorl %eax, %eax
movq (%rbp,%r14,8), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
movslq (%rsp), %rbx
cmpq %rbx, %rax
jl 0xb559
incq %r14
cmpq 0x20(%rsp), %r14
jne 0xb542
testl %ebx, %ebx
movl 0x4(%rsp), %r14d
jle 0xb643
xorl %r13d, %r13d
movslq %r14d, %rbx
movq (%r12,%r13,8), %rdi
cmpl $0x0, (%rdi)
jle 0xb5d1
movq 0x8(%rdi), %rcx
xorl %eax, %eax
movq 0x10(%rdi), %rdx
movb (%rdx,%rax), %dl
movslq (%rcx,%rax,4), %rcx
imulq %rbx, %rcx
movq (%rbp,%rcx,8), %rcx
xorb %dl, (%rcx,%r13)
movq (%r12,%r13,8), %rdi
movq 0x8(%rdi), %rcx
movslq (%rcx,%rax,4), %rdx
movl $0x1, (%r15,%rdx,4)
incq %rax
movslq (%rdi), %rdx
cmpq %rdx, %rax
jl 0xb59a
cmpl $0x0, 0x18(%rdi)
jle 0xb62e
movq 0x20(%rdi), %rcx
xorl %eax, %eax
movq 0x28(%rdi), %rdx
movq 0x30(%rdi), %rsi
movb (%rdx,%rax), %dl
movq (%rcx,%rax,8), %rcx
movq 0x8(%rcx), %rcx
movslq (%rcx), %rcx
imulq %rbx, %rcx
movzbl (%rsi,%rax), %esi
addq %rcx, %rsi
movq 0x8(%rbp,%rsi,8), %rcx
xorb %dl, (%rcx,%r13)
movq (%r12,%r13,8), %rdi
movq 0x20(%rdi), %rcx
movq (%rcx,%rax,8), %rdx
movq 0x8(%rdx), %rdx
movslq (%rdx), %rdx
movl $0x1, (%r15,%rdx,4)
incq %rax
movslq 0x18(%rdi), %rdx
cmpq %rdx, %rax
jl 0xb5dd
callq 0x4ad9
incq %r13
movslq (%rsp), %rax
cmpq %rax, %r13
jl 0xb58b
movq %r12, %rdi
callq 0x2030
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, %r12
movq 0x18(%rsp), %rbx
movq %rax, 0x20(%rbx)
movq %r13, %rdi
callq 0x21d0
movq %rax, 0x18(%rbx)
movq 0x8(%rsp), %rbp
testl %ebp, %ebp
jle 0xb7af
leal 0x1(%rbp), %ecx
andl $-0x2, %ecx
leaq -0x1(%rbp), %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x1da77(%rip), %xmm3    # 0x29110
xorl %edx, %edx
movdqa 0x1da7d(%rip), %xmm1    # 0x29120
pxor %xmm1, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x1daad(%rip), %xmm2    # 0x29160
movdqa %xmm3, %xmm5
pxor %xmm1, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0xb6e9
movl %edx, (%r12,%rdx,4)
pxor %xmm4, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb700
leal 0x1(%rdx), %esi
movl %esi, 0x4(%r12,%rdx,4)
addq $0x2, %rdx
paddq %xmm2, %xmm3
cmpq %rdx, %rcx
jne 0xb6b3
testl %ebp, %ebp
jle 0xb7af
movdqa 0x1d9f3(%rip), %xmm3    # 0x29110
xorl %edx, %edx
pcmpeqd %xmm4, %xmm4
movdqa %xmm3, %xmm5
pxor %xmm1, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0xb758
movl %edx, (%rax,%rdx,4)
pxor %xmm4, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb76e
leal 0x1(%rdx), %esi
movl %esi, 0x4(%rax,%rdx,4)
addq $0x2, %rdx
paddq %xmm2, %xmm3
cmpq %rdx, %rcx
jne 0xb723
testl %ebp, %ebp
jle 0xb7af
xorl %r13d, %r13d
cmpl $0x0, (%r15,%r13,4)
jne 0xb7a7
movl 0x8(%rbx), %eax
subl %r14d, %eax
movl %eax, 0x8(%rbx)
cltd
idivl %r14d
cltq
movl (%r12,%rax,4), %esi
movl %r13d, %edi
movq %rbx, %rdx
callq 0xb3f1
incq %r13
cmpq %r13, %rbp
jne 0xb782
movb $0x0, 0x28(%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq