// File: /workspace/github_c_makefile_star2_O2/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
movq %r8, 0x18(%rsp)
movq %r9, 0x20(%rsp)
testl %r9d, %r9d
je 0x3891
movq %rcx, %r15
testl %edx, %edx
je 0x3895
movq %rsi, %r12
movq %rdi, 0x60(%rsp)
movq 0x20(%rsp), %rax
movq %rdx, 0x30(%rsp)
leal (%rax,%rdx), %ebx
movq 0x18(%rsp), %r14
movslq %r14d, %r13
leaq (,%r13,8), %rdi
callq 0x21c0
movq %rax, %rdx
movl %ebx, 0x14(%rsp)
movslq %ebx, %rbp
xorl %ebx, %ebx
testl %r13d, %r13d
movl $0x0, %eax
cmovgl %r14d, %eax
movq %rax, %r14
movq %rdx, 0x8(%rsp)
cmpq %rbx, %r14
je 0x3515
movq %rbp, %rdi
callq 0x21c0
movq 0x8(%rsp), %rdx
movq %rax, (%rdx,%rbx,8)
incq %rbx
jmp 0x34fa
movq %r14, 0x48(%rsp)
xorl %eax, %eax
movq 0x30(%rsp), %r10
testl %r10d, %r10d
movl $0x0, %ecx
cmovgl %r10d, %ecx
movslq %r10d, %r14
movq 0x20(%rsp), %rsi
testl %esi, %esi
movl $0x0, %r9d
cmovgl %esi, %r9d
cmpq 0x48(%rsp), %rax
je 0x359c
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x356e
movq (%r12,%rax,8), %rdi
movb (%rdi,%rsi), %dil
movq 0x8(%rsp), %rdx
movq (%rdx,%rax,8), %r8
movb %dil, (%r8,%rsi)
movq 0x8(%rsp), %rdx
incq %rsi
jmp 0x354a
xorl %esi, %esi
cmpq %rsi, %r9
je 0x3597
movq (%r15,%rax,8), %rdi
movb (%rdi,%rsi), %dil
movq 0x8(%rsp), %rdx
movq (%rdx,%rax,8), %r8
addq %r14, %r8
movb %dil, (%rsi,%r8)
movq 0x8(%rsp), %rdx
incq %rsi
jmp 0x3570
incq %rax
jmp 0x3541
movq %r13, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq 0x18(%rsp), %rax
cmpl %r10d, %eax
movl %r10d, %ecx
cmovll %eax, %ecx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
movq %rcx, 0x38(%rsp)
movl %r10d, %r8d
movl %eax, %r12d
leaq 0x13a43(%rip), %rbx     # 0x17010
movq %r8, 0x28(%rsp)
movl 0x14(%rsp), %eax
cmpl %eax, %esi
movl %eax, %r13d
cmovgl %esi, %r13d
cmpq 0x38(%rsp), %rsi
je 0x36de
movq %rsi, %r15
movq %rsi, 0x40(%rsp)
cmpq %r8, %r15
je 0x365c
movq %rsi, %rax
cmpq %rax, %r12
je 0x364c
movq (%rdx,%rax,8), %rcx
cmpb $0x0, (%rcx,%r15)
jne 0x360f
incq %rax
jmp 0x35fa
movl %eax, %eax
cmpq %rsi, %rax
je 0x3626
movq (%rdx,%rax,8), %rcx
movq (%rdx,%rsi,8), %rdi
movq %rdi, (%rdx,%rax,8)
movq %rcx, (%rdx,%rsi,8)
cmpq %rsi, %r15
je 0x364c
movl %r15d, %edi
movq 0x18(%rsp), %rcx
movl 0x14(%rsp), %r8d
callq 0x2b55
movq 0x28(%rsp), %r8
movq 0x40(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq (%rdx,%rsi,8), %rax
movb (%rax,%rsi), %cl
incq %r15
testb %cl, %cl
je 0x35f2
jmp 0x3667
movq (%rdx,%rsi,8), %rax
movb (%rax,%rsi), %cl
testb %cl, %cl
je 0x36de
movzbl %cl, %ecx
shll $0x8, %ecx
addq %rbx, %rcx
movq %rsi, %r15
movq %rsi, %r8
leaq 0x1(%r8), %rdx
cmpl 0x18(%rsp), %edx
jge 0x36c9
movq 0x8(%rsp), %rsi
movq 0x8(%rsi,%r8,8), %rsi
movzbl (%rsi,%r15), %edi
movq %rdx, %r8
testq %rdi, %rdi
je 0x3676
movq %r15, %r8
cmpq %r8, %r13
je 0x36c4
movzbl (%rsi,%r8), %r9d
movzbl (%rax,%r8), %r10d
movl %edi, %r11d
shll $0x8, %r11d
addq %rbx, %r11
movb (%r10,%r11), %r10b
xorb (%r9,%rcx), %r10b
movb %r10b, (%rsi,%r8)
incq %r8
jmp 0x369a
movq %rdx, %r8
jmp 0x3676
movq %r15, %rsi
incq %rsi
movq 0x8(%rsp), %rdx
movq 0x28(%rsp), %r8
jmp 0x35d2
movq 0x20(%rsp), %rax
subl 0x30(%rsp), %eax
movl %eax, 0x38(%rsp)
movq 0x18(%rsp), %rcx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
cmovgel %ecx, %eax
cltq
movq %rax, 0x40(%rsp)
leaq (%rdx,%r14,8), %r12
movq 0x50(%rsp), %r13
cmpq 0x40(%rsp), %r14
jge 0x382b
movl %r14d, %eax
subl 0x30(%rsp), %eax
movl %eax, 0x28(%rsp)
movq %r14, %r15
cmpq %rbp, %r15
jge 0x37b0
xorl %eax, %eax
leaq (%r14,%rax), %rcx
cmpq %r13, %rcx
jge 0x379b
movq (%r12,%rax,8), %rcx
cmpb $0x0, (%rcx,%r15)
jne 0x3746
incq %rax
jmp 0x372d
testq %rax, %rax
je 0x3757
movq (%rdx,%r14,8), %rsi
movq %rsi, (%r12,%rax,8)
movq %rcx, (%rdx,%r14,8)
cmpq %r14, %r15
je 0x379b
movl %r15d, %edi
movl %r14d, %esi
movq 0x18(%rsp), %r13
movl %r13d, %ecx
movl 0x14(%rsp), %r8d
callq 0x2b55
movl %r15d, %edi
subl 0x30(%rsp), %edi
movl 0x28(%rsp), %esi
movq 0x58(%rsp), %rdx
movl %r13d, %ecx
movq 0x50(%rsp), %r13
movq 0x20(%rsp), %r8
callq 0x2b55
movq 0x8(%rsp), %rdx
movq (%rdx,%r14,8), %rax
movb (%rax,%r14), %cl
incq %r15
testb %cl, %cl
je 0x3722
jmp 0x37bc
movq (%rdx,%r14,8), %rax
movb (%rax,%r14), %cl
testb %cl, %cl
je 0x382b
movzbl %cl, %ecx
shll $0x8, %ecx
addq %rbx, %rcx
movq %r14, %r8
leaq 0x1(%r8), %rdx
cmpq %r13, %rdx
jge 0x381a
movq 0x8(%rsp), %rsi
movq 0x8(%rsi,%r8,8), %rsi
movzbl (%rsi,%r14), %edi
movq %rdx, %r8
testq %rdi, %rdi
je 0x37c8
movq %r14, %r8
cmpq %rbp, %r8
jge 0x3815
movzbl (%rsi,%r8), %r9d
movzbl (%rax,%r8), %r10d
movl %edi, %r11d
shll $0x8, %r11d
addq %rbx, %r11
movb (%r10,%r11), %r10b
xorb (%r9,%rcx), %r10b
movb %r10b, (%rsi,%r8)
incq %r8
jmp 0x37eb
movq %rdx, %r8
jmp 0x37c8
incq %r14
addq $0x8, %r12
movq 0x8(%rsp), %rdx
jmp 0x3709
xorl %eax, %eax
movl 0x38(%rsp), %ebp
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
movq 0x60(%rsp), %r8
movq 0x48(%rsp), %r14
movq 0x58(%rsp), %r9
cmpq %rcx, %rax
je 0x3870
xorl %edx, %edx
cmpq %rdx, %r14
je 0x386b
movq (%r9,%rdx,8), %rsi
movb (%rsi,%rax), %sil
movq (%r8,%rdx,8), %rdi
movb %sil, (%rdi,%rax)
incq %rdx
jmp 0x3851
incq %rax
jmp 0x384a
xorl %ebx, %ebx
cmpq %rbx, %r14
movq 0x8(%rsp), %rdi
je 0x388a
movq (%rdi,%rbx,8), %rdi
callq 0x2030
incq %rbx
jmp 0x3872
callq 0x2030
jmp 0x38df
xorl %ebp, %ebp
jmp 0x38df
xorl %eax, %eax
movq 0x20(%rsp), %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movq 0x18(%rsp), %r9
testl %r9d, %r9d
cmovlel %eax, %r9d
cmpq %r9, %rax
je 0x38d8
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x38d3
movq (%r15,%rax,8), %rsi
movb (%rsi,%rdx), %sil
movq (%rdi,%rax,8), %r8
movb %sil, (%r8,%rdx)
incq %rdx
jmp 0x38b9
incq %rax
jmp 0x38b2
movq 0x20(%rsp), %rax
movl %eax, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq