// File: /workspace/github_cpp_makefile_star2_O2/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: findBranch(InputTree, int*, int*)
void findBranch(struct InputTree aTree,int *branch, int * elt){
	
	double max = INFINI; //= disctance between root and intersection
	int j;

	(*branch) = 0;
	
	if(elt[0]==1){
		for(j=1;j<=2*aTree.size-3-aTree.kt;j++)
			if(aTree.ARETE[2*j-1]==elt[1] || aTree.ARETE[2*j-2]==elt[1])
				(*branch) = j;
	}
	else{
		for(j=2;j<=elt[0];j++){		
			if(max > ( (aTree.ADD[aTree.Root][elt[1]] + aTree.ADD[aTree.Root][elt[j]] - aTree.ADD[elt[1]][elt[j]]) / 2.0 ) )
				max = (aTree.ADD[aTree.Root][elt[1]] + aTree.ADD[aTree.Root][elt[j]] - aTree.ADD[elt[1]][elt[j]]) / 2.0 ;  
		}
		//printf("\nmax=%lf",max);	

		for(j=1;j<=2*aTree.size-3-aTree.kt;j++){
			if( (fabs(aTree.ADD[aTree.Root][aTree.ARETE[2*j-1]]- max) < 2*epsilon) && (aTree.ADD[aTree.Root][aTree.ARETE[2*j-2]] < aTree.ADD[aTree.Root][aTree.ARETE[2*j-1]]) && (fabs(aTree.ADD[aTree.Root][aTree.ARETE[2*j-1]]+aTree.ADD[aTree.ARETE[2*j-1]][elt[1]] - aTree.ADD[aTree.Root][elt[1]]) < 2*epsilon)  )
				(*branch) = j;
			if( (fabs(aTree.ADD[aTree.Root][aTree.ARETE[2*j-2]]- max) < 2*epsilon) && (aTree.ADD[aTree.Root][aTree.ARETE[2*j-1]] < aTree.ADD[aTree.Root][aTree.ARETE[2*j-2]]) && (fabs(aTree.ADD[aTree.Root][aTree.ARETE[2*j-2]]+aTree.ADD[aTree.ARETE[2*j-2]][elt[1]] - aTree.ADD[aTree.Root][elt[1]]) < 2*epsilon))
				(*branch) = j;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
andl $0x0, (%rdi)
leaq 0x10(%rbp), %r8
movslq (%rsi), %rdx
cmpq $0x1, %rdx
jne 0xc1d4
movl (%r8), %eax
addl %eax, %eax
subl 0x48(%r8), %eax
addl $-0x3, %eax
movq 0x30(%r8), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
shlq $0x4, %rax
movl $0x1, %r8d
cmpq %rdx, %rax
je 0xc305
movslq 0x4(%rsi), %r9
cmpq %r9, 0x8(%rcx,%rdx)
je 0xc1c8
cmpq %r9, (%rcx,%rdx)
jne 0xc1cb
movl %r8d, (%rdi)
addq $0x10, %rdx
incl %r8d
jmp 0xc1ae
movq 0x8(%r8), %rax
movslq 0x20(%r8), %rcx
movsd 0x7e64(%rip), %xmm0     # 0x14048
movabsq $0x2, %r9
movsd 0x7e12(%rip), %xmm1     # 0x14008
cmpq %rdx, %r9
jg 0xc22e
movq (%rax,%rcx,8), %r10
movslq 0x4(%rsi), %r11
movsd (%r10,%r11,8), %xmm2
movslq (%rsi,%r9,4), %rbx
addsd (%r10,%rbx,8), %xmm2
movq (%rax,%r11,8), %r10
subsd (%r10,%rbx,8), %xmm2
mulsd %xmm1, %xmm2
minsd %xmm0, %xmm2
incq %r9
movapd %xmm2, %xmm0
jmp 0xc1f6
movl (%r8), %edx
addl %edx, %edx
subl 0x48(%r8), %edx
addl $-0x3, %edx
movq 0x30(%r8), %r8
xorl %r9d, %r9d
testl %edx, %edx
cmovlel %r9d, %edx
shlq $0x4, %rdx
movl $0x1, %r10d
movapd 0x7e27(%rip), %xmm1     # 0x14080
movsd 0x7daf(%rip), %xmm2     # 0x14010
cmpq %r9, %rdx
je 0xc305
movq (%rax,%rcx,8), %r11
movq (%r8,%r9), %rbx
movq 0x8(%r8,%r9), %r14
movsd (%r11,%r14,8), %xmm4
movapd %xmm4, %xmm3
subsd %xmm0, %xmm3
andpd %xmm1, %xmm3
ucomisd %xmm3, %xmm2
movsd (%r11,%rbx,8), %xmm3
jbe 0xc2c0
ucomisd %xmm3, %xmm4
jbe 0xc2c0
movq (%rax,%r14,8), %r14
movslq 0x4(%rsi), %r15
movsd (%r14,%r15,8), %xmm5
addsd %xmm4, %xmm5
subsd (%r11,%r15,8), %xmm5
andpd %xmm1, %xmm5
ucomisd %xmm5, %xmm2
jbe 0xc2c0
movl %r10d, (%rdi)
movapd %xmm3, %xmm5
subsd %xmm0, %xmm5
andpd %xmm1, %xmm5
ucomisd %xmm5, %xmm2
jbe 0xc2f9
ucomisd %xmm4, %xmm3
jbe 0xc2f9
movq (%rax,%rbx,8), %rbx
movslq 0x4(%rsi), %r14
addsd (%rbx,%r14,8), %xmm3
subsd (%r11,%r14,8), %xmm3
andpd %xmm1, %xmm3
ucomisd %xmm3, %xmm2
jbe 0xc2f9
movl %r10d, (%rdi)
addq $0x10, %r9
incl %r10d
jmp 0xc261
popq %rbx
popq %r14
popq %r15
popq %rbp
retq