// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rcx, -0x30(%rbp)
movl %edx, %r15d
movq %rsi, -0x50(%rbp)
movq 0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x4c55(%rip), %rsi      # 0x15795
callq 0x10e0
testq %rax, %rax
je 0x11101
movq %rax, %rbx
leaq 0x10(%rbp), %r14
leaq 0x5d2d(%rip), %rdi      # 0x16889
movl $0x12, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x11f0
leaq 0x5d27(%rip), %rdi      # 0x1689c
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5d1f(%rip), %rdi      # 0x168ad
movl $0xf, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5d16(%rip), %rdi      # 0x168bd
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5d10(%rip), %rdi      # 0x168d0
movl $0x14, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5d0c(%rip), %rdi      # 0x168e5
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x5d10(%rip), %rdi      # 0x16902
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movl 0x48(%r14), %r13d
leaq 0x5d05(%rip), %rsi      # 0x16914
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x1180
movl %r15d, -0x40(%rbp)
cmpl $0x1, %r15d
leaq 0x6258(%rip), %rax      # 0x16e83
leaq 0x4ea6(%rip), %rdx      # 0x15ad8
cmoveq %rax, %rdx
leaq 0x5ce0(%rip), %rsi      # 0x1691d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1180
movl (%r14), %r15d
leaq 0x5cdc(%rip), %rsi      # 0x1692d
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1180
leaq 0x5cd0(%rip), %rdi      # 0x16935
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
testl %r15d, %r15d
jle 0x10cae
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r14
xorl %r12d, %r12d
testq %r12, %r12
je 0x10c99
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 0x10c87
leaq 0x5c87(%rip), %rdi      # 0x1693c
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leal (%r15,%r15), %ecx
subl %r13d, %ecx
leal -0x3(%rcx), %eax
testl %eax, %eax
jle 0x10d97
movl %eax, -0x44(%rbp)
leaq 0x10(%rbp), %rax
movq 0x30(%rax), %r13
addl $-0x2, %ecx
addq $0x8, %r13
movq %rcx, -0x58(%rbp)
leaq -0x1(%rcx), %r14
leaq 0x5c4d(%rip), %r15      # 0x16947
xorl %r12d, %r12d
testq %r12, %r12
je 0x10d0f
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x8(%r13), %rcx
movq (%r13), %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
addq $0x10, %r13
incq %r12
cmpq %r12, %r14
jne 0x10cfd
leaq 0x5c18(%rip), %rdi      # 0x1694f
movl $0xc, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x44(%rbp)
movq -0x58(%rbp), %r13
jle 0x10db0
leaq 0x10(%rbp), %rax
movq 0x38(%rax), %r14
decq %r13
xorl %r12d, %r12d
leaq 0x46d3(%rip), %r15      # 0x1543b
testq %r12, %r12
je 0x10d7a
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movsd (%r14,%r12,8), %xmm0
movq %rbx, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x1180
incq %r12
cmpq %r12, %r13
jne 0x10d68
jmp 0x10db0
leaq 0x5bb1(%rip), %rdi      # 0x1694f
movl $0xc, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x1, -0x40(%rbp)
jne 0x10ef9
leaq 0x5b9b(%rip), %rdi      # 0x1695c
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq -0x30(%rbp), %rax
testl %eax, %eax
jle 0x10f17
incl %eax
movq %rax, -0x40(%rbp)
imulq $0xa8, %rax, %r13
addq $-0xa8, %r13
leaq 0x5b6a(%rip), %r15      # 0x16964
xorl %r12d, %r12d
xorl %eax, %eax
movq -0x50(%rbp), %r14
cmpl $0x0, 0xa8(%r14,%r12)
jle 0x10e52
cmpl $0x1, %eax
jne 0x10e20
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movl 0x128(%r14,%r12), %edx
movl 0x12c(%r14,%r12), %ecx
movl 0x130(%r14,%r12), %r8d
movl 0x134(%r14,%r12), %r9d
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r12
cmpq %r12, %r13
jne 0x10e03
leaq 0x5b0b(%rip), %rdi      # 0x16970
movl $0xd, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x30(%rbp)
jle 0x10f30
imulq $0xa8, -0x40(%rbp), %r12
addq $-0xa8, %r12
leaq 0x5acd(%rip), %r15      # 0x16964
xorl %r13d, %r13d
xorl %eax, %eax
cmpl $0x0, 0xa8(%r14,%r13)
jle 0x10eeb
cmpl $0x1, %eax
jne 0x10eb9
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movl 0x140(%r14,%r13), %edx
movl 0x144(%r14,%r13), %ecx
movl 0x148(%r14,%r13), %r8d
movl 0x14c(%r14,%r13), %r9d
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r13
cmpq %r13, %r12
jne 0x10e9c
jmp 0x10f30
leaq 0x5aba(%rip), %rdi      # 0x169ba
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
jmp 0x110eb
leaq 0x5a52(%rip), %rdi      # 0x16970
movl $0xd, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpq $0x0, -0x38(%rbp)
je 0x10fa5
leaq 0x5a40(%rip), %rdi      # 0x1697e
movl $0x1, %r12d
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq -0x30(%rbp), %rax
testl %eax, %eax
jle 0x110a1
leal 0x1(%rax), %r14d
xorl %r13d, %r13d
leaq 0x5a1a(%rip), %r15      # 0x1698a
testb $0x1, %r13b
je 0x10f83
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movq -0x38(%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 0x10f70
leaq 0x59e5(%rip), %rdi      # 0x16991
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
movq -0x30(%rbp), %rax
testl %eax, %eax
jle 0x110ba
incl %eax
movq %rax, -0x38(%rbp)
imulq $0xa8, %rax, %r13
movl $0xa8, %r12d
leaq 0x51f6(%rip), %r15      # 0x161da
xorl %eax, %eax
movq -0x50(%rbp), %r14
movl (%r14,%r12), %edx
testl %edx, %edx
jle 0x1101a
cmpl $0x1, %eax
jne 0x11008
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movl (%r14,%r12), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r12
cmpq %r12, %r13
jne 0x10fea
leaq 0x5973(%rip), %rdi      # 0x169a0
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
cmpl $0x0, -0x30(%rbp)
jle 0x110d3
imulq $0xa8, -0x38(%rbp), %r12
movl $0xa8, %r13d
leaq 0x517c(%rip), %r15      # 0x161da
xorl %eax, %eax
cmpl $0x0, (%r14,%r13)
jle 0x11093
cmpl $0x1, %eax
jne 0x11079
movl $0x2c, %edi
movq %rbx, %rsi
callq 0x1130
movl 0x94(%r14,%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1180
movl $0x1, %eax
addq $0xa8, %r13
cmpq %r13, %r12
jne 0x11060
jmp 0x110d3
leaq 0x58e9(%rip), %rdi      # 0x16991
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x58df(%rip), %rdi      # 0x169a0
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11f0
leaq 0x10(%rbp), %rax
movl 0x20(%rax), %edx
leaq 0x58d0(%rip), %rsi      # 0x169b1
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1180
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a0
leaq 0x5765(%rip), %rdi      # 0x1686d
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110