// File: /workspace/github_cpp_makefile_star2_O2/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, -0x2c(%rbp)
leaq 0x6c63(%rip), %rsi      # 0x15372
movq %rax, %rdi
callq 0x10d0
testq %rax, %rax
je 0xe963
movq %rax, %r15
leaq 0x6ab0(%rip), %rsi      # 0x151da
xorl %r13d, %r13d
leaq -0x30(%rbp), %r12
movq %rax, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x11c0
movslq (%r12), %r12
movl %r12d, (%rbx)
movq %r12, %r14
incq %r14
leal 0x2(%r12), %eax
movl %eax, -0x4c(%rbp)
movslq %eax, %rdi
shlq $0x3, %rdi
movq %rdi, -0x58(%rbp)
callq 0x1130
movq %rax, 0x18(%rbx)
movq %r14, -0x38(%rbp)
leal (%r14,%r14), %ecx
movq %rcx, -0x40(%rbp)
shlq $0x4, %r14
movq %r14, %rdi
callq 0x1130
movq %rax, 0x10(%rbx)
movq %r14, -0x60(%rbp)
movq %r14, %rdi
callq 0x1130
movq %rax, 0x8(%rbx)
movq -0x58(%rbp), %rdi
callq 0x1130
movq %rax, 0x40(%rbx)
movslq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
testl %eax, %eax
cmovlel %r13d, %eax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %r14
cmpq %r13, -0x40(%rbp)
je 0xe80c
movq %r14, %rdi
callq 0x1130
movq 0x8(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq %r14, %rdi
callq 0x1130
movq 0x10(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
cmpq -0x38(%rbp), %r13
jg 0xe807
pushq $0x32
popq %rdi
callq 0x1130
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq -0x58(%rbp), %rdi
callq 0x1130
movq 0x40(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0xe7ba
movl -0x4c(%rbp), %eax
xorl %ecx, %ecx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
cmpq -0x38(%rbp), %rcx
jg 0xe83e
xorl %esi, %esi
cmpq %rsi, %rax
je 0xe839
movq 0x40(%rbx), %rdi
movq (%rdi,%rcx,8), %rdi
movq %rdx, (%rdi,%rsi,8)
incq %rsi
jmp 0xe823
incq %rcx
jmp 0xe81b
pushq $0x1
popq %r13
movslq %r12d, %rax
cmpq %rax, %r13
jg 0xe8c1
movq %r15, %rdi
leaq 0x6bd0(%rip), %rsi      # 0x15424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11c0
cmpl $0x1, -0x2c(%rbp)
jne 0xe87c
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1070
pushq $0x1
popq %r14
movslq -0x30(%rbp), %r12
cmpq %r12, %r14
jg 0xe8bc
movq %r15, %rdi
leaq 0x5ba8(%rip), %rsi      # 0x1443b
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x11c0
cmpl $0x1, -0x2c(%rbp)
jne 0xe8b7
movsd -0x48(%rbp), %xmm0
movq 0x10(%rbx), %rax
movq (%rax,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0xe880
incq %r13
jmp 0xe842
pushq $0x1
popq %r13
movslq %r12d, %rax
cmpq %rax, %r13
jg 0xe944
movq %r15, %rdi
leaq 0x6b4d(%rip), %rsi      # 0x15424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11c0
cmpl $0x2, -0x2c(%rbp)
jne 0xe8ff
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1070
pushq $0x1
popq %r14
movslq -0x30(%rbp), %r12
cmpq %r12, %r14
jg 0xe93f
movq %r15, %rdi
leaq 0x5b25(%rip), %rsi      # 0x1443b
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x11c0
cmpl $0x2, -0x2c(%rbp)
jne 0xe93a
movsd -0x48(%rbp), %xmm0
movq 0x10(%rbx), %rax
movq (%rax,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0xe903
incq %r13
jmp 0xe8c5
movq 0x18(%rbx), %rcx
movq 0x8(%rcx,%rax,8), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f52, (%rax)     # imm = 0x746F6F52
movq %r15, %rdi
callq 0x1080
xorl %eax, %eax
jmp 0xe966
pushq $-0x1
popq %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq