// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rcx, -0x40(%rbp)
movq %rdx, -0x30(%rbp)
movq %rsi, %r14
movq %rdi, %r12
leaq 0x32f9(%rip), %rsi      # 0x84ec
callq 0x2240
testq %rax, %rax
je 0x5240
movq %rax, %rbx
movq %r15, -0x38(%rbp)
movq 0x6dcd(%rip), %r15      # 0xbfd8
leaq 0x32dd(%rip), %rsi      # 0x84ef
movl $0x15, %edx
movq %r15, %rdi
callq 0x2230
testq %r12, %r12
je 0x5283
movq %r12, %rdi
callq 0x2100
movq 0x6da5(%rip), %rdi      # 0xbfd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x529b
movq 0x6d91(%rip), %rbx      # 0xbfd8
leaq 0x3285(%rip), %rsi      # 0x84d3
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2230
testq %r12, %r12
je 0x55d5
movq %r12, %rdi
callq 0x2100
movq 0x6d65(%rip), %rdi      # 0xbfd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x55ec
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x2360
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
leaq -0x60(%rbp), %rdi
movl $0x4, %esi
movl $0x8, %edx
movq %rbx, %rcx
callq 0x22c0
movslq 0x38(%rbp), %r15
movl $0x8, %esi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x8, %esi
movq -0x30(%rbp), %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x8, %esi
movq -0x40(%rbp), %rdi
movq %r15, -0x30(%rbp)
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
movslq 0x48(%rbp), %r14
movl 0x40(%rbp), %r12d
movl %r12d, %eax
movq %rax, -0x40(%rbp)
testl %r12d, %r12d
jle 0x53a7
xorl %r15d, %r15d
movq -0x40(%rbp), %r12
movq (%r13,%r15,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r12
jne 0x5336
movl $0x8, %esi
movq -0x38(%rbp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x8, %esi
movq 0x10(%rbp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
cmpl $0x0, 0x40(%rbp)
movq 0x18(%rbp), %r13
jle 0x53cf
xorl %r15d, %r15d
movq (%r13,%r15,8), %rdi
movl $0x4, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r12
jne 0x5388
jmp 0x53cf
movl $0x8, %esi
movq -0x38(%rbp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x8, %esi
movq 0x10(%rbp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x4, %esi
movq 0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq %rbx, %rcx
callq 0x22c0
movl 0x48(%rbp), %eax
testl %eax, %eax
jle 0x5413
movq 0x30(%rbp), %r12
movl %eax, %r13d
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x53f5
movl 0x38(%rbp), %eax
testl %eax, %eax
jle 0x5442
movq 0x20(%rbp), %r12
movl %eax, %r13d
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x5424
movq 0x58(%rbp), %r13
movq 0x50(%rbp), %r15
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r12
cmpq $0x3, %r12
jne 0x544d
xorl %r15d, %r15d
movq (%r13,%r15,8), %rdi
movl $0x4, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq $0x3, %r15
jne 0x546d
movl 0x40(%rbp), %r12d
testl %r12d, %r12d
movq -0x40(%rbp), %r13
jle 0x55c9
movslq 0x90(%rbp), %r14
xorl %r15d, %r15d
movq 0x60(%rbp), %r12
movq (%r12,%r15,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x54aa
cmpl $0x0, 0x40(%rbp)
jle 0x55c9
movslq 0x98(%rbp), %r15
movq %r13, %r12
xorl %r13d, %r13d
movq 0x68(%rbp), %rax
movq (%rax,%r13,8), %rdi
movl $0x8, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r13
cmpq %r13, %r12
jne 0x54dd
movq %r15, -0x30(%rbp)
cmpl $0x0, 0x40(%rbp)
jle 0x55c9
movslq 0xa0(%rbp), %r15
xorl %r13d, %r13d
movq 0x70(%rbp), %rax
movq (%rax,%r13,8), %rdi
movl $0x8, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r13
cmpq %r13, %r12
jne 0x5515
cmpl $0x0, 0x40(%rbp)
jle 0x55c9
movq %r15, -0x38(%rbp)
xorl %r13d, %r13d
movq 0x78(%rbp), %r15
movq (%r15,%r13,8), %rdi
movl $0x4, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r13
cmpq %r13, %r12
jne 0x554a
cmpl $0x0, 0x40(%rbp)
jle 0x55c9
movq %r12, %r13
xorl %r14d, %r14d
movq 0x80(%rbp), %r15
movq -0x30(%rbp), %r12
movq (%r15,%r14,8), %rdi
movl $0x4, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x557d
cmpl $0x0, 0x40(%rbp)
movq -0x38(%rbp), %r15
jle 0x55c9
xorl %r14d, %r14d
movq 0x88(%rbp), %rax
movq (%rax,%r14,8), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x55a6
movq %rbx, %rdi
callq 0x21f0
xorl %eax, %eax
jmp 0x562c
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2360
leaq 0x2eed(%rip), %rsi      # 0x84e0
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq