// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r13
movq %r8, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %rdx, -0x48(%rbp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x2b75(%rip), %rsi      # 0x74cc
callq 0x2210
testq %rax, %rax
je 0x4c33
movq %rax, %rbx
movq %r13, -0x40(%rbp)
movl 0x40(%rbp), %r13d
movq 0x6661(%rip), %rdi      # 0xafd8
leaq 0x2b51(%rip), %rsi      # 0x74cf
callq 0x21d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2120
leaq -0x70(%rbp), %rdi
pushq $0x4
popq %rsi
pushq $0x8
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
movl 0x38(%rbp), %eax
movslq %eax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22b0
movq -0x48(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22b0
movq -0x38(%rbp), %rdi
movq %r14, %r15
movq %r14, %rsi
movq %r12, -0x38(%rbp)
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22b0
movl 0x48(%rbp), %eax
movslq %eax, %r14
xorl %r12d, %r12d
testl %r13d, %r13d
cmovlel %r12d, %r13d
cmpq %r12, %r13
je 0x4a1e
movq -0x30(%rbp), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r12
jmp 0x49fe
pushq $0x8
popq %r12
movq -0x40(%rbp), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
movq 0x10(%rbp), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
xorl %r15d, %r15d
pushq $0x4
popq %r12
cmpq %r15, %r13
je 0x4a6d
movq 0x18(%rbp), %rax
movq (%rax,%r15,8), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r15
jmp 0x4a4d
pushq $0x4
popq %rsi
movq 0x28(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq %rbx, %rcx
callq 0x22b0
xorl %r15d, %r15d
movl 0x48(%rbp), %r12d
testl %r12d, %r12d
cmovlel %r15d, %r12d
cmpq %r15, %r12
je 0x4aae
movq 0x30(%rbp), %rax
movq (%rax,%r15,8), %rdi
pushq $0x1
popq %rsi
pushq $0x1e
popq %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r15
jmp 0x4a8e
xorl %r15d, %r15d
movl 0x38(%rbp), %r12d
testl %r12d, %r12d
cmovlel %r15d, %r12d
cmpq %r15, %r12
je 0x4adc
movq 0x20(%rbp), %rax
movq (%rax,%r15,8), %rdi
pushq $0x1
popq %rsi
pushq $0x1e
popq %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r15
jmp 0x4abc
xorl %r12d, %r12d
pushq $0x8
popq %r15
cmpq $0x3, %r12
je 0x4b04
movq 0x50(%rbp), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r12
jmp 0x4ae3
xorl %r12d, %r12d
pushq $0x4
popq %r15
cmpq $0x3, %r12
je 0x4b2c
movq 0x58(%rbp), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r12
jmp 0x4b0b
movslq 0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
pushq $0x8
popq %r15
movq 0x68(%rbp), %r14
cmpq %r12, %r13
je 0x4b63
movq 0x60(%rbp), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r12
jmp 0x4b42
movslq 0x98(%rbp), %r15
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x4b89
movq (%r14,%r12,8), %rdi
pushq $0x8
popq %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r12
jmp 0x4b6d
movslq 0xa0(%rbp), %r12
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x4bb3
movq 0x70(%rbp), %rax
movq (%rax,%r14,8), %rdi
pushq $0x8
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r14
jmp 0x4b93
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x4bd7
movq 0x78(%rbp), %rax
movq (%rax,%r14,8), %rdi
pushq $0x4
popq %rsi
movq -0x30(%rbp), %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r14
jmp 0x4bb6
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x4bfd
movq 0x80(%rbp), %rax
movq (%rax,%r14,8), %rdi
pushq $0x4
popq %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r14
jmp 0x4bda
xorl %r15d, %r15d
pushq $0x4
popq %r14
cmpq %r15, %r13
je 0x4c27
movq 0x88(%rbp), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22b0
incq %r15
jmp 0x4c04
movq %rbx, %rdi
callq 0x21e0
xorl %eax, %eax
jmp 0x4c6b
movq 0x639e(%rip), %rdi      # 0xafd8
leaq 0x2872(%rip), %rsi      # 0x74b3
callq 0x21d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
leaq 0x2868(%rip), %rsi      # 0x74c0
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2120
pushq $0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq