// File: /workspace/github_cpp_makefile_star2_O3/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: expandBestHGT(HGT, HGT*, ReduceTrace, DescTree*, InputTree)
void expandBestHGT(struct HGT bestHGTRed,struct HGT *bestHGT,struct ReduceTrace aMap,struct DescTree * DTSpecies,struct InputTree SpeciesTree){
	
	//bestHGT->source = (int*)malloc(

	int i,j,nbSource=0,nbDest=0,tmp;

	for(i=1;i<=bestHGTRed.listSource[0];i++){
		for(j=1;j<=DTSpecies[aMap.map[bestHGTRed.listSource[i]]].nbSommet;j++){
			nbSource++;
		}
	}

	bestHGT->listSource = (int*)malloc((nbSource+1)*sizeof(int));
	bestHGT->listSource[0] = nbSource;
	tmp=1;
	for(i=1;i<=bestHGTRed.listSource[0];i++){
		for(j=1;j<=DTSpecies[aMap.map[bestHGTRed.listSource[i]]].nbSommet;j++){
			bestHGT->listSource[tmp] = DTSpecies[aMap.map[bestHGTRed.listSource[i]]].Tableau[j];
			tmp++;
		}
	}
	TrierTableau(bestHGT->listSource,tmp-1);
	
/*	printf("\nSource :");
	for(i=1;i<=bestHGT->listSource[0];i++)
		printf(" %d",bestHGT->listSource[i]);
    */

	for(i=1;i<=bestHGTRed.listDestination[0];i++){
		for(j=1;j<=DTSpecies[aMap.map[bestHGTRed.listDestination[i]]].nbSommet;j++){
			nbDest++;
		}
	}

	bestHGT->listDestination = (int*)malloc((nbDest+1)*sizeof(int));
	bestHGT->listDestination[0] = nbDest;
	tmp=1;
	for(i=1;i<=bestHGTRed.listDestination[0];i++){
		for(j=1;j<=DTSpecies[aMap.map[bestHGTRed.listDestination[i]]].nbSommet;j++){
			bestHGT->listDestination[tmp] = DTSpecies[aMap.map[bestHGTRed.listDestination[i]]].Tableau[j];
			tmp++;
		}
	}
	TrierTableau(bestHGT->listDestination,tmp-1);
	
/*	printf("\nDest   :");
	for(i=1;i<=bestHGT->listDestination[0];i++)
		printf(" %d",bestHGT->listDestination[i]);
	*/

	//== find branches
	findBranch(SpeciesTree,&i,bestHGT->listSource);
	findBranch(SpeciesTree,&j,bestHGT->listDestination);
	bestHGT->source = i;
	bestHGT->destination = j;

	bestHGT->source_A = SpeciesTree.ARETE[2*i-1];
	bestHGT->source_B = SpeciesTree.ARETE[2*i-2];
	bestHGT->dest_A = SpeciesTree.ARETE[2*j-1];
	bestHGT->dest_B = SpeciesTree.ARETE[2*j-2];

	bestHGT->valide = bestHGTRed.valide;
	bestHGT->crit = bestHGTRed.crit;

	free(bestHGTRed.listSource);
	free(bestHGTRed.listDestination);
	bestHGTRed.listSource = NULL;
	bestHGTRed.listDestination = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r12
movq %rdi, -0x38(%rbp)
leaq 0xb8(%rbp), %rax
movq 0x20(%rbp), %r10
movl (%r10), %ebx
testl %ebx, %ebx
movq %r10, -0x40(%rbp)
jle 0xd44d
movq 0x18(%rax), %rcx
leaq 0x1(%rbx), %rdx
xorl %esi, %esi
movl $0x1, %edi
xorl %eax, %eax
movslq (%r10,%rdi,4), %r8
movslq (%rcx,%r8,4), %r8
leaq (%r8,%r8,2), %r8
movl (%r12,%r8,8), %r8d
testl %r8d, %r8d
movl %r8d, %r9d
cmovlel %esi, %r9d
addl %r9d, %eax
incq %rdi
cmpq %rdi, %rdx
jne 0xd415
leal 0x1(%r8), %ecx
testl %r8d, %r8d
movl $0x1, %r14d
cmovgl %ecx, %r14d
jmp 0xd44f
xorl %eax, %eax
movslq %eax, %r15
leaq 0x4(,%r15,4), %rdi
callq 0x1140
movq %rax, %r13
movq -0x38(%rbp), %rax
movq %r13, 0x10(%rax)
movl %r15d, (%r13)
testl %ebx, %ebx
leaq 0xb8(%rbp), %r11
jle 0xd52d
movq 0x18(%r11), %rcx
movl $0x1, %eax
movl $0x1, %edx
movq -0x40(%rbp), %r10
movslq (%r10,%rdx,4), %rsi
movslq (%rcx,%rsi,4), %rdi
leaq (%rdi,%rdi,2), %r8
cmpl $0x0, (%r12,%r8,8)
jle 0xd4e1
movslq %eax, %r8
leaq (,%r8,4), %r8
addq %r13, %r8
xorl %r14d, %r14d
leaq (%rdi,%rdi,2), %rdi
movq 0x10(%r12,%rdi,8), %rdi
movl 0x4(%rdi,%r14,4), %edi
movl %edi, (%r8,%r14,4)
movslq (%rcx,%rsi,4), %rdi
leaq (%rdi,%rdi,2), %r9
movslq (%r12,%r9,8), %r9
incq %r14
cmpq %r9, %r14
jl 0xd4b3
addl %r14d, %eax
incl %r14d
jmp 0xd4e7
movl $0x1, %r14d
leaq 0x1(%rdx), %rsi
cmpq %rbx, %rdx
movq %rsi, %rdx
jb 0xd48f
cmpl $0x3, %eax
jl 0xd52d
decl %eax
movl 0x4(%r13), %ecx
xorl %esi, %esi
movl $0x1, %edx
movl 0x4(%r13,%rdx,4), %edi
cmpl %edi, %ecx
jle 0xd51f
movl %edi, (%r13,%rdx,4)
movl %ecx, 0x4(%r13,%rdx,4)
movl $0x1, %esi
jmp 0xd521
movl %edi, %ecx
incq %rdx
cmpq %rdx, %rax
jne 0xd505
testl %esi, %esi
jne 0xd4fa
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r15
movl (%r15), %ebx
testl %ebx, %ebx
jle 0xd585
movq 0x18(%r11), %rcx
leaq 0x1(%rbx), %rdx
xorl %esi, %esi
movl $0x1, %edi
xorl %eax, %eax
movslq (%r15,%rdi,4), %r8
movslq (%rcx,%r8,4), %r8
leaq (%r8,%r8,2), %r8
movl (%r12,%r8,8), %r8d
testl %r8d, %r8d
movl %r8d, %r9d
cmovlel %esi, %r9d
addl %r9d, %eax
incq %rdi
cmpq %rdi, %rdx
jne 0xd54d
leal 0x1(%r8), %ecx
testl %r8d, %r8d
movl $0x1, %r14d
cmovgl %ecx, %r14d
jmp 0xd587
xorl %eax, %eax
movl %r14d, -0x2c(%rbp)
cltq
movq %rax, -0x48(%rbp)
leaq 0x4(,%rax,4), %rdi
callq 0x1140
movq %rax, %r14
movq -0x38(%rbp), %rax
movq %r14, 0x18(%rax)
movq -0x48(%rbp), %rax
movl %eax, (%r14)
movl $0x1, -0x30(%rbp)
testl %ebx, %ebx
jle 0xd66c
leaq 0xb8(%rbp), %rax
movq 0x18(%rax), %rcx
movl $0x1, %eax
movl $0x1, %edx
movslq (%r15,%rdx,4), %rdi
movslq (%rcx,%rdi,4), %r8
leaq (%r8,%r8,2), %rsi
cmpl $0x0, (%r12,%rsi,8)
jle 0xd61c
movslq %eax, %rsi
leaq (%r14,%rsi,4), %r9
xorl %esi, %esi
leaq (%r8,%r8,2), %r8
movq 0x10(%r12,%r8,8), %r8
movl 0x4(%r8,%rsi,4), %r8d
movl %r8d, (%r9,%rsi,4)
movslq (%rcx,%rdi,4), %r8
leaq (%r8,%r8,2), %r10
movslq (%r12,%r10,8), %r10
incq %rsi
cmpq %r10, %rsi
jl 0xd5f0
addl %esi, %eax
incl %esi
jmp 0xd621
movl $0x1, %esi
leaq 0x1(%rdx), %rdi
cmpq %rbx, %rdx
movq %rdi, %rdx
jb 0xd5d4
movl %esi, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
cmpl $0x3, %eax
jl 0xd66c
decl %eax
movl 0x4(%r14), %ecx
xorl %esi, %esi
movl $0x1, %edx
movl 0x4(%r14,%rdx,4), %edi
cmpl %edi, %ecx
jle 0xd65e
movl %edi, (%r14,%rdx,4)
movl %ecx, 0x4(%r14,%rdx,4)
movl $0x1, %esi
jmp 0xd660
movl %edi, %ecx
incq %rdx
cmpq %rdx, %rax
jne 0xd645
testl %esi, %esi
jne 0xd63a
movl $0xb, %ecx
movq %rsp, %rdi
leaq 0xe0(%rbp), %rbx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x30(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0xd232
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x2c(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0xd232
movslq (%r12), %rax
movq -0x38(%rbp), %rdi
movl %eax, 0x4(%rdi)
movslq (%r13), %rcx
movl %ecx, 0x8(%rdi)
movq 0x30(%rbx), %rdx
shlq $0x4, %rax
movl -0x8(%rdx,%rax), %esi
movl %esi, 0x80(%rdi)
movl -0x10(%rdx,%rax), %eax
movl %eax, 0x84(%rdi)
shlq $0x4, %rcx
movl -0x8(%rdx,%rcx), %eax
movl %eax, 0x88(%rdi)
movl -0x10(%rdx,%rcx), %eax
movl %eax, 0x8c(%rdi)
leaq 0x10(%rbp), %rsi
movl (%rsi), %eax
movl %eax, (%rdi)
addq $0x20, %rsi
addq $0x20, %rdi
movl $0xc, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x40(%rbp), %rdi
callq 0x1100
movq %r15, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100