// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_signal_enrichment_utils.cpp
// Function: prune_region_ends_per_p_value_minimization_buffered_binomial_p_vals(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, double*, int, double*, int, int)
vector<t_annot_region*>* prune_region_ends_per_p_value_minimization_buffered_binomial_p_vals(vector<t_annot_region*>* regions, 
																							double* signal_profile, int l_profile, 
																							double* control_profile, int l_control,
																							int l_fragment)
{	
	// List of pruned regions.
	vector<t_annot_region*>* pruned_regions = new vector<t_annot_region*>();

	double max_grand_total_int = 0.0;
	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		// Get the extrema signal values.
		double current_grand_total = 0.0;
		for(int i = regions->at(i_reg)->start; i <= regions->at(i_reg)->end; i++)
		{
			if(i < l_profile)
			{
				current_grand_total += signal_profile[i];
			}

			if(i < l_control)
			{
				current_grand_total += control_profile[i];
			}
		} // i loop.

		if(max_grand_total_int < current_grand_total)
		{
			max_grand_total_int = (int)(floor(current_grand_total));
		} 
	} // i_reg loop.

if(__DUMP_SIGNAL_ENRICHMENT_MSGS__)
{
	fprintf(stderr, "Setting up the log factorials with maximum grand total of %lf\n", max_grand_total_int);
}

	double* log_factorials = buffer_log_factorials((int)(max_grand_total_int+20));

	int buffered_binomial_bin_size = 500;
	double** buffered_binomial_p_vals = buffer_binomial_pvalues((max_grand_total_int / l_fragment) + 100, log_factorials, buffered_binomial_bin_size);

if(__DUMP_SIGNAL_ENRICHMENT_MSGS__)
{
	fprintf(stderr, "Pruning region ends for %d regions via p-value minimization.\n", (int)regions->size());
}

	// Go over all the regions.
	vector<double>* p_values_per_threshold = new vector<double>();
	vector<double>* pruned_starts_per_thresholds = new vector<double>();
	vector<double>* pruned_ends_per_thresholds = new vector<double>();
	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		//if(i_reg % 1000 == 0)
		//{
		//	fprintf(stderr, "Processing %d.(%d) region: %d-%d\n", i_reg, (int)regions->size(), regions->at(i_reg)->start, regions->at(i_reg)->end);
		//}

		// Skip the region if the signal is out of the control signal range.
		if(regions->at(i_reg)->end > l_control)
		{
			fprintf(stderr, "Skipping pruning %d-%d\n", regions->at(i_reg)->start, regions->at(i_reg)->end);
			continue;
		}

		// Get the extrema signal values.
		int max_sig = 0;
		int min_sig = 1000*1000;
		double total_signal = 0;
		for(int i = regions->at(i_reg)->start; i <= regions->at(i_reg)->end; i++)
		{
			int cur_floorized_val = (int)(floor(signal_profile[i]));
			if(max_sig < cur_floorized_val)
			{
				max_sig = cur_floorized_val;
			}

			if(min_sig > cur_floorized_val)
			{
				min_sig = cur_floorized_val;
			}

			total_signal += signal_profile[i];
		} // i loop.

		// Limit the maximum at 500.
		max_sig = (max_sig > 500)?(500):(max_sig);

		// Start thresholding over all possible thresholds.			
		for(int sig_thresh = min_sig; sig_thresh <= max_sig; sig_thresh++)
		{
			// Threshold the ends.
			int pruned_start = regions->at(i_reg)->start;
			int pruned_end = regions->at(i_reg)->end;

			//bool passed_threshold = false;
			for(int i_pr = pruned_start; i_pr <= pruned_end; i_pr++)
			{
				if(signal_profile[i_pr] > sig_thresh)
				{
					//passed_threshold = true;
					pruned_start = i_pr;
					break;
				}
			} // i_pr loop.

			for(int i_pr = pruned_end; i_pr >= pruned_start; i_pr--)
			{
				if(signal_profile[i_pr] > sig_thresh)
				{
					pruned_end = i_pr;
					break;
				}
			} // i_pr loop.

			// Get the binomial p-value for current region.
			//double test_cur_pruned_pvalue = get_binomial_pvalue_per_region(signal_profile, control_profile, pruned_start, pruned_end, log_factorials, l_fragment, false, 0);

			// Get the p-value for the current region.
			double total_profile_signal = 0;
			double total_control_signal = 0;
			for(int i = pruned_start; i <= pruned_end; i++)
			{
				total_profile_signal += floor(signal_profile[i]);
				total_control_signal += (control_profile[i]);
			} // i loop.

			total_profile_signal /= l_fragment;
			total_control_signal /= l_fragment;
	
			int grand_total_int = (int)(total_profile_signal + total_control_signal);

			double log_flip = log(.5);

			int buffered_base_val = ((int)(total_control_signal / buffered_binomial_bin_size)) * buffered_binomial_bin_size;
			double cur_pruned_pvalue = buffered_binomial_p_vals[grand_total_int][buffered_base_val];
			for(int i = buffered_base_val+1; i <= total_control_signal; i++)
			{
				double log_cur_half_pow = log_flip * grand_total_int;
				double log_cur_perm = 0.0; // = xlog(1.0).

				// Compute the current permutation.
				log_cur_perm = xlog_div(log_factorials[grand_total_int], xlog_mul(log_factorials[i], log_factorials[grand_total_int-i]));
				cur_pruned_pvalue = xlog_sum(cur_pruned_pvalue, xlog_mul(log_cur_perm, log_cur_half_pow));
			} // i loop.

			//fprintf(stderr, "p-vals: %lf, %lf\n", test_cur_pruned_pvalue, cur_pruned_pvalue);

			// Add the current p-value.
			p_values_per_threshold->push_back(cur_pruned_pvalue);
			pruned_starts_per_thresholds->push_back(pruned_start);
			pruned_ends_per_thresholds->push_back(pruned_end);

			double total_pruned_sig = 0;
			for(int i_sig = pruned_start; i_sig <= pruned_end; i_sig++)
			{
				total_pruned_sig += signal_profile[i_sig];
			} // i_sig.

			// If we are below 50% of the total probability, stop since most of the signal is lost already.
			if(total_pruned_sig/total_signal <= 0.5)
			{
				break;
			}
		} // sig thresh loop.

		// If the condition is satisfied, we are done.
		if(p_values_per_threshold->size() > 0)
		{
			double min_p_val = p_values_per_threshold->at(0);
			int min_p_val_i = 0;
			for(int i_th = 0; i_th < (int)p_values_per_threshold->size(); i_th++)
			{
				if(min_p_val > p_values_per_threshold->at(i_th))
				{
					min_p_val = p_values_per_threshold->at(i_th);
					min_p_val_i = i_th;
				}
			} // total mass fraction check.

			t_annot_region* pruned_peak = duplicate_region(regions->at(i_reg));
			pruned_peak->start = (int)(pruned_starts_per_thresholds->at(min_p_val_i));
			pruned_peak->end = (int)(pruned_ends_per_thresholds->at(min_p_val_i));

			pruned_regions->push_back(pruned_peak);
		}
		else
		{
			t_annot_region* pruned_peak = duplicate_region(regions->at(i_reg));
			pruned_regions->push_back(pruned_peak);
		}

		// Clear the values.
		p_values_per_threshold->clear();
		pruned_starts_per_thresholds->clear();
		pruned_ends_per_thresholds->clear();
	} // i_reg loop.

	// Free buffered value memory.
	delete [] log_factorials;
	delete_buffered_binomial_pvalues(buffered_binomial_p_vals, max_grand_total_int, buffered_binomial_bin_size);

	// Dump the bed file.
	//dump_BED(op_bed_fp, pruned_regions);

	return(pruned_regions);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r9d, %ebx
movl %r8d, 0x2c(%rsp)
movq %rcx, 0x78(%rsp)
movl %edx, %ebp
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %rax, 0x68(%rsp)
movq $0x0, 0x10(%rax)
movq (%r14), %r15
movq %r14, 0x18(%rsp)
movq 0x8(%r14), %rax
movq %rax, %r14
subq %r15, %r14
sarq $0x3, %r14
testl %r14d, %r14d
jle 0x2071f
cmpq %r15, %rax
je 0x20ecc
movslq %ebp, %r12
movslq 0x2c(%rsp), %r13
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
xorl %ebp, %ebp
movq 0x78(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq (%r15,%rbp,8), %rcx
movslq 0xc(%rcx), %rax
movl 0x20(%rcx), %ecx
xorpd %xmm0, %xmm0
cmpl %ecx, %eax
jg 0x206f0
subl %eax, %ecx
incl %ecx
cmpq %r12, %rax
jge 0x206df
addsd (%rsi,%rax,8), %xmm0
cmpq %r13, %rax
jge 0x206e9
addsd (%rdx,%rax,8), %xmm0
incq %rax
decl %ecx
jne 0x206d5
ucomisd 0x50(%rsp), %xmm0
jbe 0x20715
callq 0x22c0
movq 0x8(%rsp), %rsi
movq 0x78(%rsp), %rdx
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
incq %rbp
cmpq %r14, %rbp
jne 0x206be
jmp 0x20729
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
cmpb $0x0, 0x18aa0(%rip)     # 0x391d0
jne 0x20e66
movsd 0xc27a(%rip), %xmm0     # 0x2c9b8
addsd 0x50(%rsp), %xmm0
cvttsd2si %xmm0, %edi
callq 0x236bc
cvtsi2sd %ebx, %xmm1
movapd 0x50(%rsp), %xmm0
movapd %xmm1, 0xc0(%rsp)
divsd %xmm1, %xmm0
addsd 0x98b4(%rip), %xmm0     # 0x2a020
cvttsd2si %xmm0, %edi
movq %rax, 0x70(%rsp)
movq %rax, %rsi
movl $0x1f4, %edx            # imm = 0x1F4
callq 0x2352b
movq %rax, 0xa8(%rsp)
cmpb $0x1, 0x18a3f(%rip)     # 0x391d0
movq 0x68(%rsp), %r14
je 0x20e89
movl $0x18, %edi
callq 0x2180
movq %rax, %r13
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)
movl $0x18, %edi
callq 0x2180
movq %rax, %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq %rbx, 0x10(%rax)
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
movq 0x8(%rsp), %rsi
jle 0x20e2a
movapd 0xc0(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0xc0(%rsp)
movq 0x70(%rsp), %rcx
leaq 0x8(%rcx), %rdi
movq %rdi, 0xe0(%rsp)
addq $-0x8, %rcx
movq %rcx, 0xd8(%rsp)
xorl %ebx, %ebx
movq %r13, 0xb0(%rsp)
movq %r15, 0x88(%rsp)
movq %r12, 0x80(%rsp)
cmpq %rbx, %rdx
jbe 0x20eaf
movq (%rax,%rbx,8), %rax
movl 0x20(%rax), %r13d
cmpl 0x2c(%rsp), %r13d
jg 0x20e05
movslq 0xc(%rax), %rax
cmpl %r13d, %eax
jg 0x20c90
movq %rbx, 0x90(%rsp)
leaq (%rsi,%rax,8), %rbx
subl %eax, %r13d
incl %r13d
xorl %r15d, %r15d
movl $0xf4240, %r14d         # imm = 0xF4240
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
movsd %xmm0, 0x20(%rsp)
movl %r14d, %r12d
movsd (%rbx,%r15,8), %xmm0
movsd %xmm0, 0x30(%rsp)
callq 0x22c0
cvttsd2si %xmm0, %r14d
movsd 0x20(%rsp), %xmm0
cmpl %r14d, %ebp
cmovlel %r14d, %ebp
cmpl %r14d, %r12d
cmovll %r12d, %r14d
addsd 0x30(%rsp), %xmm0
incq %r15
cmpl %r15d, %r13d
jne 0x208a0
movsd %xmm0, 0x20(%rsp)
movl $0x1f4, %eax            # imm = 0x1F4
cmpl %eax, %ebp
cmovgel %eax, %ebp
cmpl %eax, %r14d
movq 0x8(%rsp), %rsi
movq 0x88(%rsp), %r15
movq 0x80(%rsp), %r12
movq 0x90(%rsp), %rbx
movl %ebp, 0xa4(%rsp)
jg 0x20c90
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x20eaf
movq (%rax,%rbx,8), %rcx
movslq 0xc(%rcx), %rax
movl %eax, %r10d
movl 0x20(%rcx), %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
cmpl %r9d, %eax
jg 0x20984
leaq (%rsi,%rax,8), %rcx
movl %r9d, %edx
notl %edx
addq %r10, %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2097a
incq %rsi
movl %edx, %edi
addl %esi, %edi
jne 0x20964
jmp 0x2097f
addl %esi, %eax
movl %eax, %r10d
movq 0x8(%rsp), %rsi
movslq %r10d, %rdx
cmpl %r10d, %r9d
movq %rdx, 0xb8(%rsp)
jl 0x209b8
movslq %r9d, %rax
incq %rax
movl %r9d, %ecx
movsd -0x8(%rsi,%rax,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x209b5
decl %ecx
decq %rax
cmpq %rdx, %rax
jg 0x2099d
jmp 0x209b8
movl %ecx, %r9d
xorpd %xmm0, %xmm0
movq %r9, 0x48(%rsp)
movq %r10, 0x40(%rsp)
cmpl %r9d, %r10d
jg 0x20a2a
movq 0x8(%rsp), %rax
movq 0xb8(%rsp), %rcx
leaq (%rax,%rcx,8), %rbx
movq 0x78(%rsp), %rax
leaq (%rax,%rcx,8), %r15
movq 0x48(%rsp), %r12
subl 0x40(%rsp), %r12d
incl %r12d
xorl %r13d, %r13d
movapd %xmm0, 0x30(%rsp)
movsd (%rbx,%r13,8), %xmm0
callq 0x22c0
movhpd (%r15,%r13,8), %xmm0    # xmm0 = xmm0[0],mem[0]
movapd 0x30(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movapd 0x30(%rsp), %xmm0
incq %r13
cmpl %r13d, %r12d
jne 0x209f5
divpd 0xc0(%rsp), %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
movapd %xmm2, %xmm0
divsd 0xd699(%rip), %xmm0     # 0x2e0e8
cvttsd2si %xmm0, %ecx
imull $0x1f4, %ecx, %ecx      # imm = 0x1F4
movslq %eax, %r13
movq 0xa8(%rsp), %rax
movq (%rax,%r13,8), %rax
movslq %ecx, %rbx
movsd (%rax,%rbx,8), %xmm0
movsd %xmm0, 0x10(%rsp)
leal 0x1(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm2
jb 0x20b5b
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0xd646(%rip), %xmm0     # 0x2e0e0
movsd %xmm0, 0xe8(%rsp)
leaq (,%rbx,8), %rax
movq 0xe0(%rsp), %rcx
leaq (%rcx,%rbx,8), %r12
leaq (,%r13,8), %r15
subq %rax, %r15
addq 0xd8(%rsp), %r15
addl $0x2, %ebx
movq 0x70(%rsp), %rbp
movapd %xmm2, 0xf0(%rsp)
movsd (%rbp,%r13,8), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd (%r12), %xmm0
movsd (%r15), %xmm1
callq 0x253c5
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
callq 0x25400
movsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x30(%rsp)
movsd 0xe8(%rsp), %xmm1
callq 0x253c5
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
callq 0x252b0
movapd 0xf0(%rsp), %xmm2
movsd %xmm0, 0x10(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
addq $0x8, %r12
addq $-0x8, %r15
incl %ebx
ucomisd %xmm1, %xmm2
jae 0x20adb
movl 0xa4(%rsp), %ebp
movq 0xb0(%rsp), %r13
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0x20b7b
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r13)
jmp 0x20b88
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
callq 0xb60c
movq 0x88(%rsp), %r15
movq 0x80(%rsp), %r12
movq 0x90(%rsp), %rbx
movq 0x40(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
movsd 0x20(%rsp), %xmm1
movq 0x48(%rsp), %rdx
je 0x20bd8
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r15)
jmp 0x20bf8
movq %r15, %rdi
leaq 0x98(%rsp), %rdx
callq 0x2192c
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd 0x20(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x20c23
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r12)
jmp 0x20c43
movq %r12, %rdi
leaq 0x98(%rsp), %rdx
callq 0x2192c
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
movsd 0x20(%rsp), %xmm1
xorpd %xmm0, %xmm0
cmpl %edx, %ecx
movq 0x8(%rsp), %rsi
jg 0x20c6e
movq 0xb8(%rsp), %rax
leaq (%rsi,%rax,8), %rax
subl %ecx, %edx
incl %edx
xorl %ecx, %ecx
addsd (%rax,%rcx,8), %xmm0
incq %rcx
cmpl %ecx, %edx
jne 0x20c62
divsd %xmm1, %xmm0
movsd 0x93de(%rip), %xmm1     # 0x2a058
ucomisd %xmm0, %xmm1
jae 0x20c90
leal 0x1(%r14), %eax
cmpl %ebp, %r14d
movl %eax, %r14d
jl 0x2091e
movq 0xb0(%rsp), %r13
movq (%r13), %rax
movq 0x8(%r13), %rdx
subq %rax, %rdx
je 0x20cec
sarq $0x3, %rdx
testl %edx, %edx
movq 0x68(%rsp), %r14
jle 0x20d1d
movsd (%rax), %xmm0
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorl %edi, %edi
cmpq %rsi, %rdx
je 0x20e9c
movsd (%rax,%rsi,8), %xmm1
ucomisd %xmm1, %xmm0
cmoval %esi, %edi
minsd %xmm0, %xmm1
incq %rsi
movapd %xmm1, %xmm0
cmpq %rsi, %rcx
jne 0x20cc2
movslq %edi, %rbp
jmp 0x20d1f
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
movq 0x68(%rsp), %r14
jbe 0x20eaf
movq (%rax,%rbx,8), %rdi
callq 0x16f1f
movq %rax, 0x10(%rsp)
jmp 0x20d89
xorl %ebp, %ebp
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x20eaf
movq (%rax,%rbx,8), %rdi
callq 0x16f1f
movq %rax, 0x10(%rsp)
movq (%r15), %rcx
movq 0x8(%r15), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rbp, %rdx
jbe 0x20ec0
cvttsd2si (%rcx,%rbp,8), %ecx
movl %ecx, 0xc(%rax)
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rbp, %rdx
jbe 0x20ec0
cvttsd2si (%rcx,%rbp,8), %ecx
movl %ecx, 0x20(%rax)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x20d9d
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x20daa
movq %r14, %rdi
leaq 0x10(%rsp), %rdx
callq 0xb74c
movq 0x8(%rsp), %rsi
movq (%r13), %rax
cmpq %rax, 0x8(%r13)
je 0x20dbd
movq %rax, 0x8(%r13)
movq (%r15), %rax
cmpq %rax, 0x8(%r15)
je 0x20dca
movq %rax, 0x8(%r15)
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x20dda
movq %rax, 0x8(%r12)
incq %rbx
movq 0x18(%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, %rbx
jl 0x20856
jmp 0x20e2a
movq 0x181d4(%rip), %rcx     # 0x38fe0
movq (%rcx), %rdi
movl 0xc(%rax), %edx
leaq 0xd472(%rip), %rsi      # 0x2e28b
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2250
movq 0x8(%rsp), %rsi
jmp 0x20dda
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x20e39
callq 0x2220
cvttsd2si 0x50(%rsp), %esi
movq 0xa8(%rsp), %rdi
movl $0x1f4, %edx            # imm = 0x1F4
callq 0x23677
movq %r14, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18173(%rip), %rax     # 0x38fe0
movq (%rax), %rdi
leaq 0xd397(%rip), %rsi      # 0x2e20e
movapd 0x50(%rsp), %xmm0
movb $0x1, %al
callq 0x2250
jmp 0x20736
movq 0x18(%rsp), %rsi
leaq 0x8(%rsi), %rdi
callq 0x5167
jmp 0x2079c
leal -0x1(%rdx), %esi
cmpq %rsi, %rdx
cmovbq %rdx, %rsi
leaq 0xba23(%rip), %rdi      # 0x2c8d0
jmp 0x20eb9
leaq 0xba1a(%rip), %rdi      # 0x2c8d0
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0xba09(%rip), %rdi      # 0x2c8d0
movq %rbp, %rsi
jmp 0x20eb9
leaq 0xb9fd(%rip), %rdi      # 0x2c8d0
movq %r14, %rsi
movq %r14, %rdx
jmp 0x20eb9