// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: readInputFile(_IO_FILE*, char const*, char*)
int readInputFile(FILE *in, const char *tmpFile/*, struct InputTree *speciesTree, struct InputTree *geneTree*/,char *fichier_erreur){
	
	char *newick;
	struct InputTree speciesTree_t;
	struct InputTree geneTree_t;
	int ret;

	initInputTree(&speciesTree_t);
	initInputTree(&geneTree_t);

	//== read the species tree
  ret = nextTreeIsNewick(in);
	if(ret==-1)
		return -1;
	else if(ret==1){
		newick = readNewick(in);
		ret = (int)strlen(newick);
		newickToMatrix(newick,&speciesTree_t);
		free(newick);
	}
	else
		readMatrix(in,&speciesTree_t);
	
	//== read the gene tree
	ret = nextTreeIsNewick(in);
	if(ret==-1)
		return -1;
	else if(ret==1){
		newick = readNewick(in);
		newickToMatrix(newick,&geneTree_t);
		free(newick);
	}
	else
		readMatrix(in,&geneTree_t);
//	printf("%d--%d",speciesTree_t.size,geneTree_t.size);
	filtrerMatrice(speciesTree_t.Input,geneTree_t.Input,speciesTree_t.SpeciesName,geneTree_t.SpeciesName,speciesTree_t.size,geneTree_t.size,fichier_erreur);
//	printf("%d--%d",speciesTree_t.size,geneTree_t.size);

	if(ecrireMatrice(speciesTree_t.Input,tmpFile,speciesTree_t.size,speciesTree_t.SpeciesName) == -1)
		return -2;
	ajouterMatriceGene(geneTree_t.Input,tmpFile,geneTree_t.size,geneTree_t.SpeciesName);
	/*
	TrierMatrices(geneTree_t.Input,geneTree_t.SpeciesName,speciesTree_t.SpeciesName,speciesTree_t.size);
	
  (*speciesTree) = speciesTree_t;
  (*geneTree)    = geneTree_t;
  */
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xd040
leaq -0xd8(%rbp), %rdi
callq 0xd040
movq -0x10(%rbp), %rdi
callq 0x13980
movl %eax, -0xdc(%rbp)
cmpl $-0x1, -0xdc(%rbp)
jne 0x13d50
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e77
cmpl $0x1, -0xdc(%rbp)
jne 0x13d8d
movq -0x10(%rbp), %rdi
callq 0x13a10
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1050
movl %eax, -0xdc(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13b30
movq -0x28(%rbp), %rdi
callq 0x10e0
jmp 0x13d9a
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13c00
jmp 0x13d9c
movq -0x10(%rbp), %rdi
callq 0x13980
movl %eax, -0xdc(%rbp)
cmpl $-0x1, -0xdc(%rbp)
jne 0x13dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13e77
cmpl $0x1, -0xdc(%rbp)
jne 0x13df1
movq -0x10(%rbp), %rdi
callq 0x13a10
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x13b30
movq -0x28(%rbp), %rdi
callq 0x10e0
jmp 0x13e01
movq -0x10(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x13c00
jmp 0x13e03
movq -0x70(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0xc0(%rbp), %rcx
movl -0x80(%rbp), %r8d
movl -0xd8(%rbp), %r9d
movq -0x20(%rbp), %rax
movq %rax, (%rsp)
callq 0xa6a0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x80(%rbp), %edx
movq -0x68(%rbp), %rcx
callq 0xa930
cmpl $-0x1, %eax
jne 0x13e53
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x13e77
movq -0xc8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xd8(%rbp), %edx
movq -0xc0(%rbp), %rcx
callq 0xab00
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)