// File: /workspace/github_cpp_makefile_star2_O1/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: addLeafAndUpdate(InputTree*, int)
void addLeafAndUpdate(struct InputTree *aTree, int choix){
	
	int n = aTree->size;
	int i,j;


	for(i=1;i<=2*n-3-aTree->kt;i++){
		if(aTree->ARETE[2*i-1] > n) aTree->ARETE[2*i-1] += 1 ;
		if(aTree->ARETE[2*i-2] > n) aTree->ARETE[2*i-2] += 1 ;
	}
	

	//= ajout des 2 nouvelles branches
	aTree->ARETE[2*(2*n-2-aTree->kt)-1] = aTree->ARETE[2*choix-1];
	aTree->ARETE[2*(2*n-2-aTree->kt)-2] = 2*n-aTree->kt;
	aTree->LONGUEUR[(2*n-2-aTree->kt)-1] = ((aTree->LONGUEUR[choix-1]/2.0)>5*epsilon)?(aTree->LONGUEUR[choix-1]/2.0):5*epsilon;

	aTree->ARETE[2*(2*n-1-aTree->kt)-1] = aTree->ARETE[2*choix-2];
	aTree->ARETE[2*(2*n-1-aTree->kt)-2] = 2*n-aTree->kt;
	aTree->LONGUEUR[(2*n-1-aTree->kt)-1] = ((aTree->LONGUEUR[choix-1]/2.0)>5*epsilon)?(aTree->LONGUEUR[choix-1]/2.0):5*epsilon;
	
	aTree->ARETE[2*choix-1] = n+1;
	aTree->ARETE[2*choix-2] = 2*n-aTree->kt;
	aTree->LONGUEUR[choix-1]= 5*epsilon;  

	aTree->size = aTree->size+1;


	loadAdjacenceMatrix(aTree->Adjacence,aTree->ARETE, aTree->LONGUEUR,n+1,aTree->kt);

	Floyd(aTree->Adjacence,aTree->ADD,aTree->Input,n+1,aTree->kt);//5eme fois

	strcpy(aTree->SpeciesName[aTree->size],"Root");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq (%rdi), %rcx
leaq (%rcx,%rcx), %rdi
movslq 0x48(%rbx), %r8
movl %edi, %eax
subl %r8d, %eax
addl $-0x3, %eax
testl %eax, %eax
jle 0x723f
movq 0x30(%rbx), %rax
movl %edi, %edx
subl %r8d, %edx
addl $-0x2, %edx
addq $0x8, %rax
decq %rdx
movq (%rax), %r9
cmpq %rcx, %r9
jle 0x7226
incq %r9
movq %r9, (%rax)
movq -0x8(%rax), %r9
cmpq %rcx, %r9
jle 0x7236
incq %r9
movq %r9, -0x8(%rax)
addq $0x10, %rax
decq %rdx
jne 0x7218
movq 0x30(%rbx), %rax
leal (%rsi,%rsi), %edx
movslq %edx, %r9
movq -0x8(%rax,%r9,8), %rdx
movq %rdi, %r11
addq $-0x2, %r11
movl %r8d, %r10d
notl %r10d
leal (%r11,%r10), %r14d
movq %r11, %r15
subq %r8, %r15
shlq $0x4, %r15
movq %rdx, -0x8(%rax,%r15)
movl %edi, %edx
subl %r8d, %edx
movslq %edx, %r11
movq %r11, -0x10(%rax,%r15)
movq 0x38(%rbx), %rdx
movslq %esi, %rsi
movsd 0xdd7e(%rip), %xmm0     # 0x15008
movsd -0x8(%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd 0xdda4(%rip), %xmm2     # 0x15040
maxsd %xmm2, %xmm1
movslq %r14d, %r14
movsd %xmm1, (%rdx,%r14,8)
movq -0x10(%rax,%r9,8), %r14
leal -0x1(%rdi), %r15d
subl %r8d, %r15d
addl %r15d, %r15d
movslq %r15d, %r15
movq %r14, -0x8(%rax,%r15,8)
movq %r11, -0x10(%rax,%r15,8)
mulsd -0x8(%rdx,%rsi,8), %xmm0
maxsd %xmm2, %xmm0
addl %r10d, %edi
decl %edi
movslq %edi, %rdi
movsd %xmm0, (%rdx,%rdi,8)
incl %ecx
movslq %ecx, %r14
movq %r14, -0x8(%rax,%r9,8)
movq %r11, -0x10(%rax,%r9,8)
movabsq $0x3f0a36e2eb1c432d, %rcx # imm = 0x3F0A36E2EB1C432D
movq %rcx, -0x8(%rdx,%rsi,8)
movl %r14d, (%rbx)
movq 0x28(%rbx), %rdi
movq %rax, %rsi
movl %r14d, %ecx
callq 0x22a4
movq 0x28(%rbx), %rdi
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movl 0x48(%rbx), %r8d
movl %r14d, %ecx
callq 0x1de5
movq 0x18(%rbx), %rax
movslq (%rbx), %rcx
movq (%rax,%rcx,8), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f52, (%rax)     # imm = 0x746F6F52
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq