// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rdx, %rbp
movl %esi, 0x18(%rsp)
movq %rdi, 0x28(%rsp)
movl $0x40, %edi
callq 0x21d0
movq %rax, %r12
movl 0x8(%rbp), %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x8(%r12)
movslq 0xc(%rbp), %r15
movl %r15d, 0xc(%r12)
movl 0x10(%rbp), %ecx
movl %ecx, 0x10(%r12)
leaq 0x25fd2(%rip), %rax     # 0x322b8
movslq (%rax), %rax
movq %rax, %rbx
movl %ecx, 0xc(%rsp)
imull %ecx, %eax
movl %eax, 0x24(%rsp)
movslq %eax, %r14
leaq (,%r14,8), %rdi
callq 0x21d0
movq %rax, %r13
movq %r12, 0x10(%rsp)
movq %rax, (%r12)
testl %r14d, %r14d
movq %r15, 0x30(%rsp)
jle 0xc372
movq %r15, %rdi
movl %edi, %r14d
xorl %r12d, %r12d
movl 0xc(%rsp), %r15d
callq 0x21d0
movq 0x30(%rsp), %rdi
movq %rax, (%r13,%r12,8)
testl %edi, %edi
movq %rbx, %rsi
jle 0xc362
xorl %eax, %eax
movq (%rbp), %rcx
movq (%rcx,%r12,8), %rcx
movb (%rcx,%rax), %cl
movq (%r13,%r12,8), %rdx
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, %r14
jne 0xc343
movl 0x10(%rbp), %r15d
incq %r12
movl %r15d, %eax
imull %esi, %eax
cltq
cmpq %rax, %r12
jl 0xc32b
leaq (,%rbx,4), %r14
movq %r14, %rdi
callq 0x21d0
movq %rax, %r15
movq 0x10(%rsp), %r12
movq %rax, 0x20(%r12)
movq %r14, %rdi
callq 0x21d0
movq %rax, %r14
movq %rax, 0x18(%r12)
testl %ebx, %ebx
movq 0x28(%rsp), %r9
movq 0x38(%rsp), %r10
jle 0xc3db
movq 0x20(%rbp), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%r15,%rcx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0xc3b3
testl %ebx, %ebx
jle 0xc3db
movq 0x18(%rbp), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
movl %edx, (%r14,%rcx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0xc3cc
movl 0x18(%rsp), %eax
testl %eax, %eax
jle 0xc4bd
movl %eax, %ebx
xorl %ebp, %ebp
movl 0xc(%rsp), %r11d
movq %r15, 0x40(%rsp)
movq %rbx, 0x18(%rsp)
movl (%r9,%rbp,4), %ecx
movslq %ecx, %rdi
movl (%r14,%rdi,4), %esi
movl %esi, %eax
imull %r11d, %eax
cmpl %r10d, %eax
jge 0xc4a8
subl %r11d, %r10d
testl %r11d, %r11d
jle 0xc484
xorl %r12d, %r12d
movl 0x24(%rsp), %ebx
movslq (%r9,%rbp,4), %rax
movl (%r14,%rax,4), %edi
imull %r11d, %edi
addl %r12d, %edi
leal (%r10,%r12), %esi
movq %r13, %rdx
movl %ebx, %ecx
movq 0x30(%rsp), %r8
movq %rbp, %r15
movq %r13, %rbp
movq %r14, %r13
movq %r10, %r14
callq 0x313c
movl 0xc(%rsp), %r11d
movq %r14, %r10
movq %r13, %r14
movq %rbp, %r13
movq %r15, %rbp
movq 0x28(%rsp), %r9
incl %r12d
cmpl %r12d, %r11d
jne 0xc423
movl (%r9,%rbp,4), %ecx
movslq %ecx, %rdi
movl (%r14,%rdi,4), %esi
movq 0x40(%rsp), %r15
movq 0x18(%rsp), %rbx
movl %r10d, %eax
cltd
idivl %r11d
cltq
movslq (%r15,%rax,4), %rdx
movl (%r14,%rdx,4), %r8d
movl %r8d, (%r14,%rdi,4)
movl %esi, (%r14,%rdx,4)
movl %ecx, (%r15,%rax,4)
movslq %esi, %rax
movl %edx, (%r15,%rax,4)
incq %rbp
cmpq %rbx, %rbp
jne 0xc3fa
movq 0x10(%rsp), %rax
movl %r10d, 0x8(%rax)
movq 0x10(%rsp), %rax
movb $0x0, 0x28(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq