// File: /workspace/github_c_makefile_star2_O1/cbouilla[P]AES-attacks-finder/Algebre.c
// Function: Supplementaire_tmp
int Supplementaire_tmp(unsigned char **dst, unsigned char **mat1, int b1, unsigned char **mat2, int a, int b2)
{
	if (b2==0) return 0;
	if (b1==0)
	{
		int i,j;
		for (i = 0; i < a; i++) for ( j = 0; j < b2; j++) dst[i][j]=mat2[i][j];
		return b2;
	}
	int b=b1+b2,i;
	unsigned char **m=malloc(a*sizeof(unsigned char *));
	for (i = 0; i < a; i++) m[i]=malloc(b*sizeof(unsigned char)); 
	for (i = 0; i < a; i++)
	{
		int j;
		for (j = 0; j < b1; j++) m[i][j]=mat1[i][j];
		for (j = 0; j < b2; j++) m[i][j+b1]=mat2[i][j];	
	}
	for (i = 0; i < min(a,b1); i++)
	{
		int k1;
		for (k1 = i; k1 < b1; k1++)
		{
			int k2;
			for (k2 = i; k2 < a; k2++)
			{
				if (m[k2][k1]!=0)
				{
					if (k2!=i) echangeligne(k2,i,m,a,b);
					if (k1!=i) echangecolonne(k1,i,m,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 b3=b2-b1;
	for (i = b1; i < min(a,b); i++)
	{
		int k1;
		for (k1 = i; k1 < b; k1++)
		{
			int k2;
			for (k2 = i; k2 < a; 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-b1,i-b1,mat2,a,b2);
					}
					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]);
				}
			}
		}	
	}
	for (i = 0; i < b3; i++)
	{
		int j;
		for (j = 0; j < a; j++) dst[j][i]=mat2[j][i];
	}
	for (i = 0; i < a; i++) free(m[i]);
	free(m);
	return b3;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
testl %r9d, %r9d
je 0x3d79
movl %r8d, %r15d
movq %rcx, %rbx
testl %edx, %edx
je 0x3d7d
movq %rsi, 0x10(%rsp)
movq %rdi, 0x70(%rsp)
movq %r9, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
leal (%r9,%rdx), %ebp
movslq %r15d, %r14
leaq (,%r14,8), %rdi
callq 0x21d0
movq %rax, %r12
movl %ebp, 0x1c(%rsp)
movslq %ebp, %rdi
movl %r15d, %ebp
testl %r14d, %r14d
movq %rdi, 0x48(%rsp)
jle 0x3951
xorl %r13d, %r13d
callq 0x21d0
movq 0x48(%rsp), %rdi
movq %rax, (%r12,%r13,8)
incq %r13
cmpq %r13, %rbp
jne 0x393b
movq %r12, 0x20(%rsp)
movq 0x50(%rsp), %r13
movslq %r13d, %r10
movq 0x58(%rsp), %r12
movl %r12d, %r11d
testl %r15d, %r15d
movq %rbp, %r9
movq 0x10(%rsp), %rbp
jle 0x39cc
movl %r13d, %edx
xorl %esi, %esi
testl %r13d, %r13d
jle 0x399d
movq 0x20(%rsp), %rax
movq (%rax,%rsi,8), %rax
xorl %ecx, %ecx
movq (%rbp,%rsi,8), %r8
movb (%r8,%rcx), %r8b
movb %r8b, (%rax,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x3988
testl %r12d, %r12d
jle 0x39c4
movq 0x20(%rsp), %rax
movq (%rax,%rsi,8), %rax
addq %r10, %rax
xorl %ecx, %ecx
movq (%rbx,%rsi,8), %r8
movb (%r8,%rcx), %r8b
movb %r8b, (%rax,%rcx)
incq %rcx
cmpq %rcx, %r11
jne 0x39b0
incq %rsi
cmpq %r9, %rsi
jne 0x3978
movq %r11, 0x68(%rsp)
movq %r10, 0x30(%rsp)
movq %r9, 0x10(%rsp)
movq %rbx, 0x60(%rsp)
cmpl %r13d, %r15d
movl %r13d, %eax
movl %r15d, 0xc(%rsp)
cmovll %r15d, %eax
testl %eax, %eax
movq 0x20(%rsp), %rbx
jle 0x3b42
movl %eax, %eax
movq %rax, 0x40(%rsp)
movl $0x1, %eax
movq %rax, 0x28(%rsp)
xorl %r9d, %r9d
leaq 0x155f9(%rip), %rbp     # 0x19010
movq %rbx, %r8
movq %r9, %r10
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %r15
xorl %eax, %eax
movq (%r8,%rax,8), %rdx
cmpb $0x0, (%rdx,%r10)
jne 0x3a45
leaq (%r9,%rax), %rdx
incq %rdx
incq %rax
cmpq %r14, %rdx
jl 0x3a29
jmp 0x3a87
testq %rax, %rax
je 0x3a5a
movq (%r8,%rax,8), %rdx
movq (%rbx,%r9,8), %rsi
movq %rsi, (%r8,%rax,8)
movq %rdx, (%rbx,%r9,8)
cmpq %r9, %r10
je 0x3a87
cmpq %rdi, %r9
jge 0x3a87
cmpq %rdi, %r10
jge 0x3a87
xorl %eax, %eax
movq (%rbx,%rax,8), %rdx
movb (%rdx,%r10), %sil
movb (%rdx,%r9), %r11b
movb %r11b, (%rdx,%r10)
movb %sil, (%rdx,%r9)
incq %rax
cmpq %rax, %rcx
jne 0x3a6b
movq (%rbx,%r9,8), %rax
cmpb $0x0, (%rax,%r9)
jne 0x3a9a
incq %r10
cmpq %r15, %r10
jl 0x3a27
movq (%rbx,%r9,8), %r13
movzbl (%r13,%r9), %r12d
testq %r12, %r12
je 0x3b42
leaq 0x1(%r9), %rax
movq %rax, 0x38(%rsp)
cmpq %r14, %rax
jge 0x3b21
movq 0x28(%rsp), %rsi
cmpq %rdi, %r9
setge %al
movq (%rbx,%rsi,8), %rdx
movzbl (%rdx,%r9), %r15d
testq %r15, %r15
sete %bl
orb %al, %bl
jne 0x3b12
movq %r9, %rax
movzbl (%rdx,%rax), %ebx
movl %r12d, %r11d
shll $0x8, %r11d
addq %rbp, %r11
movzbl (%r13,%rax), %ecx
movl %r15d, %r10d
shll $0x8, %r10d
addq %rbp, %r10
movb (%rcx,%r10), %cl
xorb (%rbx,%r11), %cl
movb %cl, (%rdx,%rax)
movq 0x48(%rsp), %rdi
incq %rax
cmpq %rdi, %rax
jl 0x3adc
incq %rsi
cmpq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rbx
jne 0x3ac0
testq %r12, %r12
je 0x3b42
incq 0x28(%rsp)
addq $0x8, %r8
movq 0x38(%rsp), %rax
movq %rax, %r9
cmpq 0x40(%rsp), %rax
jne 0x3a1a
movq 0x58(%rsp), %rcx
movl %ecx, %eax
movq 0x50(%rsp), %rdx
subl %edx, %eax
movl %eax, 0x40(%rsp)
movl 0xc(%rsp), %esi
movl 0x1c(%rsp), %eax
cmpl %esi, %eax
cmovgel %esi, %eax
movl %eax, 0x1c(%rsp)
cmpl %edx, %eax
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %rbp
jle 0x3d13
movslq %ecx, %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %r9
leaq (%rbx,%r9,8), %rsi
leaq 0x15481(%rip), %rdi     # 0x19010
leaq 0x1(%r9), %rax
movq %rax, 0x28(%rsp)
movslq %eax, %r10
movq %r9, %r11
subq 0x30(%rsp), %r11
movb $0x1, %r8b
movq %r9, %r13
xorl %eax, %eax
movq (%rsi,%rax,8), %rdx
cmpb $0x0, (%rdx,%r13)
jne 0x3bca
leaq (%r9,%rax), %rcx
incq %rcx
incq %rax
cmpq %r14, %rcx
jl 0x3bab
jmp 0x3c66
testq %rax, %rax
je 0x3bdb
movq (%rbx,%r9,8), %rcx
movq %rcx, (%rsi,%rax,8)
movq %rdx, (%rbx,%r9,8)
cmpq %r9, %r13
je 0x3c66
movq %rbp, %r12
cmpl $0x0, 0xc(%rsp)
setle %al
notb %r8b
orb %al, %r8b
testb $0x1, %r8b
movq 0x10(%rsp), %rbp
jne 0x3c1e
xorl %eax, %eax
movq (%rbx,%rax,8), %rcx
movb (%rcx,%r13), %dl
movb (%rcx,%r9), %r8b
movb %r8b, (%rcx,%r13)
movb %dl, (%rcx,%r9)
incq %rax
cmpq %rax, %rbp
jne 0x3c02
cmpl $0x0, 0xc(%rsp)
movq %r12, %rbp
jle 0x3c66
cmpq 0x38(%rsp), %r11
jge 0x3c66
movq %r13, %rax
subq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jge 0x3c66
xorl %edx, %edx
movq (%r15,%rdx,8), %rcx
movb (%rcx,%rax), %r8b
movb (%rcx,%r11), %bl
movb %bl, (%rcx,%rax)
movq 0x20(%rsp), %rbx
movq (%r15,%rdx,8), %rcx
movb %r8b, (%rcx,%r11)
incq %rdx
cmpq %rdx, 0x10(%rsp)
jne 0x3c40
movq (%rbx,%r9,8), %rax
cmpb $0x0, (%rax,%r9)
movq 0x48(%rsp), %rax
jne 0x3c86
incq %r13
cmpq %rax, %r13
setl %r8b
jl 0x3ba9
movq (%rbx,%r9,8), %r13
movzbl (%r13,%r9), %r11d
testq %r11, %r11
je 0x3d13
cmpq %r14, 0x28(%rsp)
jge 0x3cf0
addq %r9, %r13
movq (%rbx,%r10,8), %r8
movzbl (%r8,%r9), %edx
testq %rdx, %rdx
je 0x3ce3
addq %r9, %r8
xorl %eax, %eax
movzbl (%r8,%rax), %ecx
movl %r11d, %ebx
shll $0x8, %ebx
addq %rdi, %rbx
movzbl (%r13,%rax), %r15d
movl %edx, %r12d
shll $0x8, %r12d
addq %rdi, %r12
movb (%r15,%r12), %r15b
xorb (%rcx,%rbx), %r15b
movb %r15b, (%r8,%rax)
incq %rax
cmpl %eax, %ebp
jne 0x3cb2
incq %r10
cmpq %r14, %r10
movq 0x20(%rsp), %rbx
jl 0x3c9f
testq %r11, %r11
movq 0x60(%rsp), %r15
je 0x3d13
addq $0x8, %rsi
decq %rbp
movq 0x28(%rsp), %rax
movq %rax, %r9
cmpl %eax, 0x1c(%rsp)
jne 0x3b8f
movl 0x40(%rsp), %ebp
testl %ebp, %ebp
movq 0x70(%rsp), %r8
movq 0x10(%rsp), %r13
jle 0x3d52
movl %ebp, %eax
xorl %ecx, %ecx
cmpl $0x0, 0xc(%rsp)
jle 0x3d4a
xorl %edx, %edx
movq (%r15,%rdx,8), %rsi
movb (%rsi,%rcx), %sil
movq (%r8,%rdx,8), %rdi
movb %sil, (%rdi,%rcx)
incq %rdx
cmpq %rdx, %r13
jne 0x3d32
incq %rcx
cmpq %rax, %rcx
jne 0x3d29
cmpl $0x0, 0xc(%rsp)
movq %rbx, %r14
jle 0x3d6f
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0x2030
incq %rbx
cmpq %rbx, %r13
jne 0x3d5e
movq %r14, %rdi
callq 0x2030
jmp 0x3db4
xorl %ebp, %ebp
jmp 0x3db4
testl %r15d, %r15d
jle 0x3db1
movl %r15d, %eax
movl %r9d, %ecx
xorl %edx, %edx
testl %r9d, %r9d
jle 0x3da9
xorl %esi, %esi
movq (%rbx,%rdx,8), %r8
movb (%r8,%rsi), %r10b
movq (%rdi,%rdx,8), %r8
movb %r10b, (%r8,%rsi)
incq %rsi
cmpq %rsi, %rcx
jne 0x3d91
incq %rdx
cmpq %rax, %rdx
jne 0x3d8a
movl %r9d, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq