// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_peak_calling_utils.cpp
// Function: write_decomposition_WAV(char*, int, char*, int, double, double, double, int, double)
void write_decomposition_WAV(char* chip_reads_dir,
		int l_fragment,
		char* mapability_signal_dir,
		int l_read_mapability_signal,
		double base_scale_l_win,
		double end_scale_l_win,
		double log_step,
		int l_mapability_filtering_win,
		double max_normalized_mapability_signal)
{
	char chr_ids_fp[1000];
	sprintf(chr_ids_fp, "%s/chr_ids.txt", chip_reads_dir);
	vector<char*>* chr_ids = buffer_file(chr_ids_fp);
	if(chr_ids == NULL)
	{
		fprintf(stderr, "Could not load the chromosome id's for the chip data.\n");
		exit(0);
	}

	// Process each chromosome.
	for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
	{
		fprintf(stderr, "Writing %s..", chr_ids->at(i_chr));

		// Skip chromosome M for now.
		if(strcmp(chr_ids->at(i_chr), "M") == 0)
		{
			continue;
		}

		// Generate the current signal profile.
		int l_buffer = 300*1000*1000;
		int l_profile = 0;
		//int l_read = l_read_mapability_signal;
		double* buffered_signal_profile = new double[l_buffer + 2];	
		char cur_chr_chip_reads_fp[1000];
		sprintf(cur_chr_chip_reads_fp, "%s/%s_mapped_reads.txt", chip_reads_dir, chr_ids->at(i_chr));
		buffer_per_nucleotide_profile_no_buffer(cur_chr_chip_reads_fp, l_fragment, 
			buffered_signal_profile, NULL, NULL,
			l_buffer, l_profile);

		double* signal_profile = new double[l_profile + 2];	
		for(int i = 1; i <= l_profile; i++)
		{
			signal_profile[i] = buffered_signal_profile[i];
		} // i loop.
		delete [] buffered_signal_profile;

		//// Generate the current control profile.
		//l_buffer = 300*1000*1000;
		//int l_control = 0;
		//double* buffered_control_profile = new double[l_buffer + 2];
		//char cur_chr_control_reads_fp[1000];
		//sprintf(cur_chr_control_reads_fp, "%s/%s_mapped_reads.txt", control_reads_dir, chr_ids->at(i_chr));
		//buffer_per_nucleotide_profile_no_buffer(cur_chr_control_reads_fp, l_fragment, 
		//	buffered_control_profile, NULL, NULL, 
		//	l_buffer, l_control);


		//double* control_profile = new double[l_control + 2];
		//for(int i = 1; i <= l_control; i++)
		//{
		//	control_profile[i] = buffered_control_profile[i];
		//} // i loop.
		//delete [] buffered_control_profile;
		
		// Load and process the mapability profile.
		char mapability_signal_profile_fp[1000];
		sprintf(mapability_signal_profile_fp, "%s/%s.bin", mapability_signal_dir, chr_ids->at(i_chr));

		double* mapability_aware_smoothed_signal_profile = NULL;
		int l_mapability_profile = 0;
		if(check_file(mapability_signal_profile_fp))
		{
			double* mapability_signal_profile = NULL;

#define __UCHAR_MAPPABILITY__
#ifdef __DOUBLE_MAPPABILITY__
			// Load the mapability map signal profile, do filtering.
			mapability_signal_profile = load_per_nucleotide_binary_profile(mapability_signal_profile_fp, l_mapability_profile);

			// Do mapability aware median filtering on the current signal profile.
if(__DUMP_PEAK_CALLING_UTILS_MSGS__)
			fprintf(stderr, "Scaling the mapability map with %d.\n", l_read_mapability_signal * 2);

			int mapability_scaling = l_read * 2;
			for(int i = 1; i <= l_mapability_profile; i++)
			{
				mapability_signal_profile[i] /= mapability_scaling;
			} // i loop.
#elif defined(__UCHAR_MAPPABILITY__)
			// Following loads the mappability signal profile from the char version of the multi-mappability profile.
			// Load the mapability map signal profile, do filtering.
			unsigned char* mapability_signal_char_profile = load_per_nucleotide_binary_uchar_profile(mapability_signal_profile_fp, l_mapability_profile);
			mapability_signal_profile = new double[l_mapability_profile + 2];
			for(int i = 1; i <= l_mapability_profile; i++)
			{
				unsigned char unsigned_char_val = (unsigned char)(mapability_signal_char_profile[i]);
				mapability_signal_profile[i] = (double)(unsigned_char_val);
				mapability_signal_profile[i] /= 100;

				if(mapability_signal_profile[i] < 0)
				{
					fprintf(stderr, "Sanity check failed.\n");
					exit(0);
				}
			} // i loop.
			delete [] mapability_signal_char_profile;
#else
			#error "Must define the type of mappability."
#endif

if(__DUMP_PEAK_CALLING_UTILS_MSGS__)
			fprintf(stderr, "Smoothing the signal profile.\n");
			mapability_aware_smoothed_signal_profile = mapability_aware_median_filter(signal_profile, l_profile,
																					mapability_signal_profile, l_mapability_profile,
																					max_normalized_mapability_signal,
																					l_mapability_filtering_win);

			delete [] mapability_signal_profile;
		} // mapability based filtering check.
		else
		{
			fprintf(stderr, "Could not find the mapability map profile, skipping it.");
			mapability_aware_smoothed_signal_profile = new double[l_profile + 2];
			for(int i = 1; i <= l_profile; i++)
			{
				mapability_aware_smoothed_signal_profile[i] = signal_profile[i];
			} // i loop.
		}

//		// Scale the control with respect to signal.
//		double per_win_2DOF_lls_scaling_factor = 0;
//		double per_win_1DOF_lls_scaling_factor = 0;
//		double total_sig_scaling_factor = 0;
//		get_per_window_scaling_factors_for_profile1_per_profile2(control_profile, l_control, signal_profile, l_profile, 10000,
//																	per_win_2DOF_lls_scaling_factor,
//																	per_win_1DOF_lls_scaling_factor,
//																	total_sig_scaling_factor);
//
//		double scaling_factor = per_win_1DOF_lls_scaling_factor;
//
//if(__DUMP_PEAK_CALLING_UTILS_MSGS__)
//		fprintf(stderr, "Scaling control with factor of %lf\n", scaling_factor);
//
//		// Go over the whole control signal.
//		for(int i = 0; i < l_control; i++)
//		{
//			control_profile[i] *= scaling_factor;
//		} // i loop.

		// Now, do the multiscale decomposition, 
		vector<double>* scales_per_i_scale = new vector<double>();
		vector<double*>* filtered_tracks = multiscale_median_filter_data(mapability_aware_smoothed_signal_profile, l_profile, 
			base_scale_l_win, end_scale_l_win, log_step, 
			scales_per_i_scale,
			true,
			false, 
			false, 
			false, 
			NULL, 
			NULL,
			"temp");

		// Dump the tracks.
		short int* merged_waveform_buffer = new short int[l_profile + 2];
		memset(merged_waveform_buffer, 0, sizeof(short int) * l_profile);
		for(int i_scale = 0; i_scale < (int)scales_per_i_scale->size(); i_scale++)
		{
			char cur_decomp_fp[1000];
			sprintf(cur_decomp_fp, "%s_scale_%d.bin", "temp", i_scale);

			if(check_file(cur_decomp_fp))
			{
				int l_cur_decomp;
				double* cur_filtered_track = load_per_nucleotide_binary_profile(cur_decomp_fp, l_cur_decomp);

				int l_cur_last_index = MIN(l_cur_decomp, l_profile);
				for(int i = 1; i < l_cur_last_index; i++)
				{
					merged_waveform_buffer[i] += (short int)(cur_filtered_track[i]);
				} // i loop.

				// Delete the temp file.
				remove(cur_decomp_fp);

				//char cur_bgr_fp[1000];
				//sprintf(cur_bgr_fp, "chr%s_scale_%d.bgr", chr_ids->at(i_chr), (int)(floor(scales_per_i_scale->at(i_scale))));
				//dump_bedGraph_per_per_nucleotide_binary_profile(cur_filtered_track, l_cur_decomp, chr_ids->at(i_chr), cur_bgr_fp);
				delete [] cur_filtered_track;
			}
		} // i_scale loop.
		delete filtered_tracks;

		fprintf(stderr, "Dumping WAV file.\n");

		// Amplify to get 
		short max_val = 0;
		short min_val = 60*1000;
		for(int i = 0; i < l_profile; i++)
		{
			if(max_val < merged_waveform_buffer[i])
			{
				max_val = merged_waveform_buffer[i];
			}

			if(min_val > merged_waveform_buffer[i])
			{
				min_val = merged_waveform_buffer[i];
			}
		} // i_loop.

		double norm_val = ((double)64000 / (double)(max_val - min_val));
		double half_val = (max_val + min_val) / 2;
		for(int i = 0; i < l_profile; i++)
		{
			double fraction_posn_per_cur_val = fabs((merged_waveform_buffer[i] - half_val)/half_val);
			double a = (1 - fraction_posn_per_cur_val);
			double warping_factor = pow((1 - a*a),.5) / (a+.05);
			//if(warping_factor > 1 || warping_factor < 0)
			//{
			//	fprintf(stderr, "Sanity check failed: %lf\n", warping_factor);
			//	exit(0);
			//}
			merged_waveform_buffer[i] *= (short)(warping_factor * norm_val * (merged_waveform_buffer[i] - half_val));
		} // i loop.

		char cur_chr_wav_fp[1000];
		sprintf(cur_chr_wav_fp, "%s.wav", chr_ids->at(i_chr));
		FILE * f_wave = wavfile_open(cur_chr_wav_fp);
		fprintf(stderr, "Opened WAV file.\n");
		if(f_wave == NULL) 
		{
			fprintf(stderr, "couldn't open %s for writing.", cur_chr_wav_fp);
			exit(0);
		}

		fprintf(stderr, "Writing WAV file.\n");
		wavfile_write(f_wave,merged_waveform_buffer,l_profile);
		fprintf(stderr, "Closing WAV file.\n");
		wavfile_close(f_wave);
		fprintf(stderr, "Done!\n");

		delete [] merged_waveform_buffer;
		delete scales_per_i_scale;
		delete [] signal_profile;
		//delete [] control_profile;
		delete [] mapability_aware_smoothed_signal_profile;
	} // i_chr loop.
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1058, %rsp           # imm = 0x1058
movsd %xmm3, 0x70(%rsp)
movl %r8d, %ebp
movsd %xmm2, 0x88(%rsp)
movsd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x78(%rsp)
movq %rdx, %r13
movl %esi, %r12d
movq %rdi, %r15
leaq 0x1f748(%rip), %rsi     # 0x2b9e4
leaq 0xc70(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2080
movq %rbx, %rdi
callq 0x2613e
testq %rax, %rax
je 0xc9ad
movq (%rax), %rsi
movq 0x8(%rax), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0xc96a
movq 0x2dd01(%rip), %rcx     # 0x39fe0
leaq 0xa0(%rsp), %rbx
xorl %r14d, %r14d
movq %rax, 0x30(%rsp)
cmpq %r14, %rdx
jbe 0xc97c
movq (%rcx), %rdi
movq (%rsi,%r14,8), %rdx
leaq 0x2188d(%rip), %rsi     # 0x2db93
xorl %eax, %eax
callq 0x2250
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0xc97c
movq (%rax,%r14,8), %rdi
leaq 0x1f5c9(%rip), %rsi     # 0x2b8fd
callq 0x2240
testl %eax, %eax
jne 0xc36e
incq %r14
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rcx
subq %rsi, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
movq 0x2dc79(%rip), %rcx     # 0x39fe0
jl 0xc2ef
jmp 0xc96a
movq %r15, 0x58(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x8f0d1810, %edi       # imm = 0x8F0D1810
callq 0x2040
movq %rax, %r15
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0xc97c
movq (%rax,%r14,8), %rcx
leaq 0x490(%rsp), %rdi
leaq 0x1f687(%rip), %rsi     # 0x2ba3e
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x2080
leaq 0x28(%rsp), %rax
movq %rax, (%rsp)
leaq 0x490(%rsp), %rdi
movl %r12d, 0x50(%rsp)
movl %r12d, %esi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x11e1a300, %r9d       # imm = 0x11E1A300
callq 0x1225e
movslq 0x28(%rsp), %r12
cmpq $-0x2, %r12
leaq 0x10(,%r12,8), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x2040
movq %rax, 0x40(%rsp)
testq %r12, %r12
jle 0xc436
movq 0x40(%rsp), %rax
leaq 0x8(%rax), %rdi
movq %r15, %rsi
addq $0x8, %rsi
shlq $0x3, %r12
movq %r12, %rdx
callq 0x2130
movl %ebp, 0x3c(%rsp)
movq %r15, %rdi
callq 0x2220
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0xc97c
movq (%rax,%r14,8), %rcx
leaq 0x880(%rsp), %r15
movq %r15, %rdi
leaq 0x1fb25(%rip), %rsi     # 0x2bf99
movq %r13, %rdx
xorl %eax, %eax
callq 0x2080
movl $0x0, 0x2c(%rsp)
movq %r15, %rdi
callq 0x26362
testb %al, %al
movq %r13, 0x68(%rsp)
je 0xc54f
movq %r15, %rdi
leaq 0x2c(%rsp), %rsi
callq 0x1d115
movq %rax, %r12
movslq 0x2c(%rsp), %r13
cmpq $-0x2, %r13
leaq 0x10(,%r13,8), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x2040
movq %rax, %r15
testq %r13, %r13
movsd 0x1eb46(%rip), %xmm1    # 0x2b020
jle 0xc505
movl %r13d, %eax
incq %rax
movl $0x1, %ecx
movzbl (%r12,%rcx), %edx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xc4e7
testq %r12, %r12
movl 0x3c(%rsp), %ebp
je 0xc516
movq %r12, %rdi
callq 0x2220
cmpb $0x1, 0x2dcad(%rip)     # 0x3a1ca
jne 0xc524
callq 0x3487
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %ecx
movq 0x40(%rsp), %rdi
movq %r15, %rdx
movsd 0x70(%rsp), %xmm0
movl %ebp, %r8d
callq 0x15307
movq %rax, %r12
movq %r15, %rdi
callq 0x2220
jmp 0xc569
leaq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %rbx, %rdx
callq 0x340e
movq 0xa0(%rsp), %r12
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl 0x28(%rsp), %esi
leaq 0x21666(%rip), %rax     # 0x2dbf7
movq %rax, 0x18(%rsp)
movupd %xmm0, 0x8(%rsp)
movl $0x0, (%rsp)
movq %r12, 0x60(%rsp)
movq %r12, %rdi
movsd 0x78(%rsp), %xmm0
movsd 0x80(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
movq %r15, %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x14341
movq %rax, 0x48(%rsp)
movslq 0x28(%rsp), %r13
cmpq $-0x2, %r13
leaq 0x4(%r13,%r13), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
callq 0x2040
movq %rax, %r12
addq %r13, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20f0
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0xc6b1
xorl %r13d, %r13d
movq %rbx, %rdi
leaq 0x215d0(%rip), %rsi     # 0x2dbfc
leaq 0x215c4(%rip), %rdx     # 0x2dbf7
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2080
movq %rbx, %rdi
callq 0x26362
testb %al, %al
je 0xc69a
movq %rbx, %rdi
leaq 0x54(%rsp), %rsi
callq 0x1d724
movq %rax, %rbp
movl 0x54(%rsp), %ecx
movl 0x28(%rsp), %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
cmpl $0x2, %eax
jl 0xc685
movl %eax, %eax
movl $0x1, %ecx
cvttsd2si (%rbp,%rcx,8), %edx
addw %dx, (%r12,%rcx,2)
incq %rcx
cmpq %rcx, %rax
jne 0xc672
movq %rbx, %rdi
callq 0x2310
testq %rbp, %rbp
je 0xc69a
movq %rbp, %rdi
callq 0x2220
incl %r13d
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x3, %rax
cmpl %eax, %r13d
jl 0xc622
movq 0x48(%rsp), %r13
testq %r13, %r13
je 0xc6dd
movq (%r13), %rdi
testq %rdi, %rdi
je 0xc6d0
movq 0x10(%r13), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r13, %rdi
callq 0x2190
movq 0x2d8fc(%rip), %rax     # 0x39fe0
movq (%rax), %rcx
movl $0x12, %esi
movl $0x1, %edx
leaq 0x21514(%rip), %rdi     # 0x2dc0c
callq 0x2340
movslq 0x28(%rsp), %rax
testq %rax, %rax
jle 0xc730
movw $0xea60, %cx            # imm = 0xEA60
xorl %edx, %edx
xorl %esi, %esi
movzwl (%r12,%rdx,2), %edi
cmpw %di, %si
cmovlel %edi, %esi
cmpw %di, %cx
cmovgel %edi, %ecx
incq %rdx
cmpq %rdx, %rax
jne 0xc70f
movzwl %si, %edx
movswl %cx, %eax
jmp 0xc737
xorl %edx, %edx
movl $0xffffea60, %eax       # imm = 0xFFFFEA60
cmpl $0x0, 0x28(%rsp)
movapd 0x2129c(%rip), %xmm2    # 0x2d9e0
movsd 0x1e8bc(%rip), %xmm3    # 0x2b008
movsd 0x1e904(%rip), %xmm4    # 0x2b058
jle 0xc845
movl %edx, %ecx
subl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd 0x21243(%rip), %xmm1    # 0x2d9b0
divsd %xmm0, %xmm1
movsd %xmm1, 0x90(%rsp)
addl %edx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x48(%rsp)
xorl %r13d, %r13d
movswl (%r12,%r13,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x48(%rsp), %xmm1
subsd %xmm1, %xmm0
divsd %xmm1, %xmm0
andpd %xmm2, %xmm0
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x98(%rsp)
mulsd %xmm1, %xmm1
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
movaps %xmm4, %xmm1
callq 0x22d0
movsd 0x1e870(%rip), %xmm1    # 0x2b050
movsd 0x1e870(%rip), %xmm4    # 0x2b058
movsd 0x1e818(%rip), %xmm3    # 0x2b008
movapd 0x211e8(%rip), %xmm2    # 0x2d9e0
movsd 0x98(%rsp), %xmm5
addsd %xmm1, %xmm5
divsd %xmm5, %xmm0
mulsd 0x90(%rsp), %xmm0
movswl (%r12,%r13,2), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subsd 0x48(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
imull %eax, %ecx
movw %cx, (%r12,%r13,2)
incq %r13
movslq 0x28(%rsp), %rax
cmpq %rax, %r13
jl 0xc795
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0xc97c
movq (%rax,%r14,8), %rdx
movq %rbx, %rdi
leaq 0x213b0(%rip), %rsi     # 0x2dc1f
xorl %eax, %eax
callq 0x2080
movq %rbx, %rdi
callq 0x2a60c
movq %rax, %r13
movq 0x2d758(%rip), %rbp     # 0x39fe0
movq (%rbp), %rcx
movl $0x11, %esi
movl $0x1, %edx
leaq 0x21389(%rip), %rdi     # 0x2dc26
callq 0x2340
movq (%rbp), %rcx
testq %r13, %r13
je 0xc98d
movl $0x12, %esi
movl $0x1, %edx
leaq 0x21396(%rip), %rdi     # 0x2dc56
callq 0x2340
movl 0x28(%rsp), %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x2a689
movq (%rbp), %rcx
movl $0x12, %esi
movl $0x1, %edx
leaq 0x21380(%rip), %rdi     # 0x2dc69
callq 0x2340
movq %r13, %rdi
callq 0x2a69f
movq (%rbp), %rcx
movl $0x6, %esi
movl $0x1, %edx
leaq 0x21371(%rip), %rdi     # 0x2dc7c
callq 0x2340
movq %r12, %rdi
callq 0x2220
movq (%r15), %rdi
testq %rdi, %rdi
je 0xc92c
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r15, %rdi
callq 0x2190
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
movl 0x3c(%rsp), %ebp
movq 0x68(%rsp), %r13
movl 0x50(%rsp), %r12d
je 0xc960
callq 0x2220
movq 0x58(%rsp), %r15
jmp 0xc33d
addq $0x1058, %rsp           # imm = 0x1058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20f53(%rip), %rdi     # 0x2d8d6
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x212a4(%rip), %rsi     # 0x2dc38
leaq 0xa0(%rsp), %rdx
movq %rcx, %rdi
xorl %eax, %eax
callq 0x2250
xorl %edi, %edi
callq 0x21e0
callq 0x34a9