// File: /workspace/github_cpp_makefile_star2_O1/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 $0x898, %rsp            # imm = 0x898
movl %r9d, 0x6c(%rsp)
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %rbx
movsd %xmm2, 0x78(%rsp)
movapd %xmm1, 0xb0(%rsp)
movsd %xmm0, 0xa8(%rsp)
movl %esi, %r15d
movq %rdi, %r13
movl $0x18, %edi
callq 0x2180
movl %r15d, 0x3c(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x40(%rsp)
movq $0x0, 0x10(%rax)
movsd 0x17981(%rip), %xmm0    # 0x2b008
divsd 0x78(%rsp), %xmm0
leaq 0x28(%rsp), %rcx
movslq %r15d, %rax
cmpl $-0x2, %eax
leaq 0x10(,%rax,8), %rdx
movq $-0x1, %rsi
cmovlq %rsi, %rdx
movq %rdx, 0xa0(%rsp)
movsd %xmm0, (%rcx)
leaq 0x8(,%rax,4), %rcx
movq %rcx, 0x80(%rsp)
cmovgeq %rcx, %rsi
movq %rsi, 0x88(%rsp)
movl %eax, %eax
movq %rax, 0x98(%rsp)
movl $0x1, %r12d
movl $0x0, 0x14(%rsp)
movq %rbx, 0x70(%rsp)
movl %ebp, 0x68(%rsp)
movl %r14d, 0x64(%rsp)
movsd 0x28(%rsp), %xmm0
mulsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x13723
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x13730
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
callq 0xb836
movq 0x40(%rsp), %rdi
movsd 0x28(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x137fa
movq $0x0, 0xc0(%rsp)
leaq 0xc0(%rsp), %rsi
callq 0x154fc
testb %bpl, %bpl
je 0x137f1
movq 0x8d0(%rsp), %r15
testq %r15, %r15
je 0x137af
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xc0(%rsp)
movq %r15, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x15668
cmpq $0x0, 0x8d8(%rsp)
je 0x137f1
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xc0(%rsp)
movq 0x8d8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x15668
incl 0x14(%rsp)
jmp 0x136f9
cmpb $0x1, 0x269cc(%rip)     # 0x3a1cd
je 0x14099
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2040
movq %rax, 0x30(%rsp)
movl 0x3c(%rsp), %r15d
testl %r15d, %r15d
movq 0x98(%rsp), %r11
movsd 0x1adcb(%rip), %xmm3    # 0x2e608
jle 0x1390b
cvttsd2si 0x8(%rsp), %ecx
movl %ecx, %edx
andl $0x80000001, %edx       # imm = 0x80000001
xorl %esi, %esi
cmpl $0x1, %edx
sete %sil
subl %esi, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movslq %edx, %rcx
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
movapd %xmm3, %xmm1
movl %edi, %r8d
movl %esi, %r9d
movl %edx, %esi
subl %ecx, %esi
cmpq %rcx, %rdx
cmovlel %r12d, %esi
leal (%rcx,%rdx), %edi
cmpl %r15d, %edi
cmovgel %r15d, %edi
ucomisd %xmm3, %xmm1
jne 0x1389c
jnp 0x138d2
cmpl %esi, %r9d
jge 0x138b6
movslq %r9d, %r9
movslq %esi, %r10
subsd (%r13,%r9,8), %xmm1
incq %r9
cmpq %r9, %r10
jne 0x138a7
cmpl %edi, %r8d
jge 0x138f2
movslq %r8d, %r8
movslq %edi, %r9
addsd 0x8(%r13,%r8,8), %xmm1
incq %r8
cmpq %r9, %r8
jl 0x138c1
jmp 0x138f2
xorpd %xmm1, %xmm1
cmpl %edi, %esi
jg 0x138f2
movslq %esi, %r8
movslq %edi, %r9
decq %r8
addsd 0x8(%r13,%r8,8), %xmm1
incq %r8
cmpq %r9, %r8
jl 0x138e3
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%rax,%rdx,8)
incq %rdx
cmpq %r11, %rdx
jne 0x13879
testb %r14b, %r14b
jne 0x140bf
testb %bpl, %bpl
je 0x13af7
cmpb $0x1, 0x268a9(%rip)     # 0x3a1cd
je 0x14169
movl $0x18, %edi
callq 0x2180
movq %rax, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
xorl %ebx, %ebx
movq %rbx, 0x10(%rax)
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %rbx, 0x10(%rax)
movq 0x88(%rsp), %rdi
callq 0x2040
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq 0x80(%rsp), %rdx
callq 0x20f0
movq 0x30(%rsp), %rdi
movl 0x3c(%rsp), %esi
movq %r14, 0x8(%rsp)
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, 0x90(%rsp)
movq %rbx, %r8
xorl %r9d, %r9d
callq 0x24787
movq (%r15), %rbx
movq %r15, 0x20(%rsp)
movq 0x8(%r15), %r15
cmpq %r15, %rbx
je 0x13bac
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 0x10d99(%rip), %rcx     # 0x2477c
callq 0x10dc5
leaq 0x8(%rbx), %rax
cmpq $0x81, %r14
movq %r15, 0x18(%rsp)
jl 0x13b22
movl $0x8, %r14d
movq %rax, 0x48(%rsp)
movq %rax, %rbp
movq %rbx, %rax
movq %rax, 0x50(%rsp)
leaq (%rbx,%r14), %r15
movq (%rbx,%r14), %rdi
movq (%rbx), %rsi
callq 0x2477c
movq (%rbx,%r14), %r12
testb %al, %al
movq %r15, 0x58(%rsp)
je 0x13a46
movq 0x48(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x22b0
movq %rbx, %r15
jmp 0x13a7b
movq 0x50(%rsp), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0x2477c
testb %al, %al
je 0x13a7b
movq %rbp, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x2477c
movq %r15, %rcx
testb %al, %al
jne 0x13a5d
movq %r12, (%r15)
addq $0x8, %r14
addq $0x8, %rbp
cmpq $0x80, %r14
movq 0x58(%rsp), %rax
jne 0x13a0f
subq $-0x80, %rbx
cmpq 0x18(%rsp), %rbx
movl $0x1, %r12d
je 0x13bac
movq -0x8(%rbx), %rsi
movq (%rbx), %r14
movq %r14, %rdi
callq 0x2477c
movq %rbx, %r15
testb %al, %al
je 0x13ae4
movq %rbx, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x2477c
movq %r15, %rcx
testb %al, %al
jne 0x13ac6
movq %r14, (%r15)
addq $0x8, %rbx
cmpq 0x18(%rsp), %rbx
jne 0x13aad
jmp 0x13bac
movq 0x40(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13b13
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x14062
leaq 0x30(%rsp), %rdx
callq 0x15774
jmp 0x14062
cmpq %r15, %rax
je 0x13bac
movq %rbx, %rbp
movq %rbp, %r12
movq %rax, %rbp
movq (%rax), %rdi
movq (%rbx), %rsi
callq 0x2477c
movq (%rbp), %r14
testb %al, %al
je 0x13b64
movq %rbp, %rdx
subq %rbx, %rdx
subq %rdx, %r12
addq $0x10, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x22b0
movq %rbx, %r15
jmp 0x13b98
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2477c
movq %rbp, %r15
testb %al, %al
je 0x13b98
movq %rbp, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x2477c
movq %r15, %rcx
testb %al, %al
jne 0x13b7a
movq %r14, (%r15)
leaq 0x8(%rbp), %rax
cmpq 0x18(%rsp), %rax
movl $0x1, %r12d
jne 0x13b2e
movq 0x8(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r14
cmpq %r14, %rbp
je 0x13d97
movq %r14, %rbx
subq %rbp, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x10b94(%rip), %rcx     # 0x2477c
callq 0x10dc5
leaq 0x8(%rbp), %rax
cmpq $0x81, %rbx
jl 0x13d01
movq %r14, 0x18(%rsp)
movl $0x8, %r14d
movq %rax, 0x48(%rsp)
movq %rax, %rbx
movq %rbp, %rax
movq %rax, 0x50(%rsp)
leaq (%r14,%rbp), %r15
movq (%rbp,%r14), %rdi
movq (%rbp), %rsi
callq 0x2477c
movq (%rbp,%r14), %r12
testb %al, %al
movq %r15, 0x58(%rsp)
je 0x13c4e
movq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x22b0
movq %rbp, %r15
jmp 0x13c83
movq 0x50(%rsp), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0x2477c
testb %al, %al
je 0x13c83
movq %rbx, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x2477c
movq %r15, %rcx
testb %al, %al
jne 0x13c65
movq %r12, (%r15)
addq $0x8, %r14
addq $0x8, %rbx
cmpq $0x80, %r14
movq 0x58(%rsp), %rax
jne 0x13c14
subq $-0x80, %rbp
movq 0x18(%rsp), %r15
cmpq %r15, %rbp
movl $0x1, %r12d
je 0x13d97
movq -0x8(%rbp), %rsi
movq (%rbp), %r14
movq %r14, %rdi
callq 0x2477c
movq %rbp, %rbx
testb %al, %al
je 0x13cf0
movq %rbp, %rcx
leaq -0x8(%rcx), %rbx
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x2477c
movq %rbx, %rcx
testb %al, %al
jne 0x13cd2
movq %r14, (%rbx)
addq $0x8, %rbp
cmpq %r15, %rbp
jne 0x13cb8
jmp 0x13d97
cmpq %r14, %rax
je 0x13d97
movq %rbp, %rbx
movq %r14, 0x18(%rsp)
movq %rbx, %r12
movq %rax, %rbx
movq (%rax), %rdi
movq (%rbp), %rsi
callq 0x2477c
movq (%rbx), %r14
testb %al, %al
je 0x13d48
movq %rbx, %rdx
subq %rbp, %rdx
subq %rdx, %r12
addq $0x10, %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x22b0
movq %rbp, %r15
jmp 0x13d7c
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2477c
movq %rbx, %r15
testb %al, %al
je 0x13d7c
movq %rbx, %rcx
leaq -0x8(%rcx), %r15
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x2477c
movq %r15, %rcx
testb %al, %al
jne 0x13d5e
movq %r14, (%r15)
leaq 0x8(%rbx), %rax
movq 0x18(%rsp), %r14
cmpq %r14, %rax
movl $0x1, %r12d
jne 0x13d12
cmpb $0x0, 0x6c(%rsp)
movl 0x68(%rsp), %ebp
movq 0x70(%rsp), %rbx
jne 0x14173
cmpq $0x0, 0x8d0(%rsp)
je 0x13ef4
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xc0(%rsp)
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x3, %rax
cmpl $0x2, %eax
jl 0x13ec3
movl $0x1, %r14d
leaq -0x1(%r14), %r15
callq 0x15990
movq %rax, 0x4b0(%rsp)
leaq 0x1a8e7(%rip), %rdi     # 0x2e6fa
callq 0x273e0
movq 0x20(%rsp), %r8
movq 0x4b0(%rsp), %rcx
movq %rax, (%rcx)
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x1431b
movq -0x8(%rax,%r14,8), %rcx
movl (%rcx), %esi
movq 0x4b0(%rsp), %rcx
movl %esi, 0xc(%rcx)
cmpq %r14, %rdx
jbe 0x14327
movq (%rax,%r14,8), %rax
movl (%rax), %eax
incl %eax
movl %eax, 0x20(%rcx)
movb $0x2b, 0x8(%rcx)
movq 0xc0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13e85
movq %rcx, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13e97
leaq 0x4b0(%rsp), %rdx
callq 0xb976
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 0x13dfb
movq 0x8d0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13ee7
movq 0xc0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13ef4
leaq 0xc0(%rsp), %rdx
callq 0x10c8a
cmpq $0x0, 0x8d8(%rsp)
je 0x1402d
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xc0(%rsp)
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x13ffc
movl $0x1, %r14d
leaq -0x1(%r14), %r15
callq 0x15990
movq %rax, 0x4b0(%rsp)
leaq 0x1a79f(%rip), %rdi     # 0x2e6fa
callq 0x273e0
movq 0x8(%rsp), %r8
movq 0x4b0(%rsp), %rcx
movq %rax, (%rcx)
movq (%r8), %rax
movq 0x8(%r8), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x1431b
movq -0x8(%rax,%r14,8), %rcx
movl (%rcx), %esi
movq 0x4b0(%rsp), %rcx
movl %esi, 0xc(%rcx)
cmpq %r14, %rdx
jbe 0x14327
movq (%rax,%r14,8), %rax
movl (%rax), %eax
incl %eax
movl %eax, 0x20(%rcx)
movb $0x2b, 0x8(%rcx)
movq 0xc0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x13fcd
movq %rcx, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x13fdf
leaq 0x4b0(%rsp), %rdx
callq 0xb976
movq 0x8(%rsp), %r8
movq 0x8(%r8), %rax
subq (%r8), %rax
shrq $0x3, %rax
cltq
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jl 0x13f43
movq 0x8d8(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x14020
movq 0xc0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x1402d
leaq 0xc0(%rsp), %rdx
callq 0x10c8a
movq 0x20(%rsp), %rdi
callq 0x25358
movq 0x8(%rsp), %rdi
callq 0x25358
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movl 0x64(%rsp), %r14d
je 0x14062
callq 0x2220
movsd 0x28(%rsp), %xmm0
xorpd %xmm1, %xmm1
movapd 0xb0(%rsp), %xmm2
cmpnltpd %xmm2, %xmm1
cmpnlepd %xmm0, %xmm2
orpd %xmm1, %xmm2
movq %xmm2, %rax
subl %eax, 0x14(%rsp)
testb $0x1, %al
jne 0x136f9
jmp 0x14304
movq 0x25f40(%rip), %rax     # 0x39fe0
movq (%rax), %rdi
leaq 0x1a5a9(%rip), %rsi     # 0x2e653
movapd 0xb0(%rsp), %xmm1
movb $0x2, %al
callq 0x2250
jmp 0x13807
leaq 0xc0(%rsp), %r12
movq %r12, %rdi
leaq 0x19b2b(%rip), %rsi     # 0x2dbfc
movq 0x8e0(%rsp), %rdx
movl 0x14(%rsp), %ecx
xorl %eax, %eax
callq 0x2080
movq 0x25ef5(%rip), %rax     # 0x39fe0
movq (%rax), %rdi
leaq 0x1a57a(%rip), %rsi     # 0x2e66f
movq %r12, %rdx
xorl %eax, %eax
callq 0x2250
movq 0x30(%rsp), %rdi
movl %r15d, %esi
callq 0x1d255
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x1d6be
movq 0x25ebc(%rip), %rax     # 0x39fe0
movq (%rax), %rcx
movl $0xd, %esi
movl $0x1, %edx
leaq 0x1a543(%rip), %rdi     # 0x2e67b
callq 0x2340
testq %rbx, %rbx
je 0x1414a
movq %rbx, %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x14159
callq 0x2220
movq 0x70(%rsp), %rbx
movl $0x1, %r12d
jmp 0x14062
callq 0x492f
jmp 0x1392a
leaq 0xc0(%rsp), %rdi
leaq 0x1a525(%rip), %rsi     # 0x2e6a7
movq 0x8e0(%rsp), %rdx
movl 0x14(%rsp), %r14d
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2080
leaq 0x4b0(%rsp), %r15
movq %r15, %rdi
leaq 0x1a511(%rip), %rsi     # 0x2e6bc
movq 0x8e0(%rsp), %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2080
movq 0x25e1c(%rip), %rax     # 0x39fe0
movq (%rax), %rcx
movl $0x1d, %esi
movl $0x1, %edx
leaq 0x1a4fa(%rip), %rdi     # 0x2e6d2
callq 0x2340
movq %r15, %rdi
leaq 0x178c7(%rip), %rsi     # 0x2baae
callq 0x26387
movq %rax, %r14
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x14251
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x1431b
movq (%rax,%r15,8), %rax
movl (%rax), %edx
leal 0x1(%rdx), %ecx
movq %r14, %rdi
leaq 0x1a4cb(%rip), %rsi     # 0x2e6f0
xorl %eax, %eax
callq 0x2250
incq %r15
movq 0x8(%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 0x14209
movq %r14, %rdi
callq 0x2170
leaq 0xc0(%rsp), %rdi
leaq 0x17846(%rip), %rsi     # 0x2baae
callq 0x26387
movq %rax, %r14
movq 0x20(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpl $0x2, %edx
jl 0x142f7
movl $0x1, %r15d
leaq -0x1(%r15), %rsi
cmpq %rsi, %rdx
jbe 0x14338
cmpq %r15, %rdx
jbe 0x1431b
movq -0x8(%rax,%r15,8), %rcx
movq (%rax,%r15,8), %rax
movl (%rcx), %edx
movl (%rax), %ecx
incl %ecx
movq %r14, %rdi
leaq 0x1a437(%rip), %rsi     # 0x2e6f0
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 0x1428e
movq %r14, %rdi
callq 0x2170
jmp 0x13dab
movq 0x40(%rsp), %rax
addq $0x898, %rsp            # imm = 0x898
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x195b4(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
jmp 0x14331
leaq 0x195a8(%rip), %rdi     # 0x2d8d6
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x19597(%rip), %rdi     # 0x2d8d6
jmp 0x14331