// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_signal_track_tools.cpp
// Function: exclude_regions_from_signal_profiles(double*, int, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, double*, int&)
void exclude_regions_from_signal_profiles(double* signal_profile, int l_profile, vector<t_annot_region*>* regions_2_exclude, double* pruned_signal_profile, int& l_pruned_profile)
{
	sort(regions_2_exclude->begin(), regions_2_exclude->end(), sort_regions);

	bool* exclusion_profile = new bool[l_profile+2];
	for(int i = 1; i <= l_profile; i++)
	{
		exclusion_profile[i] = false;
	} // i loop.

	for(int i_reg = 0; i_reg < (int)regions_2_exclude->size(); i_reg++)
	{
		for(int i = regions_2_exclude->at(i_reg)->start; i <= regions_2_exclude->at(i_reg)->end; i++)
		{
			if(i <= l_profile)
			{
				exclusion_profile[i] = true;
			}
		} // i loop.
	} // i_reg loop.

	l_pruned_profile = 1;

	for(int i = 1; i <= l_profile; i++)
	{
		if(exclusion_profile[i])
		{
		}
		else
		{
			pruned_signal_profile[l_pruned_profile] = signal_profile[i];
			l_pruned_profile++;
		}
	} // i loop.

	// Must move the pruned profile index back by one.
	l_pruned_profile--;

	fprintf(stderr, "Pruned the signal of %d values to %d values.\n", l_profile, l_pruned_profile);
	delete [] exclusion_profile;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
movq (%rdx), %rbp
movq %rdx, 0x20(%rsp)
movq 0x8(%rdx), %r14
cmpq %r14, %rbp
jne 0x1d916
movq 0x28(%rsp), %r14
leal 0x2(%r14), %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %rbx
testl %r14d, %r14d
jle 0x1d839
leaq 0x1(%rbx), %rdi
movl %r14d, %edx
xorl %esi, %esi
callq 0x20f0
movq 0x20(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x1d897
movslq %r14d, %rcx
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %esi, %esi
cmpq %rdx, %rsi
je 0x1dabc
movq (%rax,%rsi,8), %r9
movslq 0xc(%r9), %r8
movl 0x20(%r9), %r9d
cmpl %r9d, %r8d
jg 0x1d88f
subl %r8d, %r9d
incl %r9d
cmpq %rcx, %r8
jg 0x1d887
movb $0x1, (%rbx,%r8)
incq %r8
decl %r9d
jne 0x1d87d
incq %rsi
cmpq %rdi, %rsi
jne 0x1d85d
movq 0x18(%rsp), %rsi
movl $0x1, (%rsi)
testl %r14d, %r14d
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
jle 0x1d8df
leal 0x1(%r14), %eax
movl $0x1, %ecx
movl $0x1, %edx
cmpb $0x0, (%rbx,%rdx)
jne 0x1d8d7
movsd (%r8,%rdx,8), %xmm0
movslq %ecx, %rcx
movsd %xmm0, (%rdi,%rcx,8)
incl %ecx
movl %ecx, (%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x1d8bf
movl (%rsi), %ecx
decl %ecx
movl %ecx, (%rsi)
movq 0x1c6f4(%rip), %rax     # 0x39fe0
movq (%rax), %rdi
leaq 0x117b8(%rip), %rsi     # 0x2f0ae
movl %r14d, %edx
xorl %eax, %eax
callq 0x2250
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
movq %r14, %rbx
subq %rbp, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x66a6(%rip), %rcx     # 0x17291
movq %rbp, %rdi
movq %r14, %rsi
callq 0x1c869
leaq 0x8(%rbp), %rax
cmpq $0x81, %rbx
jl 0x1da34
movq %r14, (%rsp)
movl $0x8, %r15d
movq %rax, 0x30(%rsp)
movq %rax, %r13
movq %rbp, %r14
movq %r14, %rbx
leaq (%r15,%rbp), %r14
movq (%rbp,%r15), %rdi
movq (%rbp), %rsi
callq 0x17291
movq (%rbp,%r15), %r12
testb %al, %al
je 0x1d99b
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x22b0
movq %rbp, %rbx
jmp 0x1d9ce
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x17291
movq %r14, %rbx
testb %al, %al
je 0x1d9ce
movq %r13, %rcx
leaq -0x8(%rcx), %rbx
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r12, %rdi
callq 0x17291
movq %rbx, %rcx
testb %al, %al
jne 0x1d9b0
movq %r12, (%rbx)
addq $0x8, %r15
addq $0x8, %r13
cmpq $0x80, %r15
jne 0x1d968
subq $-0x80, %rbp
movq (%rsp), %r14
cmpq %r14, %rbp
je 0x1d812
movq -0x8(%rbp), %rsi
movq (%rbp), %r15
movq %r15, %rdi
callq 0x17291
movq %rbp, %rbx
testb %al, %al
je 0x1da2b
movq %rbp, %rcx
leaq -0x8(%rcx), %rbx
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r15, %rdi
callq 0x17291
movq %rbx, %rcx
testb %al, %al
jne 0x1da0d
movq %r15, (%rbx)
addq $0x8, %rbp
jmp 0x1d9ea
cmpq %r14, %rax
je 0x1d812
movq %rbp, %r13
movq %r13, %r12
movq %rax, %r13
movq (%rax), %rdi
movq (%rbp), %rsi
callq 0x17291
movq (%r13), %r15
testb %al, %al
je 0x1da77
movq %r13, %rdx
subq %rbp, %rdx
subq %rdx, %r12
addq $0x10, %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x22b0
movq %rbp, %rbx
jmp 0x1daab
movq (%r12), %rsi
movq %r15, %rdi
callq 0x17291
movq %r13, %rbx
testb %al, %al
je 0x1daab
movq %r13, %rcx
leaq -0x8(%rcx), %rbx
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r15, %rdi
callq 0x17291
movq %rbx, %rcx
testb %al, %al
jne 0x1da8d
movq %r15, (%rbx)
leaq 0x8(%r13), %rax
cmpq %r14, %rax
jne 0x1da40
jmp 0x1d812
leaq 0xfe13(%rip), %rdi      # 0x2d8d6
xorl %eax, %eax
callq 0x2270