// File: /workspace/github_cpp_makefile_star2_O3/WeiqiangZhou[P]BIRD/source/create_library_main.cpp
// Function: main
int main(int argc, char *argv[])
{
	char infile[255]="./par_file.txt";
	char outfile[255]="./model_file.bin";
	
    if (argc == 5 && strcmp(argv[1], "-i") == 0 && strcmp(argv[3], "-o") == 0)
	{
		strcpy(infile, argv[2]);
		strcpy(outfile, argv[4]);
	}
    else if (argc == 2 && strcmp(argv[1], "-h") == 0)
    {
                std::cout << "Usage: BIRD_build_library -i par_file.txt -o model_file.bin" << std::endl;
                std::cout << "-i Specify input file which contains the required parameters and files list." << std::endl;
                std::cout << "-o Specify output name of the model file to be used by BIRD." << std::endl;
                return 1;
    }
	else
	{
		std::cout << "Please input the correct parameters." << std::endl;
		std::cout << "Example: BIRD_build_library -i par_file.txt -o model_file.bin" << std::endl;
		return 1;
	}

	FILE * p_out;
	int param[8];
	int num_loci, num_gene, cluster_size, bin_size, num_var, DH_num1, DH_num2, DH_num3;
	char **filelist = new char *[18];
	for (int i = 0; i < 18; i++)
	{
		filelist[i] = new char[255];
	}

	if (ReadParam(infile, param, filelist)){ return 1; }

	num_loci = param[0];
	num_gene = param[1];
	cluster_size = param[2];
	bin_size = param[3];
	num_var = param[4];
	DH_num1 = param[5];
	DH_num2 = param[6];
	DH_num3 = param[7];

	double *uw_quantile = new double[num_gene];
	double *exon_mean = new double[num_gene];
	double *exon_sd = new double[num_gene];
	double *DNase_mean = new double[num_loci];
	double *DNase_sd = new double[num_loci];
	int *cluster_idx = new int[num_gene];

	double **coef = new double *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		coef[j] = new double[num_loci]();
	}

	double **dis_matrix = new double *[3];
	for (int j = 0; j < 3; j++)
	{
		dis_matrix[j] = new double[num_loci]();
	}

	double **DH_coef1 = new double *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_coef1[j] = new double[DH_num1]();
	}

	double **DH_coef2 = new double *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_coef2[j] = new double[DH_num2]();
	}

	double **DH_coef3 = new double *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_coef3[j] = new double[DH_num3]();
	}

	int **pre_idx = new int *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		pre_idx[j] = new int[num_loci]();
	}

	int **DH_pre_idx1 = new int *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_pre_idx1[j] = new int[DH_num1]();
	}

	int **DH_pre_idx2 = new int *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_pre_idx2[j] = new int[DH_num2]();
	}

	int **DH_pre_idx3 = new int *[num_var];
	for (int j = 0; j < num_var; j++)
	{
		DH_pre_idx3[j] = new int[DH_num3]();
	}

	int **DH_cluster = new int *[3];
	for (int j = 0; j < 3; j++)
	{
		DH_cluster[j] = new int[num_loci]();
	}

	char **select_loci = new char *[num_loci];
	for (int j = 0; j < num_loci; j++)
	{
		select_loci[j] = new char[30];
	}

	char **row_name = new char *[num_gene];
	for (int j = 0; j < num_gene; j++)
	{
		row_name[j] = new char[30];
	}

        //read in all required files
	if (ReadVector_d(filelist[0], uw_quantile)){ return 1; }
	if (ReadVector_d(filelist[1], exon_mean)){ return 1; }
	if (ReadVector_d(filelist[2], exon_sd)){ return 1; }
	if (ReadVector_i(filelist[3], cluster_idx)){ return 1; }
	if (ReadVector_d(filelist[4], DNase_mean)){ return 1; }
	if (ReadVector_d(filelist[5], DNase_sd)){ return 1; }
	if (ReadMatrix_d(filelist[6], coef)){ return 1; }
	if (ReadMatrix_i(filelist[7], pre_idx)){ return 1; }
	if (ReadName(filelist[8], select_loci)){ return 1; }
	if (ReadName(filelist[9], row_name)){ return 1; }
	if (ReadMatrix_d(filelist[10], dis_matrix)){ return 1; }
	if (ReadMatrix_i(filelist[11], DH_cluster)){ return 1; }
	if (ReadMatrix_d(filelist[12], DH_coef1)){ return 1; }
	if (ReadMatrix_d(filelist[13], DH_coef2)){ return 1; }
	if (ReadMatrix_d(filelist[14], DH_coef3)){ return 1; }
	if (ReadMatrix_i(filelist[15], DH_pre_idx1)){ return 1; }
	if (ReadMatrix_i(filelist[16], DH_pre_idx2)){ return 1; }
	if (ReadMatrix_i(filelist[17], DH_pre_idx3)){ return 1; }

        //combine all information into one binary file
	p_out = fopen(outfile, "wb");
	if (p_out != NULL)
	{
		std::cout << "Writing " << outfile << "..." << std::endl;
		fwrite(param, sizeof(int), 8, p_out);
		fwrite(uw_quantile, sizeof(double), num_gene, p_out);
		fwrite(exon_mean, sizeof(double), num_gene, p_out);
		fwrite(exon_sd, sizeof(double), num_gene, p_out);
		for (int k = 0; k < num_var; k++)
		{
			fwrite(coef[k], sizeof(double), num_loci, p_out);
		}
		fwrite(DNase_mean, sizeof(double), num_loci, p_out);
		fwrite(DNase_sd, sizeof(double), num_loci, p_out);
		for (int k = 0; k < num_var; k++)
		{
			fwrite(pre_idx[k], sizeof(int), num_loci, p_out);
		}
		fwrite(cluster_idx, sizeof(int), num_gene, p_out);
		for (int k = 0; k < num_loci; k++)
		{
			fwrite(select_loci[k], sizeof(char), 30, p_out);
		}
		for (int k = 0; k < num_gene; k++)
		{
			fwrite(row_name[k], sizeof(char), 30, p_out);
		}
		for (int k = 0; k < 3; k++)
		{
			fwrite(dis_matrix[k], sizeof(double), num_loci, p_out);
		}
		for (int k = 0; k < 3; k++)
		{
			fwrite(DH_cluster[k], sizeof(int), num_loci, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_coef1[k], sizeof(double), DH_num1, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_coef2[k], sizeof(double), DH_num2, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_coef3[k], sizeof(double), DH_num3, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_pre_idx1[k], sizeof(int), DH_num1, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_pre_idx2[k], sizeof(int), DH_num2, p_out);
		}
		for (int k = 0; k < num_var; k++)
		{
			fwrite(DH_pre_idx3[k], sizeof(int), DH_num3, p_out);
		}
		fclose(p_out);
		std::cout << "Successfully generated library file." << std::endl;
	}
	else
	{
		std::cout << "Error! Cannot write " << outfile << std::endl;
		return 1;
	}

	

	//Release memory
	delete[] uw_quantile;
	delete[] exon_mean;
	delete[] exon_sd;
	delete[] DNase_mean;
	delete[] DNase_sd;
	delete[] cluster_idx;
	for (int j = 0; j < 3; j++)
	{
		delete[] dis_matrix[j];
		delete[] DH_cluster[j];
	}
	for (int j = 0; j < num_var; j++)
	{
		delete[] coef[j];
		delete[] pre_idx[j];
		delete[] DH_coef1[j];
		delete[] DH_coef2[j];
		delete[] DH_coef3[j];
		delete[] DH_pre_idx1[j];
		delete[] DH_pre_idx2[j];
		delete[] DH_pre_idx3[j];
	}
	delete[] coef;
	delete[] pre_idx;
	delete[] DH_coef1;
	delete[] DH_coef2;
	delete[] DH_coef3;
	delete[] DH_pre_idx1;
	delete[] DH_pre_idx2;
	delete[] DH_pre_idx3;
	delete[] dis_matrix;
	delete[] DH_cluster;

	return 0;


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x2c43(%rip), %rsi      # 0x5010
leaq -0x320(%rbp), %rdi
movl $0xff, %edx
callq 0x20f0
leaq 0x2d2b(%rip), %rsi      # 0x5110
leaq -0x220(%rbp), %rdi
movl $0xff, %edx
callq 0x20f0
cmpl $0x2, %r14d
je 0x2905
cmpl $0x5, %r14d
jne 0x291e
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x291e
cmpb $0x69, 0x1(%rax)
jne 0x291e
cmpb $0x0, 0x2(%rax)
jne 0x291e
movq 0x18(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x291e
cmpb $0x6f, 0x1(%rax)
jne 0x291e
cmpb $0x0, 0x2(%rax)
jne 0x291e
movq 0x10(%rbx), %rsi
leaq -0x320(%rbp), %rdi
callq 0x2110
movq 0x20(%rbx), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2110
movl $0x90, %edi
callq 0x2030
movq %rax, %r14
xorl %ebx, %ebx
movl $0xff, %edi
callq 0x2030
movq %rax, (%r14,%rbx,8)
incq %rbx
cmpq $0x12, %rbx
jne 0x247b
leaq -0x320(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movq %r14, %rdx
callq 0x32b8
movl $0x1, %ebx
testl %eax, %eax
jne 0x29a0
movq %r14, -0x48(%rbp)
movslq -0x110(%rbp), %r13
movslq -0x10c(%rbp), %rcx
movslq -0x100(%rbp), %r12
movslq -0xfc(%rbp), %rax
movq %rax, -0xc8(%rbp)
movslq -0xf8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movslq -0xf4(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq (,%rcx,8), %r15
testq %rcx, %rcx
movq $-0x1, %rax
cmovsq %rax, %r15
movq %rcx, -0x78(%rbp)
leaq (,%rcx,4), %r14
cmovsq %rax, %r14
movq %r15, %rdi
callq 0x2030
movq %rax, -0xe8(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0xe0(%rbp)
movq %r15, -0x118(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0xd8(%rbp)
leaq (,%r13,8), %r15
movq %r13, -0x38(%rbp)
testq %r13, %r13
movq $-0x1, %r13
cmovsq %r13, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, -0xb0(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0xa8(%rbp)
movq %r14, %rdi
callq 0x2030
movq %rax, -0xd0(%rbp)
leaq (,%r12,8), %rdi
testq %r12, %r12
cmovsq %r13, %rdi
movq %rdi, -0x40(%rbp)
callq 0x2030
movq %rax, %r13
testq %r12, %r12
movq %r15, -0x88(%rbp)
jle 0x25f3
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x2030
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq -0x88(%rbp), %rdx
callq 0x20c0
movq %r15, (%r13,%r14,8)
movq -0x88(%rbp), %r15
incq %r14
cmpq %r14, %r12
jne 0x25c3
movl $0x18, %edi
callq 0x2030
xorl %r14d, %r14d
movq %rax, -0x80(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq -0x88(%rbp), %rdx
callq 0x20c0
movq -0x80(%rbp), %rax
movq %r15, (%rax,%r14,8)
movq -0x88(%rbp), %r15
incq %r14
cmpq $0x3, %r14
jne 0x2604
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x2030
testl %r12d, %r12d
movq %r12, -0x30(%rbp)
movq %r13, -0xa0(%rbp)
movq %rax, -0x90(%rbp)
jle 0x2a42
movq -0xc8(%rbp), %rdx
leaq (,%rdx,8), %rcx
testl %edx, %edx
movq $-0x1, %r15
cmovnsq %rcx, %r15
xorl %r12d, %r12d
movq %rax, %r13
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x2681
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x2030
movq -0x30(%rbp), %rcx
testl %ecx, %ecx
movq %rax, -0x68(%rbp)
jle 0x2a4e
movq %rax, %r13
movq -0xc0(%rbp), %rdx
leaq (,%rdx,8), %rax
testl %edx, %edx
movq $-0x1, %r15
cmovnsq %rax, %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x26e5
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x2030
movq -0x30(%rbp), %rdx
testl %edx, %edx
movq %rax, -0x60(%rbp)
jle 0x2a5a
movq -0xb8(%rbp), %rcx
movq %rax, %r13
leaq (,%rcx,8), %rax
testl %ecx, %ecx
movq $-0x1, %r15
cmovnsq %rax, %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x2749
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x2030
movq -0x30(%rbp), %r13
testl %r13d, %r13d
movq %rax, -0x70(%rbp)
jle 0x2e83
movq -0x38(%rbp), %rdx
leaq (,%rdx,4), %rcx
testl %edx, %edx
movq $-0x1, %r15
cmovnsq %rcx, %r15
xorl %r12d, %r12d
movq %rax, %r13
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x27ab
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x2030
movq -0x30(%rbp), %r13
testl %r13d, %r13d
movq %rax, -0x58(%rbp)
jle 0x2e8c
movq -0xc8(%rbp), %rcx
leaq (,%rcx,4), %rdx
testl %ecx, %ecx
movq $-0x1, %r15
cmovnsq %rdx, %r15
xorl %r12d, %r12d
movq %rax, %r13
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x2810
movq -0x40(%rbp), %rdi
callq 0x2030
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x2e95
movq -0xc0(%rbp), %rcx
leaq (,%rcx,4), %rax
testl %ecx, %ecx
movq $-0x1, %r15
cmovnsq %rax, %r15
xorl %r12d, %r12d
movq -0x50(%rbp), %r13
movq %r15, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20c0
movq %r14, (%r13,%r12,8)
incq %r12
cmpq %r12, -0x30(%rbp)
jne 0x2870
movq -0x40(%rbp), %rdi
callq 0x2030
cmpl $0x0, -0x30(%rbp)
jle 0x2ea6
movq -0xb8(%rbp), %rcx
leaq (,%rcx,4), %rdx
testl %ecx, %ecx
movq $-0x1, %r14
cmovnsq %rdx, %r14
xorl %r12d, %r12d
movq -0x30(%rbp), %r13
movq %rax, -0x40(%rbp)
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20c0
movq -0x40(%rbp), %rax
movq %r15, (%rax,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x28d0
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %rax
jmp 0x2a8a
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x291e
cmpb $0x68, 0x1(%rax)
jne 0x291e
cmpb $0x0, 0x2(%rax)
je 0x29b4
movq 0x46b3(%rip), %rbx      # 0x6fd8
leaq 0x29a9(%rip), %rsi      # 0x52d5
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
leaq 0x2993(%rip), %rsi      # 0x52fa
movl $0x3d, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movl $0x1, %ebx
movl %ebx, %eax
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x461d(%rip), %rbx      # 0x6fd8
leaq 0x284d(%rip), %rsi      # 0x520f
movl $0x3b, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
leaq 0x284e(%rip), %rsi      # 0x524b
movl $0x4c, %edx
movq %rbx, %rdi
callq 0x2150
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
leaq 0x2860(%rip), %rsi      # 0x5298
movl $0x3c, %edx
jmp 0x296c
movq %r15, %rdi
callq 0x2030
movq %rax, -0x68(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %r14
movq %r15, %rdi
callq 0x2030
movq %rax, -0x70(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0x58(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0x50(%rbp)
movq %r15, %rdi
callq 0x2030
movq %rax, -0x40(%rbp)
movl $0x18, %edi
callq 0x2030
movq %rax, %r13
leaq (,%r14,4), %rax
testl %r14d, %r14d
movq $-0x1, %r14
cmovnsq %rax, %r14
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20c0
movq %r15, (%r13,%r12,8)
incq %r12
cmpq $0x3, %r12
jne 0x2ab4
movq %r13, -0x98(%rbp)
movq -0x88(%rbp), %rdi
callq 0x2030
movq %rax, %r13
movq -0x38(%rbp), %r15
testl %r15d, %r15d
jle 0x2b13
xorl %r14d, %r14d
movl $0x1e, %edi
callq 0x2030
movq %rax, (%r13,%r14,8)
incq %r14
cmpq %r14, %r15
jne 0x2afc
movq -0x118(%rbp), %rdi
callq 0x2030
movq %rax, %r14
movq -0x78(%rbp), %r12
testl %r12d, %r12d
jle 0x2b44
xorl %r15d, %r15d
movl $0x1e, %edi
callq 0x2030
movq %rax, (%r14,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x2b2e
movq -0x48(%rbp), %r15
movq (%r15), %rdi
movq -0xe8(%rbp), %rsi
callq 0x3d73
testl %eax, %eax
jne 0x29a0
movq 0x8(%r15), %rdi
movq -0xe0(%rbp), %rsi
callq 0x3d73
testl %eax, %eax
jne 0x29a0
movq 0x10(%r15), %rdi
movq -0xd8(%rbp), %rsi
callq 0x3d73
testl %eax, %eax
jne 0x29a0
movq 0x18(%r15), %rdi
movq -0xd0(%rbp), %rsi
callq 0x3f23
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0xb0(%rbp), %rsi
callq 0x3d73
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0xa8(%rbp), %rsi
callq 0x3d73
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0xa0(%rbp), %rsi
callq 0x40cf
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x4423
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rdi
movq %r13, %rsi
callq 0x4775
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x48(%rax), %rdi
movq %r14, %rsi
callq 0x4775
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x80(%rbp), %rsi
callq 0x40cf
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x98(%rbp), %rsi
callq 0x4423
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x90(%rbp), %rsi
callq 0x40cf
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x40cf
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x60(%rbp), %rsi
callq 0x40cf
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x78(%rax), %rdi
movq -0x58(%rbp), %rsi
callq 0x4423
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x4423
testl %eax, %eax
jne 0x29a0
movq -0x48(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x4423
testl %eax, %eax
jne 0x29a0
leaq 0x2619(%rip), %rsi      # 0x5338
leaq -0x220(%rbp), %rdi
callq 0x2160
testq %rax, %rax
je 0x2eaf
movq %rax, %r12
movq 0x429a(%rip), %rbx      # 0x6fd8
leaq 0x25f6(%rip), %rsi      # 0x533b
movl $0x8, %edx
movq %rbx, %rdi
callq 0x2150
leaq -0x220(%rbp), %r15
movq %r15, %rdi
callq 0x2090
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2150
leaq 0x25ce(%rip), %rsi      # 0x5344
movl $0x3, %edx
movq %rbx, %rdi
callq 0x2150
movq %rbx, %rdi
callq 0x20a0
leaq -0x110(%rbp), %rdi
movl $0x4, %esi
movl $0x8, %edx
movq %r12, %rcx
callq 0x2230
movl $0x8, %esi
movq -0xe8(%rbp), %rdi
movq -0x78(%rbp), %rbx
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
movl $0x8, %esi
movq -0xe0(%rbp), %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
movl $0x8, %esi
movq -0xd8(%rbp), %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
cmpl $0x0, -0x30(%rbp)
jle 0x2ef4
xorl %ebx, %ebx
movq -0xa0(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x8, %esi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x2df9
movl $0x8, %esi
movq -0xb0(%rbp), %rdi
movq -0x38(%rbp), %rbx
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
movl $0x8, %esi
movq -0xa8(%rbp), %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
cmpl $0x0, -0x30(%rbp)
jle 0x2f26
xorl %ebx, %ebx
movq -0x70(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x4, %esi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x2e5c
jmp 0x2f26
movq -0x38(%rbp), %r14
jmp 0x2a6a
movq -0x38(%rbp), %r14
jmp 0x2a76
movq -0x38(%rbp), %r14
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %r15
jmp 0x2a7e
movq -0x38(%rbp), %r14
jmp 0x2a8a
movq 0x4122(%rip), %r14      # 0x6fd8
leaq 0x24b0(%rip), %rsi      # 0x536d
movl $0x14, %edx
movq %r14, %rdi
callq 0x2150
leaq -0x220(%rbp), %r15
movq %r15, %rdi
callq 0x2090
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2150
movq %r14, %rdi
callq 0x20a0
jmp 0x29a0
movl $0x8, %esi
movq -0xb0(%rbp), %rdi
movq -0x38(%rbp), %rbx
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
movl $0x8, %esi
movq -0xa8(%rbp), %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2230
movl $0x4, %esi
movq -0xd0(%rbp), %rdi
movq -0x78(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
cmpl $0x0, -0x38(%rbp)
jle 0x2f66
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x38(%rbp)
jne 0x2f46
cmpl $0x0, -0x78(%rbp)
jle 0x2f8d
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
movl $0x1, %esi
movl $0x1e, %edx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x78(%rbp)
jne 0x2f6e
xorl %ebx, %ebx
movq -0x80(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x8, %esi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq $0x3, %rbx
jne 0x2f8f
xorl %ebx, %ebx
movq -0x98(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x4, %esi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq $0x3, %rbx
jne 0x2fb3
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x90(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x8, %esi
movq -0xc8(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x2fe4
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x68(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x8, %esi
movq -0xc0(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x3018
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x60(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x8, %esi
movq -0xb8(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x3049
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x58(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x4, %esi
movq -0xc8(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x307a
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x50(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x4, %esi
movq -0xc0(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x30a7
cmpl $0x0, -0x30(%rbp)
jle 0x30f9
xorl %ebx, %ebx
movq -0x40(%rbp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x4, %esi
movq -0xb8(%rbp), %rdx
movq %r12, %rcx
callq 0x2230
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x30d4
movq %r12, %rdi
callq 0x2130
movq 0x3ed0(%rip), %rbx      # 0x6fd8
leaq 0x2239(%rip), %rsi      # 0x5348
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2150
movq %rbx, %rdi
callq 0x20a0
movq -0xe8(%rbp), %rdi
callq 0x2180
movq -0xe0(%rbp), %rdi
callq 0x2180
movq -0xd8(%rbp), %rdi
callq 0x2180
movq -0xb0(%rbp), %rdi
callq 0x2180
movq -0xa8(%rbp), %rdi
callq 0x2180
movq -0xd0(%rbp), %rdi
callq 0x2180
xorl %ebx, %ebx
movq -0x80(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3180
callq 0x2180
movq -0x98(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3195
callq 0x2180
incq %rbx
cmpq $0x3, %rbx
jne 0x316e
cmpl $0x0, -0x30(%rbp)
jle 0x324d
xorl %ebx, %ebx
movq -0xa0(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x31bf
callq 0x2180
movq -0x70(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x31d1
callq 0x2180
movq -0x90(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x31e6
callq 0x2180
movq -0x68(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x31f8
callq 0x2180
movq -0x60(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x320a
callq 0x2180
movq -0x58(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x321c
callq 0x2180
movq -0x50(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x322e
callq 0x2180
movq -0x40(%rbp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3240
callq 0x2180
incq %rbx
cmpq %rbx, -0x30(%rbp)
jne 0x31aa
movq -0xa0(%rbp), %rdi
callq 0x2180
movq -0x70(%rbp), %rdi
callq 0x2180
movq -0x90(%rbp), %rdi
callq 0x2180
movq -0x68(%rbp), %rdi
callq 0x2180
movq -0x60(%rbp), %rdi
callq 0x2180
movq -0x58(%rbp), %rdi
callq 0x2180
movq -0x50(%rbp), %rdi
callq 0x2180
movq -0x40(%rbp), %rdi
callq 0x2180
movq -0x80(%rbp), %rdi
callq 0x2180
movq -0x98(%rbp), %rdi
callq 0x2180
xorl %ebx, %ebx
jmp 0x29a0
nop