// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/Algebre.c
// Function: Dimension_tmp
int Dimension_tmp(unsigned char ** __restrict m, const int a, const int b) // calcul le rang de la matrice mat de taille a x b, ie la dimension de l'espace engendré par les b vecteurs colonnes.
{
	int dim = 0;
	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++)
		{
			if (m[new_pivot_l][pivot_c])
			{
				if (new_pivot_l!=dim)
				{
					unsigned char * __restrict const tmp = m[dim];
					m[dim]=m[new_pivot_l];
					m[new_pivot_l]=tmp;
				}

				const unsigned char * __restrict const 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])
					{
						int colonne;
						unsigned char * __restrict ligne_need_update = m[ligne];
						const unsigned char coeff = Multiply(Inverse(ligne_pivot[pivot_c]),ligne_need_update[pivot_c]);
						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++;
				if (dim != a) break;
				else return dim;
			}
		}
	}
	return dim;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x3aeb
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3adb
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x3acb
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x39c8
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3ab0
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x3aa0
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %edi
callq 0x24c0
movzbl %al, %eax
movl %eax, %ecx
leaq 0x215dc(%rip), %rax     # 0x25010
shlq $0x8, %rcx
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x3a9e
movzbl -0x49(%rbp), %eax
movl %eax, %ecx
leaq 0x215a5(%rip), %rax     # 0x25010
shlq $0x8, %rcx
addq %rcx, %rax
movq -0x38(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movzbl (%rax,%rcx), %esi
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x3a56
jmp 0x3aa0
jmp 0x3aa2
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x39e1
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x3ac3
jmp 0x3adb
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3af1
jmp 0x3acd
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3962
jmp 0x3add
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3950
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)