// File: /workspace/github_c_makefile_star2_O1/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, %r13
movl %esi, 0x10(%rsp)
movq %rdi, 0x28(%rsp)
movl $0x40, %edi
callq 0x21d0
movq %rax, %rbx
movl 0x8(%r13), %eax
movl %eax, 0x8(%rbx)
movslq 0xc(%r13), %r15
movl %r15d, 0xc(%rbx)
movl 0x10(%r13), %ecx
movl %ecx, 0x10(%rbx)
leaq 0x2639f(%rip), %rax     # 0x322b8
movslq (%rax), %r14
movl %r14d, %eax
movl %ecx, 0x4(%rsp)
imull %ecx, %eax
movl %eax, 0x1c(%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x21d0
movq %r14, %rcx
movq %rax, %r12
movq %rbx, 0x20(%rsp)
movq %rax, (%rbx)
movl 0x10(%r13), %eax
imull %ecx, %eax
testl %eax, %eax
movq %r14, %rbp
jle 0xbf98
movl %r15d, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x21d0
movq %rax, (%r12,%r14,8)
testl %r15d, %r15d
jle 0xbf85
xorl %eax, %eax
movq (%r13), %rcx
movq (%rcx,%r14,8), %rcx
movb (%rcx,%rax), %cl
movq (%r12,%r14,8), %rdx
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, %rbx
jne 0xbf6b
incq %r14
movslq 0x10(%r13), %rax
movq %rbp, %rcx
imulq %rbp, %rax
cmpq %rax, %r14
jl 0xbf58
leaq (,%rcx,4), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21d0
movq %rax, %r14
movq 0x20(%rsp), %rbx
movq %rax, 0x20(%rbx)
movq 0x8(%rsp), %rdi
callq 0x21d0
movq %rbp, %rdi
movq %r14, %rbp
movq %rax, %r10
movq %rax, 0x18(%rbx)
testl %edi, %edi
jle 0xbfe6
movq 0x20(%r13), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%rbp,%rcx,4)
incq %rcx
cmpq %rcx, %rdi
jne 0xbfd7
testl %edi, %edi
movq 0x28(%rsp), %r14
movl 0x4(%rsp), %r9d
movl 0x10(%rsp), %esi
jle 0xc00d
movq 0x18(%r13), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%r10,%rcx,4)
incq %rcx
cmpq %rcx, %rdi
jne 0xbffe
testl %esi, %esi
jle 0xc0eb
movl 0x8(%rbx), %r11d
movl %esi, %ecx
xorl %ebx, %ebx
movq %rbp, 0x30(%rsp)
movq %rcx, 0x8(%rsp)
movslq (%r14,%rbx,4), %rax
movl (%r10,%rax,4), %eax
imull %r9d, %eax
cmpl %r11d, %eax
jge 0xc0d6
subl %r9d, %r11d
testl %r9d, %r9d
movq %r15, %r8
movl 0x1c(%rsp), %ebp
jle 0xc09f
xorl %r15d, %r15d
movq %rbx, 0x10(%rsp)
movslq (%r14,%rbx,4), %rax
movl (%r10,%rax,4), %edi
imull %r9d, %edi
addl %r15d, %edi
leal (%r11,%r15), %esi
movq %r12, %rdx
movl %ebp, %ecx
movq %r10, %r13
movq %r8, %rbx
movq %r12, %r14
movq %r11, %r12
callq 0x2e00
movq %r12, %r11
movq %r14, %r12
movq %rbx, %r8
movq 0x10(%rsp), %rbx
movq %r13, %r10
movl 0x4(%rsp), %r9d
movq 0x28(%rsp), %r14
incl %r15d
cmpl %r15d, %r9d
jne 0xc053
movl %r11d, %eax
cltd
idivl %r9d
cltq
movq 0x30(%rsp), %rbp
movslq (%rbp,%rax,4), %rcx
movslq (%r14,%rbx,4), %rdx
movslq (%r10,%rdx,4), %rsi
movl (%r10,%rcx,4), %edi
movl %edi, (%r10,%rdx,4)
movl %esi, (%r10,%rcx,4)
movl %edx, (%rbp,%rax,4)
movl %ecx, (%rbp,%rsi,4)
movq %r8, %r15
movq 0x8(%rsp), %rcx
incq %rbx
cmpq %rcx, %rbx
jne 0xc027
movq 0x20(%rsp), %rbx
movl %r11d, 0x8(%rbx)
movb $0x0, 0x28(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq