// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rcx, -0x30(%rbp)
movq %rdx, -0x40(%rbp)
movq %rsi, %r14
movq %rdi, %r13
leaq 0x32c7(%rip), %rsi      # 0x84ec
callq 0x2240
testq %rax, %rax
je 0x5272
movq %rax, %rbx
movq %r15, -0x38(%rbp)
movq 0x6d9b(%rip), %r15      # 0xbfd8
leaq 0x32ab(%rip), %rsi      # 0x84ef
movl $0x15, %edx
movq %r15, %rdi
callq 0x2230
testq %r13, %r13
je 0x52b5
movq %r13, %rdi
callq 0x2100
movq 0x6d73(%rip), %rdi      # 0xbfd8
movq %r13, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x52cd
movq 0x6d5f(%rip), %rbx      # 0xbfd8
leaq 0x3253(%rip), %rsi      # 0x84d3
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2230
testq %r13, %r13
je 0x55bb
movq %r13, %rdi
callq 0x2100
movq 0x6d33(%rip), %rdi      # 0xbfd8
movq %r13, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x55d2
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 -0x40(%rbp), %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
movl $0x8, %esi
movq -0x30(%rbp), %rdi
movq %r15, -0x30(%rbp)
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
movslq 0x48(%rbp), %r14
movl 0x40(%rbp), %eax
movl %eax, %r13d
testl %eax, %eax
jle 0x537a
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x535e
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)
jle 0x53cb
movq 0x18(%rbp), %r12
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
movl $0x4, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x53af
movl $0x4, %esi
movq 0x28(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq %rbx, %rcx
callq 0x22c0
movl 0x48(%rbp), %eax
testl %eax, %eax
jle 0x540f
movl %eax, %r12d
xorl %r15d, %r15d
movq 0x30(%rbp), %rax
movq (%rax,%r15,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r12
jne 0x53ed
movl 0x38(%rbp), %eax
testl %eax, %eax
jle 0x543e
movl %eax, %r12d
xorl %r15d, %r15d
movq 0x20(%rbp), %rax
movq (%rax,%r15,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r12
jne 0x541c
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 0x5445
xorl %r15d, %r15d
movq 0x58(%rbp), %r12
movq (%r12,%r15,8), %rdi
movl $0x4, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq $0x3, %r15
jne 0x5469
movslq 0x90(%rbp), %r14
cmpl $0x0, 0x40(%rbp)
movq 0x60(%rbp), %r12
jle 0x54b6
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r15
cmpq %r15, %r13
jne 0x549a
movq %r14, -0x40(%rbp)
movslq 0x98(%rbp), %r14
cmpl $0x0, 0x40(%rbp)
movq 0x68(%rbp), %r15
jle 0x54ea
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
movl $0x8, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r12
cmpq %r12, %r13
jne 0x54ce
movq %r14, -0x30(%rbp)
movslq 0xa0(%rbp), %r15
cmpl $0x0, 0x40(%rbp)
movq 0x70(%rbp), %r12
jle 0x551e
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
movl $0x8, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x5502
movq %r15, -0x38(%rbp)
cmpl $0x0, 0x40(%rbp)
movq 0x78(%rbp), %r12
movq -0x40(%rbp), %r15
jle 0x554f
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x5533
cmpl $0x0, 0x40(%rbp)
movq 0x80(%rbp), %r12
movq -0x30(%rbp), %r15
jle 0x557f
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
movl $0x4, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x5563
cmpl $0x0, 0x40(%rbp)
movq 0x88(%rbp), %r15
movq -0x38(%rbp), %r12
jle 0x55af
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
movl $0x4, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x22c0
incq %r14
cmpq %r14, %r13
jne 0x5593
movq %rbx, %rdi
callq 0x21f0
xorl %eax, %eax
jmp 0x5612
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2360
leaq 0x2f07(%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