// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/viterbi.cpp
// Function: fwdbck(std::vector<std::vector<bool, std::allocator<bool>>, std::allocator<std::vector<bool, std::allocator<bool>>>> const&, std::vector<double, std::allocator<double>> const&, int, parameters const&, std::vector<int, std::allocator<int>>&, std::vector<double, std::allocator<double>>&)
void fwdbck(const vector<vector<bool> > &haps, const vector<double> &map, int indv_idx, const parameters &params, vector<int> &out_path, vector<double> &out_prob)
{
	int N_hap = haps.size()-1;	// The minus 1 accounts for the current haplotype.
	int N_pos = haps[0].size();

	vector<vector<double> > f(N_pos, vector<double>(N_hap, -numeric_limits<double>::max()));	// Lots of memory used here
	vector<vector<double> > b(N_pos, vector<double>(N_hap, -numeric_limits<double>::max()));	// Lots of memory used here

	double em_match = log(1.0 - params.p_error);
	double em_mismatch = max(log(params.p_error), -9999.9);

	vector<int> f_idx_to_hap_idx(N_hap);
	int idx_i=0;
	for (int i=0; i<haps.size(); i++)
	{
		if (i == indv_idx)
			continue;
		f_idx_to_hap_idx[idx_i] = i;

		if (haps[indv_idx][0] == haps[i][0])
			f[0][idx_i] = em_match - log(N_hap);
		else
			f[0][idx_i] = em_mismatch - log(N_hap);

		idx_i++;
	}

	for (int i=1; i < N_pos; i++)
	{
		bool allele = haps[indv_idx][i];
		double rho = 4.0*params.Ne*((map[i] - map[i-1])/100.0);

		double tmp = exp(-rho / N_hap);
		double p_rec = (1.0-tmp) / N_hap;
		double p_no_rec = tmp + p_rec;

		p_rec = log(p_rec);
		p_no_rec = log(p_no_rec);

		for (int j=0; j < N_hap; j++)	// Could parallelize this loop?
		{
			vector<double> tmp(N_hap, -numeric_limits<double>::max());
			double m=-numeric_limits<double>::max();
			for (int k=0; k<N_hap; k++)
			{
				if (j == k)
					tmp[k] = p_no_rec + f[i-1][k];
				else
					tmp[k] = p_rec + f[i-1][k];
				m = max(m, tmp[k]);
			}

			double s = 0;
			for (int k=0; k<N_hap; k++)
				s += exp(tmp[k] - m);
			s = log(s);
			s += m;

			if (haps[ f_idx_to_hap_idx[j] ][i] == allele)
				f[i][j] = s + em_match;
			else
				f[i][j] = s + em_mismatch;
		}

		if ((i % 100) == 0)
		{
			LOG.printLOG(output_log::dbl2str(double(i)/N_pos*100, 3) + "%\n");
		}
	}

	{
		double m=-numeric_limits<double>::max();
		for (int k=0; k<N_hap; k++)
			m = max(m, f[N_pos-1][k]);
		double post = 0;
		for (int k=0; k<N_hap; k++)
			post += exp(f[N_pos-1][k] - m);
		post = log(post);
		post += m;
		LOG.printLOG("Fwd posterior: " + LOG.dbl2str(post, 3) + "\n");
	}

	for (int i=0; i<b[0].size(); i++)
	{
		b[N_pos-1][i] = -log(N_hap);
	}

	for (int i=N_pos-2; i > -1; i--)
	{
		bool allele = haps[indv_idx][i+1];
		double rho = 4.0*params.Ne*((map[i+1] - map[i])/100.0);

		double tmp = exp(-rho / N_hap);
		double p_rec = (1.0-tmp) / N_hap;
		double p_no_rec = tmp + p_rec;

		p_rec = log(p_rec);
		p_no_rec = log(p_no_rec);

		for (int j=0; j < N_hap; j++)	// Could parallelize this loop?
		{
			vector<double> tmp(N_hap, -numeric_limits<double>::max());
			double m=-numeric_limits<double>::max();
			for (int k=0; k<N_hap; k++)
			{
				tmp[k] = em_mismatch;
				if (haps[ f_idx_to_hap_idx[k] ][i+1] == allele)
					tmp[k] = em_match;

				if (j == k)
					tmp[k] += p_no_rec + b[i+1][k];
				else
					tmp[k] += p_rec + b[i+1][k];

				m = max(m, tmp[k]);
			}

			double s = 0;
			for (int k=0; k<N_hap; k++)
				s += exp(tmp[k] - m);
			s = log(s);
			s += m;

			b[i][j] = s;
		}

		if ((i % 100) == 0)
		{
			LOG.printLOG(output_log::dbl2str(double(i)/N_pos*100, 3) + "%\n");
		}
	}

	{
		bool allele = haps[indv_idx][0];
		double m=-numeric_limits<double>::max();
		for (int k=0; k<N_hap; k++)
		{
			if (haps[ f_idx_to_hap_idx[k] ][0] == allele)
				m = max(m, b[0][k] + em_match);
			else
				m = max(m, b[0][k] + em_mismatch);
		}
		double post = 0;
		for (int k=0; k<N_hap; k++)
		{
			if (haps[ f_idx_to_hap_idx[k] ][0] == allele)
				post += exp((b[0][k] + em_match) - m);
			else
				post += exp((b[0][k] + em_mismatch) - m);
		}
		post = log(post);
		post += m;
		LOG.printLOG("Bwd posterior: " + LOG.dbl2str(post, 3) + "\n");
	}

	out_path.resize(N_pos, 0);
	out_prob.resize(N_pos,0);
	for (int i=0; i<N_pos; i++)
	{
		vector<double> post(N_hap, -numeric_limits<double>::max());
		double m = -numeric_limits<double>::max();
		int m_idx = 0;
		for (int j=0; j<N_hap; j++)
		{
			post[j] = f[i][j] + b[i][j];
			if (post[j] > m)
			{
				m = post[j];
				m_idx = j;
			}
		}
		double sum = 0;
		for (int j=0; j<N_hap; j++)
		{
			post[j] = exp(post[j] - m);
			sum += post[j];
		}
		for (int j=0; j<N_hap; j++)
			post[j] /= sum;

		out_path[i] = f_idx_to_hap_idx[m_idx];
		out_prob[i] = post[m_idx];
	}


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %r9, 0x118(%rsp)
movq %r8, 0x120(%rsp)
movq %rcx, 0xc0(%rsp)
movl %edx, %ebp
movq %rsi, 0x128(%rsp)
movq (%rdi), %rax
movq %rdi, 0x48(%rsp)
movq 0x8(%rdi), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xcccccccd, %ecx, %ecx # imm = 0xCCCCCCCD
decl %ecx
movq 0x10(%rax), %rbx
movl 0x18(%rax), %r14d
subq (%rax), %rbx
movl %ecx, 0x1c(%rsp)
movslq %ecx, %r15
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
leaq 0x88(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x28(%rsp), %rdi
leaq 0x100(%rsp), %rcx
movq %r15, %rsi
callq 0xb886
leaq (%r14,%rbx,8), %rax
movq %rax, 0x58(%rsp)
movslq %eax, %rbx
leaq 0x130(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0xe8(%rsp), %rcx
movq %rbx, %rsi
callq 0xb9a8
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x722d
callq 0x5410
leaq 0x88(%rsp), %rdx
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, (%rdx)
leaq 0x28(%rsp), %rdi
leaq 0xe8(%rsp), %rcx
movq %r15, %rsi
callq 0xb886
leaq 0x100(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq %rbx, %rsi
callq 0xb9a8
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x7280
callq 0x5410
movq %rbx, 0x148(%rsp)
movsd 0x30d88(%rip), %xmm0    # 0x38018
movq 0xc0(%rsp), %rbx
subsd 0x520(%rbx), %xmm0
callq 0x5370
movsd %xmm0, 0x68(%rsp)
movsd 0x520(%rbx), %xmm0
callq 0x5370
movsd %xmm0, 0x10(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r15, 0x70(%rsp)
movq %r15, %rsi
callq 0xba38
movsd 0x30d40(%rip), %xmm0    # 0x38020
maxsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movl %ebp, 0x84(%rsp)
movslq %ebp, %rdx
movq %rdx, 0xa8(%rsp)
cmpq %rax, %rcx
je 0x73cf
xorps %xmm0, %xmm0
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xa8(%rsp), %rdx
movl %edx, %ebx
xorl %r14d, %r14d
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
leaq (%rdx,%rdx,4), %rdx
movq %rdx, 0x20(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq %r13, %rbx
je 0x73b1
movslq %ebp, %rbp
movq 0xe8(%rsp), %rcx
movl %r13d, (%rcx,%rbp,4)
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movl (%rcx), %r15d
movq (%rax,%r14), %rax
xorl (%rax), %r15d
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd 0x68(%rsp), %xmm2
movsd 0x78(%rsp), %xmm1
testb $0x1, %r15b
jne 0x738f
movapd %xmm2, %xmm1
movq 0x130(%rsp), %rax
movq (%rax), %rax
subsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
incl %ebp
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
incq %r13
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
addq $0x28, %r14
cmpq %r13, %rdx
ja 0x7347
cmpl $0x2, 0x58(%rsp)
jl 0x774f
movslq 0x84(%rsp), %rax
movl 0x1c(%rsp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x58(%rsp), %rdx
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0x150(%rsp)
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rdx, 0xb0(%rsp)
movl %ecx, %r15d
movl $0x1, %ebx
leaq (%rax,%rax,4), %rax
movq %rax, 0xb8(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0xb8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, %r12d
movl %ebx, %ecx
shlq %cl, %r12
movl %ebx, %ecx
shrl $0x6, %ecx
movq %rcx, 0xe0(%rsp)
movq (%rax,%rcx,8), %rax
movq %rax, 0xd8(%rsp)
movq 0x128(%rsp), %rax
movq (%rax), %rax
movsd (%rax,%rbx,8), %xmm1
movq %rbx, 0x50(%rsp)
subsd -0x8(%rax,%rbx,8), %xmm1
divsd 0x30ba3(%rip), %xmm1    # 0x38028
movq 0xc0(%rsp), %rax
movsd 0x4f0(%rax), %xmm0
mulsd 0x30b93(%rip), %xmm0    # 0x38030
mulsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x57e0
movapd %xmm0, %xmm1
movsd 0x30b60(%rip), %xmm0    # 0x38018
subsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0x5370
movsd %xmm0, 0xd0(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd %xmm0, 0xc8(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x765a
movq 0x50(%rsp), %rcx
leaq -0x1(%rcx), %rax
leaq (%rax,%rax,2), %r13
leaq (%rcx,%rcx,2), %rbp
xorl %r14d, %r14d
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, 0x88(%rsp)
leaq 0x28(%rsp), %rdi
movq 0x70(%rsp), %rsi
leaq 0x88(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0xb886
movq 0x130(%rsp), %rcx
movq 0x28(%rsp), %rax
movq (%rcx,%r13,8), %rcx
xorl %edx, %edx
movsd 0x30ae2(%rip), %xmm0    # 0x38038
movsd 0xd0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm2
movapd %xmm2, %xmm3
cmpq %rdx, %r14
je 0x7575
movapd %xmm1, %xmm3
addsd (%rcx,%rdx,8), %xmm3
movsd %xmm3, (%rax,%rdx,8)
maxsd %xmm0, %xmm3
incq %rdx
movapd %xmm3, %xmm0
cmpq %rdx, %r15
jne 0x7568
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
movsd %xmm3, 0x20(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x28(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
subsd 0x20(%rsp), %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
incq %rbx
cmpq %rbx, %r15
jne 0x759b
testq %r12, 0xd8(%rsp)
setne %bl
callq 0x5370
movq 0xe8(%rsp), %rax
movslq (%rax,%r14,4), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rax
movq 0xe0(%rsp), %rcx
testq %r12, (%rax,%rcx,8)
setne %al
xorb %bl, %al
movq 0x130(%rsp), %rax
movq (%rax,%rbp,8), %rax
movsd 0x78(%rsp), %xmm1
jne 0x762b
movsd 0x68(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
addsd %xmm0, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rax,%r14,8)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x764e
callq 0x5410
incq %r14
cmpq %r15, %r14
jne 0x750d
movq 0x50(%rsp), %rbx
imull $0xc28f5c29, %ebx, %eax # imm = 0xC28F5C29
rorl $0x2, %eax
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
leaq 0x188(%rsp), %r14
leaq 0x28(%rsp), %r12
jae 0x773e
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
divsd 0x150(%rsp), %xmm0
mulsd 0x30990(%rip), %xmm0    # 0x38028
movq %r12, %rdi
movl $0x3, %esi
callq 0x373a0
movq %r12, %rdi
leaq 0x30a2b(%rip), %rsi     # 0x380da
callq 0x5870
movq %r14, 0x178(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x76e0
movq %rdx, 0x178(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x188(%rsp)
jmp 0x76e9
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x180(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x41d9d(%rip), %rdi     # 0x494a8
leaq 0x178(%rsp), %rsi
callq 0x36e72
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x772a
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x773e
callq 0x5410
incq %rbx
cmpq 0xb0(%rsp), %rbx
jb 0x742a
movq 0x58(%rsp), %rbx
shlq $0x20, %rbx
movabsq $-0x100000000, %r14     # imm = 0xFFFFFFFF00000000
xorpd %xmm1, %xmm1
cmpl $0x0, 0x1c(%rsp)
jle 0x77fc
leaq (%rbx,%r14), %rax
sarq $0x20, %rax
movq 0x130(%rsp), %rcx
leaq (%rax,%rax,2), %r15
movq (%rcx,%r15,8), %rax
movsd 0x308a7(%rip), %xmm2    # 0x38038
xorl %ecx, %ecx
movq 0x70(%rsp), %r13
movapd %xmm2, %xmm0
movsd (%rax,%rcx,8), %xmm2
maxsd %xmm0, %xmm2
incq %rcx
cmpq %rcx, %r13
jne 0x7798
cmpl $0x0, 0x1c(%rsp)
jle 0x7811
xorpd %xmm1, %xmm1
xorl %r12d, %r12d
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x20(%rsp)
movq 0x130(%rsp), %rax
movq (%rax,%r15,8), %rax
movsd (%rax,%r12,8), %xmm0
subsd %xmm2, %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
incq %r12
cmpq %r12, %r13
jne 0x77bb
jmp 0x7817
movsd 0x30834(%rip), %xmm0    # 0x38038
movsd %xmm0, 0x10(%rsp)
movq 0x70(%rsp), %r13
jmp 0x7817
movsd %xmm2, 0x10(%rsp)
movapd %xmm1, %xmm0
callq 0x5370
addsd 0x10(%rsp), %xmm0
leaq 0x88(%rsp), %rdi
movl $0x3, %esi
callq 0x373a0
leaq 0x3089e(%rip), %rcx     # 0x380dd
leaq 0x88(%rsp), %rdi
movl $0xf, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d0
leaq 0x38(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x787d
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x7885
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x308ae(%rip), %rsi     # 0x38156
callq 0x5870
leaq 0x1c8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x78dd
movq %rdx, 0x1b8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1c8(%rsp)
jmp 0x78e6
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x1b8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x41b9c(%rip), %rdi     # 0x494a8
callq 0x36e72
movq 0x1b8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7923
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %r15
cmpq %r15, %rdi
je 0x7937
callq 0x5410
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x794d
callq 0x5410
movq 0x100(%rsp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x79b3
xorps %xmm0, %xmm0
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq %r14, %rbx
sarq $0x20, %rbx
xorl %r14d, %r14d
leaq (%rbx,%rbx,2), %rbx
movsd 0x10(%rsp), %xmm0
callq 0x5370
xorpd 0x306c2(%rip), %xmm0    # 0x38050
movq 0x100(%rsp), %rax
movq (%rax,%rbx,8), %rcx
movlpd %xmm0, (%rcx,%r14,8)
incq %r14
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x797b
movq 0x58(%rsp), %rcx
cmpl $0x1, %ecx
jle 0x7d52
leal -0x2(%rcx), %esi
movslq 0x84(%rsp), %rdx
movl 0x1c(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0xb0(%rsp)
movl %eax, %r15d
movq %rdx, 0xa8(%rsp)
leaq (%rdx,%rdx,4), %rax
movq %rax, 0xb8(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
leaq 0x1(%rsi), %r12
movq 0xb8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, %r14d
movl %r12d, %ecx
shlq %cl, %r14
movl %r12d, %ebp
shrl $0x6, %ebp
movq (%rax,%rbp,8), %rbx
movq 0x128(%rsp), %rax
movq (%rax), %rax
movsd 0x8(%rax,%rsi,8), %xmm1
movq %rsi, 0x50(%rsp)
subsd (%rax,%rsi,8), %xmm1
divsd 0x305d3(%rip), %xmm1    # 0x38028
movq 0xc0(%rsp), %rax
movsd 0x4f0(%rax), %xmm0
mulsd 0x305c3(%rip), %xmm0    # 0x38030
mulsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x57e0
movapd %xmm0, %xmm1
movsd 0x30590(%rip), %xmm0    # 0x38018
subsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0x5370
movsd %xmm0, 0xe0(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd %xmm0, 0xd8(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x7c53
leaq (%r12,%r12,2), %rax
movq %rax, 0xd0(%rsp)
movq 0x50(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0xc8(%rsp)
xorl %r12d, %r12d
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, 0x88(%rsp)
leaq 0x28(%rsp), %rdi
movq %r13, %rsi
leaq 0x88(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0xb886
movq 0x28(%rsp), %rax
movq 0xe8(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq (%rdx), %rdx
movq 0x100(%rsp), %rsi
movq 0xd0(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
xorl %edi, %edi
movsd 0x304f0(%rip), %xmm0    # 0x38038
movsd 0x68(%rsp), %xmm2
movsd 0x78(%rsp), %xmm3
movsd 0xe0(%rsp), %xmm4
movsd 0xd8(%rsp), %xmm5
testq %r14, %rbx
setne %r8b
movsd %xmm3, (%rax,%rdi,8)
movslq (%rcx,%rdi,4), %r9
leaq (%r9,%r9,4), %r9
movq (%rdx,%r9,8), %r9
testq %r14, (%r9,%rbp,8)
setne %r9b
xorb %r8b, %r9b
movapd %xmm3, %xmm6
jne 0x7b98
movsd %xmm2, (%rax,%rdi,8)
movapd %xmm2, %xmm6
movapd %xmm5, %xmm1
cmpq %rdi, %r12
je 0x7ba5
movapd %xmm4, %xmm1
addsd (%rsi,%rdi,8), %xmm1
addsd %xmm1, %xmm6
movsd %xmm6, (%rax,%rdi,8)
maxsd %xmm0, %xmm6
incq %rdi
movapd %xmm6, %xmm0
cmpq %rdi, %r15
jne 0x7b66
xorpd %xmm0, %xmm0
xorl %r13d, %r13d
movsd %xmm6, 0x20(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x28(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
subsd 0x20(%rsp), %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
incq %r13
cmpq %r13, %r15
jne 0x7bd0
callq 0x5370
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x100(%rsp), %rax
movq 0xc8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm1, (%rax,%r12,8)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
movq 0x70(%rsp), %r13
je 0x7c47
callq 0x5410
incq %r12
cmpq %r15, %r12
jne 0x7ae9
movq 0x50(%rsp), %rcx
imull $0xc28f5c29, %ecx, %eax # imm = 0xC28F5C29
rorl $0x2, %eax
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
leaq 0x168(%rsp), %r14
leaq 0x28(%rsp), %rbx
jae 0x7d3c
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
divsd 0xb0(%rsp), %xmm0
mulsd 0x30397(%rip), %xmm0    # 0x38028
movq %rbx, %rdi
movl $0x3, %esi
callq 0x373a0
movq %rbx, %rdi
leaq 0x30432(%rip), %rsi     # 0x380da
callq 0x5870
movq %r14, 0x158(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7cd9
movq %rdx, 0x158(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x168(%rsp)
jmp 0x7ce2
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x160(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x417a4(%rip), %rdi     # 0x494a8
leaq 0x158(%rsp), %rsi
callq 0x36e72
movq 0x158(%rsp), %rdi
cmpq %r14, %rdi
je 0x7d23
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x7d37
callq 0x5410
movq 0x50(%rsp), %rcx
movq %rcx, %rax
decq %rax
testl %ecx, %ecx
movq %rax, %rsi
jg 0x7a04
leaq 0x38(%rsp), %r15
xorpd %xmm3, %xmm3
cmpl $0x0, 0x1c(%rsp)
movsd 0x68(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
jle 0x7e60
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0xa8(%rsp), %rcx
leaq (%rcx,%rcx,4), %rcx
movq (%rax,%rcx,8), %rcx
movq (%rcx), %rbx
movq 0xe8(%rsp), %rcx
movq 0x100(%rsp), %rdx
movq (%rdx), %rdx
movsd 0x30295(%rip), %xmm0    # 0x38038
xorl %esi, %esi
movslq (%rcx,%rsi,4), %rdi
leaq (%rdi,%rdi,4), %rdi
movq (%rax,%rdi,8), %rdi
movb (%rdi), %dil
xorb %bl, %dil
movapd %xmm2, %xmm4
testb $0x1, %dil
jne 0x7dc5
movapd %xmm1, %xmm4
addsd (%rdx,%rsi,8), %xmm4
maxsd %xmm0, %xmm4
incq %rsi
movapd %xmm4, %xmm0
cmpq %rsi, %r13
jne 0x7da5
cmpl $0x0, 0x1c(%rsp)
jle 0x7e70
xorpd %xmm3, %xmm3
xorl %r14d, %r14d
movsd %xmm3, 0x20(%rsp)
movq 0xe8(%rsp), %rax
movslq (%rax,%r14,4), %rax
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,4), %rax
movq (%rcx,%rax,8), %rax
movl (%rax), %eax
xorl %ebx, %eax
movapd %xmm2, %xmm0
testb $0x1, %al
jne 0x7e20
movsd 0x68(%rsp), %xmm0
movq 0x100(%rsp), %rax
movq (%rax), %rax
addsd (%rax,%r14,8), %xmm0
subsd %xmm4, %xmm0
movsd %xmm4, 0x10(%rsp)
callq 0x57e0
movsd 0x10(%rsp), %xmm4
movsd 0x20(%rsp), %xmm3
addsd %xmm0, %xmm3
incq %r14
cmpq %r14, %r13
movsd 0x78(%rsp), %xmm2
jne 0x7dec
jmp 0x7e76
movsd 0x301d0(%rip), %xmm0    # 0x38038
movsd %xmm0, 0x10(%rsp)
jmp 0x7e76
movsd %xmm4, 0x10(%rsp)
movapd %xmm3, %xmm0
callq 0x5370
addsd 0x10(%rsp), %xmm0
leaq 0x88(%rsp), %rdi
movl $0x3, %esi
callq 0x373a0
leaq 0x3024f(%rip), %rcx     # 0x380ed
leaq 0x88(%rsp), %rdi
movl $0xf, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d0
movq %r15, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7ed8
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x7ee1
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30252(%rip), %rsi     # 0x38156
callq 0x5870
leaq 0x1a8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7f39
movq %rdx, 0x198(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1a8(%rsp)
jmp 0x7f42
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x198(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x41540(%rip), %rdi     # 0x494a8
callq 0x36e72
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x7f7f
callq 0x5410
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
movq 0x148(%rsp), %rbx
je 0x7f96
callq 0x5410
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x7fb0
callq 0x5410
leaq 0x28(%rsp), %rdx
movl $0x0, (%rdx)
movq 0x120(%rsp), %rdi
movq %rbx, %rsi
callq 0xbac4
leaq 0x28(%rsp), %rdx
movq $0x0, (%rdx)
movq 0x118(%rsp), %rdi
movq %rbx, %rsi
callq 0xbaf8
movq 0x58(%rsp), %r14
testl %r14d, %r14d
jle 0x8166
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl 0x1c(%rsp), %r15d
xorl %r13d, %r13d
leaq 0x28(%rsp), %rbx
leaq 0x88(%rsp), %r12
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, 0x88(%rsp)
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
movq %r12, %rdx
leaq 0xf(%rsp), %rcx
callq 0xb886
movq 0x28(%rsp), %rdi
cmpl $0x0, 0x1c(%rsp)
jle 0x8119
movq 0x130(%rsp), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx), %rax
movq 0x100(%rsp), %rdx
movq (%rdx,%rcx), %rcx
xorl %edx, %edx
xorl %esi, %esi
movsd 0x2ffc0(%rip), %xmm1    # 0x38038
movapd %xmm1, %xmm0
movsd (%rax,%rdx,8), %xmm1
addsd (%rcx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edx, %esi
movsd %xmm1, (%rdi,%rdx,8)
maxsd %xmm0, %xmm1
incq %rdx
cmpq %rdx, %r15
jne 0x8078
movslq %esi, %rbp
cmpl $0x0, 0x1c(%rsp)
jle 0x8125
movq %rbx, %r12
xorpd %xmm2, %xmm2
xorl %ebx, %ebx
movsd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd (%rdi,%rbx,8), %xmm0
subsd %xmm1, %xmm0
callq 0x57e0
movsd 0x20(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
movq 0x28(%rsp), %rdi
movsd %xmm0, (%rdi,%rbx,8)
addsd %xmm0, %xmm2
incq %rbx
cmpq %rbx, %r15
jne 0x80b1
cmpl $0x0, 0x1c(%rsp)
movq %r12, %rbx
jle 0x811d
xorl %eax, %eax
leaq 0x88(%rsp), %r12
movsd (%rdi,%rax,8), %xmm0
divsd %xmm2, %xmm0
movsd %xmm0, (%rdi,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0x8101
jmp 0x8125
xorl %ebp, %ebp
jmp 0x8125
leaq 0x88(%rsp), %r12
movq 0xe8(%rsp), %rax
movl (%rax,%rbp,4), %eax
movq 0x120(%rsp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx,%r13,4)
movsd (%rdi,%rbp,8), %xmm0
movq 0x118(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax,%r13,8)
callq 0x5410
incq %r13
cmpq %r14, %r13
jb 0x8011
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x8178
callq 0x5410
leaq 0x100(%rsp), %rdi
callq 0xbb2c
leaq 0x130(%rsp), %rdi
callq 0xbb2c
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82d3
jmp 0x82d3
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x81c8
callq 0x5410
jmp 0x81c8
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x81e1
callq 0x5410
jmp 0x81e1
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
jmp 0x82c1
jmp 0x82d3
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r15, %rdi
je 0x8215
callq 0x5410
jmp 0x8215
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x822e
callq 0x5410
jmp 0x822e
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x82c1
jmp 0x82d3
movq %rax, %rbx
jmp 0x82e8
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x82f5
callq 0x5410
jmp 0x82f5
movq %rax, %rbx
jmp 0x82f5
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x8302
callq 0x5410
jmp 0x8302
movq %rax, %rbx
jmp 0x8302
movq %rax, %rbx
movq 0x158(%rsp), %rdi
jmp 0x82a8
jmp 0x82b4
jmp 0x82d3
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x82b7
callq 0x5410
jmp 0x82b7
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x82d6
callq 0x5410
jmp 0x82d6
jmp 0x82d3
jmp 0x82d3
jmp 0x82d3
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x82e8
callq 0x5410
leaq 0x100(%rsp), %rdi
callq 0xbb2c
leaq 0x130(%rsp), %rdi
callq 0xbb2c
movq %rbx, %rdi
callq 0x57d0