// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/Algebre.c
// Function: DimensionBorne_tmp
int DimensionBorne_tmp(unsigned char ** __restrict m, const int a, const int b, const int borne) // calcul le rang de la matrice mat de taille a x b, ie la dimension de l'espace engendré par les b vecteurs colonnes.
{
	//PrintMat(m,a,b);
	//getchar();
	int dim = 0;
	const int dim_max = min(a-1,borne);
	int pivot_c;
	for (pivot_c = 0; pivot_c < b; pivot_c++)
	{
		int new_pivot_l;
		for (new_pivot_l = dim; new_pivot_l < a; new_pivot_l++) // on cherche un pivot sur la colonne
		{
			if (m[new_pivot_l][pivot_c]) // on en a trouvé un
			{
				if (dim!=dim_max)
				{
					if (new_pivot_l!=dim) // on echange les lignes
					{
						unsigned char * __restrict const tmp = m[dim];
						m[dim]=m[new_pivot_l];
						m[new_pivot_l]=tmp;
					}
							
					const unsigned char * const __restrict ligne_pivot = m[dim];
					int ligne;
					for (ligne = new_pivot_l+1; ligne < a; ligne++) // on fait le pivot de Gauss
					{
						if (m[ligne][pivot_c])
						{
							unsigned char * __restrict ligne_need_update = m[ligne];
							const unsigned char coeff = Multiply(Inverse(ligne_pivot[pivot_c]),ligne_need_update[pivot_c]);
							int colonne;
							for (colonne = pivot_c+1; colonne < b; colonne++)
							{
								//m[ligne][colonne]=Multiply(m[dim][pivot_c],m[ligne][colonne]) ^ Multiply(m[ligne][pivot_c],m[dim][colonne]);
								ligne_need_update[colonne]^=Multiply(coeff,ligne_pivot[colonne]);
							}
						}
					}
					dim++;
					break;
				}
				else return dim+1;
			}
		}
	}
	return dim;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
cmpl -0x1c(%rbp), %eax
jge 0x3762
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3768
movl -0x1c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x3917
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3907
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x38f7
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x38ec
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0x37f9
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x38e1
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x38d1
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edi
callq 0x24c0
movzbl %al, %eax
movl %eax, %ecx
leaq 0x217ab(%rip), %rax     # 0x25010
shlq $0x8, %rcx
addq %rcx, %rax
movq -0x50(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movb (%rax,%rcx), %al
movb %al, -0x51(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x38cf
movzbl -0x51(%rbp), %eax
movl %eax, %ecx
leaq 0x21774(%rip), %rax     # 0x25010
shlq $0x8, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movzbl (%rax,%rcx), %esi
movq -0x50(%rbp), %rax
movslq -0x58(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3887
jmp 0x38d1
jmp 0x38d3
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3812
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3907
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x391d
jmp 0x38f9
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3787
jmp 0x3909
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3775
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)