// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rsi, %rax
movl %edi, -0x2c(%rbp)
leaq 0x68ca(%rip), %rsi      # 0x16372
movq %rax, %rdi
callq 0x10e0
testq %rax, %rax
je 0xfbad
leaq 0x671a(%rip), %rsi      # 0x161da
leaq -0x30(%rbp), %r12
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x11e0
movslq (%r12), %rbx
movl %ebx, (%r14)
leaq 0x1(%rbx), %r12
leal 0x2(%rbx), %eax
movl %eax, -0x4c(%rbp)
movslq %eax, %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x1140
movq %rax, 0x18(%r14)
movq %r12, -0x40(%rbp)
shlq $0x4, %r12
movq %r12, %rdi
callq 0x1140
movq %rax, 0x10(%r14)
movq %r12, %rdi
callq 0x1140
movq %rax, 0x8(%r14)
movq %r15, -0x58(%rbp)
movq %r15, %rdi
callq 0x1140
movq %r14, -0x38(%rbp)
movq %rax, 0x40(%r14)
testq %rbx, %rbx
js 0xfba0
movq -0x40(%rbp), %rcx
movl %ecx, %eax
movq %rax, -0x60(%rbp)
addl %ecx, %ecx
movl %ecx, %eax
movq %rax, -0x40(%rbp)
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x1140
movq -0x38(%rbp), %r15
movq 0x8(%r15), %rcx
movq %rax, (%rcx,%r14,8)
movq %r12, %rdi
callq 0x1140
movq 0x10(%r15), %rcx
movq %rax, (%rcx,%r14,8)
cmpq -0x60(%rbp), %r14
ja 0xfb97
movl $0x32, %edi
callq 0x1140
movq -0x38(%rbp), %r15
movq 0x18(%r15), %rcx
movq %rax, (%rcx,%r14,8)
movq -0x58(%rbp), %rdi
callq 0x1140
movq 0x40(%r15), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, -0x40(%rbp)
jne 0xfb46
cmpl $-0x1, %ebx
jge 0xfbb7
movq %r13, %rdi
jmp 0xfd35
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xfd56
movl -0x4c(%rbp), %eax
movq -0x38(%rbp), %r12
movq 0x40(%r12), %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 0xfbd6
incq %rdx
cmpq %rax, %rdx
jne 0xfbcf
testl %ebx, %ebx
movq %r13, %rdi
jle 0xfd35
movl $0x1, %r14d
leaq 0x6822(%rip), %rsi      # 0x16424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x1, -0x2c(%rbp)
jne 0xfc2b
movq 0x18(%r12), %rax
movq (%rax,%r14,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
movslq -0x30(%rbp), %rax
testq %rax, %rax
jle 0xfc7a
xorl %r15d, %r15d
movq %r13, %rdi
leaq 0x57fa(%rip), %rsi      # 0x1543b
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x1, -0x2c(%rbp)
jne 0xfc67
movsd -0x48(%rbp), %xmm0
movq 0x10(%r12), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, 0x8(%rax,%r15,8)
movl -0x30(%rbp), %ebx
movslq %ebx, %rax
incq %r15
cmpq %rax, %r15
movq %r13, %rdi
jl 0xfc3a
jmp 0xfc7f
movl %eax, %ebx
movq %r13, %rdi
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jl 0xfbfb
testl %ebx, %ebx
jle 0xfd35
movl $0x1, %ebx
leaq 0x5798(%rip), %r12      # 0x1543b
leaq -0x48(%rbp), %r15
leaq 0x6776(%rip), %rsi      # 0x16424
leaq -0xa0(%rbp), %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x2, -0x2c(%rbp)
jne 0xfcda
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax,%rbx,8), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
movslq -0x30(%rbp), %rax
testq %rax, %rax
movq %r13, %rdi
jle 0xfd23
xorl %r14d, %r14d
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x11e0
cmpl $0x2, -0x2c(%rbp)
jne 0xfd14
movsd -0x48(%rbp), %xmm0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, 0x8(%rax,%r14,8)
movslq -0x30(%rbp), %rax
incq %r14
cmpq %rax, %r14
movq %r13, %rdi
jl 0xfce9
leaq 0x1(%rbx), %rcx
cmpq %rax, %rbx
movq %rcx, %rbx
jl 0xfca7
jmp 0xfd38
movslq %ebx, %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x8(%rcx,%rax,8), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f52, (%rax)     # imm = 0x746F6F52
callq 0x10a0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq