// File: /workspace/github_c_makefile_star2_O3/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 $0x68, %rsp
testl %r9d, %r9d
je 0x400d
movl %r9d, %ebp
movl %r8d, %r12d
movl %edx, %r13d
testl %edx, %edx
je 0x4012
movq %rsi, 0x28(%rsp)
movq %rdi, 0x60(%rsp)
leal (%rbp,%r13), %ebx
movslq %r12d, %r14
leaq (,%r14,8), %rdi
movq %rcx, 0x48(%rsp)
callq 0x21d0
movq %rax, %r15
movl %ebx, 0x4(%rsp)
movslq %ebx, %rdi
movl %r12d, %ebx
testl %r14d, %r14d
movq %rdi, 0x50(%rsp)
movq %r13, 0x8(%rsp)
jle 0x3c7f
xorl %r13d, %r13d
callq 0x21d0
movq 0x50(%rsp), %rdi
movq %rax, (%r15,%r13,8)
incq %r13
cmpq %r13, %rbx
jne 0x3bfa
testl %r12d, %r12d
movq 0x48(%rsp), %r10
movq 0x8(%rsp), %r13
jle 0x3c7f
movslq %r13d, %rax
movq %rax, 0x20(%rsp)
movl %r13d, %ecx
movl %ebp, %edx
xorl %esi, %esi
movq 0x28(%rsp), %rax
testl %r13d, %r13d
jle 0x3c53
movq (%r15,%rsi,8), %r11
xorl %r8d, %r8d
movq (%rax,%rsi,8), %r9
movb (%r9,%r8), %r9b
movb %r9b, (%r11,%r8)
incq %r8
cmpq %r8, %rcx
jne 0x3c3f
testl %ebp, %ebp
jle 0x3c77
movq (%r15,%rsi,8), %r11
addq 0x20(%rsp), %r11
xorl %r8d, %r8d
movq (%r10,%rsi,8), %r9
movb (%r9,%r8), %r9b
movb %r9b, (%r11,%r8)
incq %r8
cmpq %r8, %rdx
jne 0x3c63
incq %rsi
cmpq %rbx, %rsi
jne 0x3c33
movq %rbp, 0x58(%rsp)
movq %rbx, 0x28(%rsp)
cmpl %r13d, %r12d
movl %r13d, %eax
cmovll %r12d, %eax
testl %eax, %eax
movl %r12d, 0x34(%rsp)
movq %r15, 0x20(%rsp)
jle 0x3df0
movl %eax, %eax
movq %rax, 0x38(%rsp)
movslq %r13d, %r11
movl $0x1, %eax
movq %rax, 0x10(%rsp)
xorl %ecx, %ecx
leaq 0x1534e(%rip), %rsi     # 0x19010
movq %r15, %rbp
movq %r11, 0x40(%rsp)
movq %rcx, %r9
xorl %eax, %eax
movq (%rbp,%rax,8), %rdx
cmpb $0x0, (%rdx,%r9)
jne 0x3cec
leaq (%rcx,%rax), %rdx
incq %rdx
incq %rax
cmpq %r14, %rdx
jl 0x3ccf
jmp 0x3d32
testq %rax, %rax
je 0x3d03
movq (%rbp,%rax,8), %rdx
movq (%r15,%rcx,8), %r8
movq %r8, (%rbp,%rax,8)
movq %rdx, (%r15,%rcx,8)
cmpq %rcx, %r9
je 0x3d32
cmpq %rdi, %rcx
jge 0x3d32
cmpq %rdi, %r9
jge 0x3d32
xorl %eax, %eax
movq (%r15,%rax,8), %rdx
movb (%rdx,%r9), %r8b
movb (%rdx,%rcx), %r10b
movb %r10b, (%rdx,%r9)
movb %r8b, (%rdx,%rcx)
incq %rax
cmpq %rax, 0x28(%rsp)
jne 0x3d14
movq (%r15,%rcx,8), %r10
movzbl (%r10,%rcx), %ebx
testq %rbx, %rbx
jne 0x3d48
incq %r9
cmpq %r11, %r9
jl 0x3ccd
testq %rbx, %rbx
je 0x3df0
leaq 0x1(%rcx), %rax
movq %rax, 0x18(%rsp)
cmpq %r14, %rax
jge 0x3dc8
movq 0x10(%rsp), %r13
cmpq %rdi, %rcx
setge %r8b
movq (%r15,%r13,8), %rax
movzbl (%rax,%rcx), %r15d
testq %r15, %r15
sete %r9b
orb %r8b, %r9b
jne 0x3db9
movq %rcx, %r8
movzbl (%rax,%r8), %r9d
movl %ebx, %r11d
shll $0x8, %r11d
addq %rsi, %r11
movzbl (%r10,%r8), %r12d
movl %r15d, %edx
shll $0x8, %edx
addq %rsi, %rdx
movb (%r12,%rdx), %dl
xorb (%r9,%r11), %dl
movq 0x50(%rsp), %rdi
movb %dl, (%rax,%r8)
incq %r8
cmpq %rdi, %r8
jl 0x3d83
incq %r13
cmpq 0x28(%rsp), %r13
movq 0x20(%rsp), %r15
jne 0x3d64
incq 0x10(%rsp)
addq $0x8, %rbp
movq 0x18(%rsp), %rcx
cmpq 0x38(%rsp), %rcx
movl 0x34(%rsp), %r12d
movq 0x8(%rsp), %r13
movq 0x40(%rsp), %r11
jne 0x3cca
movq 0x58(%rsp), %rcx
movl %ecx, %eax
subl %r13d, %eax
movl %eax, 0x40(%rsp)
movl 0x4(%rsp), %eax
cmpl %r12d, %eax
cmovgel %r12d, %eax
movl %eax, 0x4(%rsp)
cmpl %r13d, %eax
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %rbp
jle 0x3fb0
movslq %r13d, %rax
movslq %ecx, %rdx
movq %rdx, 0x10(%rsp)
leaq (%r15,%rax,8), %rdx
movl %ecx, %esi
leaq 0x151d8(%rip), %rdi     # 0x19010
movq %rax, 0x8(%rsp)
movq %rax, %r9
leaq 0x1(%r9), %rax
movq %rax, 0x38(%rsp)
cltq
movq %rax, 0x18(%rsp)
movq %r9, %r11
subq 0x8(%rsp), %r11
movq %r9, %r13
xorl %eax, %eax
movq (%rdx,%rax,8), %rcx
cmpb $0x0, (%rcx,%r13)
jne 0x3e7c
leaq (%r9,%rax), %rcx
incq %rcx
incq %rax
cmpq %r14, %rcx
jl 0x3e5d
jmp 0x3efd
testq %rax, %rax
je 0x3e8d
movq (%r15,%r9,8), %r8
movq %r8, (%rdx,%rax,8)
movq %rcx, (%r15,%r9,8)
testl %r12d, %r12d
setle %al
cmpq %r9, %r13
sete %cl
orb %al, %cl
jne 0x3efd
xorl %eax, %eax
movq (%r15,%rax,8), %rcx
movb (%rcx,%r13), %r8b
movb (%rcx,%r9), %bl
movb %bl, (%rcx,%r13)
movb %r8b, (%rcx,%r9)
incq %rax
cmpq %rax, %rbp
jne 0x3e9f
testl %r12d, %r12d
jle 0x3efd
cmpq 0x10(%rsp), %r11
jge 0x3efd
movq %r13, %rax
subq 0x8(%rsp), %rax
cmpq 0x10(%rsp), %rax
jge 0x3efd
xorl %ecx, %ecx
movq (%r10,%rcx,8), %r8
movb (%r8,%rax), %bl
movb (%r8,%r11), %r15b
movb %r15b, (%r8,%rax)
movq 0x20(%rsp), %r15
movq (%r10,%rcx,8), %r8
movb %bl, (%r8,%r11)
incq %rcx
cmpq %rcx, %rbp
jne 0x3ed8
movq (%r15,%r9,8), %r8
movzbl (%r8,%r9), %eax
testq %rax, %rax
jne 0x3f19
incq %r13
cmpq 0x50(%rsp), %r13
jl 0x3e5b
testq %rax, %rax
movq 0x38(%rsp), %rcx
je 0x3fb0
cmpq %r14, %rcx
movq 0x18(%rsp), %rcx
jge 0x3f8f
addq %r9, %r8
movq %rcx, 0x18(%rsp)
movq (%r15,%rcx,8), %r11
movzbl (%r11,%r9), %r10d
testq %r10, %r10
je 0x3f7d
addq %r9, %r11
xorl %ecx, %ecx
movzbl (%r11,%rcx), %ebx
movl %eax, %r15d
shll $0x8, %r15d
addq %rdi, %r15
movzbl (%r8,%rcx), %r12d
movl %r10d, %r13d
shll $0x8, %r13d
addq %rdi, %r13
movb (%r12,%r13), %r12b
xorb (%rbx,%r15), %r12b
movb %r12b, (%r11,%rcx)
incq %rcx
cmpl %ecx, %esi
jne 0x3f4c
movq 0x18(%rsp), %rcx
incq %rcx
cmpq %r14, %rcx
movq 0x20(%rsp), %r15
jl 0x3f34
addq $0x8, %rdx
decq %rsi
movq 0x38(%rsp), %r9
cmpl %r9d, 0x4(%rsp)
movq 0x48(%rsp), %r10
movl 0x34(%rsp), %r12d
jne 0x3e40
movl 0x40(%rsp), %r14d
testl %r14d, %r14d
movq 0x60(%rsp), %r8
jle 0x3feb
movl %r14d, %eax
xorl %ecx, %ecx
testl %r12d, %r12d
jle 0x3fe3
xorl %edx, %edx
movq (%r10,%rdx,8), %rsi
movb (%rsi,%rcx), %sil
movq (%r8,%rdx,8), %rdi
movb %sil, (%rdi,%rcx)
incq %rdx
cmpq %rdx, %rbp
jne 0x3fcb
incq %rcx
cmpq %rax, %rcx
jne 0x3fc4
testl %r12d, %r12d
jle 0x4003
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x2030
incq %rbx
cmpq %rbx, %rbp
jne 0x3ff2
movq %r15, %rdi
callq 0x2030
jmp 0x4048
xorl %r14d, %r14d
jmp 0x4048
testl %r12d, %r12d
jle 0x4045
movl %r12d, %eax
movl %ebp, %r9d
xorl %edx, %edx
testl %ebp, %ebp
jle 0x403d
xorl %esi, %esi
movq (%rcx,%rdx,8), %r8
movb (%r8,%rsi), %r10b
movq (%rdi,%rdx,8), %r8
movb %r10b, (%r8,%rsi)
incq %rsi
cmpq %rsi, %r9
jne 0x4025
incq %rdx
cmpq %rax, %rdx
jne 0x401f
movl %ebp, %r14d
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq