// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %r9, %r14
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r13d
movsd %xmm3, 0x38(%rsp)
movsd %xmm2, 0x20(%rsp)
movq %rsi, %r15
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rdi, %r12
movq 0x8(%rdi), %rsi
subq (%rdi), %rsi
sarq $0x3, %rsi
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xb85e
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
cmpl %ebx, %ebp
jge 0x7117
movq 0x40(%rsp), %r10
movq 0x48(%rsp), %rdx
cmpq %rdx, %r10
sete %al
movq %r10, %rcx
addq $0x8, %rcx
movq %rcx, 0x28(%rsp)
cmpq %rdx, %rcx
sete %cl
orb %al, %cl
movb %cl, 0xe(%rsp)
movslq %r13d, %rcx
leaq 0x3f(%rcx), %r8
testq %rcx, %rcx
cmovnsq %rcx, %r8
movq 0xa0(%rsp), %rax
sarq $0x6, %r8
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq 0x3f(%rsi), %rdi
andq %rcx, %rdi
xorl %r9d, %r9d
cmpq %rsi, %rdi
movq 0x98(%rsp), %rsi
movq (%rsi), %rsi
leaq (%rcx,%rcx,2), %rdi
movq -0x18(%rsi,%rdi,8), %rsi
movq %rsi, 0x30(%rsp)
movq (%r12), %r11
movq 0x8(%r12), %r12
movq (%r14), %r14
movq (%r15), %r15
setbe %r9b
leaq -0x8(,%r9,8), %r13
movl %ebx, %esi
movl $0x1, %ebx
shlq %cl, %rbx
movq (%rax), %rcx
movslq %ebp, %rbp
movslq %esi, %r9
shlq $0x3, %r8
cmpq %r12, %r11
je 0x7089
movq %r11, %rax
movq %r10, %rsi
movsd (%rax), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rax
addq $0x8, %rsi
cmpq %r12, %rax
jne 0x7070
movsd (%r11,%rbp,8), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, (%r10,%rbp,8)
movq %r10, %rdi
cmpb $0x0, 0xe(%rsp)
jne 0x70c7
movq 0x28(%rsp), %rax
movq %r10, %rsi
movsd (%rax), %xmm0
ucomisd (%rsi), %xmm0
movq %rax, %rdi
ja 0x70bb
movq %rsi, %rdi
addq $0x8, %rax
movq %rdi, %rsi
cmpq %rdx, %rax
jne 0x70ab
movl %edi, %eax
subl %r10d, %eax
shrl $0x3, %eax
movq 0x30(%rsp), %rsi
movw %ax, (%rsi,%rbp,2)
movslq (%r14,%rbp,4), %rax
leaq (%rax,%rax,4), %rax
movq (%r15,%rax,8), %rax
addq %r8, %rax
testq %rbx, (%r13,%rax)
setne %al
xorb 0x90(%rsp), %al
movsd 0x38(%rsp), %xmm0
jne 0x7102
movapd %xmm1, %xmm0
addsd (%rdi), %xmm0
movsd %xmm0, (%rcx,%rbp,8)
incq %rbp
cmpq %r9, %rbp
jne 0x7065
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x7126
callq 0x5410
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq