// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: findListSpecies(HGT*, DescTree*, InputTree)
void findListSpecies(struct HGT *bestHGT, struct DescTree *DTSpecies,struct InputTree aTree){

	int source,dest,i;
//	exit(0);

  //printf("\n%d-%d",bestHGT->source,aTree.Root);
	//== find the node inf for the source branch
	if(aTree.ADD[aTree.ARETE[2*(bestHGT->source)-1]][aTree.Root] <  aTree.ADD[aTree.ARETE[2*(bestHGT->source)-2]][aTree.Root])
		source = aTree.ARETE[2*(bestHGT->source)-2];
	else
		source = aTree.ARETE[2*(bestHGT->source)-1];

	//== find the node inf for the dest branch
	if(aTree.ADD[aTree.ARETE[2*(bestHGT->destination)-1]][aTree.Root] <  aTree.ADD[aTree.ARETE[2*(bestHGT->destination)-2]][aTree.Root])
		dest = aTree.ARETE[2*(bestHGT->destination)-2];
	else
		dest = aTree.ARETE[2*(bestHGT->destination)-1];
	
	if(bestHGT->listSource != NULL)
		free(bestHGT->listSource);
	bestHGT->listSource = (int *)malloc((DTSpecies[source].nbSommet+1)*sizeof(int));
	bestHGT->listSource[0] = DTSpecies[source].nbSommet;
	for(i=1;i<=DTSpecies[source].nbSommet;i++) bestHGT->listSource[i] = DTSpecies[source].Tableau[i];

	if(bestHGT->listDestination != NULL)
		free(bestHGT->listDestination);
	bestHGT->listDestination = (int *)malloc((DTSpecies[dest].nbSommet+1)*sizeof(int));
	bestHGT->listDestination[0] = DTSpecies[dest].nbSommet;
	for(i=1;i<=DTSpecies[dest].nbSommet;i++) bestHGT->listDestination[i] = DTSpecies[dest].Tableau[i];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x10(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x8(%rcx), %rax
movq 0x30(%rcx), %rdx
movq -0x8(%rbp), %rsi
movl 0x4(%rsi), %esi
shll %esi
subl $0x1, %esi
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x20(%rcx), %rdx
movsd (%rax,%rdx,8), %xmm1
movq 0x8(%rcx), %rax
movq 0x30(%rcx), %rdx
movq -0x8(%rbp), %rsi
movl 0x4(%rsi), %esi
shll %esi
subl $0x2, %esi
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x20(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x11bce
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x14(%rbp)
jmp 0x11bec
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x14(%rbp)
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x30(%rcx), %rdx
movq -0x8(%rbp), %rsi
movl 0x8(%rsi), %esi
shll %esi
subl $0x1, %esi
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x20(%rcx), %rdx
movsd (%rax,%rdx,8), %xmm1
movq 0x8(%rcx), %rax
movq 0x30(%rcx), %rdx
movq -0x8(%rbp), %rsi
movl 0x8(%rsi), %esi
shll %esi
subl $0x2, %esi
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x20(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x11c66
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x18(%rbp)
jmp 0x11c84
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
shll %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x11c9c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10e0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, (%rax)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jg 0x11d33
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x11ce9
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x11d4b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x10e0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, (%rax)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jg 0x11de2
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x11d98
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)