// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/Algebre.c
// Function: BaseSpeciale
int BaseSpeciale(unsigned char **dst, unsigned char **mat, int a, int b, int Known)
{
	if (b==0) return 0;
	if (Known==0) return 0;
	unsigned char **m=malloc(a*sizeof(unsigned char *));
	int i;
	for (i = 0; i < a; i++)
	{
		m[i]=malloc(b*sizeof(unsigned char));
		int j;
		for (j = 0; j < b; j++) m[i][j]=mat[i][j];
	}
	for (i = 0; i < min(Known,b); i++)
	{
		int k1;
		for (k1 = i; k1 < b; k1++)
		{
			int k2;
			for (k2 = i; k2 < Known; k2++)
			{
				if (m[k2][k1]!=0)
				{
					if (k2!=i) echangeligne(k2,i,m,a,b);
					if (k1!=i)
					{
						echangecolonne(k1,i,m,a,b);
						echangecolonne(k1,i,mat,a,b);
					}
					break;
				}
			}
			if (m[i][i]!=0) break;
		}
		unsigned char p=m[i][i];
		if (p==0) break;
		else
		{
			int j;
			for (j = i+1; j < a; j++)
			{
				unsigned char c=m[j][i];
				if (c!=0)
				{
					int k;
					for (k = i; k < b; k++) m[j][k]=Multiply(p,m[j][k])^Multiply(c,m[i][k]);
				}
			}
		}	
	}
	int tmp=i;
	for (i = 0; i < tmp; i++)
	{
		int j;
		for (j = 0; j < a; j++) dst[j][i]=mat[j][i];
	}
	for (i = 0; i < a; i++) free(m[i]);
	free(m);
	return tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0x3f2c
movl $0x0, -0x4(%rbp)
jmp 0x4267
cmpl $0x0, -0x24(%rbp)
jne 0x3f3e
movl $0x0, -0x4(%rbp)
jmp 0x4267
movslq -0x1c(%rbp), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3fc7
movslq -0x20(%rbp), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, %rdx
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3fba
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x3f81
jmp 0x3fbc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3f56
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3fe4
movl -0x24(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x3fea
movl -0x20(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
cmpl %ecx, %eax
jge 0x41cb
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x40c0
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4095
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x4085
movl -0x40(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x404f
movl -0x40(%rbp), %edi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x35a0
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x4083
movl -0x3c(%rbp), %edi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x3600
movl -0x3c(%rbp), %edi
movl -0x34(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x3600
jmp 0x4095
jmp 0x4087
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4010
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x40b0
jmp 0x40c0
jmp 0x40b2
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3ffe
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x41(%rbp)
movzbl -0x41(%rbp), %eax
cmpl $0x0, %eax
jne 0x40e4
jmp 0x41cb
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x41b9
movq -0x30(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
movzbl -0x49(%rbp), %eax
cmpl $0x0, %eax
je 0x41a9
movl -0x34(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x41a7
movzbl -0x41(%rbp), %eax
movl %eax, %ecx
leaq 0x20ed9(%rip), %rax     # 0x25010
shlq $0x8, %rcx
addq %rcx, %rax
movq -0x30(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x50(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x49(%rbp), %ecx
movl %ecx, %edx
leaq 0x20ead(%rip), %rcx     # 0x25010
shlq $0x8, %rdx
addq %rdx, %rcx
movq -0x30(%rbp), %rdx
movslq -0x34(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq -0x50(%rbp), %rsi
movzbl (%rdx,%rsi), %edx
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
movb %al, %dl
movq -0x30(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x50(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x4122
jmp 0x41a9
jmp 0x41ab
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x40ed
jmp 0x41bb
jmp 0x41bd
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3fce
movl -0x34(%rbp), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x422d
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4220
movq -0x18(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x41e7
jmp 0x4222
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x41d8
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4258
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2030
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4234
movq -0x30(%rbp), %rdi
callq 0x2030
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq