// File: /workspace/github_cpp_makefile_star2_O3/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), %r12
cmpq %r12, %rbp
jne 0x1d473
movq 0x28(%rsp), %rbx
leal 0x2(%rbx), %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %r14
testl %ebx, %ebx
jle 0x1d3a1
leaq 0x1(%r14), %rdi
movl %ebx, %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 0x1d3ff
movslq %ebx, %rcx
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %edi, %edi
cmpq %rdx, %rdi
je 0x1d61a
movq (%rax,%rdi,8), %r9
movslq 0xc(%r9), %r8
movl 0x20(%r9), %r9d
cmpl %r9d, %r8d
jg 0x1d3f7
subl %r8d, %r9d
incl %r9d
cmpq %rcx, %r8
jg 0x1d3ef
movb $0x1, (%r14,%r8)
incq %r8
decl %r9d
jne 0x1d3e5
incq %rdi
cmpq %rsi, %rdi
jne 0x1d3c5
xorl %ecx, %ecx
testl %ebx, %ebx
jle 0x1d43c
leal 0x1(%rbx), %eax
movl $0x1, %ecx
movl $0x1, %edx
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
cmpb $0x0, (%r14,%rdx)
jne 0x1d432
movsd (%rdi,%rdx,8), %xmm0
movslq %ecx, %rcx
movsd %xmm0, (%rsi,%rcx,8)
incl %ecx
incq %rdx
cmpq %rdx, %rax
jne 0x1d41c
decl %ecx
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
movq 0x1bb96(%rip), %rax     # 0x38fe0
movq (%rax), %rdi
leaq 0x10c5a(%rip), %rsi     # 0x2e0ae
movl %ebx, %edx
xorl %eax, %eax
callq 0x2250
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
movq %r12, %rbx
subq %rbp, %rbx
movq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x6590(%rip), %rcx     # 0x16f04
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1c455
leaq 0x8(%rbp), %rax
cmpq $0x81, %rbx
jl 0x1d593
movq %r12, (%rsp)
movl $0x8, %r13d
movq %rax, 0x30(%rsp)
movq %rax, %rbx
movq %rbp, %r12
movq %r12, %r14
movq %rbp, %r12
addq %r13, %r12
movq (%rbp,%r13), %rdi
movq (%rbp), %rsi
callq 0x16f04
movq (%rbp,%r13), %r15
testb %al, %al
je 0x1d4fa
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x22b0
movq %rbp, %r14
jmp 0x1d52d
movq (%r14), %rsi
movq %r15, %rdi
callq 0x16f04
movq %r12, %r14
testb %al, %al
je 0x1d52d
movq %rbx, %rcx
leaq -0x8(%rcx), %r14
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %r15, %rdi
callq 0x16f04
movq %r14, %rcx
testb %al, %al
jne 0x1d50f
movq %r15, (%r14)
addq $0x8, %r13
addq $0x8, %rbx
cmpq $0x80, %r13
jne 0x1d4c5
subq $-0x80, %rbp
movq (%rsp), %r15
cmpq %r15, %rbp
je 0x1d37d
movq -0x8(%rbp), %rsi
movq (%rbp), %rbx
movq %rbx, %rdi
callq 0x16f04
movq %rbp, %r14
testb %al, %al
je 0x1d58a
movq %rbp, %rcx
leaq -0x8(%rcx), %r14
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %rbx, %rdi
callq 0x16f04
movq %r14, %rcx
testb %al, %al
jne 0x1d56c
movq %rbx, (%r14)
addq $0x8, %rbp
jmp 0x1d549
cmpq %r12, %rax
je 0x1d37d
movq %rbp, %r13
movq %r13, %r15
movq %rax, %r13
movq (%rax), %rdi
movq (%rbp), %rsi
callq 0x16f04
movq (%r13), %rbx
testb %al, %al
je 0x1d5d6
movq %r13, %rdx
subq %rbp, %rdx
subq %rdx, %r15
addq $0x10, %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x22b0
movq %rbp, %r14
jmp 0x1d609
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x16f04
movq %r13, %r14
testb %al, %al
je 0x1d609
movq %r13, %rcx
leaq -0x8(%rcx), %r14
movq -0x10(%rcx), %rsi
movq -0x8(%rcx), %rax
movq %rax, (%rcx)
movq %rbx, %rdi
callq 0x16f04
movq %r14, %rcx
testb %al, %al
jne 0x1d5eb
movq %rbx, (%r14)
leaq 0x8(%r13), %rax
cmpq %r12, %rax
jne 0x1d59f
jmp 0x1d37d
leaq 0xf2af(%rip), %rdi      # 0x2c8d0
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2270