// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_filter_utils.cpp
// Function: multiscale_avg_filter_data(double*, int, double, double, double, std::vector<double, std::allocator<double>>*, bool, bool, bool, std::vector<std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::allocator<std::vector<t_annot_region*, std::allocator<t_annot_region*>>*>>*, std::vector<std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::allocator<std::vector<t_annot_region*, std::allocator<t_annot_region*>>*>>*, char*)
vector<double*>* multiscale_avg_filter_data(double* track_data, 
	int l_track_data, 
	double scale_start, double scale_end, double log_scale_step, 
	vector<double>* scales_per_i_scale,
	bool dump_decomposition,
	bool compute_extrema_regions,
	bool dump_extrema_regions,
	vector<vector<t_annot_region*>*>* per_scale_minima_regions, 
	vector<vector<t_annot_region*>*>* per_scale_maxima_regions,
	char* op_file_prefix)
{
	vector<double*>* decomps = new vector<double*>();

	// Start from the first scale, go over all the scales and filter the data.
	double scale = 1.0 / log_scale_step;
	int i_scale = 0;
	while(1)
	{
		scale *= log_scale_step;

		scales_per_i_scale->push_back(scale);

		// Are we going to process a scale within the requested limits? If not, we will skip this computation to save time.
		if(scale < scale_start)
		{
			decomps->push_back(NULL);

			if(compute_extrema_regions)
			{
				if(per_scale_minima_regions != NULL)
				{
					per_scale_minima_regions->push_back(new vector<t_annot_region*>());
				}

				if(per_scale_maxima_regions != NULL)
				{
					per_scale_maxima_regions->push_back(new vector<t_annot_region*>());
				}
			}

			i_scale++;
			continue;
		}
		else
		{
if(__DUMP_FILTER_MSGS__)
{
			fprintf(stderr, "Processing scale %lf (%lf)\n", scale, scale_end);
}

			// Get the filter for the current scale: The gaussian filter.
			int int_scale = (int)(scale);
			int l_averaging_win = ((int_scale % 2) == 1)?(int_scale-1):(int_scale);

			// Do copying from start to end.
			double* cur_filtered_track = new double[l_track_data + 2];

			int n_signal_wins = 0;
			int half_l_averaging = l_averaging_win / 2;

			// Initialize the current pdf.
			//int* cur_win_pdf = NULL;
			//int cur_win_max = 0;
			//int cur_win_min = 1000*1000;
			//double* cur_win_vals = new double[l_averaging_win + 2];
			int prev_avg_start = 0;
			int prev_avg_end = 0;

			// Go over all the positions as the middle of the filtering window.
			double cur_win_total = -123123;
			for(int cur_win_mid = 0; cur_win_mid < l_track_data; cur_win_mid++)
			{
				int cur_avg_start = (cur_win_mid > half_l_averaging)?(cur_win_mid - half_l_averaging):(1);
				int cur_avg_end = (cur_win_mid + half_l_averaging <= l_track_data)?(cur_win_mid + half_l_averaging):(l_track_data);
				if(cur_win_total == -123123)
				{
					// Get the total by a loop for the current window.
					cur_win_total = 0.0;
					for(int i = cur_avg_start; i <= cur_avg_end; i++)
					{
						cur_win_total += track_data[i];
					} // i loop.
				} // cur_win_pdf is NULL check.
				else
				{
					// Remove the old values from the pdf, add the new values.
					for(int i = prev_avg_start; i < cur_avg_start; i++)
					{
						cur_win_total -= track_data[i];
					} // i loop.

					// Update the min and max only for the values that are new in this window.
					for(int i = prev_avg_end+1; i <= cur_avg_end; i++)
					{
						cur_win_total += track_data[i];
					}
				} // cur_win_pdf is NULL check.

				// Set the median.
				cur_filtered_track[cur_win_mid] = cur_win_total / l_averaging_win;

				// Update the previous averaging window limits.
				prev_avg_start = cur_avg_start;
				prev_avg_end = cur_avg_end;

#undef _MANUAL_TOTAL_CHECK_
#ifdef _MANUAL_TOTAL_CHECK_
				// Get the median via qsort and compare as a sanity check.
				double manual_total = 0.0;
				for(int i = cur_avg_start; i <= cur_avg_end; i++)
				{
					manual_total += track_data[i];
				} // i loop.

				if(manual_total != cur_win_total)
				{
					fprintf(stderr, "Sanity check failed at manual total check, %s(%d)\n", __FILE__, __LINE__);
					exit(0);
				}
#endif // _MANUAL_TOTAL_CHECK_

				n_signal_wins++;
			} // main signal filtering loop.

			// Copy the data.
			if(dump_decomposition)
			{
				// Dump and free memory.
				char cur_decomp_fp[1000];
				//sprintf(cur_decomp_fp, "decomp_%d_%d_%d.bin", i_scale, cur_win_start, cur_win_start + cur_l_win);
				sprintf(cur_decomp_fp, "%s_scale_%d.bin", op_file_prefix, i_scale);
				fprintf(stderr, "Dumping %s\n", cur_decomp_fp);
				double* _cur_filtered_track = get_one_indexed_per_zero_indexed_data(cur_filtered_track, l_track_data);
				dump_per_nucleotide_binary_profile(_cur_filtered_track, l_track_data, cur_decomp_fp);
				fprintf(stderr, "Closing file\n");

				// Clean track memory.
				delete [] _cur_filtered_track;
				delete [] cur_filtered_track;
			}
			else if(compute_extrema_regions)
			{
if(__DUMP_FILTER_MSGS__)
				fprintf(stderr, "Getting the extrema regions.\n");

				// Get the extrema regions for the current filtered regions.
				vector<t_extrema_node*>* maxima = new vector<t_extrema_node*>();
				vector<t_extrema_node*>* minima = new vector<t_extrema_node*>();
				int* derivative_map = new int[l_track_data+2];
				memset(derivative_map, 0, sizeof(int) * (l_track_data+2));
				get_extrema_per_plateaus(cur_filtered_track, l_track_data, maxima, minima, derivative_map, 0);

				// Sort the extremas.
				sort(minima->begin(), minima->end(), sort_extremas_per_posn);
				sort(maxima->begin(), maxima->end(), sort_extremas_per_posn);

				if(dump_extrema_regions)
				{
					// Get the minima and maxima, then dump.
					char cur_minima_regs_fp[1000];
					char cur_maxima_regs_fp[1000];
					sprintf(cur_minima_regs_fp, "%s_scale_%d_mins.bed", op_file_prefix, i_scale);
					sprintf(cur_maxima_regs_fp, "%s_scale_%d_maxes.bed", op_file_prefix, i_scale);

					fprintf(stderr, "Dumping the extrema regions.\n");
					FILE* f_maxes = open_f(cur_maxima_regs_fp, "w");
					for(int i_m = 0; i_m < (int)maxima->size(); i_m++)
					{
						fprintf(f_maxes, "XX\t%d\t%d\n", translate_coord(maxima->at(i_m)->extrema_posn+1, CODEBASE_COORDS::start_base, BED_COORDS::start_base),
							translate_coord(maxima->at(i_m)->extrema_posn+1, CODEBASE_COORDS::end_base, BED_COORDS::end_base));
					} // i_m loop.
					fclose(f_maxes);

					FILE* f_mins = open_f(cur_minima_regs_fp, "w");
					for(int i_m = 0; i_m < (int)minima->size()-1; i_m++)
					{
						fprintf(f_mins, "XX\t%d\t%d\n", translate_coord(minima->at(i_m)->extrema_posn+1, CODEBASE_COORDS::start_base, BED_COORDS::start_base),
							translate_coord(minima->at(i_m+1)->extrema_posn+1, CODEBASE_COORDS::end_base, BED_COORDS::end_base));
					} // i_m loop.
					fclose(f_mins);
				}

				if(per_scale_minima_regions != NULL)
				{
					vector<t_annot_region*>* cur_scale_minima_regions = new vector<t_annot_region*>();
					for(int i_m = 0; i_m < (int)minima->size()-1; i_m++)
					{
						t_annot_region* new_minima = get_empty_region();
						new_minima->chrom = t_string::copy_me_str("XX");
						new_minima->start = translate_coord(minima->at(i_m)->extrema_posn+1, CODEBASE_COORDS::start_base, BED_COORDS::start_base);
						new_minima->end = translate_coord(minima->at(i_m+1)->extrema_posn+1, CODEBASE_COORDS::end_base, BED_COORDS::end_base);
						new_minima->strand = '+';

						cur_scale_minima_regions->push_back(new_minima);
					} // i_min loop.

					per_scale_minima_regions->push_back(cur_scale_minima_regions);
				}
			
				if(per_scale_maxima_regions != NULL)
				{
					vector<t_annot_region*>* cur_scale_maxima_regions = new vector<t_annot_region*>();
					for(int i_m = 0; i_m < (int)maxima->size(); i_m++)
					{
						t_annot_region* new_maxima = get_empty_region();
						new_maxima->chrom = t_string::copy_me_str("XX");
						new_maxima->start = translate_coord(maxima->at(i_m)->extrema_posn+1, CODEBASE_COORDS::start_base, BED_COORDS::start_base);
						new_maxima->end = translate_coord(maxima->at(i_m+1)->extrema_posn+1, CODEBASE_COORDS::end_base, BED_COORDS::end_base);
						new_maxima->strand = '+';

						cur_scale_maxima_regions->push_back(new_maxima);
					} // i_m loop.

					per_scale_maxima_regions->push_back(cur_scale_maxima_regions);
				}

				delete_extrema_nodes(minima);
				delete_extrema_nodes(maxima);
			
				// Free the current decomposition.
				delete [] derivative_map;
				delete [] cur_filtered_track;
			}
			else
			{
				// Store the decompositions.
				decomps->push_back(cur_filtered_track);
			}

			// Was the last processed value equal to or larger than what was requested?
			if(scale_end > 0 && 
				scale >= scale_end)
			{
				break;
			}

			i_scale++;
		} // scale computation check.
	} // scale loop.

	return(decomps);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x888, %rsp            # imm = 0x888
movl %r9d, 0x6c(%rsp)
movl %r8d, 0x44(%rsp)
movl %ecx, %r12d
movq %rdx, %r14
movsd %xmm2, 0x70(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0xa8(%rsp)
movl %esi, %ebx
movq %rdi, %r13
movl $0x18, %edi
callq 0x2180
movsd 0x8(%rsp), %xmm1
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x50(%rsp)
movq $0x0, 0x10(%rax)
movslq %ebx, %rax
cmpl $-0x2, %eax
leaq 0x10(,%rax,8), %rcx
movq $-0x1, %rdx
cmovlq %rdx, %rcx
movq %rcx, 0xa0(%rsp)
movsd 0x16c95(%rip), %xmm0    # 0x2a008
leaq 0x8(,%rax,4), %rcx
movq %rcx, 0x80(%rsp)
cmovgeq %rcx, %rdx
movq %rdx, 0x88(%rsp)
divsd 0x70(%rsp), %xmm0
movl %eax, %eax
movq %rax, 0x98(%rsp)
movl $0x1, %ebp
movl $0x0, 0x1c(%rsp)
movl %ebx, 0x40(%rsp)
movl %r12d, 0x68(%rsp)
movq %r14, 0x78(%rsp)
mulsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x133de
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r14)
jmp 0x133f1
movq %r14, %rdi
leaq 0x38(%rsp), %rdx
callq 0xb60c
movsd 0x8(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0xa8(%rsp), %xmm0
ucomisd %xmm2, %xmm0
movq 0x50(%rsp), %rdi
jbe 0x134d1
movq $0x0, 0xb0(%rsp)
leaq 0xb0(%rsp), %rsi
callq 0x1519e
movsd 0x8(%rsp), %xmm1
cmpb $0x0, 0x44(%rsp)
je 0x134c6
movq 0x8c0(%rsp), %r15
testq %r15, %r15
je 0x1347e
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xb0(%rsp)
movq %r15, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x15312
movsd 0x8(%rsp), %xmm1
cmpq $0x0, 0x8c8(%rsp)
je 0x134c6
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xb0(%rsp)
movq 0x8c8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x15312
movsd 0x8(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
jmp 0x13d4b
cmpb $0x1, 0x25cf5(%rip)     # 0x391cd
je 0x13d54
movsd %xmm2, 0x10(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2040
movq %rax, %r15
movq %rax, 0x30(%rsp)
testl %ebx, %ebx
movq 0x98(%rsp), %r10
movsd 0x1a0fd(%rip), %xmm3    # 0x2d608
jle 0x135d4
cvttsd2si 0x10(%rsp), %eax
movl %eax, %ecx
andl $0x80000001, %ecx       # imm = 0x80000001
xorl %edx, %edx
cmpl $0x1, %ecx
sete %dl
subl %edx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movslq %ecx, %rax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
movapd %xmm3, %xmm1
movl %esi, %edi
movl %edx, %r8d
movl %ecx, %edx
subl %eax, %edx
cmpq %rax, %rcx
cmovlel %ebp, %edx
leal (%rax,%rcx), %esi
cmpl %ebx, %esi
cmovgel %ebx, %esi
ucomisd %xmm3, %xmm1
jne 0x13565
jnp 0x1359a
cmpl %edx, %r8d
jge 0x1357f
movslq %r8d, %r8
movslq %edx, %r9
subsd (%r13,%r8,8), %xmm1
incq %r8
cmpq %r8, %r9
jne 0x13570
cmpl %esi, %edi
jge 0x135ba
movslq %edi, %rdi
movslq %esi, %r8
addsd 0x8(%r13,%rdi,8), %xmm1
incq %rdi
cmpq %r8, %rdi
jl 0x13589
jmp 0x135ba
xorpd %xmm1, %xmm1
cmpl %esi, %edx
jg 0x135ba
movslq %edx, %rdi
movslq %esi, %r8
decq %rdi
addsd 0x8(%r13,%rdi,8), %xmm1
incq %rdi
cmpq %r8, %rdi
jl 0x135ab
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%r15,%rcx,8)
incq %rcx
cmpq %r10, %rcx
jne 0x13546
testb %r12b, %r12b
jne 0x13d81
cmpb $0x0, 0x44(%rsp)
je 0x137c5
cmpb $0x1, 0x25bde(%rip)     # 0x391cd
je 0x13e28
movl $0x18, %edi
callq 0x2180
movq %rax, %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
xorl %r14d, %r14d
movq %r14, 0x10(%rax)
movl $0x18, %edi
callq 0x2180
movq %rax, %rbp
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %r14, 0x10(%rax)
movq 0x88(%rsp), %rdi
callq 0x2040
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq 0x80(%rsp), %rdx
callq 0x20f0
movq %r15, %rdi
movl %ebx, %esi
movq %r12, 0x10(%rsp)
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, 0x90(%rsp)
movq %r14, %r8
xorl %r9d, %r9d
callq 0x241dc
movq (%rbp), %rbx
movq %rbp, 0x20(%rsp)
movq 0x8(%rbp), %r15
cmpq %r15, %rbx
movl $0x1, %ebp
je 0x13876
movq %r15, %r14
subq %rbx, %r14
movq %r14, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x10b20(%rip), %rcx     # 0x241d1
callq 0x10afb
leaq 0x8(%rbx), %rax
cmpq $0x81, %r14
movq %r15, 0x28(%rsp)
jl 0x137f6
movl $0x8, %r15d
movq %rax, 0x48(%rsp)
movq %rax, %r14
movq %rbx, %rax
movq %rax, 0x58(%rsp)
leaq (%rbx,%r15), %rbp
movq (%rbx,%r15), %rdi
movq (%rbx), %rsi
callq 0x241d1
movq (%rbx,%r15), %r12
testb %al, %al
movq %rbp, 0x60(%rsp)
je 0x13714
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x22b0
movq %rbx, %rbp
jmp 0x13749
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0x241d1
testb %al, %al
je 0x13749
movq %r14, %rcx
leaq -0x8(%rcx), %rbp
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x241d1
movq %rbp, %rcx
testb %al, %al
jne 0x1372b
movq %r12, (%rbp)
addq $0x8, %r15
addq $0x8, %r14
cmpq $0x80, %r15
movq 0x60(%rsp), %rax
jne 0x136dd
subq $-0x80, %rbx
cmpq 0x28(%rsp), %rbx
movl $0x1, %ebp
je 0x13876
movq -0x8(%rbx), %rsi
movq (%rbx), %r14
movq %r14, %rdi
callq 0x241d1
movq %rbx, %r15
testb %al, %al
je 0x137b2
movq %rbx, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x241d1
movq %r15, %rcx
testb %al, %al
jne 0x13794
movq %r14, (%r15)
addq $0x8, %rbx
cmpq 0x28(%rsp), %rbx
jne 0x1377b
jmp 0x13876
movq 0x50(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
movsd 0x8(%rsp), %xmm1
je 0x137e7
movq %r15, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13d31
leaq 0x30(%rsp), %rdx
callq 0x15426
jmp 0x13d2b
cmpq %r15, %rax
je 0x13876
movq %rbx, %r12
movq %r12, %r15
movq %rax, %r12
movq (%rax), %rdi
movq (%rbx), %rsi
callq 0x241d1
movq (%r12), %r14
testb %al, %al
je 0x13834
movq %r12, %rdx
subq %rbx, %rdx
subq %rdx, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x22b0
movq %rbx, %r15
jmp 0x13867
movq (%r15), %rsi
movq %r14, %rdi
callq 0x241d1
movq %r12, %r15
testb %al, %al
je 0x13867
movq %r12, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x241d1
movq %r15, %rcx
testb %al, %al
jne 0x13849
movq %r14, (%r15)
leaq 0x8(%r12), %rax
cmpq 0x28(%rsp), %rax
jne 0x137fe
movq 0x10(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rax), %r14
cmpq %r14, %r12
je 0x13a5a
movq %r14, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r14, %rsi
leaq 0x1091f(%rip), %rcx     # 0x241d1
callq 0x10afb
leaq 0x8(%r12), %rax
cmpq $0x81, %rbx
jl 0x139ce
movq %r14, 0x48(%rsp)
movl $0x8, %r15d
movq %rax, 0x28(%rsp)
movq %rax, %rbx
movq %r12, %r14
movq %r12, 0x58(%rsp)
movq %r14, 0x60(%rsp)
leaq (%r12,%r15), %r14
movq (%r12,%r15), %rdi
movq (%r12), %rsi
callq 0x241d1
movq %r12, %rbp
movq (%r12,%r15), %r12
testb %al, %al
je 0x13917
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x22b0
jmp 0x1394f
movq 0x60(%rsp), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0x241d1
movq %r14, %rbp
testb %al, %al
je 0x1394f
movq %rbx, %rcx
leaq -0x8(%rcx), %rbp
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x241d1
movq %rbp, %rcx
testb %al, %al
jne 0x13931
movq %r12, (%rbp)
addq $0x8, %r15
addq $0x8, %rbx
cmpq $0x80, %r15
movq 0x58(%rsp), %r12
jne 0x138e4
subq $-0x80, %r12
movq 0x48(%rsp), %r15
cmpq %r15, %r12
movl $0x1, %ebp
je 0x13a5a
movq -0x8(%r12), %rsi
movq (%r12), %r14
movq %r14, %rdi
callq 0x241d1
movq %r12, %rbx
testb %al, %al
je 0x139bd
movq %r12, %rcx
leaq -0x8(%rcx), %rbx
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x241d1
movq %rbx, %rcx
testb %al, %al
jne 0x1399f
movq %r14, (%rbx)
addq $0x8, %r12
cmpq %r15, %r12
jne 0x13984
jmp 0x13a5a
cmpq %r14, %rax
je 0x13a5a
movq %r12, %rbx
movq %r14, %rbp
movq %rbx, %r15
movq %rax, %rbx
movq (%rax), %rdi
movq (%r12), %rsi
callq 0x241d1
movq (%rbx), %r14
testb %al, %al
je 0x13a13
movq %rbx, %rdx
subq %r12, %rdx
subq %rdx, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x22b0
movq %r12, %r15
jmp 0x13a46
movq (%r15), %rsi
movq %r14, %rdi
callq 0x241d1
movq %rbx, %r15
testb %al, %al
je 0x13a46
movq %rbx, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x241d1
movq %r15, %rcx
testb %al, %al
jne 0x13a28
movq %r14, (%r15)
leaq 0x8(%rbx), %rax
movq %rbp, %r14
cmpq %rbp, %rax
movl $0x1, %ebp
jne 0x139da
cmpb $0x0, 0x6c(%rsp)
movl 0x40(%rsp), %ebx
jne 0x13e52
cmpq $0x0, 0x8c0(%rsp)
movl 0x68(%rsp), %r12d
je 0x13bb7
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xb0(%rsp)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x3, %rax
cmpl $0x2, %eax
jl 0x13b86
movl $0x1, %r14d
leaq -0x1(%r14), %r15
callq 0x15644
movq %rax, 0x4a0(%rsp)
leaq 0x19c24(%rip), %rdi     # 0x2d6fa
callq 0x26db4
movq 0x20(%rsp), %r8
movq 0x4a0(%rsp), %rcx
movq %rax, (%rcx)
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x13ff8
movq -0x8(%rax,%r14,8), %rcx
movl (%rcx), %esi
movq 0x4a0(%rsp), %rcx
movl %esi, 0xc(%rcx)
cmpq %r14, %rdx
jbe 0x14004
movq (%rax,%r14,8), %rax
movl (%rax), %eax
incl %eax
movl %eax, 0x20(%rcx)
movb $0x2b, 0x8(%rcx)
movq 0xb0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13b48
movq %rcx, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13b5a
leaq 0x4a0(%rsp), %rdx
callq 0xb74c
movq 0x20(%rsp), %r8
movq 0x8(%r8), %rax
subq (%r8), %rax
shlq $0x1d, %rax
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rcx, %rax
sarq $0x20, %rax
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jl 0x13abe
movq 0x8c0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13baa
movq 0xb0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13bb7
leaq 0xb0(%rsp), %rdx
callq 0x109c0
cmpq $0x0, 0x8c8(%rsp)
je 0x13cf0
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xb0(%rsp)
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x13cbf
movl $0x1, %r14d
leaq -0x1(%r14), %r15
callq 0x15644
movq %rax, 0x4a0(%rsp)
leaq 0x19adc(%rip), %rdi     # 0x2d6fa
callq 0x26db4
movq 0x10(%rsp), %r8
movq 0x4a0(%rsp), %rcx
movq %rax, (%rcx)
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x13ff8
movq -0x8(%rax,%r14,8), %rcx
movl (%rcx), %esi
movq 0x4a0(%rsp), %rcx
movl %esi, 0xc(%rcx)
cmpq %r14, %rdx
jbe 0x14004
movq (%rax,%r14,8), %rax
movl (%rax), %eax
incl %eax
movl %eax, 0x20(%rcx)
movb $0x2b, 0x8(%rcx)
movq 0xb0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13c90
movq %rcx, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13ca2
leaq 0x4a0(%rsp), %rdx
callq 0xb74c
movq 0x10(%rsp), %r8
movq 0x8(%r8), %rax
subq (%r8), %rax
shrq $0x3, %rax
cltq
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jl 0x13c06
movq 0x8c8(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13ce3
movq 0xb0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13cf0
leaq 0xb0(%rsp), %rdx
callq 0x109c0
movq 0x20(%rsp), %rdi
callq 0x24d7a
movq 0x10(%rsp), %rdi
callq 0x24d7a
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movq 0x78(%rsp), %r14
movsd 0x8(%rsp), %xmm1
je 0x13d31
callq 0x2220
movsd 0x8(%rsp), %xmm1
ucomisd 0x16377(%rip), %xmm1    # 0x2a0b0
movsd 0x38(%rsp), %xmm0
jbe 0x13d4b
ucomisd %xmm1, %xmm0
jae 0x13fe1
incl 0x1c(%rsp)
jmp 0x133ba
movq 0x25285(%rip), %rax     # 0x38fe0
movq (%rax), %rdi
leaq 0x198ee(%rip), %rsi     # 0x2d653
movapd %xmm2, %xmm0
movb $0x2, %al
callq 0x2250
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x134e4
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
leaq 0x18e69(%rip), %rsi     # 0x2cbfc
movq 0x8d0(%rsp), %rdx
movl 0x1c(%rsp), %ecx
xorl %eax, %eax
callq 0x2080
movq 0x25233(%rip), %rbp     # 0x38fe0
movq (%rbp), %rdi
leaq 0x198b7(%rip), %rsi     # 0x2d66f
movq %r15, %rdx
xorl %eax, %eax
callq 0x2250
movq 0x30(%rsp), %rdi
movl %ebx, %esi
callq 0x1cdf6
movl %ebx, %esi
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rdx
callq 0x1d226
movq (%rbp), %rcx
movl $0xd, %esi
movl $0x1, %edx
leaq 0x19888(%rip), %rdi     # 0x2d67b
callq 0x2340
testq %rbx, %rbx
je 0x13e05
movq %rbx, %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x13e14
callq 0x2220
movsd 0x8(%rsp), %xmm1
movl 0x40(%rsp), %ebx
movl $0x1, %ebp
jmp 0x13d31
movq 0x251b1(%rip), %rax     # 0x38fe0
movq (%rax), %rcx
movl $0x1d, %esi
movl $0x1, %edx
leaq 0x19846(%rip), %rdi     # 0x2d689
callq 0x2340
movq 0x30(%rsp), %r15
jmp 0x135f5
leaq 0xb0(%rsp), %rdi
leaq 0x19846(%rip), %rsi     # 0x2d6a7
movq 0x8d0(%rsp), %r14
movq %r14, %rdx
movl 0x1c(%rsp), %r12d
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2080
leaq 0x4a0(%rsp), %r15
movq %r15, %rdi
leaq 0x1982f(%rip), %rsi     # 0x2d6bc
movq %r14, %rdx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2080
movq 0x2513f(%rip), %rax     # 0x38fe0
movq (%rax), %rcx
movl $0x1d, %esi
movl $0x1, %edx
leaq 0x1981d(%rip), %rdi     # 0x2d6d2
callq 0x2340
movq %r15, %rdi
leaq 0x16be4(%rip), %rsi     # 0x2aaa8
callq 0x25d5a
movq %rax, %r14
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x13f2e
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x13ff8
movq (%rax,%r15,8), %rax
movl (%rax), %edx
leal 0x1(%rdx), %ecx
movq %r14, %rdi
leaq 0x197ee(%rip), %rsi     # 0x2d6f0
xorl %eax, %eax
callq 0x2250
incq %r15
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0x13ee6
movq %r14, %rdi
callq 0x2170
leaq 0xb0(%rsp), %rdi
leaq 0x16b63(%rip), %rsi     # 0x2aaa8
callq 0x25d5a
movq %rax, %r14
movq 0x20(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpl $0x2, %edx
jl 0x13fd4
movl $0x1, %r15d
leaq -0x1(%r15), %rsi
cmpq %rsi, %rdx
jbe 0x14015
cmpq %r15, %rdx
jbe 0x13ff8
movq -0x8(%rax,%r15,8), %rcx
movq (%rax,%r15,8), %rax
movl (%rcx), %edx
movl (%rax), %ecx
incl %ecx
movq %r14, %rdi
leaq 0x1975a(%rip), %rsi     # 0x2d6f0
xorl %eax, %eax
callq 0x2250
movq 0x20(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shlq $0x1d, %rcx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %rsi, %rcx
sarq $0x20, %rcx
leaq 0x1(%r15), %rsi
cmpq %rcx, %r15
movq %rsi, %r15
jl 0x13f6b
movq %r14, %rdi
callq 0x2170
jmp 0x13a69
movq 0x50(%rsp), %rax
addq $0x888, %rsp            # imm = 0x888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x188d1(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
jmp 0x1400e
leaq 0x188c5(%rip), %rdi     # 0x2c8d0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x188b4(%rip), %rdi     # 0x2c8d0
jmp 0x1400e