// File: gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: extend_BED(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int, bool, bool)
void extend_BED(vector<t_annot_region*>* regions, int l_extend, bool extend_3p, bool extend_5p)
{	
	for(int i = 0; i < (int)regions->size(); i++)
	{
		int l_2_extend = (l_extend>0)?(l_extend):(regions->at(i)->end-regions->at(i)->start);

		if(regions->at(i)->strand == '+')
		{
			if(extend_5p)
			{
				regions->at(i)->start = (regions->at(i)->start > l_2_extend)?(regions->at(i)->start - l_2_extend):(1);
			}
			
			if(extend_3p)
			{
				regions->at(i)->end = (regions->at(i)->end + l_2_extend);
			}
		} // strand check for pos. strand.
		else
		{
			if(extend_3p)
			{
				regions->at(i)->start = (regions->at(i)->start > l_2_extend)?(regions->at(i)->start - l_2_extend):(1);
			}
			
			if(extend_5p)
			{
				regions->at(i)->end = (regions->at(i)->end + l_2_extend);
			}
		} // strand check for neg. strand.
	} // i loop.
}

// Assembly:
subq $0x48, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
andb $0x1, %cl
movb %cl, 0x3b(%rsp)
andb $0x1, %al
movb %al, 0x3a(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x40(%rsp), %rdi
callq 0xc680
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl %ecx, %eax
jge 0x288b5
cmpl $0x0, 0x3c(%rsp)
jle 0x286e8
movl 0x3c(%rsp), %eax
movl %eax, 0x28(%rsp)
jmp 0x28721
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq %rax, %rcx
movl 0x24(%rsp), %eax
movq (%rcx), %rcx
subl 0xc(%rcx), %eax
movl %eax, 0x28(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movsbl 0x8(%rax), %eax
cmpl $0x2b, %eax
jne 0x287f7
testb $0x1, 0x3a(%rsp)
je 0x287b5
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
cmpl 0x30(%rsp), %eax
jle 0x28789
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
subl 0x30(%rsp), %eax
movl %eax, 0x20(%rsp)
jmp 0x28794
movl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x28794
movl 0x20(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movl 0x1c(%rsp), %ecx
movq (%rax), %rax
movl %ecx, 0xc(%rax)
testb $0x1, 0x3b(%rsp)
je 0x287f2
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movl 0x18(%rsp), %ecx
movq (%rax), %rax
movl %ecx, 0x20(%rax)
jmp 0x288a3
testb $0x1, 0x3b(%rsp)
je 0x28864
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
cmpl 0x30(%rsp), %eax
jle 0x28838
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0xc(%rax), %eax
subl 0x30(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x28843
movl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x28843
movl 0x14(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movl 0x10(%rsp), %ecx
movq (%rax), %rax
movl %ecx, 0xc(%rax)
testb $0x1, 0x3a(%rsp)
je 0x288a1
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movq (%rax), %rax
movl 0x20(%rax), %eax
addl 0x30(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x40(%rsp), %rdi
movslq 0x34(%rsp), %rsi
callq 0xc800
movl 0xc(%rsp), %ecx
movq (%rax), %rax
movl %ecx, 0x20(%rax)
jmp 0x288a3
jmp 0x288a5
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x286b6
addq $0x48, %rsp
retq
nopw (%rax,%rax)