// File: gersteinlab[P]MUSIC/src/ms_peak_calling_utils.cpp
// Function: merge_SSERs_2_features_per_chromosome(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*>>*>>*, double*, int, double*, int, double, int, int)
vector<t_annot_region*>* merge_SSERs_2_features_per_chromosome(vector<t_annot_region*>* top_scale_merged_regions,
																vector<vector<t_annot_region*>*>* per_scale_SSERs, 
																double* signal_profile, int l_chip_signal,
																double* control_profile, int l_control_signal,
																double max_p_val,
																int l_fragment, 
																int l_p_val_norm_win)
{
	// Initialize the list of regions.
	for(int i_reg = 0; i_reg < (int)top_scale_merged_regions->size(); i_reg++)
	{
		vector<t_annot_region*>** per_scale_merged_regions = new vector<t_annot_region*>*[per_scale_SSERs->size() + 2];
		for(int scale_i = 0; scale_i < (int)per_scale_SSERs->size(); scale_i++)
		{
			per_scale_merged_regions[scale_i] = new vector<t_annot_region*>();
		} // scale_i

		top_scale_merged_regions->at(i_reg)->data = per_scale_merged_regions;
	} // i_reg loop.

	// Merge SSERs cumulatively.
	double max_grand_total_int = 1000*1000*10;
	double* log_factorials = buffer_log_factorials((int)(max_grand_total_int+20));
	for(int scale_i = 0; scale_i < (int)per_scale_SSERs->size(); scale_i++)
	{
		fprintf(stderr, "Generating cumulative merged regions @ scale %d                  \r", scale_i);

		// If there are no SSERs in this scale, dont process.
		if(per_scale_SSERs->at(scale_i)->size() == 0)
		{
			continue;
		}

		// Pool all the regions upto this scale.
		vector<t_annot_region*>* SSERs_upto_cur_scale = new vector<t_annot_region*>();
		for(int scale_j = 0; scale_j <= scale_i; scale_j++)
		{
			SSERs_upto_cur_scale->insert(SSERs_upto_cur_scale->end(), per_scale_SSERs->at(scale_j)->begin(), per_scale_SSERs->at(scale_j)->end());
		} // scale_j 

		vector<t_annot_region*>* merged_SSERs_upto_cur_scale = merge_annot_regions(SSERs_upto_cur_scale, 1);

		fprintf(stderr, "Computing p-values @ scale %d                  \r", scale_i);
		for(int i_reg = 0; i_reg < (int)merged_SSERs_upto_cur_scale->size(); i_reg++)
		{
			double cur_region_log_p_val = 0;
			if(merged_SSERs_upto_cur_scale->at(i_reg)->end < l_control_signal && 
				merged_SSERs_upto_cur_scale->at(i_reg)->end < l_chip_signal)
			{
				cur_region_log_p_val = get_binomial_pvalue_per_region_neighborhood_window_control(signal_profile, control_profile, 
																	merged_SSERs_upto_cur_scale->at(i_reg)->start, 
																	merged_SSERs_upto_cur_scale->at(i_reg)->end,
																	log_factorials,
																	l_fragment, 
																	true, 
																	l_p_val_norm_win, 
																	l_chip_signal, 
																	l_control_signal,
																	1);
			}

			t_significance_info* sig_info = new t_significance_info();
			sig_info->log_p_val = cur_region_log_p_val;
			merged_SSERs_upto_cur_scale->at(i_reg)->data = sig_info;
		} // i_reg loop.

		vector<t_annot_region*>* cur_scale_intersects = intersect_annot_regions(top_scale_merged_regions, merged_SSERs_upto_cur_scale, true);
		for(int i_int = 0; i_int < (int)cur_scale_intersects->size(); i_int++)
		{
			t_intersect_info* int_info = (t_intersect_info*)(cur_scale_intersects->at(i_int)->data);
			t_annot_region* cur_top_scale_merged_reg = int_info->src_reg;
			t_annot_region* merged_SSER_reg_upto_cur_scale = int_info->dest_reg;

			vector<t_annot_region*>* cur_scale_regs = ((vector<t_annot_region*>**)(cur_top_scale_merged_reg->data))[scale_i];
			t_annot_region* dup_reg = duplicate_region(merged_SSER_reg_upto_cur_scale);
			dup_reg->data = merged_SSER_reg_upto_cur_scale->data;
			cur_scale_regs->push_back(dup_reg);

			delete int_info;
		} // i_int loop.

		// Free memory.
		delete_annot_regions(cur_scale_intersects);
		delete_annot_regions(merged_SSERs_upto_cur_scale);
		delete SSERs_upto_cur_scale;
	} // scale_i loop.
	delete [] log_factorials;

	// For each region at the highest scale, compute p-value, if not significant, fall down to smaller scale merged ERs. If there are significant ERs, use those.
	//FILE* f_merging_info = fopen("merging_info.bed", "w");
	vector<t_annot_region*>* merged_SSERs = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)top_scale_merged_regions->size(); i_reg++)
	{
		vector<t_annot_region*>** cur_regs_per_scale_SSERs = (vector<t_annot_region*>**)(top_scale_merged_regions->at(i_reg)->data); 

		//Start from top scale and check whether there is a significant merged SSER.
		bool found_cur_reg_scale = false;
		//int found_scale_i = 0;
		for(int scale_i = per_scale_SSERs->size()-1; scale_i >= 0; scale_i--)
		{
			for(int cur_scale_reg_i = 0; cur_scale_reg_i < (int)(cur_regs_per_scale_SSERs[scale_i]->size()); cur_scale_reg_i++)
			{
				t_annot_region* cur_reg_per_scale_SSERs = cur_regs_per_scale_SSERs[scale_i]->at(cur_scale_reg_i);
				t_significance_info* sig_info = (t_significance_info*)(cur_reg_per_scale_SSERs->data);
				if(sig_info->log_p_val < max_p_val)
				{
					// Significant region. Break.
					found_cur_reg_scale = true;
					break;
				}
			} // cur_scale_reg_i optino.

			if(found_cur_reg_scale)
			{
				for(int cur_scale_reg_i = 0; cur_scale_reg_i < (int)(cur_regs_per_scale_SSERs[scale_i]->size()); cur_scale_reg_i++)
				{
					t_annot_region* cur_reg_per_scale_SSERs = cur_regs_per_scale_SSERs[scale_i]->at(cur_scale_reg_i);
					//t_significance_info* sig_info = (t_significance_info*)(cur_reg_per_scale_SSERs->data);
					merged_SSERs->push_back(duplicate_region(cur_reg_per_scale_SSERs));

					//fprintf(f_merging_info, "%s\t%d\t%d\t%s\t%d\t%d\t%lf\n", top_scale_merged_regions->at(i_reg)->chrom, 
					//	top_scale_merged_regions->at(i_reg)->start,
					//	top_scale_merged_regions->at(i_reg)->end, 
					//	cur_reg_per_scale_SSERs->chrom, 
					//	cur_reg_per_scale_SSERs->start, 
					//	cur_reg_per_scale_SSERs->end,
					//	sig_info->log_p_val);
				} // cur_scale_reg_i loop.

				//found_scale_i = scale_i;

				break;
			}
		} // scale_i loop.

		if(!found_cur_reg_scale)
		{
			fprintf(stderr, "Could not find a significant scale for %s:%d-%d\n", top_scale_merged_regions->at(i_reg)->chrom, 
				top_scale_merged_regions->at(i_reg)->start, top_scale_merged_regions->at(i_reg)->end);
			exit(0);
		}

		//else if(found_scale_i != per_scale_SSERs->size()-1)
		//{
		//	fprintf(stderr, "Significant scale not top %s:%d-%d\n", top_scale_merged_regions->at(i_reg)->chrom,
		//			top_scale_merged_regions->at(i_reg)->start, top_scale_merged_regions->at(i_reg)->end);
		//			getc(stdin);
		//}
	} // i_reg loop.

	//fclose(f_merging_info);

	// Free the merged region list.
	for(int i_reg = 0; i_reg < (int)top_scale_merged_regions->size(); i_reg++)
	{
		vector<t_annot_region*>** per_scale_merged_regions = (vector<t_annot_region*>**)(top_scale_merged_regions->at(i_reg)->data);
		for(int scale_i = 0; scale_i < (int)per_scale_SSERs->size(); scale_i++)
		{
			for(int cur_scale_reg_i = 0; cur_scale_reg_i < (int)(per_scale_merged_regions[scale_i]->size()); cur_scale_reg_i++)
			{
				t_significance_info* sig_info = (t_significance_info*)(per_scale_merged_regions[scale_i]->at(cur_scale_reg_i)->data);
				delete sig_info;
			} // i_reg loop.

			if(per_scale_merged_regions[scale_i]->size() > 0)
			{
				delete_annot_regions(per_scale_merged_regions[scale_i]);
			}
			else
			{
				delete per_scale_merged_regions[scale_i];
			}
		} // scale_i
		delete [] per_scale_merged_regions;
	} // i_reg loop.

	return(merged_SSERs);
}

// Assembly:
subq $0x268, %rsp            # imm = 0x268
movl 0x278(%rsp), %eax
movl 0x270(%rsp), %eax
movq %rdi, 0x260(%rsp)
movq %rsi, 0x258(%rsp)
movq %rdx, 0x250(%rsp)
movl %ecx, 0x24c(%rsp)
movq %r8, 0x240(%rsp)
movl %r9d, 0x23c(%rsp)
movsd %xmm0, 0x230(%rsp)
movl $0x0, 0x22c(%rsp)
movl 0x22c(%rsp), %eax
movl %eax, 0xfc(%rsp)
movq 0x260(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0xfc(%rsp), %eax
cmpl %ecx, %eax
jge 0x12ddd
movq 0x258(%rsp), %rdi
callq 0x1ac60
addq $0x2, %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, 0x220(%rsp)
movl $0x0, 0x21c(%rsp)
movl 0x21c(%rsp), %eax
movl %eax, 0xf8(%rsp)
movq 0x258(%rsp), %rdi
callq 0x1ac60
movq %rax, %rcx
movl 0xf8(%rsp), %eax
cmpl %ecx, %eax
jge 0x12d93
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0xf0(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0xf0(%rsp), %rdi
callq 0xc670
movq 0xf0(%rsp), %rdx
movq 0x220(%rsp), %rax
movslq 0x21c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x21c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x21c(%rsp)
jmp 0x12d0a
movq 0x220(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x260(%rsp), %rdi
movslq 0x22c(%rsp), %rsi
callq 0xc800
movq 0xe8(%rsp), %rcx
movq (%rax), %rax
movq %rcx, 0x48(%rax)
movl 0x22c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x22c(%rsp)
jmp 0x12c98
movsd 0x41f7b(%rip), %xmm0    # 0x54d60
movsd %xmm0, 0x210(%rsp)
movsd 0x41f62(%rip), %xmm0    # 0x54d58
addsd 0x210(%rsp), %xmm0
cvttsd2si %xmm0, %edi
callq 0x3f420
movq %rax, 0x208(%rsp)
movl $0x0, 0x204(%rsp)
movl 0x204(%rsp), %eax
movl %eax, 0xe4(%rsp)
movq 0x258(%rsp), %rdi
callq 0x1ac60
movq %rax, %rcx
movl 0xe4(%rsp), %eax
cmpl %ecx, %eax
jge 0x13383
movq 0x52191(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movl 0x204(%rsp), %edx
leaq 0x42007(%rip), %rsi     # 0x54e67
movb $0x0, %al
callq 0x2250
movq 0x258(%rsp), %rdi
movslq 0x204(%rsp), %rsi
callq 0x1ac80
movq (%rax), %rdi
callq 0xc680
cmpq $0x0, %rax
jne 0x12e8f
jmp 0x1336d
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0xd8(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0xd8(%rsp), %rdi
callq 0xc670
movq 0xd8(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movl $0x0, 0x1f4(%rsp)
movl 0x1f4(%rsp), %eax
cmpl 0x204(%rsp), %eax
jg 0x12fb3
movq 0x1f8(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0xc760
movq %rax, 0x1e0(%rsp)
leaq 0x1e8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0xc790
movq 0x258(%rsp), %rdi
movslq 0x1f4(%rsp), %rsi
callq 0x1ac80
movq (%rax), %rdi
callq 0xc7d0
movq %rax, 0x1d8(%rsp)
movq 0x258(%rsp), %rdi
movslq 0x1f4(%rsp), %rsi
callq 0x1ac80
movq (%rax), %rdi
callq 0xc760
movq 0xd0(%rsp), %rdi
movq %rax, 0x1d0(%rsp)
movq 0x1e8(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
movq 0x1d0(%rsp), %rcx
callq 0xc6a0
movq %rax, 0x1c8(%rsp)
movl 0x1f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f4(%rsp)
jmp 0x12ed8
movq 0x1f8(%rsp), %rdi
movl $0x1, %esi
callq 0x308f0
movq %rax, 0x1c0(%rsp)
movq 0x5200c(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movl 0x204(%rsp), %edx
leaq 0x41ec5(%rip), %rsi     # 0x54eaa
movb $0x0, %al
callq 0x2250
movl $0x0, 0x1bc(%rsp)
movl 0x1bc(%rsp), %eax
movl %eax, 0xcc(%rsp)
movq 0x1c0(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0xcc(%rsp), %eax
cmpl %ecx, %eax
jge 0x131d5
xorps %xmm0, %xmm0
movsd %xmm0, 0x1b0(%rsp)
movq 0x1c0(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
cmpl 0x23c(%rsp), %eax
jge 0x13145
movq 0x1c0(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
cmpl 0x24c(%rsp), %eax
jge 0x13145
movq 0x250(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x240(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x1c0(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0xc8(%rsp)
movq 0x1c0(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0xc800
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movl 0xc8(%rsp), %edx
movq (%rax), %rax
movl 0x20(%rax), %ecx
movq 0x208(%rsp), %r8
cvtsi2sdl 0x270(%rsp), %xmm0
movl 0x278(%rsp), %r11d
movl 0x24c(%rsp), %r10d
movl 0x23c(%rsp), %eax
movl $0x1, %r9d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
callq 0x36a30
movsd %xmm0, 0x1b0(%rsp)
movl $0x10, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0xa8(%rsp)
xorl %esi, %esi
movl $0x10, %edx
callq 0x2110
movq 0xa8(%rsp), %rax
movq %rax, 0x1a8(%rsp)
movsd 0x1b0(%rsp), %xmm0
movq 0x1a8(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x1a8(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x1c0(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0xc800
movq 0xb0(%rsp), %rcx
movq (%rax), %rax
movq %rcx, 0x48(%rax)
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0x12ff7
movq 0x260(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movl $0x1, %edx
callq 0x2d070
movq %rax, 0x1a0(%rsp)
movl $0x0, 0x19c(%rsp)
movl 0x19c(%rsp), %eax
movl %eax, 0xa4(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0xa4(%rsp), %eax
cmpl %ecx, %eax
jge 0x1331c
movq 0x1a0(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x190(%rsp)
movq 0x190(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x188(%rsp)
movq 0x190(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x204(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x178(%rsp)
movq 0x180(%rsp), %rdi
callq 0x2a410
movq %rax, 0x170(%rsp)
movq 0x180(%rsp), %rax
movq 0x48(%rax), %rcx
movq 0x170(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x178(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0xc8c0
movq 0x190(%rsp), %rax
movq %rax, 0x98(%rsp)
cmpq $0x0, %rax
je 0x13304
movq 0x98(%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
jmp 0x13306
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x13202
movq 0x1a0(%rsp), %rdi
callq 0x2f560
movq 0x1c0(%rsp), %rdi
callq 0x2f560
movq 0x1f8(%rsp), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, %rax
je 0x1336b
movq 0x90(%rsp), %rdi
callq 0xc970
movq 0x90(%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
jmp 0x1336d
movl 0x204(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x204(%rsp)
jmp 0x12e1b
movq 0x208(%rsp), %rax
movq %rax, 0x88(%rsp)
cmpq $0x0, %rax
je 0x133a6
movq 0x88(%rsp), %rdi
callq 0x2220
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x80(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x80(%rsp), %rdi
callq 0xc670
movq 0x80(%rsp), %rax
movq %rax, 0x168(%rsp)
movl $0x0, 0x164(%rsp)
movl 0x164(%rsp), %eax
movl %eax, 0x7c(%rsp)
movq 0x260(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x7c(%rsp), %eax
cmpl %ecx, %eax
jge 0x136aa
movq 0x260(%rsp), %rdi
movslq 0x164(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x158(%rsp)
movb $0x0, 0x157(%rsp)
movq 0x258(%rsp), %rdi
callq 0x1ac60
subq $0x1, %rax
movl %eax, 0x150(%rsp)
cmpl $0x0, 0x150(%rsp)
jl 0x135f7
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, 0x78(%rsp)
movq 0x158(%rsp), %rax
movslq 0x150(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x78(%rsp), %eax
cmpl %ecx, %eax
jge 0x1351f
movq 0x158(%rsp), %rax
movslq 0x150(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x14c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x230(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x13507
movb $0x1, 0x157(%rsp)
jmp 0x1351f
jmp 0x13509
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x13473
testb $0x1, 0x157(%rsp)
je 0x135df
movl $0x0, 0x134(%rsp)
movl 0x134(%rsp), %eax
movl %eax, 0x74(%rsp)
movq 0x158(%rsp), %rax
movslq 0x150(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x74(%rsp), %eax
cmpl %ecx, %eax
jge 0x135dd
movq 0x158(%rsp), %rax
movslq 0x150(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x134(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq %rax, 0x128(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x128(%rsp), %rdi
callq 0x2a410
movq 0x68(%rsp), %rdi
movq %rax, 0x120(%rsp)
leaq 0x120(%rsp), %rsi
callq 0x1acc0
movl 0x134(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x134(%rsp)
jmp 0x13538
jmp 0x135f7
jmp 0x135e1
movl 0x150(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x1345a
testb $0x1, 0x157(%rsp)
jne 0x13692
movq 0x519d4(%rip), %rax     # 0x64fe0
movq (%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x260(%rsp), %rdi
movslq 0x164(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x260(%rsp), %rdi
movslq 0x164(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0x64(%rsp)
movq 0x260(%rsp), %rdi
movslq 0x164(%rsp), %rsi
callq 0xc800
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rdx
movl 0x64(%rsp), %ecx
movq (%rax), %rax
movl 0x20(%rax), %r8d
leaq 0x41857(%rip), %rsi     # 0x54edb
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x21f0
jmp 0x13694
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x133ef
movl $0x0, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0x260(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x4c(%rsp), %eax
cmpl %ecx, %eax
jge 0x13897
movq 0x260(%rsp), %rdi
movslq 0x11c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x110(%rsp)
movl $0x0, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, 0x48(%rsp)
movq 0x258(%rsp), %rdi
callq 0x1ac60
movq %rax, %rcx
movl 0x48(%rsp), %eax
cmpl %ecx, %eax
jge 0x13862
movl $0x0, 0x108(%rsp)
movl 0x108(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x110(%rsp), %rax
movslq 0x10c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x137d6
movq 0x110(%rsp), %rax
movslq 0x10c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x108(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x137be
movq 0x38(%rsp), %rdi
movl $0x10, %esi
callq 0x21a0
jmp 0x137c0
movl 0x108(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x108(%rsp)
jmp 0x1373d
movq 0x110(%rsp), %rax
movslq 0x10c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xc680
cmpq $0x0, %rax
jbe 0x13810
movq 0x110(%rsp), %rax
movslq 0x10c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2f560
jmp 0x1384a
movq 0x110(%rsp), %rax
movslq 0x10c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x13848
movq 0x30(%rsp), %rdi
callq 0xc970
movq 0x30(%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
jmp 0x1384a
jmp 0x1384c
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x1370b
movq 0x110(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x1387f
movq 0x28(%rsp), %rdi
callq 0x2220
jmp 0x13881
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x136b5
movq 0x168(%rsp), %rax
addq $0x268, %rsp            # imm = 0x268
retq
nopw (%rax,%rax)