// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %rbx
movq %rsi, %rax
movl %edi, %r15d
leaq 0x6892(%rip), %rsi      # 0x16372
movq %rax, %rdi
callq 0x10e0
testq %rax, %rax
je 0xfd97
movq %rax, %r14
leaq 0x66df(%rip), %rsi      # 0x161da
leaq -0x2c(%rbp), %r13
movq %rax, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x11e0
movslq (%r13), %r12
movq %r13, %rax
movl %r12d, (%rbx)
leaq 0x1(%r12), %r13
movl %r13d, (%rax)
leaq 0x10(,%r12,8), %rdi
movq %rdi, -0x50(%rbp)
callq 0x1140
movq %rax, 0x18(%rbx)
movq %r13, -0x40(%rbp)
shlq $0x4, %r13
movq %r13, %rdi
callq 0x1140
movq %rax, 0x10(%rbx)
movq %r13, %rdi
callq 0x1140
movq %rax, 0x8(%rbx)
movq -0x50(%rbp), %rdi
callq 0x1140
movq %rbx, -0x38(%rbp)
movq %rax, 0x40(%rbx)
movq %r12, -0x58(%rbp)
testq %r12, %r12
js 0xfbe9
movq -0x40(%rbp), %rcx
movl %ecx, %eax
movq %rax, -0x60(%rbp)
leal (%rcx,%rcx), %eax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movq %rcx, -0x40(%rbp)
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x1140
movq -0x38(%rbp), %r12
movq 0x8(%r12), %rcx
movq %rax, (%rcx,%rbx,8)
movq %r13, %rdi
callq 0x1140
movq 0x10(%r12), %rcx
movq %rax, (%rcx,%rbx,8)
cmpq -0x60(%rbp), %rbx
ja 0xfbe0
movl $0x32, %edi
callq 0x1140
movq -0x38(%rbp), %r12
movq 0x18(%r12), %rcx
movq %rax, (%rcx,%rbx,8)
movq -0x50(%rbp), %rdi
callq 0x1140
movq 0x40(%r12), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, -0x40(%rbp)
jne 0xfb8b
movq -0x58(%rbp), %r9
cmpl $-0x1, %r9d
movq -0x38(%rbp), %rcx
jl 0xfc26
leal 0x2(%r9), %eax
movq 0x40(%rcx), %rcx
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq (%rcx,%rdx,8), %rdi
xorl %r8d, %r8d
movq %rsi, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0xfc12
incq %rdx
cmpq %rax, %rdx
jne 0xfc0b
movl %r9d, -0x2c(%rbp)
testl %r9d, %r9d
jle 0xfccd
movl $0x1, %ebx
leaq -0x48(%rbp), %r13
movq %r14, %rdi
leaq 0x67de(%rip), %rsi      # 0x16424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x1, %r15d
jne 0xfc72
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax,%rbx,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
cmpl $0x0, -0x2c(%rbp)
jle 0xfcb9
xorl %r12d, %r12d
movq %r14, %rdi
leaq 0x57b6(%rip), %rsi      # 0x1543b
movq %r13, %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x1, %r15d
jne 0xfcad
movsd -0x48(%rbp), %xmm0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, 0x8(%rax,%r12,8)
movslq -0x2c(%rbp), %rax
incq %r12
cmpq %rax, %r12
jl 0xfc7b
leaq 0x1(%rbx), %rax
movslq -0x2c(%rbp), %rcx
cmpq %rcx, %rbx
movq %rax, %rbx
jl 0xfc3c
movl -0x2c(%rbp), %eax
testl %eax, %eax
jle 0xfd72
movl $0x1, %ebx
leaq -0x48(%rbp), %r13
movq %r14, %rdi
leaq 0x6739(%rip), %rsi      # 0x16424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x2, %r15d
jne 0xfd17
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax,%rbx,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
cmpl $0x0, -0x2c(%rbp)
jle 0xfd5e
xorl %r12d, %r12d
movq %r14, %rdi
leaq 0x5711(%rip), %rsi      # 0x1543b
movq %r13, %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x2, %r15d
jne 0xfd52
movsd -0x48(%rbp), %xmm0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, 0x8(%rax,%r12,8)
movslq -0x2c(%rbp), %rax
incq %r12
cmpq %rax, %r12
jl 0xfd20
leaq 0x1(%rbx), %rcx
movslq -0x2c(%rbp), %rax
cmpq %rax, %rbx
movq %rcx, %rbx
jl 0xfce1
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %rcx
cltq
movq 0x8(%rcx,%rax,8), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f52, (%rax)     # imm = 0x746F6F52
movq %r14, %rdi
callq 0x10a0
xorl %eax, %eax
jmp 0xfd9c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq