// File: /workspace/github_cpp_makefile_star2_O1/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: saveTree(char*, InputTree, HGT*, int, int, char const*, char*, double*)
void saveTree(char * fichier,struct InputTree SpeciesTree,struct HGT *bestHGT, int addHGT,int cpt_hgt,const char *subtree,char *SCENARIO,double *bootStrap){
	
	FILE *out;
	int i, first=0;

	if ((out=fopen(fichier,"w+"))==NULL){
		printf("can't open species web file");
		exit(-1);
	}

	fprintf(out,"maptype = VERTICAL");
	fprintf(out,"\nintVerPrint = O");
	fprintf(out,"\nproportion = N");
	fprintf(out,"\ndrawRealNames = 1");
	fprintf(out,"\ncolorobject = BLACK");
	fprintf(out,"\ncolorreticulation = MAGENTA");
	fprintf(out,"\ncoloredge = BLUE");
	fprintf(out,"\nkt = %d",SpeciesTree.kt);
	fprintf(out,"\ndrawRetic = %s",(addHGT == 1)?"2":"0");
	fprintf(out,"\nn = %d",SpeciesTree.size);
	fprintf(out,"\net = ");
	for(i=1;i<=SpeciesTree.size;i++){
		if(i!=1) fprintf(out,",");
		fprintf(out,"%s",SpeciesTree.SpeciesName[i]);
	}
	fprintf(out,"\naretes = ");
	for(i=1;i<=2*SpeciesTree.size-3-SpeciesTree.kt;i++){
		if(i!=1) fprintf(out,",");
		fprintf(out,"%ld,%ld",SpeciesTree.ARETE[2*i-1],SpeciesTree.ARETE[2*i-2]);
	}
	fprintf(out,"\nlongueur = ");
	for(i=1;i<=2*SpeciesTree.size-3-SpeciesTree.kt;i++){
		if(i!=1) fprintf(out,",");
		fprintf(out,"%lf",SpeciesTree.LONGUEUR[i-1]);
	}
	if(addHGT == 1){
		fprintf(out,"\nhgt = ");
		for(i=1;i<=cpt_hgt;i++){
			if((bestHGT[i].valide >=1)/* && (bestHGT[i].trivial==0)*/){
				if(first==1) fprintf(out,","); 
				first=1;
				fprintf(out,"%d,%d,%d,%d",bestHGT[i].source_A,bestHGT[i].source_B,bestHGT[i].dest_A,bestHGT[i].dest_B);
			}
		}
		fprintf(out,"\nhgt_reels = ");
		first=0;
		for(i=1;i<=cpt_hgt;i++){
			if((bestHGT[i].valide >=1)/* && (bestHGT[i].trivial==0)*/){
				if(first==1) fprintf(out,","); 
				first=1;
				fprintf(out,"%d,%d,%d,%d",bestHGT[i].source_Ar,bestHGT[i].source_Br,bestHGT[i].dest_Ar,bestHGT[i].dest_Br);
			}
		}
		if(bootStrap != NULL){
			first=0;
			fprintf(out,"\nbootHGT = ");
			for(i=1;i<=cpt_hgt;i++){
				if(first==1) fprintf(out,","); 
				first=1;
				fprintf(out,"%1.0lf",bootStrap[i]);
			}
		}
		fprintf(out,"\nhgt_valide = ");
		first=0;
		for(i=1;i<=cpt_hgt;i++){
			if((bestHGT[i].valide >=1)/* && (bestHGT[i].trivial==0)*/){
				if(first==1) fprintf(out,","); 
				first=1;
				
				fprintf(out,"%d",bestHGT[i].valide);
			}
		}
		fprintf(out,"\nhgt_sequence = ");
		first=0;
		for(i=1;i<=cpt_hgt;i++){
			if((bestHGT[i].valide >=1)/* && (bestHGT[i].trivial==0)*/){
				if(first==1) fprintf(out,","); 
				first=1;
				fprintf(out,"%d",bestHGT[i].sequence);
			}
		}
	}
	if(addHGT == 1)
		fprintf(out,"\nroot=%d",SpeciesTree.Root);
	else
		fprintf(out,"\nroot=0");

	fclose(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, -0x38(%rbp)
movl %edx, %r15d
movq %rsi, -0x30(%rbp)
movq 0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x4c1a(%rip), %rsi      # 0x15795
callq 0x10e0
testq %rax, %rax
je 0x110d6
movq %rax, %rbx
leaq 0x10(%rbp), %r14
leaq 0x5cf2(%rip), %rdi      # 0x16889
movl $0x12, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x11f0
leaq 0x5cec(%rip), %rdi      # 0x1689c
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5ce4(%rip), %rdi      # 0x168ad
movl $0xf, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5cdb(%rip), %rdi      # 0x168bd
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5cd5(%rip), %rdi      # 0x168d0
movl $0x14, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5cd1(%rip), %rdi      # 0x168e5
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5cd5(%rip), %rdi      # 0x16902
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movl 0x48(%r14), %r13d
leaq 0x5cca(%rip), %rsi      # 0x16914
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x1180
movl %r15d, -0x40(%rbp)
cmpl $0x1, %r15d
leaq 0x621d(%rip), %rax      # 0x16e83
leaq 0x4e6b(%rip), %rdx      # 0x15ad8
cmoveq %rax, %rdx
leaq 0x5ca5(%rip), %rsi      # 0x1691d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1180
movl (%r14), %r15d
leaq 0x5ca1(%rip), %rsi      # 0x1692d
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1180
leaq 0x5c95(%rip), %rdi      # 0x16935
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
testl %r15d, %r15d
jle 0x10ce9
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r14
xorl %r12d, %r12d
testq %r12, %r12
je 0x10cd4
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq 0x8(%r14,%r12,8), %rdi
movq %rbx, %rsi
callq 0x10c0
incq %r12
cmpq %r12, %r15
jne 0x10cc2
leaq 0x5c4c(%rip), %rdi      # 0x1693c
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leal (%r15,%r15), %r12d
subl %r13d, %r12d
leal -0x3(%r12), %eax
movl %eax, -0x3c(%rbp)
testl %eax, %eax
jle 0x10d63
leaq 0x10(%rbp), %rax
movq 0x30(%rax), %r13
leal -0x2(%r12), %r14d
addq $0x8, %r13
decq %r14
xorl %r15d, %r15d
testq %r15, %r15
je 0x10d3e
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x8(%r13), %rcx
movq (%r13), %rdx
movq %rbx, %rdi
leaq 0x5bf7(%rip), %rsi      # 0x16947
xorl %eax, %eax
callq 0x1180
addq $0x10, %r13
incq %r15
cmpq %r15, %r14
jne 0x10d2c
leaq 0x5be5(%rip), %rdi      # 0x1694f
movl $0xc, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x3c(%rbp)
jle 0x10dc8
leaq 0x10(%rbp), %rax
movq 0x38(%rax), %r14
addl $-0x2, %r12d
decq %r12
xorl %r13d, %r13d
leaq 0x46a0(%rip), %r15      # 0x1543b
testq %r13, %r13
je 0x10dad
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movsd (%r14,%r13,8), %xmm0
movq %rbx, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1180
incq %r13
cmpq %r13, %r12
jne 0x10d9b
cmpl $0x1, -0x40(%rbp)
jne 0x110a7
leaq 0x5b83(%rip), %rdi      # 0x1695c
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq -0x38(%rbp), %r14
testl %r14d, %r14d
jle 0x10e79
leal 0x1(%r14), %eax
imulq $0xa8, %rax, %r12
addq $-0xa8, %r12
leaq 0x5b53(%rip), %r15      # 0x16964
xorl %r13d, %r13d
xorl %eax, %eax
movq -0x30(%rbp), %rcx
cmpl $0x0, 0xa8(%rcx,%r13)
jle 0x10e6d
cmpl $0x1, %eax
jne 0x10e37
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x30(%rbp), %rax
movl 0x128(%rax,%r13), %edx
movl 0x12c(%rax,%r13), %ecx
movl 0x130(%rax,%r13), %r8d
movl 0x134(%rax,%r13), %r9d
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r13
cmpq %r13, %r12
jne 0x10e16
leaq 0x5af0(%rip), %rdi      # 0x16970
movl $0xd, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
testl %r14d, %r14d
jle 0x10f1c
leal 0x1(%r14), %eax
imulq $0xa8, %rax, %r12
addq $-0xa8, %r12
leaq 0x5ab0(%rip), %r15      # 0x16964
xorl %r13d, %r13d
xorl %eax, %eax
movq -0x30(%rbp), %rcx
cmpl $0x0, 0xa8(%rcx,%r13)
jle 0x10f10
cmpl $0x1, %eax
jne 0x10eda
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x30(%rbp), %rax
movl 0x140(%rax,%r13), %edx
movl 0x144(%rax,%r13), %ecx
movl 0x148(%rax,%r13), %r8d
movl 0x14c(%rax,%r13), %r9d
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r13
cmpq %r13, %r12
jne 0x10eb9
cmpq $0x0, -0x48(%rbp)
je 0x10f8f
leaq 0x5a54(%rip), %rdi      # 0x1697e
movl $0x1, %r12d
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x38(%rbp)
jle 0x10f8f
movq -0x38(%rbp), %rax
leal 0x1(%rax), %r14d
xorl %r13d, %r13d
leaq 0x5a30(%rip), %r15      # 0x1698a
testb $0x1, %r13b
je 0x10f6d
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x48(%rbp), %rax
movsd (%rax,%r12,8), %xmm0
movb $0x1, %r13b
movq %rbx, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1180
incq %r12
cmpq %r12, %r14
jne 0x10f5a
leaq 0x59fb(%rip), %rdi      # 0x16991
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x38(%rbp)
jle 0x1100d
movq -0x38(%rbp), %rax
incl %eax
imulq $0xa8, %rax, %r12
movl $0xa8, %r14d
leaq 0x5212(%rip), %r15      # 0x161da
xorl %eax, %eax
movq -0x30(%rbp), %rcx
cmpl $0x0, (%rcx,%r14)
jle 0x11001
cmpl $0x1, %eax
jne 0x10fe7
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x30(%rbp), %rax
movl (%rax,%r14), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r14
cmpq %r14, %r12
jne 0x10fca
leaq 0x598c(%rip), %rdi      # 0x169a0
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq -0x38(%rbp), %rax
testl %eax, %eax
jle 0x1108d
incl %eax
imulq $0xa8, %rax, %r12
movl $0xa8, %r14d
leaq 0x5196(%rip), %r15      # 0x161da
xorl %eax, %eax
movq -0x30(%rbp), %rcx
cmpl $0x0, (%rcx,%r14)
jle 0x11081
cmpl $0x1, %eax
jne 0x11063
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x30(%rbp), %rax
movl 0x94(%rax,%r14), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r14
cmpq %r14, %r12
jne 0x11046
leaq 0x10(%rbp), %rax
movl 0x20(%rax), %edx
leaq 0x5916(%rip), %rsi      # 0x169b1
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1180
jmp 0x110c0
leaq 0x590c(%rip), %rdi      # 0x169ba
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a0
leaq 0x5790(%rip), %rdi      # 0x1686d
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110