// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq %rdi, %r12
movl $0x40, %edi
callq 0x21d0
movq %rax, %r14
leaq 0x273f0(%rip), %rax     # 0x322b8
movslq (%rax), %r13
movl %r13d, %eax
imull %ebx, %eax
movl %eax, 0x8(%r14)
movl %ebp, 0xc(%rsp)
movl %ebp, 0xc(%r14)
movl %ebx, 0x14(%rsp)
movl %ebx, 0x10(%r14)
movl %eax, 0x10(%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x21d0
movq %rax, %rbp
movq %r14, 0x28(%rsp)
movq %rax, (%r14)
leaq (,%r13,4), %rbx
movq %rbx, %rdi
callq 0x21d0
movq %rax, %r15
movq %r13, 0x20(%rsp)
testq %r13, %r13
jle 0xaf2a
movq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2120
movq %rbx, 0x18(%rsp)
movl 0xc(%rsp), %r13d
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0xaf7c
movslq 0xc(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movl %eax, %r14d
xorl %ebx, %ebx
movq 0x30(%rsp), %rdi
callq 0x21d0
movq %rax, (%rbp,%rbx,8)
cmpl $0x0, 0xc(%rsp)
jle 0xaf74
xorl %eax, %eax
movq (%rbp,%rbx,8), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
cmpq %rax, %r13
jne 0xaf63
incq %rbx
cmpq %r14, %rbx
jne 0xaf4b
cmpl $0x0, 0xc(%rsp)
movl 0x14(%rsp), %r14d
movq 0x18(%rsp), %rbx
jle 0xb053
xorl %eax, %eax
movslq %r14d, %rcx
movq (%r12,%rax,8), %rsi
cmpl $0x0, (%rsi)
jle 0xafe1
xorl %edx, %edx
movq 0x8(%rsi), %rdi
movq 0x10(%rsi), %rsi
movb (%rsi,%rdx), %sil
movslq (%rdi,%rdx,4), %rdi
imulq %rcx, %rdi
movq (%rbp,%rdi,8), %rdi
xorb %sil, (%rdi,%rax)
movq (%r12,%rax,8), %rsi
movq 0x8(%rsi), %rsi
movslq (%rsi,%rdx,4), %rsi
movl $0x1, (%r15,%rsi,4)
incq %rdx
movq (%r12,%rax,8), %rsi
movslq (%rsi), %rdi
cmpq %rdi, %rdx
jl 0xafa1
movq (%r12,%rax,8), %rsi
cmpl $0x0, 0x18(%rsi)
jle 0xb047
xorl %edx, %edx
movq 0x20(%rsi), %rdi
movq 0x28(%rsi), %r8
movb (%r8,%rdx), %r8b
movq (%rdi,%rdx,8), %rdi
movq 0x8(%rdi), %rdi
movslq (%rdi), %rdi
imulq %rcx, %rdi
movq 0x30(%rsi), %rsi
movzbl (%rsi,%rdx), %esi
addq %rdi, %rsi
movq 0x8(%rbp,%rsi,8), %rsi
xorb %r8b, (%rsi,%rax)
movq (%r12,%rax,8), %rsi
movq 0x20(%rsi), %rsi
movq (%rsi,%rdx,8), %rsi
movq 0x8(%rsi), %rsi
movslq (%rsi), %rsi
movl $0x1, (%r15,%rsi,4)
incq %rdx
movq (%r12,%rax,8), %rsi
movslq 0x18(%rsi), %rdi
cmpq %rdi, %rdx
jl 0xafed
incq %rax
cmpq %r13, %rax
jne 0xaf96
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 0xb08a
xorl %ecx, %ecx
movl %ecx, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0xb07e
testl %ebp, %ebp
jle 0xb09b
xorl %ecx, %ecx
movl %ecx, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0xb090
testl %ebp, %ebp
jle 0xb0cf
xorl %ebx, %ebx
cmpl $0x0, (%r15,%rbx,4)
jne 0xb0c7
movl 0x8(%r13), %eax
subl %r14d, %eax
movl %eax, 0x8(%r13)
cltd
idivl %r14d
cltq
movl (%r12,%rax,4), %esi
movl %ebx, %edi
movq %r13, %rdx
callq 0xb0e6
incq %rbx
cmpq %rbx, %rbp
jne 0xb0a1
movb $0x0, 0x28(%r13)
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq