// File: /workspace/github_c_makefile_star2_O3/cbouilla[P]AES-attacks-finder/SysEqLin.c
// Function: Transform
SysEqLin Transform(Equation *Eq, int taille, int gen) // Transforme une système d'équations en SysEqLin
{
	int i;
#if DISPLAY_EQUATIONS==1
	for (i = 0; i < taille; i++)
	{
		printf("Eq[%d] : ",i);
		PrintEq(Eq[i]);
		printf("\n");
	}
#endif
	SysEqLin E=malloc(sizeof(SYSEQLIN));
	E->a=gen*VARIABLES;
	E->b=taille;
	E->gen=gen;
	E->mat=malloc(E->a*sizeof(unsigned char *));
	int * __restrict 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(taille*sizeof(unsigned char));
		int j;
		for (j = 0; j < taille; j++) E->mat[i][j]=0;
	}
	for (i = 0; i < taille; i++)
	{
		int j;
		for (j = 0; j < Eq[i]->nV; j++)
		{
			E->mat[gen*Eq[i]->var[j]][i]^=Eq[i]->coefV[j];
			dedans[Eq[i]->var[j]]=1;
		}
		for (j = 0; j < Eq[i]->nS; j++)
		{
			E->mat[gen*Eq[i]->S[j]->var[0]+Eq[i]->sbox[j]+1][i]^=Eq[i]->coefS[j];
			dedans[Eq[i]->S[j]->var[0]]=1;
		}
	}
	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 $0x38, %rsp
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r12
movl $0x40, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x271be(%rip), %rax     # 0x322b8
movslq (%rax), %rbp
movl %ebp, %eax
imull %ebx, %eax
movl %eax, 0x8(%r14)
movl %r15d, 0x10(%rsp)
movl %r15d, 0xc(%r14)
movl %ebx, 0x14(%rsp)
movl %ebx, 0x10(%r14)
movl %eax, 0xc(%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x21d0
movq %rax, %r13
movq %r14, 0x28(%rsp)
movq %rax, (%r14)
leaq (,%rbp,4), %rbx
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r15
movq %rbp, 0x20(%rsp)
testq %rbp, %rbp
jle 0xb15c
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2120
movq %rbx, 0x18(%rsp)
movl 0x10(%rsp), %ebp
cmpl $0x0, 0xc(%rsp)
jle 0xb1ae
movslq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0xc(%rsp), %ebx
xorl %r14d, %r14d
movq 0x30(%rsp), %rdi
callq 0x21d0
movq %rax, (%r13,%r14,8)
cmpl $0x0, 0x10(%rsp)
jle 0xb1a6
xorl %eax, %eax
movq (%r13,%r14,8), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
cmpq %rax, %rbp
jne 0xb195
incq %r14
cmpq %rbx, %r14
jne 0xb17d
cmpl $0x0, 0x10(%rsp)
movl 0x14(%rsp), %r14d
movq 0x18(%rsp), %rbx
jle 0xb277
xorl %eax, %eax
movslq %r14d, %rcx
movq (%r12,%rax,8), %rdx
cmpl $0x0, (%rdx)
jle 0xb20d
movq 0x8(%rdx), %rdi
xorl %esi, %esi
movq 0x10(%rdx), %rdx
movb (%rdx,%rsi), %dl
movslq (%rdi,%rsi,4), %rdi
imulq %rcx, %rdi
movq (%r13,%rdi,8), %rdi
xorb %dl, (%rdi,%rax)
movq (%r12,%rax,8), %rdx
movq 0x8(%rdx), %rdi
movslq (%rdi,%rsi,4), %r8
movl $0x1, (%r15,%r8,4)
incq %rsi
movslq (%rdx), %r8
cmpq %r8, %rsi
jl 0xb1d7
cmpl $0x0, 0x18(%rdx)
jle 0xb26b
movq 0x20(%rdx), %rdi
xorl %esi, %esi
movq 0x28(%rdx), %r8
movq 0x30(%rdx), %rdx
movb (%r8,%rsi), %r8b
movq (%rdi,%rsi,8), %rdi
movq 0x8(%rdi), %rdi
movslq (%rdi), %rdi
imulq %rcx, %rdi
movzbl (%rdx,%rsi), %edx
addq %rdi, %rdx
movq 0x8(%r13,%rdx,8), %rdx
xorb %r8b, (%rdx,%rax)
movq (%r12,%rax,8), %rdx
movq 0x20(%rdx), %rdi
movq (%rdi,%rsi,8), %r8
movq 0x8(%r8), %r8
movslq (%r8), %r8
movl $0x1, (%r15,%r8,4)
incq %rsi
movslq 0x18(%rdx), %r8
cmpq %r8, %rsi
jl 0xb219
incq %rax
cmpq %rbp, %rax
jne 0xb1c8
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r12
movq 0x28(%rsp), %r13
movq %rax, 0x20(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x18(%r13)
movq 0x20(%rsp), %rbp
testl %ebp, %ebp
jle 0xb3da
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 0x1de50(%rip), %xmm3    # 0x29110
xorl %edx, %edx
movdqa 0x1de56(%rip), %xmm1    # 0x29120
pxor %xmm1, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x1de86(%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 0xb310
movl %edx, (%r12,%rdx,4)
pxor %xmm4, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb327
leal 0x1(%rdx), %esi
movl %esi, 0x4(%r12,%rdx,4)
addq $0x2, %rdx
paddq %xmm2, %xmm3
cmpq %rdx, %rcx
jne 0xb2da
testl %ebp, %ebp
jle 0xb3da
movdqa 0x1ddcc(%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 0xb37f
movl %edx, (%rax,%rdx,4)
pxor %xmm4, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb395
leal 0x1(%rdx), %esi
movl %esi, 0x4(%rax,%rdx,4)
addq $0x2, %rdx
paddq %xmm2, %xmm3
cmpq %rdx, %rcx
jne 0xb34a
testl %ebp, %ebp
jle 0xb3da
xorl %ebx, %ebx
cmpl $0x0, (%r15,%rbx,4)
jne 0xb3d2
movl 0xc(%rsp), %eax
subl %r14d, %eax
movl %eax, 0x8(%r13)
movl %eax, 0xc(%rsp)
cltd
idivl %r14d
cltq
movl (%r12,%rax,4), %esi
movl %ebx, %edi
movq %r13, %rdx
callq 0xb3f1
incq %rbx
cmpq %rbx, %rbp
jne 0xb3a8
movb $0x0, 0x28(%r13)
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq