// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/viterbi.cpp
// Function: inner_loop_viterbi(std::vector<double, std::allocator<double>> const&, double, double, std::vector<std::vector<bool, std::allocator<bool>>, std::allocator<std::vector<bool, std::allocator<bool>>>> const&, double, double, int, int, int, std::vector<int, std::allocator<int>> const&, bool, std::vector<std::vector<unsigned short, std::allocator<unsigned short>>, std::allocator<std::vector<unsigned short, std::allocator<unsigned short>>>>&, std::vector<double, std::allocator<double>>&)
void inner_loop_viterbi(const vector<double> &v, double p_rec, double p_no_rec,
		const vector<vector<bool> > &haps, double em_match, double em_mismatch,
		int i, int start, int end, const vector<int> &v_idx_to_hap_idx,
		bool allele,
		vector<vector<unsigned short> > &ptr, vector<double> &vb)
{
	vector<double> va(v.size());
	vector<double>::iterator it;

	for (int j=start; j < end; j++)
	{
		transform(v.begin(), v.end(), va.begin(), bind2nd(std::plus<double>(), p_rec));
		va[j] = v[j] + p_no_rec;
		it = max_element(va.begin(), va.end());
		ptr[i-1][j] = distance(va.begin(), it);

		if (haps[ v_idx_to_hap_idx[j] ][i] == allele)
		{	// Match
			vb[j] = em_match + *it;
		}
		else
		{	// Mismatch
			vb[j] = em_mismatch + *it;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r14
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r13d
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, 0x18(%rsp)
movq %rsi, %r15
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rdi, %r12
movq 0x8(%rdi), %rsi
subq (%rdi), %rsi
sarq $0x3, %rsi
leaq 0x30(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xb7f8
movsd 0x8(%rsp), %xmm4
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm2
cmpl %ebx, %ebp
jge 0x7115
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
cmpq %rdx, %rsi
sete %al
movq %rsi, %rcx
addq $0x8, %rcx
movq %rcx, 0x20(%rsp)
cmpq %rdx, %rcx
sete %cl
orb %al, %cl
movb %cl, 0x6(%rsp)
movslq %r13d, %rcx
leal 0x3f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
sarl $0x6, %eax
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
leaq 0x3f(%rdi), %r9
andq %rcx, %r9
movl %ebx, %r8d
xorl %ebx, %ebx
cmpq %rdi, %r9
movq 0x88(%rsp), %rdi
movq (%rdi), %rdi
leaq (%rcx,%rcx,2), %r9
movq -0x18(%rdi,%r9,8), %r9
movq (%r12), %r10
movq 0x8(%r12), %r11
movq (%r14), %r14
movq (%r15), %r15
movslq %eax, %r12
setbe %bl
leaq -0x8(,%rbx,8), %r13
movl $0x1, %ebx
shlq %cl, %rbx
movq 0x90(%rsp), %rax
movq (%rax), %rcx
movslq %ebp, %rbp
movslq %r8d, %r8
shlq $0x3, %r12
cmpq %r11, %r10
je 0x7082
movq %r10, %rax
movq %rsi, %rdi
movsd (%rax), %xmm0
addsd %xmm4, %xmm0
movsd %xmm0, (%rdi)
addq $0x8, %rax
addq $0x8, %rdi
cmpq %r11, %rax
jne 0x7069
movsd (%r10,%rbp,8), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rsi,%rbp,8)
movq %rsi, %rdi
movq %rsi, %rax
cmpb $0x0, 0x6(%rsp)
jne 0x70ca
movsd (%rsi), %xmm0
movq 0x20(%rsp), %rdi
movq %rsi, %rax
movsd (%rdi), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rdi, %rax
maxsd %xmm0, %xmm1
addq $0x8, %rdi
movapd %xmm1, %xmm0
cmpq %rdx, %rdi
jne 0x70aa
movq %rax, %rdi
subl %esi, %edi
shrl $0x3, %edi
movw %di, (%r9,%rbp,2)
movslq (%r14,%rbp,4), %rdi
leaq (%rdi,%rdi,4), %rdi
movq (%r15,%rdi,8), %rdi
addq %r12, %rdi
testq %rbx, (%r13,%rdi)
setne %dil
xorb 0x80(%rsp), %dil
movsd 0x28(%rsp), %xmm0
jne 0x7100
movapd %xmm2, %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rcx,%rbp,8)
incq %rbp
cmpq %r8, %rbp
jne 0x705e
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7124
callq 0x5410
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq