// File: /workspace/github_c_makefile_star2_O2/cbouilla[P]AES-attacks-finder/SysEqLin.c
// Function: EsachantX
SysEqLin EsachantX(int *var, int N, SysEqLin E) // Calcul E|_X (les variables X sont maintenant supposées connues
{
	SysEqLin F=malloc(sizeof(SYSEQLIN));
	F->a=E->a;
	F->b=E->b;
	F->gen=E->gen;
	F->mat=malloc(E->gen*VARIABLES*sizeof(unsigned char *));
	int i;
	for (i = 0; i < E->gen*VARIABLES; i++)
	{
		F->mat[i]=malloc(F->b*sizeof(unsigned char));
		int j;
		for (j = 0; j < F->b; j++) F->mat[i][j]=E->mat[i][j];		
	}
	F->varligne=malloc(VARIABLES*sizeof(int));
	F->lignevar=malloc(VARIABLES*sizeof(int));
	
	for (i = 0; i < VARIABLES; i++) F->varligne[i]=E->varligne[i];
	for (i = 0; i < VARIABLES; i++) F->lignevar[i]=E->lignevar[i];
	for (i = 0; i < N; i++)
	{
		if (F->gen*F->lignevar[var[i]]<F->a)
		{
			F->a=F->a-F->gen;
			int l;
			for (l = 0; l < F->gen; l++) echangeligne(F->gen*F->lignevar[var[i]]+l,F->a+l,F->mat,F->gen*VARIABLES,F->b);
			int j=F->varligne[F->a/F->gen];
			int k=F->lignevar[var[i]];
			F->lignevar[var[i]]=F->lignevar[j];
			F->lignevar[j]=k;
			F->varligne[F->a/F->gen]=var[i];
			F->varligne[k]=j;
		}
	}
	F->initialise=0;
	return F;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
pushq $0x40
popq %rdi
callq 0x21c0
movq %rax, %r13
movl 0x8(%rbx), %r12d
movl %r12d, 0x8(%rax)
movslq 0xc(%rbx), %rax
movq %rax, 0x18(%rsp)
movl %eax, 0xc(%r13)
movslq 0x10(%rbx), %rdi
movq %rdi, (%rsp)
movl %edi, 0x10(%r13)
leaq 0x25249(%rip), %rax     # 0x302b8
movslq (%rax), %rax
movq %rax, %r14
imulq %rax, %rdi
movq %rdi, 0x30(%rsp)
shlq $0x3, %rdi
callq 0x21c0
movq %rax, %r15
movq %r13, 0x8(%rsp)
movq %rax, (%r13)
xorl %ebp, %ebp
movq 0x18(%rsp), %rax
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
movq (%rsp), %rax
imull %r14d, %eax
cltq
cmpq %rax, %rbp
jge 0xb0e8
movq 0x18(%rsp), %rdi
callq 0x21c0
movq %rax, (%r15,%rbp,8)
xorl %eax, %eax
cmpq %rax, %r13
je 0xb0e0
movq (%rbx), %rcx
movq (%rcx,%rbp,8), %rcx
movb (%rcx,%rax), %cl
movq (%r15,%rbp,8), %rdx
movb %cl, (%rdx,%rax)
incq %rax
jmp 0xb0c5
incq %rbp
movl 0x10(%rbx), %eax
jmp 0xb0aa
movq %r14, %rbp
shlq $0x2, %rbp
movq %rbp, %rdi
callq 0x21c0
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %r13
movq %rax, 0x20(%r13)
movq %rbp, %rdi
callq 0x21c0
movq %rax, %rbp
movq %rax, 0x18(%r13)
movq 0x28(%rsp), %rsi
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %eax
cmovgl %r14d, %eax
cmpq %rcx, %rax
je 0xb13b
movq 0x20(%rbx), %rdx
movl (%rdx,%rcx,4), %edx
movl %edx, (%rsi,%rcx,4)
incq %rcx
jmp 0xb127
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xb152
movq 0x18(%rbx), %rdx
movl (%rdx,%rcx,4), %edx
movl %edx, (%rbp,%rcx,4)
incq %rcx
jmp 0xb13d
xorl %ebx, %ebx
movq (%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
movq 0x10(%rsp), %rdx
testl %edx, %edx
cmovlel %ebx, %edx
movq %rdx, 0x10(%rsp)
cmpq %rdx, %rbx
je 0xb220
movq 0x20(%rsp), %rax
movslq (%rax,%rbx,4), %rax
movl (%rbp,%rax,4), %eax
imull %ecx, %eax
cmpl %r12d, %eax
jge 0xb218
subl %ecx, %r12d
movq 0x8(%rsp), %rax
movl %r12d, 0x8(%rax)
xorl %r14d, %r14d
cmpl %r14d, %r13d
je 0xb1d8
movq 0x20(%rsp), %rax
movslq (%rax,%rbx,4), %rax
movl (%rbp,%rax,4), %edi
imull (%rsp), %edi
addl %r14d, %edi
leal (%r12,%r14), %esi
movq %r15, %rdx
movq 0x30(%rsp), %rcx
movq 0x18(%rsp), %r8
callq 0x2b30
incl %r14d
jmp 0xb1a4
movl %r12d, %eax
cltd
movq (%rsp), %r8
idivl %r8d
cltq
movq 0x28(%rsp), %r9
movslq (%r9,%rax,4), %rcx
movq 0x20(%rsp), %rdx
movslq (%rdx,%rbx,4), %rdx
movslq (%rbp,%rdx,4), %rsi
movl (%rbp,%rcx,4), %edi
movl %edi, (%rbp,%rdx,4)
movl %esi, (%rbp,%rcx,4)
movl %edx, (%r9,%rax,4)
movl %ecx, (%r9,%rsi,4)
movq %r8, %rcx
movq 0x10(%rsp), %rdx
incq %rbx
jmp 0xb173
movq 0x8(%rsp), %rax
movb $0x0, 0x28(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq