// File: CominLab[P]QCluster/qcluster.cc
// Function: main
int main(int argc, char **argv)
{
	int num_clusters = 5;  // target number of clusters
	char dist_type = 'e'; // default to L2
	int K = 2;  // k-mer size
	bool normalize_matrix_flag = false; // make columns univariant ("whiten");
		// off by default
	int normalize = 2; // normalize each row. Deafult: method 2
	bool redistribute = true; //Redistribute missing quality by default
	int e_method = 1;
	int p_method = 1;
	double pseudocount = PC; // pseudocount for k-mers
	bool rc_flag = false; // append reverse complement to each sequence;
		// off by default
	unsigned int random_seed = time(NULL); // initial seed
	int num_trials = 0; // later we check if it was specified using "-t" arg
		// and set the correct default if it was not; note that the default 
		// depends on whether consensus clustering is performed
	int verbose_level = 0;
	bool write_flag = false; // write sequences by cluster; off by default
	int default_max_iterations = 1000;

	int opt;
	while((opt = getopt(argc, argv, "c:d:e:k:m:N:nP:p:q:rRsS:t:vwh")) != -1 ){
		switch(opt){
            case 'c':
                num_clusters = atoi(optarg);
                break;
			case 'd':
                dist_type = *optarg;
                break;
			case 'e':
				e_method = atoi(optarg);
				break;
            case 'k':
                K = atoi(optarg);
                break;
			case 'm':
				max_iterations = atoi(optarg);
				//If max_iterations < 2 the default value will be restored
				if (max_iterations<2) max_iterations = default_max_iterations;
				break;
			case 'N':
				normalize = atoi(optarg);
				break;
            case 'n':
                normalize_matrix_flag = true;
                break;
			case 'P':
				p_method = atoi(optarg);
				if (p_method<1 || p_method>3) p_method = 2;
				break;				
			case 'p':
				pseudocount = atof(optarg);
				break;
			case 'R':
				//Do not redistribute quality
				redistribute = false;
				break;
            case 'r':
                rc_flag = true;
                break;
			case 'S':
				random_seed = atoi(optarg);
				break;
            case 't':
                num_trials = atoi(optarg);
                break;
            case 'v':
                ++verbose_level;
                break;
            case 'w':
                write_flag = true;
                break;
            case 'h':
				print_usage(argv[0]);
				return EXIT_SUCCESS;
            case '?':
                print_usage(argv[0]);
                return EXIT_FAILURE;
            default:
                // You won't actually get here
                break;
        }
	}

	if (dist_type != 'a'){
		p_method = 0;//No calculation of expected freq and expected quality
		e_method = 0;
	}

	// if "-t" argument was absent, use the appropriate default
	if (!num_trials) {
		num_trials = 1;
	}

	if(argc != optind + 1){
		cout<<"Missing/extra input file name"<<endl;
		print_usage(argv[0]);
		return EXIT_FAILURE;
	}
	char* fastq_file_name = *(argv + optind );

	// initialize random number generator
	srand(random_seed);

	// initialize constants
	int L = 1; // length of the freq. vector L = NUM_NT**K
	for(int k=0; k<K; ++k){
		L *= NUM_NT;
	}

	// count sequences
	int N = CountReads(fastq_file_name);  // number of sequences
	if (verbose_level>0){
		cerr<<"Found "<<N<<" sequences\n";
	}

	// read sequences and build count matrix
	RecordGenerator rec_gen(fastq_file_name);
	double **freq = new double*[N];
	freq[0] = new double[N * L];
	double **quality = new double*[N];
	for (int i=0; i<N; i++) quality[i] = new double[L];
	
	double **freq_1  = new double*[N];
	freq_1[0] = new double[N * NUM_NT];
	double **quality_1 = new double*[N];
	for (int i=0; i<N; i++) quality_1[i] = new double[NUM_NT];
	
	//Vector for calculus of E(Pxi)2
	double *avg_quality_1 = new double[NUM_NT];
	for(int i=0; i<NUM_NT; i++) avg_quality_1[i] = 0;
	
	//Vector for calculus of E(Pxi)3
	double **avg_quality = new double*[L];
	for (int i=0; i<L; i++) {
		avg_quality[i] = new double[NUM_NT];
		for (int j=0; j<NUM_NT; j++) avg_quality[i][j] = 0;
	}
	
	//For each read we count the number of kmers
	for(int i=0; i<N; ++i){
		SeqRecord rec = rec_gen.next();
		string seq = rc_flag ? rec.seq() + rec.rc().seq() : rec.seq();
		freq[i] = freq[0] + i*L;

		//Calculate frequencies of individual bases
		freq_1[i] = freq_1[0] + i*NUM_NT;
		fill_overlap_count_vector(seq, rec.qual(), 1, freq_1[i], 
								  quality_1[i], false, pseudocount, 
								  avg_quality_1, NULL, NULL, false);
		
		//Calculate frequencies of kmers
		fill_overlap_count_vector(seq, rec.qual(), K, freq[i], quality[i],
								normalize, pseudocount, NULL, avg_quality, 
								freq_1[i], redistribute);
	}
	
	if (verbose_level>0){
		cerr<<"Read counts calculated\n";
	}

	
	//Compute the expected quality of each kmer
	double *expected_qual = NULL;
	if (e_method != 0) {
		expected_qual = new double[L];
		calculate_quality_expected_value(e_method, N, K, L, freq, quality,
						freq_1, avg_quality_1, avg_quality, expected_qual);
	}
	
	//Expected frequancy of each kmer
	double *expected_freq = NULL;
	//Instantiate the vector only if p_method is global (P1G or P2G)
	if (p_method==2 || p_method==3) expected_freq = new double[L];
	
	//P1G Average frequency of every word over the entire dataset
	if (p_method==2)
		expected_frequency_p1global(N, K, L, expected_freq, freq);
	
	//P2G Markovian model based on average frequency of single bases
	if (p_method==3)
		expected_frequency_p2global(N, K, L, expected_freq, freq_1);
	

	
	
	// whiten if requested; in this case reset the distance to euclidean L2
	if (normalize_matrix_flag){
		dist_type = 'e';
		normalize_freq_matrix(freq, quality, N, L);
	}
	if (verbose_level > 0){
		cerr<<"Word frequencies calculated\n";
	}


	// hard EM clustering
	int* assignment = new int[N];
	double* Z = new double[num_clusters * N];
		if (verbose_level > 0) {
			cerr<<"Running regular EM clustering "<<num_trials<<" times "
			"to chose the best partitioning"<<endl;
		}
		num_clusters = hard_em(num_clusters, N, L, freq, quality, expected_qual, 
			quality_1, expected_freq, NUM_NT, freq_1, assignment, Z, num_trials, 
			dist_type, verbose_level);
		
	if (verbose_level > 0){
		cerr<<"Clustering done\n";
	}

	// release memory previously allocated for frequency data
	delete[] freq[0];
	delete[] freq;
	delete[] freq_1[0];
	delete[] freq_1;
	
	for(int i=0; i<N; i++) {
		delete[] quality[i];
		delete[] quality_1[i];
	}
	for(int i=0; i<L; i++)
		delete[] avg_quality[i];
	delete[] quality;
	delete[] quality_1;
	delete[] avg_quality_1;
	delete[] avg_quality;
	if (p_method==2 || p_method==3) delete [] expected_freq;
	if (e_method != 0) delete[] expected_qual;

	// reassign cluster names so that they are sorted 
	// in the descending order of the number of members
	int* num_members = new int[num_clusters];
	int* ix = new int[num_clusters];
	int* rix = new int[num_clusters];
	for (int i=0; i<num_clusters; ++i){
		*(num_members + i) = 0;
		*(ix + i) = i;
	}
	for (int i=0; i<N; ++i){
		num_members[assignment[i]]++;
	}
	for (int i=0; i<num_clusters; ++i){
		int max_pos = i;
		for (int j=i+1; j<num_clusters; ++j){
			if (num_members[ix[j]] > num_members[ix[max_pos]]) {
				max_pos = j;
			}
		}
		int tmp = ix[i];
		ix[i] = ix[max_pos];
		ix[max_pos] = tmp;
	}
	for (int i=0; i<num_clusters; ++i){
		rix[ix[i]] = i;
	}
	for (int i=0; i<N; ++i) {
		*(assignment + i) = *(rix + *(assignment + i));
	}
	delete[] num_members;
	//delete[] ix and rix later

	cout.setf(ios_base::fixed);
	cout.precision(4);

	// output assignment to stdout
	RecordGenerator rec_gen_2(fastq_file_name);
	for(int n=0; n<N; ++n){
		cout<<rec_gen_2.next().id()<<"\t"<<*(assignment+n);
		cout<<endl;
	}
	delete[] ix;
	delete[] rix;

	// write sequences to individual files if requested
	if (write_flag) {
		vector<SeqRecord> rec_vec;
		FastqRead(fastq_file_name, rec_vec);
		int N = rec_vec.size();
		char fname[256];
		for (int i=0; i<num_clusters; ++i){
			sprintf(fname, "part_%i.fastq", i+1);
			ofstream ofs(fname);
			for (int j=0; j<N; ++j) {
				if (*(assignment + j) == i) {
					ofs<<"@"<<rec_vec[j].desc()<<endl;
					ofs<<rec_vec[j].seq()<<endl;
					ofs<<"+"<<endl;
					ofs<<rec_vec[j].qual()<<endl;
				}
			}
		}
	}

	// free allocated memory
	delete[] Z;
	delete[] assignment;
	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xec8, %rsp            # imm = 0xEC8
movl $0x0, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movl $0x5, -0x3c(%rbp)
movb $0x65, -0x3d(%rbp)
movl $0x2, -0x44(%rbp)
movb $0x0, -0x45(%rbp)
movl $0x2, -0x4c(%rbp)
movb $0x1, -0x4d(%rbp)
movl $0x1, -0x54(%rbp)
movl $0x1, -0x58(%rbp)
movsd 0x77ff(%rip), %xmm0     # 0xb008
movsd %xmm0, -0x60(%rbp)
movb $0x0, -0x61(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3240
movl %eax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movb $0x0, -0x71(%rbp)
movl $0x3e8, -0x78(%rbp)     # imm = 0x3E8
movl -0x30(%rbp), %edi
movq -0x38(%rbp), %rsi
leaq 0x820e(%rip), %rdx      # 0xba53
callq 0x3090
movl %eax, -0x7c(%rbp)
cmpl $-0x1, %eax
je 0x39f1
movl -0x7c(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0xcc8(%rbp)
subl $0x38, %eax
ja 0x39ea
movq -0xcc8(%rbp), %rax
leaq 0x7794(%rip), %rcx      # 0xb010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xb72c(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x3c(%rbp)
jmp 0x39ec
movq 0xb715(%rip), %rax      # 0xefb8
movq (%rax), %rax
movb (%rax), %al
movb %al, -0x3d(%rbp)
jmp 0x39ec
movq 0xb701(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x54(%rbp)
jmp 0x39ec
movq 0xb6ea(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x44(%rbp)
jmp 0x39ec
movq 0xb6d3(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, %ecx
leaq 0xb982(%rip), %rax      # 0xf278
movl %ecx, (%rax)
leaq 0xb979(%rip), %rax      # 0xf278
cmpl $0x2, (%rax)
jge 0x3910
movl -0x78(%rbp), %ecx
leaq 0xb96a(%rip), %rax      # 0xf278
movl %ecx, (%rax)
jmp 0x39ec
movq 0xb69c(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x4c(%rbp)
jmp 0x39ec
movb $0x1, -0x45(%rbp)
jmp 0x39ec
movq 0xb67c(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x58(%rbp)
cmpl $0x1, -0x58(%rbp)
jl 0x3953
cmpl $0x3, -0x58(%rbp)
jle 0x395a
movl $0x2, -0x58(%rbp)
jmp 0x39ec
movq 0xb652(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x3330
movsd %xmm0, -0x60(%rbp)
jmp 0x39ec
movb $0x0, -0x4d(%rbp)
jmp 0x39ec
movb $0x1, -0x61(%rbp)
jmp 0x39ec
movq 0xb630(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x68(%rbp)
jmp 0x39ec
movq 0xb61c(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x33c0
movl %eax, -0x6c(%rbp)
jmp 0x39ec
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x39ec
movb $0x1, -0x71(%rbp)
jmp 0x39ec
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x3740
movl $0x0, -0x2c(%rbp)
jmp 0x533d
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x3740
movl $0x1, -0x2c(%rbp)
jmp 0x533d
jmp 0x39ec
jmp 0x3837
movsbl -0x3d(%rbp), %eax
cmpl $0x61, %eax
je 0x3a08
movl $0x0, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
cmpl $0x0, -0x6c(%rbp)
jne 0x3a15
movl $0x1, -0x6c(%rbp)
movl -0x30(%rbp), %eax
movq 0xb5b1(%rip), %rcx      # 0xefd0
movl (%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x3a62
movq 0xb599(%rip), %rdi      # 0xefc8
leaq 0x803b(%rip), %rsi      # 0xba71
callq 0x3260
movq %rax, %rdi
movq 0xb56b(%rip), %rsi      # 0xefb0
callq 0x32a0
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x3740
movl $0x1, -0x2c(%rbp)
jmp 0x533d
movq -0x38(%rbp), %rax
movq 0xb563(%rip), %rcx      # 0xefd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x88(%rbp)
movl -0x68(%rbp), %edi
callq 0x3250
movl $0x1, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x3ac2
movl -0x8c(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x8c(%rbp)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x3a97
movq -0x88(%rbp), %rax
movq %rax, -0xcd8(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xcd0(%rbp)
callq 0x3430
movq -0xcd8(%rbp), %rsi
movq -0xcd0(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x5360
jmp 0x3aff
leaq -0xb8(%rbp), %rdi
callq 0xa070
movl %eax, -0xcdc(%rbp)
jmp 0x3b13
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xb9(%rbp), %rdi
callq 0x32c0
movl -0xcdc(%rbp), %eax
movl %eax, -0x94(%rbp)
cmpl $0x0, -0x70(%rbp)
jle 0x3bb2
movq 0xb4ac(%rip), %rdi      # 0xeff0
leaq 0x7f44(%rip), %rsi      # 0xba8f
callq 0x3260
movq %rax, %rdi
movl -0x94(%rbp), %esi
callq 0x3400
movq %rax, %rdi
leaq 0x7f2e(%rip), %rsi      # 0xba96
callq 0x3260
jmp 0x3bb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x3ba1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xb9(%rbp), %rdi
callq 0x32c0
jmp 0x5352
movq -0x88(%rbp), %rax
movq %rax, -0xcf0(%rbp)
leaq -0x341(%rbp), %rdi
movq %rdi, -0xce8(%rbp)
callq 0x3430
movq -0xcf0(%rbp), %rsi
movq -0xce8(%rbp), %rdx
leaq -0x340(%rbp), %rdi
callq 0x5360
jmp 0x3bef
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x9750
jmp 0x3c04
leaq -0x340(%rbp), %rdi
callq 0x3180
leaq -0x341(%rbp), %rdi
callq 0x32c0
movslq -0x94(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xcf8(%rbp)
jmp 0x3c47
movq -0xcf8(%rbp), %rax
movq %rax, -0x350(%rbp)
movl -0x94(%rbp), %eax
movl -0x8c(%rbp), %ecx
imull %ecx, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd00(%rbp)
jmp 0x3c8a
movq -0xd00(%rbp), %rcx
movq -0x350(%rbp), %rax
movq %rcx, (%rax)
movslq -0x94(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd08(%rbp)
jmp 0x3cc6
movq -0xd08(%rbp), %rax
movq %rax, -0x358(%rbp)
movl $0x0, -0x35c(%rbp)
movl -0x35c(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x3d9f
movslq -0x8c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd10(%rbp)
jmp 0x3d1b
movq -0xd10(%rbp), %rdx
movq -0x358(%rbp), %rax
movslq -0x35c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x35c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x35c(%rbp)
jmp 0x3cde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x3d77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x3180
leaq -0x341(%rbp), %rdi
callq 0x32c0
jmp 0x5352
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x532f
movslq -0x94(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd18(%rbp)
jmp 0x3dca
movq -0xd18(%rbp), %rax
movq %rax, -0x368(%rbp)
movl -0x94(%rbp), %eax
shll $0x2, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd20(%rbp)
jmp 0x3e07
movq -0xd20(%rbp), %rcx
movq -0x368(%rbp), %rax
movq %rcx, (%rax)
movslq -0x94(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd28(%rbp)
jmp 0x3e43
movq -0xd28(%rbp), %rax
movq %rax, -0x370(%rbp)
movl $0x0, -0x374(%rbp)
movl -0x374(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x3ea6
movl $0x20, %edi
callq 0x3030
movq %rax, -0xd30(%rbp)
jmp 0x3e7c
movq -0xd30(%rbp), %rdx
movq -0x370(%rbp), %rax
movslq -0x374(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x374(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x374(%rbp)
jmp 0x3e5b
movl $0x20, %edi
callq 0x3030
movq %rax, -0xd38(%rbp)
jmp 0x3eb9
movq -0xd38(%rbp), %rax
movq %rax, -0x380(%rbp)
movl $0x0, -0x384(%rbp)
cmpl $0x4, -0x384(%rbp)
jge 0x3f01
movq -0x380(%rbp), %rax
movslq -0x384(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x384(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x384(%rbp)
jmp 0x3ed1
movslq -0x8c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd40(%rbp)
jmp 0x3f2c
movq -0xd40(%rbp), %rax
movq %rax, -0x390(%rbp)
movl $0x0, -0x394(%rbp)
movl -0x394(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jge 0x3fdd
movl $0x20, %edi
callq 0x3030
movq %rax, -0xd48(%rbp)
jmp 0x3f69
movq -0xd48(%rbp), %rdx
movq -0x390(%rbp), %rax
movslq -0x394(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x398(%rbp)
cmpl $0x4, -0x398(%rbp)
jge 0x3fc7
movq -0x390(%rbp), %rax
movslq -0x394(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x398(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x398(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x398(%rbp)
jmp 0x3f8c
jmp 0x3fc9
movl -0x394(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x394(%rbp)
jmp 0x3f44
movl $0x0, -0x39c(%rbp)
movl -0x39c(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4410
leaq -0x420(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x98a0
jmp 0x400e
movb -0x61(%rbp), %al
movb $0x0, -0x461(%rbp)
movb $0x0, -0x509(%rbp)
movb $0x0, -0x50a(%rbp)
testb $0x1, %al
je 0x409c
leaq -0x460(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x54e0
jmp 0x403f
movb $0x1, -0x461(%rbp)
leaq -0x508(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x94d0
jmp 0x405b
movb $0x1, -0x509(%rbp)
leaq -0x488(%rbp), %rdi
leaq -0x508(%rbp), %rsi
callq 0x54e0
jmp 0x4077
movb $0x1, -0x50a(%rbp)
leaq -0x440(%rbp), %rdi
leaq -0x460(%rbp), %rsi
leaq -0x488(%rbp), %rdx
callq 0x5410
jmp 0x409a
jmp 0x40b3
leaq -0x440(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x54e0
jmp 0x40b1
jmp 0x40b3
testb $0x1, -0x50a(%rbp)
jne 0x40be
jmp 0x40ca
leaq -0x488(%rbp), %rdi
callq 0x3180
testb $0x1, -0x509(%rbp)
jne 0x40d5
jmp 0x40e1
leaq -0x508(%rbp), %rdi
callq 0x9260
testb $0x1, -0x461(%rbp)
jne 0x40ec
jmp 0x40f8
leaq -0x460(%rbp), %rdi
callq 0x3180
movq -0x350(%rbp), %rax
movq (%rax), %rdx
movslq -0x39c(%rbp), %rcx
movl %ecx, %esi
movl -0x8c(%rbp), %edi
imull %edi, %esi
movslq %esi, %rsi
leaq (%rdx,%rsi,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x368(%rbp), %rax
movq (%rax), %rdx
movslq -0x39c(%rbp), %rcx
movl %ecx, %esi
shll $0x2, %esi
movslq %esi, %rsi
leaq (%rdx,%rsi,8), %rdx
movq %rdx, (%rax,%rcx,8)
leaq -0x530(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x3110
jmp 0x4155
leaq -0x550(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x5510
jmp 0x416a
movq -0x368(%rbp), %rax
movslq -0x39c(%rbp), %rdx
movq (%rax,%rdx,8), %rcx
movq -0x370(%rbp), %rax
movq (%rax,%rdx,8), %r8
movsd -0x60(%rbp), %xmm0
movq -0x380(%rbp), %rdx
movq %rsp, %rax
movq %rdx, (%rax)
movl $0x0, 0x18(%rax)
movq $0x0, 0x10(%rax)
movq $0x0, 0x8(%rax)
leaq -0x530(%rbp), %rdi
leaq -0x550(%rbp), %rsi
movl $0x1, %edx
xorl %r9d, %r9d
callq 0x7ee0
jmp 0x41cd
leaq -0x550(%rbp), %rdi
callq 0x3180
leaq -0x530(%rbp), %rdi
callq 0x3180
leaq -0x570(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x3110
jmp 0x41fa
leaq -0x590(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x5510
jmp 0x420f
movl -0x44(%rbp), %edx
movq -0x350(%rbp), %rax
movslq -0x39c(%rbp), %rdi
movq (%rax,%rdi,8), %rcx
movq -0x358(%rbp), %rax
movq (%rax,%rdi,8), %r8
movl -0x4c(%rbp), %r9d
movsd -0x60(%rbp), %xmm0
movq -0x390(%rbp), %rsi
movq -0x368(%rbp), %rax
movq (%rax,%rdi,8), %rdi
movzbl -0x4d(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, 0x18(%rax)
movq %rdi, 0x10(%rax)
movq %rsi, 0x8(%rax)
movq $0x0, (%rax)
leaq -0x570(%rbp), %rdi
leaq -0x590(%rbp), %rsi
callq 0x7ee0
jmp 0x427e
leaq -0x590(%rbp), %rdi
callq 0x3180
leaq -0x570(%rbp), %rdi
callq 0x3180
leaq -0x440(%rbp), %rdi
callq 0x3180
leaq -0x420(%rbp), %rdi
callq 0x9260
movl -0x39c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x39c(%rbp)
jmp 0x3fe7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x43ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x4345
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x432c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
testb $0x1, -0x50a(%rbp)
jne 0x431e
jmp 0x432a
leaq -0x488(%rbp), %rdi
callq 0x3180
jmp 0x432c
testb $0x1, -0x509(%rbp)
jne 0x4337
jmp 0x4343
leaq -0x508(%rbp), %rdi
callq 0x9260
jmp 0x4345
testb $0x1, -0x461(%rbp)
jne 0x4350
jmp 0x435c
leaq -0x460(%rbp), %rdi
callq 0x3180
jmp 0x43ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x43f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x43a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x3180
leaq -0x530(%rbp), %rdi
callq 0x3180
jmp 0x43f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x43e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x3180
leaq -0x570(%rbp), %rdi
callq 0x3180
leaq -0x440(%rbp), %rdi
callq 0x3180
leaq -0x420(%rbp), %rdi
callq 0x9260
jmp 0x532f
cmpl $0x0, -0x70(%rbp)
jle 0x442d
movq 0xabd3(%rip), %rdi      # 0xeff0
leaq 0x767e(%rip), %rsi      # 0xbaa2
callq 0x3260
jmp 0x442b
jmp 0x442d
movq $0x0, -0x598(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x44d2
movslq -0x8c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd50(%rbp)
jmp 0x446d
movq -0xd50(%rbp), %rax
movq %rax, -0x598(%rbp)
movl -0x54(%rbp), %edi
movl -0x94(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x8c(%rbp), %ecx
movq -0x350(%rbp), %r8
movq -0x358(%rbp), %r9
movq -0x368(%rbp), %r10
movq -0x380(%rbp), %r11
movq -0x390(%rbp), %rbx
movq -0x598(%rbp), %r14
movq %rsp, %rax
movq %r14, 0x18(%rax)
movq %rbx, 0x10(%rax)
movq %r11, 0x8(%rax)
movq %r10, (%rax)
callq 0x8770
jmp 0x44d0
jmp 0x44d2
movq $0x0, -0x5a0(%rbp)
cmpl $0x2, -0x58(%rbp)
je 0x44e9
cmpl $0x3, -0x58(%rbp)
jne 0x4522
movslq -0x8c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd58(%rbp)
jmp 0x4514
movq -0xd58(%rbp), %rax
movq %rax, -0x5a0(%rbp)
cmpl $0x2, -0x58(%rbp)
jne 0x454e
movl -0x94(%rbp), %edi
movl -0x44(%rbp), %esi
movl -0x8c(%rbp), %edx
movq -0x5a0(%rbp), %rcx
movq -0x350(%rbp), %r8
callq 0x8df0
jmp 0x454c
jmp 0x454e
cmpl $0x3, -0x58(%rbp)
jne 0x457a
movl -0x94(%rbp), %edi
movl -0x44(%rbp), %esi
movl -0x8c(%rbp), %edx
movq -0x5a0(%rbp), %rcx
movq -0x368(%rbp), %r8
callq 0x8c80
jmp 0x4578
jmp 0x457a
testb $0x1, -0x45(%rbp)
je 0x45a7
movb $0x65, -0x3d(%rbp)
movq -0x350(%rbp), %rdi
movq -0x358(%rbp), %rsi
movl -0x94(%rbp), %edx
movl -0x8c(%rbp), %ecx
callq 0x8ed0
jmp 0x45a5
jmp 0x45a7
cmpl $0x0, -0x70(%rbp)
jle 0x45c4
movq 0xaa3c(%rip), %rdi      # 0xeff0
leaq 0x74ff(%rip), %rsi      # 0xbaba
callq 0x3260
jmp 0x45c2
jmp 0x45c4
movslq -0x94(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd60(%rbp)
jmp 0x45ef
movq -0xd60(%rbp), %rax
movq %rax, -0x5a8(%rbp)
movl -0x3c(%rbp), %eax
movl -0x94(%rbp), %ecx
imull %ecx, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xd68(%rbp)
jmp 0x462f
movq -0xd68(%rbp), %rax
movq %rax, -0x5b0(%rbp)
cmpl $0x0, -0x70(%rbp)
jle 0x46aa
movq 0xa9a6(%rip), %rdi      # 0xeff0
leaq 0x7486(%rip), %rsi      # 0xbad7
callq 0x3260
movq %rax, -0xd70(%rbp)
jmp 0x465f
movq -0xd70(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x3400
movq %rax, -0xd78(%rbp)
jmp 0x4677
movq -0xd78(%rbp), %rdi
leaq 0x7471(%rip), %rsi      # 0xbaf6
callq 0x3260
movq %rax, -0xd80(%rbp)
jmp 0x4693
movq -0xd80(%rbp), %rdi
movq 0xa90f(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x46a8
jmp 0x46aa
movl -0x3c(%rbp), %edi
movl -0x94(%rbp), %esi
movl -0x8c(%rbp), %edx
movq -0x350(%rbp), %rax
movq %rax, -0xd90(%rbp)
movq -0x358(%rbp), %r8
movq -0x598(%rbp), %r9
movq -0x370(%rbp), %r10
movq -0x5a0(%rbp), %r11
movq -0x368(%rbp), %rbx
movq -0x5a8(%rbp), %r14
movq -0x5b0(%rbp), %r15
movl -0x6c(%rbp), %r12d
movsbl -0x3d(%rbp), %r13d
movl -0x70(%rbp), %ecx
movq %rsp, %rax
movq %rax, -0xd98(%rbp)
movl %ecx, 0x40(%rax)
movq -0xd90(%rbp), %rcx
movl %r13d, 0x38(%rax)
movl %r12d, 0x30(%rax)
movq %r15, 0x28(%rax)
movq %r14, 0x20(%rax)
movq %rbx, 0x18(%rax)
movq %r11, 0x8(%rax)
movq %r10, (%rax)
movl $0x4, 0x10(%rax)
callq 0x5f10
movl %eax, -0xd84(%rbp)
jmp 0x4747
movl -0xd84(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x70(%rbp)
jle 0x476d
movq 0xa893(%rip), %rdi      # 0xeff0
leaq 0x73b8(%rip), %rsi      # 0xbb1c
callq 0x3260
jmp 0x476b
jmp 0x476d
movq -0x350(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xda0(%rbp)
cmpq $0x0, %rax
je 0x4790
movq -0xda0(%rbp), %rdi
callq 0x3350
movq -0x350(%rbp), %rax
movq %rax, -0xda8(%rbp)
cmpq $0x0, %rax
je 0x47b0
movq -0xda8(%rbp), %rdi
callq 0x3350
movq -0x368(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xdb0(%rbp)
cmpq $0x0, %rax
je 0x47d3
movq -0xdb0(%rbp), %rdi
callq 0x3350
movq -0x368(%rbp), %rax
movq %rax, -0xdb8(%rbp)
cmpq $0x0, %rax
je 0x47f3
movq -0xdb8(%rbp), %rdi
callq 0x3350
movl $0x0, -0x5b4(%rbp)
movl -0x5b4(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4874
movq -0x358(%rbp), %rax
movslq -0x5b4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xdc0(%rbp)
cmpq $0x0, %rax
je 0x4836
movq -0xdc0(%rbp), %rdi
callq 0x3350
movq -0x370(%rbp), %rax
movslq -0x5b4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xdc8(%rbp)
cmpq $0x0, %rax
je 0x4861
movq -0xdc8(%rbp), %rdi
callq 0x3350
jmp 0x4863
movl -0x5b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5b4(%rbp)
jmp 0x47fd
movl $0x0, -0x5b8(%rbp)
movl -0x5b8(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jge 0x48ca
movq -0x390(%rbp), %rax
movslq -0x5b8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xdd0(%rbp)
cmpq $0x0, %rax
je 0x48b7
movq -0xdd0(%rbp), %rdi
callq 0x3350
jmp 0x48b9
movl -0x5b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5b8(%rbp)
jmp 0x487e
movq -0x358(%rbp), %rax
movq %rax, -0xdd8(%rbp)
cmpq $0x0, %rax
je 0x48ea
movq -0xdd8(%rbp), %rdi
callq 0x3350
movq -0x370(%rbp), %rax
movq %rax, -0xde0(%rbp)
cmpq $0x0, %rax
je 0x490a
movq -0xde0(%rbp), %rdi
callq 0x3350
movq -0x380(%rbp), %rax
movq %rax, -0xde8(%rbp)
cmpq $0x0, %rax
je 0x492a
movq -0xde8(%rbp), %rdi
callq 0x3350
movq -0x390(%rbp), %rax
movq %rax, -0xdf0(%rbp)
cmpq $0x0, %rax
je 0x494a
movq -0xdf0(%rbp), %rdi
callq 0x3350
cmpl $0x2, -0x58(%rbp)
je 0x4956
cmpl $0x3, -0x58(%rbp)
jne 0x4978
movq -0x5a0(%rbp), %rax
movq %rax, -0xdf8(%rbp)
cmpq $0x0, %rax
je 0x4976
movq -0xdf8(%rbp), %rdi
callq 0x3350
jmp 0x4978
cmpl $0x0, -0x54(%rbp)
je 0x49a0
movq -0x598(%rbp), %rax
movq %rax, -0xe00(%rbp)
cmpq $0x0, %rax
je 0x499e
movq -0xe00(%rbp), %rdi
callq 0x3350
jmp 0x49a0
movslq -0x3c(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xe08(%rbp)
jmp 0x49c8
movq -0xe08(%rbp), %rax
movq %rax, -0x5c0(%rbp)
movslq -0x3c(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xe10(%rbp)
jmp 0x49fe
movq -0xe10(%rbp), %rax
movq %rax, -0x5c8(%rbp)
movslq -0x3c(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xe18(%rbp)
jmp 0x4a34
movq -0xe18(%rbp), %rax
movq %rax, -0x5d0(%rbp)
movl $0x0, -0x5d4(%rbp)
movl -0x5d4(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4a94
movq -0x5c0(%rbp), %rax
movslq -0x5d4(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x5d4(%rbp), %edx
movq -0x5c8(%rbp), %rax
movslq -0x5d4(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5d4(%rbp)
jmp 0x4a4c
movl $0x0, -0x5d8(%rbp)
movl -0x5d8(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4adf
movq -0x5c0(%rbp), %rax
movq -0x5a8(%rbp), %rcx
movslq -0x5d8(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x5d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5d8(%rbp)
jmp 0x4a9e
movl $0x0, -0x5dc(%rbp)
movl -0x5dc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4bdb
movl -0x5dc(%rbp), %eax
movl %eax, -0x5e0(%rbp)
movl -0x5dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5e4(%rbp)
movl -0x5e4(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4b77
movq -0x5c0(%rbp), %rax
movq -0x5c8(%rbp), %rcx
movslq -0x5e4(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movq -0x5c0(%rbp), %rcx
movq -0x5c8(%rbp), %rdx
movslq -0x5e0(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x4b64
movl -0x5e4(%rbp), %eax
movl %eax, -0x5e0(%rbp)
jmp 0x4b66
movl -0x5e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5e4(%rbp)
jmp 0x4b13
movq -0x5c8(%rbp), %rax
movslq -0x5dc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5e8(%rbp)
movq -0x5c8(%rbp), %rax
movslq -0x5e0(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x5c8(%rbp), %rax
movslq -0x5dc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5e8(%rbp), %edx
movq -0x5c8(%rbp), %rax
movslq -0x5e0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5dc(%rbp)
jmp 0x4ae9
movl $0x0, -0x5ec(%rbp)
movl -0x5ec(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4c23
movl -0x5ec(%rbp), %edx
movq -0x5d0(%rbp), %rax
movq -0x5c8(%rbp), %rcx
movslq -0x5ec(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5ec(%rbp)
jmp 0x4be5
movl $0x0, -0x5f0(%rbp)
movl -0x5f0(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4c79
movq -0x5d0(%rbp), %rax
movq -0x5a8(%rbp), %rcx
movslq -0x5f0(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
movq -0x5a8(%rbp), %rax
movslq -0x5f0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5f0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5f0(%rbp)
jmp 0x4c2d
movq -0x5c0(%rbp), %rax
movq %rax, -0xe20(%rbp)
cmpq $0x0, %rax
je 0x4c99
movq -0xe20(%rbp), %rdi
callq 0x3350
movq 0xa328(%rip), %rdi      # 0xefc8
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x4, %esi
callq 0x5540
jmp 0x4cb6
movq 0xa30b(%rip), %rdi      # 0xefc8
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x4, %esi
callq 0x5570
jmp 0x4cd3
movq -0x88(%rbp), %rax
movq %rax, -0xe30(%rbp)
leaq -0x861(%rbp), %rdi
movq %rdi, -0xe28(%rbp)
callq 0x3430
movq -0xe30(%rbp), %rsi
movq -0xe28(%rbp), %rdx
leaq -0x860(%rbp), %rdi
callq 0x5360
jmp 0x4d10
leaq -0x840(%rbp), %rdi
leaq -0x860(%rbp), %rsi
callq 0x9750
jmp 0x4d25
leaq -0x860(%rbp), %rdi
callq 0x3180
leaq -0x861(%rbp), %rdi
callq 0x32c0
movl $0x0, -0x868(%rbp)
movl -0x868(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x4eba
leaq -0x908(%rbp), %rdi
leaq -0x840(%rbp), %rsi
callq 0x98a0
jmp 0x4d6e
leaq -0x888(%rbp), %rdi
leaq -0x908(%rbp), %rsi
callq 0x55a0
jmp 0x4d83
movq 0xa23e(%rip), %rdi      # 0xefc8
leaq -0x888(%rbp), %rsi
callq 0x3230
movq %rax, -0xe38(%rbp)
jmp 0x4d9f
movq -0xe38(%rbp), %rdi
leaq 0x6d80(%rip), %rsi      # 0xbb2d
callq 0x3260
movq %rax, -0xe40(%rbp)
jmp 0x4dbb
movq -0xe40(%rbp), %rdi
movq -0x5a8(%rbp), %rax
movslq -0x868(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x3400
jmp 0x4dda
leaq -0x888(%rbp), %rdi
callq 0x3180
leaq -0x908(%rbp), %rdi
callq 0x9260
movq 0xa1cf(%rip), %rdi      # 0xefc8
movq 0xa1b0(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x4e07
jmp 0x4e09
movl -0x868(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x868(%rbp)
jmp 0x4d47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x4e4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x860(%rbp), %rdi
callq 0x3180
leaq -0x861(%rbp), %rdi
callq 0x32c0
jmp 0x532f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x5323
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x4ea9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x888(%rbp), %rdi
callq 0x3180
leaq -0x908(%rbp), %rdi
callq 0x9260
jmp 0x5323
movq -0x5c8(%rbp), %rax
movq %rax, -0xe48(%rbp)
cmpq $0x0, %rax
je 0x4eda
movq -0xe48(%rbp), %rdi
callq 0x3350
movq -0x5d0(%rbp), %rax
movq %rax, -0xe50(%rbp)
cmpq $0x0, %rax
je 0x4efa
movq -0xe50(%rbp), %rdi
callq 0x3350
testb $0x1, -0x71(%rbp)
je 0x52c2
leaq -0x920(%rbp), %rdi
callq 0x55d0
movq -0x88(%rbp), %rax
movq %rax, -0xe60(%rbp)
leaq -0x941(%rbp), %rdi
movq %rdi, -0xe58(%rbp)
callq 0x3430
movq -0xe60(%rbp), %rsi
movq -0xe58(%rbp), %rdx
leaq -0x940(%rbp), %rdi
callq 0x5360
jmp 0x4f4d
leaq -0x940(%rbp), %rdi
leaq -0x920(%rbp), %rsi
callq 0x9ef0
jmp 0x4f62
leaq -0x940(%rbp), %rdi
callq 0x3180
leaq -0x941(%rbp), %rdi
callq 0x32c0
leaq -0x920(%rbp), %rdi
callq 0x55f0
movl %eax, -0x948(%rbp)
movl $0x0, -0xa54(%rbp)
movl -0xa54(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x52a6
movl -0xa54(%rbp), %edx
incl %edx
leaq 0x6b7b(%rip), %rsi      # 0xbb2f
xorl %eax, %eax
leaq -0xa50(%rbp), %rdi
movq %rdi, -0xe68(%rbp)
callq 0x3070
movq -0xe68(%rbp), %rsi
leaq -0xc58(%rbp), %rdi
movl $0x10, %edx
callq 0x32d0
jmp 0x4fe3
movl $0x0, -0xc5c(%rbp)
movl -0xc5c(%rbp), %eax
cmpl -0x948(%rbp), %eax
jge 0x5278
movq -0x5a8(%rbp), %rax
movslq -0xc5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0xa54(%rbp), %eax
jne 0x5262
leaq 0x6b1a(%rip), %rsi      # 0xbb3d
leaq -0xc58(%rbp), %rdi
callq 0x3260
movq %rax, -0xe70(%rbp)
jmp 0x5038
movslq -0xc5c(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x5610
movq %rax, %rsi
leaq -0xc80(%rbp), %rdi
callq 0x5630
jmp 0x505c
movq -0xe70(%rbp), %rdi
leaq -0xc80(%rbp), %rsi
callq 0x3230
movq %rax, -0xe78(%rbp)
jmp 0x5078
movq -0xe78(%rbp), %rdi
movq 0x9f2a(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x508d
leaq -0xc80(%rbp), %rdi
callq 0x3180
movslq -0xc5c(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x5610
movq %rax, %rsi
leaq -0xca0(%rbp), %rdi
callq 0x54e0
jmp 0x50bd
leaq -0xc58(%rbp), %rdi
leaq -0xca0(%rbp), %rsi
callq 0x3230
movq %rax, -0xe80(%rbp)
jmp 0x50d9
movq -0xe80(%rbp), %rdi
movq 0x9ec9(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x50ee
leaq -0xca0(%rbp), %rdi
callq 0x3180
leaq 0x6a3e(%rip), %rsi      # 0xbb3f
leaq -0xc58(%rbp), %rdi
callq 0x3260
movq %rax, -0xe88(%rbp)
jmp 0x5116
movq -0xe88(%rbp), %rdi
movq 0x9e8c(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x512b
movslq -0xc5c(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x5610
movq %rax, %rsi
leaq -0xcc0(%rbp), %rdi
callq 0x5510
jmp 0x514f
leaq -0xc58(%rbp), %rdi
leaq -0xcc0(%rbp), %rsi
callq 0x3230
movq %rax, -0xe90(%rbp)
jmp 0x516b
movq -0xe90(%rbp), %rdi
movq 0x9e37(%rip), %rsi      # 0xefb0
callq 0x32a0
jmp 0x5180
leaq -0xcc0(%rbp), %rdi
callq 0x3180
jmp 0x5262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x51c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x940(%rbp), %rdi
callq 0x3180
leaq -0x941(%rbp), %rdi
callq 0x32c0
jmp 0x52b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x52b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x5298
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xc80(%rbp), %rdi
callq 0x3180
jmp 0x5298
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xca0(%rbp), %rdi
callq 0x3180
jmp 0x5298
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xcc0(%rbp), %rdi
callq 0x3180
jmp 0x5298
jmp 0x5264
movl -0xc5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc5c(%rbp)
jmp 0x4fed
leaq -0xc58(%rbp), %rdi
callq 0x3390
movl -0xa54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa54(%rbp)
jmp 0x4f96
leaq -0xc58(%rbp), %rdi
callq 0x3390
jmp 0x52b4
leaq -0x920(%rbp), %rdi
callq 0x5660
jmp 0x52c2
leaq -0x920(%rbp), %rdi
callq 0x5660
jmp 0x5323
movq -0x5b0(%rbp), %rax
movq %rax, -0xe98(%rbp)
cmpq $0x0, %rax
je 0x52e2
movq -0xe98(%rbp), %rdi
callq 0x3350
movq -0x5a8(%rbp), %rax
movq %rax, -0xea0(%rbp)
cmpq $0x0, %rax
je 0x5302
movq -0xea0(%rbp), %rdi
callq 0x3350
movl $0x0, -0x2c(%rbp)
leaq -0x840(%rbp), %rdi
callq 0x9860
leaq -0x320(%rbp), %rdi
callq 0x9860
jmp 0x533d
leaq -0x840(%rbp), %rdi
callq 0x9860
leaq -0x320(%rbp), %rdi
callq 0x9860
jmp 0x5352
movl -0x2c(%rbp), %eax
addq $0xec8, %rsp            # imm = 0xEC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0xc8(%rbp), %rdi
callq 0x3420
nop