// File: /workspace/github_cpp_makefile_star2_O2/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: midPoint(long*, double**, int, int)
int midPoint(long int *ARETE,double **DIST,int n,int kt){

	double max;
	int i,j,i1,j1,P;


	/*/== recherche la plus grande distance*/
	max = 0;
	for(i=1;i<=n;i++){
/*		printf("\n");*/
		for(j=1;j<=n;j++){
		/*	printf("%lf ",DIST[i][j]);*/
			if(DIST[i][j] > max){
				max = DIST[i][j];
				i1=i; j1=j;
			}
		}
	}
//		printf("\nnouvel arbre :  ");
//		printf(" %d-%d, max =%lf",i1,j1,max);
	P = -1;
	for(i=1;i<=2*n-3-kt;i++){
		if(ARETE[2*i-1] == i1 || ARETE[2*i-1] == j1 || ARETE[2*i-2] == i1 || ARETE[2*i-2] == j1 ){
			if(DIST[ARETE[2*i-1]][ARETE[2*i-2]] >= max/2.0){
				P = i;
			//	printf("icit meme ");
				break;
			}
		}
		else{
			if(ARETE[2*i-1] > n && ARETE[2*i-2]> n)
			  if( (((DIST[i1][ARETE[2*i-1]]>(max/2.0)) || (fabs(DIST[i1][ARETE[2*i-1]]-(max/2.0))<0.00001)) && 
				     ((DIST[j1][ARETE[2*i-2]]>(max/2.0)) || (fabs(DIST[j1][ARETE[2*i-2]]-(max/2.0))<0.00001))) ||
		        (((DIST[i1][ARETE[2*i-2]]>(max/2.0)) || (fabs(DIST[i1][ARETE[2*i-2]]-(max/2.0))<0.00001)) && 
				      ((DIST[j1][ARETE[2*i-1]]>(max/2.0)) || (fabs(DIST[j1][ARETE[2*i-1]]-(max/2.0))<0.00001))) 
		     ){
					P = i;
			//		printf("la meme ");

					if( fabs(DIST[i1][j1] - DIST[i1][ARETE[2*i-1]] - DIST[ARETE[2*i-1]][j1]) < 0.00001 )
						break;
			}
		}
	}
//	printf(" ,arete : %d--%d (%d) \n",ARETE[2*(*P)-1],ARETE[2*(*P)-2],(*P));

	return P;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leal 0x1(%rdx), %eax
xorl %r8d, %r8d
testl %edx, %edx
cmovgl %edx, %r8d
incl %r8d
xorpd %xmm0, %xmm0
movabsq $0x1, %r11
movq %r11, %rbx
cmpq %r8, %rbx
je 0xa6fa
movq %r11, %r14
cmpq %r14, %rax
je 0xa6f5
movq (%rsi,%rbx,8), %r15
movsd (%r15,%r14,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %ebx, %r9d
cmoval %r14d, %r10d
maxsd %xmm0, %xmm1
incq %r14
movapd %xmm1, %xmm0
jmp 0xa6cd
incq %rbx
jmp 0xa6c5
leal (%rdx,%rdx), %r8d
subl %ecx, %r8d
addl $-0x3, %r8d
movslq %r9d, %rcx
movslq %r10d, %r9
movslq %edx, %rdx
mulsd 0x98f2(%rip), %xmm0     # 0x14008
xorl %r10d, %r10d
testl %r8d, %r8d
cmovlel %r10d, %r8d
shlq $0x4, %r8
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movabsq $0x1, %rax
movapd 0x9944(%rip), %xmm1     # 0x14080
movsd 0x98e4(%rip), %xmm2     # 0x14028
cmpq %r10, %r8
je 0xa848
movq (%rdi,%r10), %r14
movq 0x8(%rdi,%r10), %rbx
cmpq %rcx, %rbx
je 0xa82c
cmpq %r9, %rbx
je 0xa82c
cmpq %rcx, %r14
je 0xa82c
cmpq %r9, %r14
je 0xa82c
cmpq %rdx, %rbx
setle %r15b
cmpq %rdx, %r14
setle %r12b
orb %r15b, %r12b
jne 0xa83c
movq (%rsi,%rcx,8), %r15
movsd (%r15,%rbx,8), %xmm3
ucomisd %xmm0, %xmm3
ja 0xa7b3
movapd %xmm3, %xmm4
subsd %xmm0, %xmm4
andpd %xmm1, %xmm4
ucomisd %xmm4, %xmm2
jbe 0xa7d1
movq (%rsi,%r9,8), %r12
movsd (%r12,%r14,8), %xmm4
ucomisd %xmm0, %xmm4
ja 0xa809
subsd %xmm0, %xmm4
andpd %xmm1, %xmm4
ucomisd %xmm4, %xmm2
ja 0xa809
movsd (%r15,%r14,8), %xmm4
ucomisd %xmm0, %xmm4
ja 0xa7eb
subsd %xmm0, %xmm4
andpd %xmm1, %xmm4
ucomisd %xmm4, %xmm2
jbe 0xa83c
movq (%rsi,%r9,8), %r14
movsd (%r14,%rbx,8), %xmm4
ucomisd %xmm0, %xmm4
ja 0xa809
subsd %xmm0, %xmm4
andpd %xmm1, %xmm4
ucomisd %xmm4, %xmm2
jbe 0xa83c
movsd (%r15,%r9,8), %xmm4
subsd %xmm3, %xmm4
movq (%rsi,%rbx,8), %r11
subsd (%r11,%r9,8), %xmm4
andpd %xmm1, %xmm4
ucomisd %xmm4, %xmm2
movl %eax, %r11d
jbe 0xa83c
jmp 0xa84b
movq (%rsi,%rbx,8), %rbx
movsd (%rbx,%r14,8), %xmm3
ucomisd %xmm0, %xmm3
jae 0xa84b
incq %rax
addq $0x10, %r10
jmp 0xa744
movl %r11d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq