// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: readInput(int, char const*, InputTree*)
int readInput(int Type, const char *file,struct InputTree * aTree){

	int size,i,j;
	char name[50];
	double val;
	FILE * in;
	
	//= ouverture du fichier
	if((in = fopen(file,"r"))== NULL)
		return -1;

	//= lecture de la taille des matrices
	fscanf(in,"%d",&size);

	//= allocation de la m�moire
	//allocMemmory(aTree,1);
	aTree->size = size;
	size++; // more space for the root
	aTree->SpeciesName = (char **)malloc((size+1)*sizeof(char*));
	aTree->Input = (double**)malloc((2*size)*sizeof(double*));
	aTree->ADD = (double**)malloc((2*size)*sizeof(double*));
	aTree->W = (double**)malloc((size+1)*sizeof(double*));
	for(i=0;i<2*size;i++){
		aTree->ADD[i] = (double*)malloc((2*size)*sizeof(double));
		aTree->Input[i] = (double*)malloc((2*size)*sizeof(double));
		if(i<=size){
			aTree->SpeciesName[i] = (char*)malloc(SPECIES_NAME_LENGTH);
			aTree->W[i] = (double*)malloc((size+1)*sizeof(double));
		}
	}

	for(i=0;i<=size;i++)
		for(j=0;j<=size;j++)
			aTree->W[i][j] = 1.0;

	size--;
	//= reads species tree
	for(i=1;i<=size;i++)
	{
		fscanf(in,"%s",name);
		if(Type == SPECIE) strcpy(aTree->SpeciesName[i],name);
		for(j=1;j<=size;j++)
		{
			fscanf(in,"%lf",&val);
			if(Type == SPECIE) aTree->Input[i][j] = val;
		}	    
	}

	//= read gene tree
	for(i=1;i<=size;i++)
	{
		fscanf(in,"%s",name);
		if(Type == GENE) strcpy(aTree->SpeciesName[i],name);
		for(j=1;j<=size;j++)
		{
			fscanf(in,"%lf",&val);
			if(Type == GENE) aTree->Input[i][j] = val;
		}	
	}

	strcpy(aTree->SpeciesName[size+1],"Root");
	
	fclose(in);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xaa69(%rip), %rsi      # 0x26417
callq 0x10c0
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
jne 0x1b9c9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1bd09
movq -0x70(%rbp), %rdi
leaq 0xa8ab(%rip), %rsi      # 0x2627f
leaq -0x1c(%rbp), %rdx
movb $0x0, %al
callq 0x1190
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %eax
shll %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x1c(%rbp), %eax
shll %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jge 0x1bb1c
movl -0x1c(%rbp), %eax
shll %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
shll %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bb0c
movl $0x32, %edi
callq 0x1110
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rdx
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1bb0e
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1ba6a
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bb73
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bb66
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd 0x94f2(%rip), %xmm0     # 0x25048
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1bb32
jmp 0x1bb68
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1bb23
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bc2a
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rdx
leaq 0xa92b(%rip), %rsi      # 0x264c9
movb $0x0, %al
callq 0x1190
cmpl $0x1, -0x8(%rbp)
jne 0x1bbc4
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1080
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bc1a
movq -0x70(%rbp), %rdi
leaq 0x983d(%rip), %rsi      # 0x2541b
leaq -0x68(%rbp), %rdx
movb $0x0, %al
callq 0x1190
cmpl $0x1, -0x8(%rbp)
jne 0x1bc0d
movsd -0x68(%rbp), %xmm0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1bc0f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1bbcb
jmp 0x1bc1c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1bb83
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bcd8
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rdx
leaq 0xa87d(%rip), %rsi      # 0x264c9
movb $0x0, %al
callq 0x1190
cmpl $0x2, -0x8(%rbp)
jne 0x1bc72
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1080
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1bcc8
movq -0x70(%rbp), %rdi
leaq 0x978f(%rip), %rsi      # 0x2541b
leaq -0x68(%rbp), %rdx
movb $0x0, %al
callq 0x1190
cmpl $0x2, -0x8(%rbp)
jne 0x1bcbb
movsd -0x68(%rbp), %xmm0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1bcbd
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1bc79
jmp 0x1bcca
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1bc31
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x9a37(%rip), %rsi      # 0x2572b
callq 0x1080
movq -0x70(%rbp), %rdi
callq 0x1090
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)