// File: gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: inter_region_distances(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
vector<int>* inter_region_distances(vector<t_annot_region*>* annot_regions)
{
	vector<char*>* chr_ids = get_chr_ids(annot_regions);

	vector<int>* inter_reg_dists = new vector<int>();

	for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
	{
		vector<t_annot_region*>* cur_chr_regs = get_regions_per_chromosome(annot_regions,
																			chr_ids->at(i_chr));

		// Dump the distances between consecutive regions.
		for(int i_reg = 0; (i_reg + 1) < (int)cur_chr_regs->size(); i_reg++)
		{
			signed int cur_dist = cur_chr_regs->at(i_reg+1)->start - cur_chr_regs->at(i_reg)->end;
		
			if(cur_dist < 0)
			{
				printf("Negative distance: <%d-%d> and <%d-%d>\n", 
					cur_chr_regs->at(i_reg)->start,
					cur_chr_regs->at(i_reg)->end,
					cur_chr_regs->at(i_reg+1)->start,
					cur_chr_regs->at(i_reg+1)->end);
			}

			inter_reg_dists->push_back(cur_dist);
		} // i_reg loop.

		cur_chr_regs->clear();
		delete(cur_chr_regs);
	} // i_chr loop.

	return(inter_reg_dists);
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x2a910
movq %rax, 0x58(%rsp)
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x30(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x30(%rsp), %rdi
callq 0xc290
movq 0x30(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x58(%rsp), %rdi
callq 0xc220
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl %ecx, %eax
jge 0x2e1c9
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x58(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0xc240
movq 0x20(%rsp), %rdi
movq (%rax), %rsi
callq 0x2e1e0
movq %rax, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movq 0x40(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl %ecx, %eax
jge 0x2e187
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0xc800
movq %rax, %rcx
movl 0x18(%rsp), %eax
movq (%rcx), %rcx
subl 0x20(%rcx), %eax
movl %eax, 0x38(%rsp)
cmpl $0x0, 0x38(%rsp)
jge 0x2e168
movq 0x40(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0xc(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x3c(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x10(%rsp)
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, 0x14(%rsp)
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xc800
movl 0xc(%rsp), %esi
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %ecx
movq (%rax), %rax
movl 0x20(%rax), %r8d
leaq 0x28017(%rip), %rdi     # 0x56178
movb $0x0, %al
callq 0x2050
movq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xc340
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x2e076
movq 0x40(%rsp), %rdi
callq 0x31d90
movq 0x40(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x2e1b7
movq (%rsp), %rdi
callq 0xc970
movq (%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
jmp 0x2e1b9
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x2e022
movq 0x50(%rsp), %rax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)