// File: gersteinlab[P]MUSIC/src/ms_peak_calling_utils.cpp
// Function: dump_ERs_per_q_value_and_summit(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char*)
void dump_ERs_per_q_value_and_summit(vector<t_annot_region*>* regions, char* op_fp)
{
	FILE* f_op = open_f(op_fp, "w");

	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		t_ER_info* cur_reg_info = (t_ER_info*)(regions->at(i_reg)->data);

		double FC = cur_reg_info->total_chip_mass / (cur_reg_info->total_control_mass+1);

		//t_significance_info* sig_info = (t_significance_info*)(regions->at(i_reg)->significance_info);
		//fprintf(f_op, "%s\t%d\t%d\t.\t%lf\t%c\t%d\t%d\t%d\t%d\t%lf\t%lf\n", regions->at(i_reg)->chrom, regions->at(i_reg)->start, regions->at(i_reg)->end, 
		//	sig_info->log_q_val, 
		//	regions->at(i_reg)->strand,
		//	(int)((cur_reg_info->rev_strand_mass_of_center + cur_reg_info->fore_strand_mass_of_center) / 2), 
		//	(int)((cur_reg_info->fore_climax_posn + cur_reg_info->rev_climax_posn) / 2), 
		//	(int)(cur_reg_info->climax_posn), 
		//	(int)(cur_reg_info->mappable_trough), 
		//	FC,
		//	cur_reg_info->max_chip_mass / cur_reg_info->max_control_mass);
		t_significance_info* sig_info = (t_significance_info*)(regions->at(i_reg)->significance_info);
		fprintf(f_op, "%s\t%d\t%d\t.\t%lf\t%c\t%d\t%d\t%lf\n", regions->at(i_reg)->chrom, regions->at(i_reg)->start, regions->at(i_reg)->end, 
			sig_info->log_q_val / log(10.0), 
			regions->at(i_reg)->strand,
			(int)(cur_reg_info->climax_posn), 
			(int)(cur_reg_info->mappable_trough), 
			FC);
	} // i_reg loop.

	fclose(f_op);
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x68(%rsp), %rdi
leaq 0x3899a(%rip), %rsi     # 0x52aa4
callq 0x455f0
movq %rax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x70(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1a28c
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x48(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movsd 0x38(%rax), %xmm0
movq 0x50(%rsp), %rax
movsd 0x37ea9(%rip), %xmm1    # 0x52018
addsd 0x40(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq 0x40(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0x28(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x40(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x3ab79(%rip), %xmm0    # 0x54d80
callq 0x2140
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0xc800
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
movl 0x2c(%rsp), %r8d
movsd 0x30(%rsp), %xmm0
movq (%rax), %rax
movsbl 0x8(%rax), %r9d
movq 0x50(%rsp), %rax
movl 0x48(%rax), %r10d
movq 0x50(%rsp), %rax
movl 0x60(%rax), %eax
movsd 0x48(%rsp), %xmm1
leaq 0x3b3c9(%rip), %rsi     # 0x55636
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x2, %al
callq 0x2250
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x1a11c
movq 0x60(%rsp), %rdi
callq 0x2180
addq $0x78, %rsp
retq
nopl (%rax,%rax)