// File: WeiqiangZhou[P]BIRD/source/predict_function.cpp
// Function: ReadinModel(char*, double*, double*, double*, double**, double*, double*, int**, char**, int*, char**, int, int, int, double**, int**, double**, double**, double**, int**, int**, int**, int, int, int)
int ReadinModel(char filename[255], double *quantile_in, double *exon_mean, double *exon_sd, double **coef, double *DNase_mean, double *DNase_sd, int **pre_idx, char **TC_id, int *cluster_idx, char **select_loci, int p_length, int var_length, int loci_length, double **dis_matrix, int **DH_cluster, double **DH_coef1, double **DH_coef2, double **DH_coef3, int **DH_pre_idx1, int **DH_pre_idx2, int **DH_pre_idx3, int DH_num1, int DH_num2, int DH_num3)
{
	int dump[8];
	FILE *pFile;
	pFile = fopen(filename, "rb");
	if (pFile != NULL)
	{
		std::cout << "Reading library file " << filename << std::endl;
		fread(dump, sizeof(int), 8, pFile);
		fread(quantile_in, sizeof(double), p_length, pFile);
		fread(exon_mean, sizeof(double), p_length, pFile);
		fread(exon_sd, sizeof(double), p_length, pFile);
		for (int k = 0; k < var_length; k++)
		{
			fread(coef[k], sizeof(double), loci_length, pFile);
		}
		fread(DNase_mean, sizeof(double), loci_length, pFile);
		fread(DNase_sd, sizeof(double), loci_length, pFile);
		for (int k = 0; k < var_length; k++)
		{
			fread(pre_idx[k], sizeof(int), loci_length, pFile);
		}
		fread(cluster_idx, sizeof(int), p_length, pFile);
		for (int k = 0; k < loci_length; k++)
		{
			fread(select_loci[k], sizeof(char), 30, pFile);
		}
		for (int k = 0; k < p_length; k++)
		{
			fread(TC_id[k], sizeof(char), 30, pFile);
		}
		for (int k = 0; k < 3; k++)
		{
			fread(dis_matrix[k], sizeof(double), loci_length, pFile);
		}
		for (int k = 0; k < 3; k++)
		{
			fread(DH_cluster[k], sizeof(int), loci_length, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_coef1[k], sizeof(double), DH_num1, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_coef2[k], sizeof(double), DH_num2, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_coef3[k], sizeof(double), DH_num3, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_pre_idx1[k], sizeof(int), DH_num1, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_pre_idx2[k], sizeof(int), DH_num2, pFile);
		}
		for (int k = 0; k < var_length; k++)
		{
			fread(DH_pre_idx3[k], sizeof(int), DH_num3, pFile);
		}
	}
	else
	{
		std::cout << "Error! File " << filename << " not found!" << std::endl;
		return 1;
	}

	fclose(pFile);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0xa0(%rbp), %eax
movl 0x98(%rbp), %eax
movl 0x90(%rbp), %eax
movq 0x88(%rbp), %rax
movq 0x80(%rbp), %rax
movq 0x78(%rbp), %rax
movq 0x70(%rbp), %rax
movq 0x68(%rbp), %rax
movq 0x60(%rbp), %rax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movl 0x48(%rbp), %eax
movl 0x40(%rbp), %eax
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7635(%rip), %rsi      # 0xf538
callq 0x2220
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x82f2
movq 0xe0ba(%rip), %rdi      # 0x15fd8
leaq 0x7616(%rip), %rsi      # 0xf53b
callq 0x21c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x21c0
movq %rax, %rdi
movq 0xe080(%rip), %rsi      # 0x15fc0
callq 0x2200
leaq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rcx
movl $0x4, %esi
movl $0x8, %edx
callq 0x22f0
movq -0x18(%rbp), %rdi
movslq 0x38(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movq -0x20(%rbp), %rdi
movslq 0x38(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movq -0x28(%rbp), %rdi
movslq 0x38(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x7fd6
movq -0x30(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x7fa5
movq -0x38(%rbp), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movq 0x10(%rbp), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x803a
movq 0x18(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x8009
movq 0x28(%rbp), %rdi
movslq 0x38(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl 0x48(%rbp), %eax
jge 0x8089
movq 0x30(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x68(%rbp), %rcx
movl $0x1, %esi
movl $0x1e, %edx
callq 0x22f0
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x8057
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl 0x38(%rbp), %eax
jge 0x80c2
movq 0x20(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x68(%rbp), %rcx
movl $0x1, %esi
movl $0x1e, %edx
callq 0x22f0
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x8090
movl $0x0, -0x7c(%rbp)
cmpl $0x3, -0x7c(%rbp)
jge 0x80f8
movq 0x50(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x80c9
movl $0x0, -0x80(%rbp)
cmpl $0x3, -0x80(%rbp)
jge 0x812e
movq 0x58(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x48(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x80ff
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x8178
movq 0x60(%rbp), %rax
movslq -0x84(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x90(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x8138
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x81c2
movq 0x68(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x98(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x8182
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x820c
movq 0x70(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0xa0(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x8, %esi
callq 0x22f0
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x81cc
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x8256
movq 0x78(%rbp), %rax
movslq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x90(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x8216
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x82a3
movq 0x80(%rbp), %rax
movslq -0x94(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x98(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x8260
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
cmpl 0x40(%rbp), %eax
jge 0x82f0
movq 0x88(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0xa0(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x4, %esi
callq 0x22f0
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x82ad
jmp 0x8338
movq 0xdcdf(%rip), %rdi      # 0x15fd8
leaq 0x721f(%rip), %rsi      # 0xf51f
callq 0x21c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x21c0
movq %rax, %rdi
leaq 0x7211(%rip), %rsi      # 0xf52c
callq 0x21c0
movq %rax, %rdi
movq 0xdc96(%rip), %rsi      # 0x15fc0
callq 0x2200
movl $0x1, -0x4(%rbp)
jmp 0x8348
movq -0x68(%rbp), %rdi
callq 0x21d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)