// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, %r13
pushq $0x40
popq %rdi
callq 0x21c0
movq %rax, %r15
leaq 0x26162(%rip), %rax     # 0x302b8
movslq (%rax), %r14
movl %r14d, %eax
imull %ebp, %eax
movl %eax, 0x8(%r15)
movl %r12d, 0xc(%r15)
movl %ebp, 0x10(%r15)
movl %eax, (%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, %rbx
movq %r15, 0x18(%rsp)
movq %rax, (%r15)
movq %r14, %rdi
shlq $0x2, %rdi
movq %rdi, 0x10(%rsp)
callq 0x21c0
movq %rax, %r15
xorl %eax, %eax
testl %r14d, %r14d
movl $0x0, %ecx
cmovgl %r14d, %ecx
cmpq %rax, %rcx
je 0xa1b6
andl $0x0, (%r15,%rax,4)
incq %rax
jmp 0xa1a7
movq %rcx, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
movslq %r12d, %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
testl %r12d, %r12d
cmovlel %r14d, %r12d
movl (%rsp), %eax
testl %eax, %eax
movl $0x0, %ebp
cmovgl %eax, %ebp
cmpq %rbp, %r14
je 0xa20a
movq 0x20(%rsp), %rdi
callq 0x21c0
movq %rax, (%rbx,%r14,8)
xorl %eax, %eax
cmpq %rax, %r12
je 0xa205
movq (%rbx,%r14,8), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
jmp 0xa1f3
incq %r14
jmp 0xa1de
xorl %eax, %eax
movl 0x4(%rsp), %ebp
movslq %ebp, %rcx
movq 0x8(%rsp), %r14
cmpq %r12, %rax
je 0xa2c7
movq (%r13,%rax,8), %rdx
xorl %esi, %esi
movslq (%rdx), %rdi
cmpq %rdi, %rsi
jge 0xa264
movq 0x8(%rdx), %rdi
movq 0x10(%rdx), %rdx
movb (%rdx,%rsi), %dl
movslq (%rdi,%rsi,4), %rdi
imulq %rcx, %rdi
movq (%rbx,%rdi,8), %rdi
xorb %dl, (%rdi,%rax)
movq (%r13,%rax,8), %rdx
movq 0x8(%rdx), %rdi
movslq (%rdi,%rsi,4), %rdi
movl $0x1, (%r15,%rdi,4)
incq %rsi
jmp 0xa228
xorl %esi, %esi
movslq 0x18(%rdx), %rdi
cmpq %rdi, %rsi
jge 0xa2bf
movq 0x20(%rdx), %rdi
movq 0x28(%rdx), %r8
movb (%r8,%rsi), %r8b
movq (%rdi,%rsi,8), %rdi
movq 0x8(%rdi), %rdi
movslq (%rdi), %rdi
imulq %rcx, %rdi
movq 0x30(%rdx), %rdx
movzbl (%rdx,%rsi), %edx
addq %rdi, %rdx
movq 0x8(%rbx,%rdx,8), %rdx
xorb %r8b, (%rdx,%rax)
movq (%r13,%rax,8), %rdx
movq 0x20(%rdx), %rdi
movq (%rdi,%rsi,8), %rdi
movq 0x8(%rdi), %rdi
movslq (%rdi), %rdi
movl $0x1, (%r15,%rdi,4)
incq %rsi
jmp 0xa266
incq %rax
jmp 0xa218
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x21c0
movq %rax, %rbx
movq 0x18(%rsp), %r12
movq %rax, 0x20(%r12)
movq %r13, %rdi
callq 0x21c0
movq %rax, 0x18(%r12)
xorl %ecx, %ecx
movl (%rsp), %r13d
cmpq %rcx, %r14
je 0xa301
movl %ecx, (%rbx,%rcx,4)
incq %rcx
jmp 0xa2f4
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0xa310
movl %ecx, (%rax,%rcx,4)
incq %rcx
jmp 0xa303
xorl %r14d, %r14d
cmpq %r14, 0x8(%rsp)
je 0xa344
cmpl $0x0, (%r15,%r14,4)
jne 0xa33f
subl %ebp, %r13d
movl %r13d, 0x8(%r12)
movl %r13d, %eax
cltd
idivl %ebp
cltq
movl (%rbx,%rax,4), %esi
movl %r14d, %edi
movq %r12, %rdx
callq 0xa35c
incq %r14
jmp 0xa313
movb $0x0, 0x28(%r12)
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq