// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1c8, %rsp            # imm = 0x1C8
movq %r9, 0x108(%rsp)
movq %r8, 0x110(%rsp)
movq %rcx, 0xb0(%rsp)
movl %edx, %ebx
movq %rsi, 0x118(%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), %r14
movl 0x18(%rax), %r15d
subq (%rax), %r14
movl %ecx, 0xc(%rsp)
movslq %ecx, %r12
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
leaq 0x80(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf0(%rsp), %rcx
movq %r12, %rsi
callq 0xb8e8
leaq (%r15,%r14,8), %rax
movq %rax, 0x40(%rsp)
movslq %eax, %r14
leaq 0x120(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
movq %r14, %rsi
callq 0xba00
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x7231
callq 0x5410
leaq 0x80(%rsp), %rdx
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xd8(%rsp), %rcx
movq %r12, %rsi
callq 0xb8e8
leaq 0xf0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0xb(%rsp), %rcx
movq %r14, %rsi
callq 0xba00
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x7284
callq 0x5410
movq %r14, 0x138(%rsp)
movsd 0x31d84(%rip), %xmm0    # 0x39018
movq 0xb0(%rsp), %r14
subsd 0x520(%r14), %xmm0
callq 0x5370
movsd %xmm0, 0x68(%rsp)
movsd 0x520(%r14), %xmm0
callq 0x5370
movsd %xmm0, 0x10(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movq %r12, 0x70(%rsp)
movq %r12, %rsi
callq 0xba90
movsd 0x31d3a(%rip), %xmm0    # 0x39020
maxsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movslq %ebx, %rdx
movq %rdx, 0x78(%rsp)
cmpq %rax, 0x8(%rcx)
je 0x73be
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x78(%rsp), %rcx
movl %ecx, %ebx
xorl %r14d, %r14d
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
leaq (%rcx,%rcx,4), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq %r13, %rbx
je 0x7397
movslq %ebp, %rbp
movq 0xd8(%rsp), %rcx
movl %r13d, (%rcx,%rbp,4)
movq (%rax,%r12,8), %rcx
movb (%rcx), %cl
movq (%rax,%r14), %rax
xorb (%rax), %cl
testb $0x1, %cl
je 0x7370
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd 0x58(%rsp), %xmm1
jmp 0x7381
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd 0x68(%rsp), %xmm1
subsd %xmm0, %xmm1
movq 0x120(%rsp), %rax
movq (%rax), %rax
movsd %xmm1, (%rax,%rbp,8)
incl %ebp
incq %r13
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
addq $0x28, %r14
cmpq %r13, %rcx
ja 0x7338
cmpl $0x2, 0x40(%rsp)
jl 0x773d
movl 0xc(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x40(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x140(%rsp)
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %rcx, 0xa0(%rsp)
movl %eax, %r15d
movl $0x1, %ebx
movq 0x78(%rsp), %rax
leaq (%rax,%rax,4), %rax
movq %rax, 0xa8(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0xa8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, %r12d
movl %ebx, %ecx
shlq %cl, %r12
movq %rbx, %rcx
shrq $0x6, %rcx
movq %rcx, 0xd0(%rsp)
movq (%rax,%rcx,8), %rax
movq %rax, 0xc8(%rsp)
movq 0x118(%rsp), %rax
movq (%rax), %rax
movsd (%rax,%rbx,8), %xmm1
movq %rbx, 0x50(%rsp)
subsd -0x8(%rax,%rbx,8), %xmm1
divsd 0x31bb5(%rip), %xmm1    # 0x39028
movq 0xb0(%rsp), %rax
movsd 0x4f0(%rax), %xmm0
mulsd 0x31ba5(%rip), %xmm0    # 0x39030
mulsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x57e0
movapd %xmm0, %xmm1
movsd 0x31b72(%rip), %xmm0    # 0x39018
subsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0x5370
movsd %xmm0, 0xc0(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x5370
movsd %xmm0, 0xb8(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x7648
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, 0x80(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x70(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0xb(%rsp), %rcx
callq 0xb8e8
movq 0x120(%rsp), %rcx
movq 0x20(%rsp), %rax
movq (%rcx,%r13,8), %rcx
xorl %edx, %edx
movsd 0x31af4(%rip), %xmm0    # 0x39038
movsd 0xc0(%rsp), %xmm1
movsd 0xb8(%rsp), %xmm2
movapd %xmm2, %xmm3
cmpq %rdx, %r14
je 0x7563
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 0x7556
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
movsd %xmm3, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x20(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
subsd 0x18(%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 0x7589
testq %r12, 0xc8(%rsp)
setne %bl
callq 0x5370
movq 0xd8(%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 0xd0(%rsp), %rcx
testq %r12, (%rax,%rcx,8)
setne %al
xorb %bl, %al
movq 0x120(%rsp), %rax
movq (%rax,%rbp,8), %rax
movsd 0x58(%rsp), %xmm1
jne 0x7619
movsd 0x68(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
addsd %xmm0, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rax,%r14,8)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x763c
callq 0x5410
incq %r14
cmpq %r15, %r14
jne 0x74fb
movq 0x50(%rsp), %rbx
imull $0xc28f5c29, %ebx, %eax # imm = 0xC28F5C29
rorl $0x2, %eax
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
leaq 0x178(%rsp), %r14
leaq 0x20(%rsp), %r12
jae 0x772c
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
divsd 0x140(%rsp), %xmm0
mulsd 0x319a2(%rip), %xmm0    # 0x39028
movq %r12, %rdi
movl $0x3, %esi
callq 0x376f6
movq %r12, %rdi
leaq 0x31a3d(%rip), %rsi     # 0x390da
callq 0x5870
movq %r14, 0x168(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x76ce
movq %rdx, 0x168(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x178(%rsp)
jmp 0x76d7
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x170(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x42daf(%rip), %rdi     # 0x4a4a8
leaq 0x168(%rsp), %rsi
callq 0x371c8
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x7718
callq 0x5410
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x772c
callq 0x5410
incq %rbx
cmpq 0xa0(%rsp), %rbx
jb 0x7416
movq 0x40(%rsp), %rbx
shlq $0x20, %rbx
movabsq $-0x100000000, %r14     # imm = 0xFFFFFFFF00000000
cmpl $0x0, 0xc(%rsp)
jle 0x7795
leaq (%rbx,%r14), %rax
sarq $0x20, %rax
movq 0x120(%rsp), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movsd 0x318c1(%rip), %xmm0    # 0x39038
xorl %ecx, %ecx
movq 0x70(%rsp), %r13
movsd (%rax,%rcx,8), %xmm1
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %r13
jne 0x777e
jmp 0x77a2
movsd 0x3189b(%rip), %xmm1    # 0x39038
movq 0x70(%rsp), %r13
cmpl $0x0, 0xc(%rsp)
movsd %xmm1, 0x18(%rsp)
jle 0x7805
leaq (%rbx,%r14), %rax
sarq $0x20, %rax
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
leaq (%rax,%rax,2), %r12
movsd %xmm0, 0x10(%rsp)
movq 0x120(%rsp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r15,8), %xmm0
subsd 0x18(%rsp), %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
incq %r15
cmpq %r15, %r13
jne 0x77c2
jmp 0x7809
xorpd %xmm0, %xmm0
callq 0x5370
addsd 0x18(%rsp), %xmm0
leaq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x376f6
leaq 0x318b0(%rip), %rcx     # 0x390dd
leaq 0x80(%rsp), %rdi
movl $0xf, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d0
leaq 0x30(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x786b
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x7873
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x318c0(%rip), %rsi     # 0x39156
callq 0x5870
leaq 0x1b8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x78cb
movq %rdx, 0x1a8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x1b8(%rsp)
jmp 0x78d4
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x1a8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x42bae(%rip), %rdi     # 0x4a4a8
callq 0x371c8
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7911
callq 0x5410
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x7925
callq 0x5410
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x793b
callq 0x5410
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x79a1
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%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 0x316d4(%rip), %xmm0    # 0x39050
movq 0xf0(%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 0x7969
cmpl $0x2, 0x40(%rsp)
jl 0x7d27
movq 0x40(%rsp), %rcx
leal -0x2(%rcx), %edx
movl 0xc(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0xa0(%rsp)
movl %eax, %r15d
movq 0x78(%rsp), %rax
leaq (%rax,%rax,4), %rax
movq %rax, 0xa8(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
leaq 0x1(%rdx), %r12
movq 0xa8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, %r14d
movl %r12d, %ecx
shlq %cl, %r14
movq %r12, %rbp
shrq $0x6, %rbp
movq (%rax,%rbp,8), %rbx
movq 0x118(%rsp), %rax
movq (%rax), %rax
movsd 0x8(%rax,%rdx,8), %xmm1
movq %rdx, 0x50(%rsp)
subsd (%rax,%rdx,8), %xmm1
divsd 0x315ed(%rip), %xmm1    # 0x39028
movq 0xb0(%rsp), %rax
movsd 0x4f0(%rax), %xmm0
mulsd 0x315dd(%rip), %xmm0    # 0x39030
mulsd %xmm1, %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x57e0
movapd %xmm0, %xmm1
movsd 0x315aa(%rip), %xmm0    # 0x39018
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, 0xc(%rsp)
jle 0x7c32
leaq (%r12,%r12,2), %rax
movq %rax, 0xc0(%rsp)
movq 0x50(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0xb8(%rsp)
xorl %r12d, %r12d
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, 0x80(%rsp)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
leaq 0xb(%rsp), %rcx
callq 0xb8e8
movq 0x20(%rsp), %rax
movq 0xd8(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq (%rdx), %rdx
movq 0xf0(%rsp), %rsi
movq 0xc0(%rsp), %rdi
movq (%rsi,%rdi,8), %rsi
xorl %edi, %edi
movsd 0x3150a(%rip), %xmm0    # 0x39038
movsd 0x68(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0xd0(%rsp), %xmm3
movsd 0xc8(%rsp), %xmm4
testq %r14, %rbx
setne %r8b
movsd %xmm2, (%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
jne 0x7b76
movsd %xmm1, (%rax,%rdi,8)
movapd %xmm4, %xmm5
cmpq %rdi, %r12
je 0x7b83
movapd %xmm3, %xmm5
addsd (%rsi,%rdi,8), %xmm5
addsd (%rax,%rdi,8), %xmm5
movsd %xmm5, (%rax,%rdi,8)
maxsd %xmm0, %xmm5
incq %rdi
movapd %xmm5, %xmm0
cmpq %rdi, %r15
jne 0x7b4c
xorpd %xmm0, %xmm0
xorl %r13d, %r13d
movsd %xmm5, 0x18(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0x20(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
subsd 0x18(%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 0x7baf
callq 0x5370
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0xf0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm1, (%rax,%r12,8)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0x70(%rsp), %r13
je 0x7c26
callq 0x5410
incq %r12
cmpq %r15, %r12
jne 0x7acf
movq 0x50(%rsp), %rcx
imull $0xc28f5c29, %ecx, %eax # imm = 0xC28F5C29
rorl $0x2, %eax
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
leaq 0x158(%rsp), %r14
leaq 0x20(%rsp), %rbx
jae 0x7d1b
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
divsd 0xa0(%rsp), %xmm0
mulsd 0x313b8(%rip), %xmm0    # 0x39028
movq %rbx, %rdi
movl $0x3, %esi
callq 0x376f6
movq %rbx, %rdi
leaq 0x31453(%rip), %rsi     # 0x390da
callq 0x5870
movq %r14, 0x148(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7cb8
movq %rdx, 0x148(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x158(%rsp)
jmp 0x7cc1
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x150(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x427c5(%rip), %rdi     # 0x4a4a8
leaq 0x148(%rsp), %rsi
callq 0x371c8
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0x7d02
callq 0x5410
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x7d16
callq 0x5410
movq 0x50(%rsp), %rcx
leaq -0x1(%rcx), %rdx
testl %ecx, %ecx
jg 0x79e9
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x78(%rsp), %rcx
leaq (%rcx,%rcx,4), %rcx
movq (%rax,%rcx,8), %rcx
movq (%rcx), %rbx
cmpl $0x0, 0xc(%rsp)
jle 0x7dab
movq 0xd8(%rsp), %rcx
movq 0xf0(%rsp), %rdx
movq (%rdx), %rdx
movsd 0x312d7(%rip), %xmm0    # 0x39038
xorl %esi, %esi
movsd 0x68(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
leaq 0x30(%rsp), %r15
movslq (%rcx,%rsi,4), %rdi
leaq (%rdi,%rdi,4), %rdi
movq (%rax,%rdi,8), %rdi
movb (%rdi), %dil
xorb %bl, %dil
movapd %xmm2, %xmm3
testb $0x1, %dil
jne 0x7d94
movapd %xmm1, %xmm3
addsd (%rdx,%rsi,8), %xmm3
maxsd %xmm0, %xmm3
incq %rsi
movapd %xmm3, %xmm0
cmpq %rsi, %r13
jne 0x7d74
jmp 0x7dbe
movsd 0x31285(%rip), %xmm3    # 0x39038
movsd 0x58(%rsp), %xmm2
leaq 0x30(%rsp), %r15
movsd %xmm3, 0x18(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x7e40
xorpd %xmm0, %xmm0
xorl %r14d, %r14d
movsd %xmm0, 0x10(%rsp)
movq 0xd8(%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 0x7e06
movsd 0x68(%rsp), %xmm0
movq 0xf0(%rsp), %rax
movq (%rax), %rax
addsd (%rax,%r14,8), %xmm0
subsd 0x18(%rsp), %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incq %r14
cmpq %r14, %r13
movsd 0x58(%rsp), %xmm2
jne 0x7dd2
jmp 0x7e44
xorpd %xmm0, %xmm0
callq 0x5370
addsd 0x18(%rsp), %xmm0
leaq 0x80(%rsp), %rdi
movl $0x3, %esi
callq 0x376f6
leaq 0x31285(%rip), %rcx     # 0x390ed
leaq 0x80(%rsp), %rdi
movl $0xf, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d0
movq %r15, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7ea2
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x7eab
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x31288(%rip), %rsi     # 0x39156
callq 0x5870
leaq 0x198(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7f03
movq %rdx, 0x188(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x198(%rsp)
jmp 0x7f0c
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x188(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x42576(%rip), %rdi     # 0x4a4a8
callq 0x371c8
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x7f49
callq 0x5410
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
movq 0x138(%rsp), %rbx
je 0x7f60
callq 0x5410
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7f7a
callq 0x5410
leaq 0x20(%rsp), %rdx
movl $0x0, (%rdx)
movq 0x110(%rsp), %rdi
movq %rbx, %rsi
callq 0xbb1a
leaq 0x20(%rsp), %rdx
movq $0x0, (%rdx)
movq 0x108(%rsp), %rdi
movq %rbx, %rsi
callq 0xbb4e
cmpl $0x0, 0x40(%rsp)
jle 0x813d
movq 0x40(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x40(%rsp)
movl 0xc(%rsp), %r15d
xorl %r13d, %r13d
leaq 0x80(%rsp), %r14
leaq 0xb(%rsp), %r12
movabsq $-0x10000000000001, %rax # imm = 0xFFEFFFFFFFFFFFFF
movq %rax, 0x80(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xb8e8
cmpl $0x0, 0xc(%rsp)
jle 0x806e
movq 0x120(%rsp), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx), %rax
movq 0xf0(%rsp), %rdx
movq (%rdx,%rcx), %rcx
xorl %edx, %edx
movq 0x20(%rsp), %rsi
xorl %edi, %edi
movsd 0x30ff5(%rip), %xmm1    # 0x39038
movapd %xmm1, %xmm0
movsd (%rax,%rdx,8), %xmm1
addsd (%rcx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edx, %edi
movsd %xmm1, (%rsi,%rdx,8)
maxsd %xmm0, %xmm1
incq %rdx
cmpq %rdx, %r15
jne 0x8043
movslq %edi, %rbp
jmp 0x8078
movsd 0x30fc2(%rip), %xmm1    # 0x39038
xorl %ebp, %ebp
cmpl $0x0, 0xc(%rsp)
jle 0x80c8
xorpd %xmm2, %xmm2
xorl %ebx, %ebx
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x10(%rsp)
movq 0x20(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
subsd %xmm1, %xmm0
callq 0x57e0
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
addsd %xmm0, %xmm2
incq %rbx
cmpq %rbx, %r15
jne 0x808b
jmp 0x80cc
xorpd %xmm2, %xmm2
cmpl $0x0, 0xc(%rsp)
jle 0x80f0
movq 0x20(%rsp), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm2, %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x80da
movq 0xd8(%rsp), %rax
movl (%rax,%rbp,4), %eax
movq 0x110(%rsp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx,%r13,4)
movq 0x20(%rsp), %rdi
movsd (%rdi,%rbp,8), %xmm0
movq 0x108(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax,%r13,8)
testq %rdi, %rdi
je 0x812f
callq 0x5410
incq %r13
cmpq 0x40(%rsp), %r13
jb 0x7fe0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x814f
callq 0x5410
leaq 0xf0(%rsp), %rdi
callq 0xbb82
leaq 0x120(%rsp), %rdi
callq 0xbb82
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x82aa
jmp 0x82aa
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x819f
callq 0x5410
jmp 0x819f
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x81b8
callq 0x5410
jmp 0x81b8
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
jmp 0x8298
jmp 0x82aa
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x81ec
callq 0x5410
jmp 0x81ec
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x8205
callq 0x5410
jmp 0x8205
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x8298
jmp 0x82aa
movq %rax, %rbx
jmp 0x82bf
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x82cc
callq 0x5410
jmp 0x82cc
movq %rax, %rbx
jmp 0x82cc
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x82d9
callq 0x5410
jmp 0x82d9
movq %rax, %rbx
jmp 0x82d9
movq %rax, %rbx
movq 0x148(%rsp), %rdi
jmp 0x827f
jmp 0x828b
jmp 0x82aa
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x828e
callq 0x5410
jmp 0x828e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x82ad
callq 0x5410
jmp 0x82ad
jmp 0x82aa
jmp 0x82aa
jmp 0x82aa
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x82bf
callq 0x5410
leaq 0xf0(%rsp), %rdi
callq 0xbb82
leaq 0x120(%rsp), %rdi
callq 0xbb82
movq %rbx, %rdi
callq 0x57d0