// File: /workspace/github_cpp_makefile_star2_O3/PeterDenton[P]Nu-Pert/src/Check.cpp
// Function: Check::W(double, int)
Matrix<std::complex<double> > W(double a, int order)
{
	assert (order >= 0 && order <= 2); // order valid for 0, 1, 2

	Matrix<std::complex<double> > W(3, 3);
	double e31, e32, coef;

	switch (order)
	{
		case 2:
			// Second order from eq. 3.2.6
			coef = -pow(epsp(a) * Dmsqee, 2) / 2.;
			W(0, 0) += coef * pow(sin(psi(a)) / Dl31(a), 2);
			W(1, 1) += coef * pow(cos(psi(a)) / Dl32(a), 2);
			W(2, 2) += coef * (pow(sin(psi(a)) / Dl31(a), 2) + pow(cos(psi(a)) / Dl32(a), 2));
			W(1, 0) += coef * s2psi(a) / (Dl31(a) * Dl21(a));
			W(0, 1) += -coef * s2psi(a) / (Dl32(a) * Dl21(a));

		case 1:
			// First order from eq. 3.2.5
			e31 = epsp(a) * Dmsqee * sin(psi(a)) / Dl31(a);
			e32 = epsp(a) * Dmsqee * cos(psi(a)) / Dl32(a);
			W(0, 2) += -e31;
			W(1, 2) += e32;
			W(2, 0) += e31;
			W(2, 1) += -e32;

		case 0:
			// zeroth order
			for (int i = 0; i < 3; i++)
				W(i, i) += 1;
	}
	return W;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movsd %xmm0, (%rsp)
cmpl $0x3, %esi
jae 0x3241
movl %esi, %ebp
movq %rdi, %rbx
movl $0x3, %esi
movl $0x3, %edx
callq 0xa076
testl %ebp, %ebp
je 0x320b
cmpl $0x1, %ebp
je 0x30a0
movsd (%rsp), %xmm0
callq 0x39d8
movapd %xmm0, 0x30(%rsp)
leaq 0x103da(%rip), %rax     # 0x13188
movapd 0x30(%rsp), %xmm0
mulsd (%rax), %xmm0
movapd %xmm0, 0x30(%rsp)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x2070
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa1d2
movapd 0x30(%rsp), %xmm0
mulsd %xmm0, %xmm0
mulsd 0xb1ff(%rip), %xmm0     # 0xe010
movsd 0x18(%rsp), %xmm2
subsd 0x10(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
movapd %xmm0, 0x30(%rsp)
mulsd %xmm0, %xmm1
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x22c0
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, 0x10(%rsp)
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0xa1d2
movsd 0x18(%rsp), %xmm1
subsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
mulsd 0x30(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x2070
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x22c0
movsd %xmm0, 0x28(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x20(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, 0x48(%rsp)
movl $0x2, %esi
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa1d2
movsd 0x18(%rsp), %xmm1
subsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
movsd 0x20(%rsp), %xmm2
subsd 0x48(%rsp), %xmm2
movsd 0x28(%rsp), %xmm1
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
mulsd 0x30(%rsp), %xmm1
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
movsd (%rsp), %xmm0
callq 0x2c3e
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, 0x28(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x20(%rsp)
movl $0x1, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xa1d2
movsd 0x8(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
subsd 0x10(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
subsd 0x20(%rsp), %xmm2
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd (%rsp), %xmm0
callq 0x2c3e
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, 0x28(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x20(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xa1d2
movapd 0x30(%rsp), %xmm0
xorpd 0xafb2(%rip), %xmm0     # 0xe020
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
subsd 0x20(%rsp), %xmm2
mulsd %xmm0, %xmm2
divsd %xmm2, %xmm1
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
movsd (%rsp), %xmm0
callq 0x39d8
movsd %xmm0, 0x30(%rsp)
leaq 0x100d1(%rip), %r14     # 0x13188
movsd (%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x2070
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x28(%rsp)
movsd (%rsp), %xmm0
callq 0x2590
movsd %xmm0, 0x20(%rsp)
movsd (%rsp), %xmm0
callq 0x39d8
movsd %xmm0, 0x8(%rsp)
movsd (%r14), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd (%rsp), %xmm0
callq 0x29c5
callq 0x22c0
movsd %xmm0, 0x58(%rsp)
movsd (%rsp), %xmm0
callq 0x6b14
movsd %xmm0, 0x50(%rsp)
movsd (%rsp), %xmm0
callq 0x2745
movsd %xmm0, (%rsp)
movl $0x2, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xa1d2
movsd 0x28(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd (%rax), %xmm0
movsd %xmm1, 0x30(%rsp)
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl $0x1, %esi
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa1d2
movsd 0x50(%rsp), %xmm0
subsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
mulsd 0x48(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd (%rax), %xmm0
movsd %xmm1, 0x8(%rsp)
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl $0x2, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xa1d2
movsd 0x30(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0xa1d2
movsd (%rax), %xmm0
subsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0xa1d2
movsd (%rax), %xmm0
addsd 0xadf0(%rip), %xmm0     # 0xe018
movsd %xmm0, (%rax)
incq %r14
cmpq $0x3, %r14
jne 0x320e
movq %rbx, %rax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0xade8(%rip), %rdi      # 0xe030
leaq 0xadfa(%rip), %rsi      # 0xe049
leaq 0xaebb(%rip), %rcx      # 0xe111
movl $0x77, %edx
callq 0x20f0
jmp 0x3262
movq %rax, %r14
movq %rbx, %rdi
callq 0xa1c4
movq %r14, %rdi
callq 0x22a0