// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: computeCriteria(double**, double**, int, CRITERIA*, double*, long*, double*, long*)
void computeCriteria(double ** Matrix1, double ** Matrix2, int size,struct CRITERIA *aCrit,double *L1, long int *A1,double *L2, long int *A2){

	int mI,m,i,j,RF,QD;
	double LS,BD=0;

	//= robinson and foulds
	m=Bipartition_Table(Matrix1,aCrit->B,aCrit->PLACE,size);
	mI=Bipartition_Table(Matrix2,aCrit->BI,aCrit->PLACEI,size);
	RF = Table_Comparaison(aCrit->B,aCrit->BI,aCrit->PLACE,aCrit->PLACEI,m,mI,size); 

	//= least-squares
	LS = 0.0;
	for (i=1;i<=size-1;i++)
	{
		for (j=i+1;j<=size;j++){
			LS=LS + (Matrix1[i][j]-Matrix2[i][j])*(Matrix1[i][j]-Matrix2[i][j]);
		}
	}

	//= Bipartition Distance
	BD = BipartitionDistance(aCrit->B,aCrit->BI,size);
	
	aCrit->LS = LS;
	aCrit->BD = BD;
	aCrit->RF = RF;
	aCrit->QD = QD;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rdx
movl -0x14(%rbp), %ecx
callq 0x40a0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rdx
movl -0x14(%rbp), %ecx
callq 0x40a0
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rcx
movl -0x38(%rbp), %r8d
movl -0x34(%rbp), %r9d
movl -0x14(%rbp), %eax
movl %eax, (%rsp)
callq 0x49c0
movl %eax, -0x44(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0xeb65
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0xeb55
movsd -0x50(%rbp), %xmm1
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xeadc
jmp 0xeb57
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xeac2
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rsi
movl -0x14(%rbp), %edx
callq 0x12a0
movsd %xmm0, -0x58(%rbp)
movsd -0x50(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x58(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movl -0x44(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
movl -0x48(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x34(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)