// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: printLeaves(char*, int, HGT*, int, char**)
void printLeaves(char *fichier,int nbHGT,struct HGT *outHGT,int noTree,char **NomsSpecies){

	FILE *out;
	int i,j;

	out = fopen(fichier,"a+");
/*	fprintf(out,"#detection %d",noTree);
	for(i=1;i<=nbHGT;i++){
		if(outHGT[i].valide == 1) {
			fprintf(out,"\n%d ",outHGT[i].listSource[0]);
			for(j=1;j<=outHGT[i].listSource[0];j++)
				fprintf(out,"%s ",NomsSpecies[outHGT[i].listSource[j]]);
			fprintf(out,"\n%d ",outHGT[i].listDestination[0]);
			for(j=1;j<=outHGT[i].listDestination[0];j++)
				fprintf(out,"%s ",NomsSpecies[outHGT[i].listDestination[j]]);
		}
	}
	fprintf(out,"\n");*/
	for(i=1;i<=nbHGT;i++){
		
		if((outHGT[i].valide == 1) || (outHGT[i].valide == 6)) {
			fprintf(out,"\ndetection %d : ",noTree);
			//fprintf(out,"\n%d ",outHGT[i].listSource[0]);
			for(j=1;j<=outHGT[i].listSource[0];j++){
				fprintf(out,"%s",NomsSpecies[outHGT[i].listSource[j]]);
				if(j<outHGT[i].listSource[0])
					fprintf(out,";");
				else
					fprintf(out," ");
			}
			//fprintf(out,"\n%d ",outHGT[i].listDestination[0]);
			for(j=1;j<=outHGT[i].listDestination[0];j++){
				fprintf(out,"%s",NomsSpecies[outHGT[i].listDestination[j]]);
				if(j<outHGT[i].listDestination[0])
					fprintf(out,";");
			}
		}
	}
	fprintf(out,"\n");
	fclose(out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x12ebf(%rip), %rsi     # 0x25774
callq 0x10c0
movq %rax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x12a78
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
je 0x12903
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
cmpl $0x6, (%rax)
jne 0x12a68
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x130b6(%rip), %rsi     # 0x259c7
movb $0x0, %al
callq 0x1140
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
cmpl (%rcx), %eax
jg 0x129cb
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x13b58(%rip), %rsi     # 0x264c9
movb $0x0, %al
callq 0x1140
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x129a9
movq -0x30(%rbp), %rdi
leaq 0x12f0f(%rip), %rsi     # 0x258af
movb $0x0, %al
callq 0x1140
jmp 0x129bb
movq -0x30(%rbp), %rdi
leaq 0x12a28(%rip), %rsi     # 0x253dc
movb $0x0, %al
callq 0x1140
jmp 0x129bd
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1291f
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jg 0x12a66
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x13aa9(%rip), %rsi     # 0x264c9
movb $0x0, %al
callq 0x1140
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x12a56
movq -0x30(%rbp), %rdi
leaq 0x12e60(%rip), %rsi     # 0x258af
movb $0x0, %al
callq 0x1140
jmp 0x12a58
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x129d2
jmp 0x12a68
jmp 0x12a6a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x128c5
movq -0x30(%rbp), %rdi
leaq 0x13774(%rip), %rsi     # 0x261f7
movb $0x0, %al
callq 0x1140
movq -0x30(%rbp), %rdi
callq 0x1090
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)