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

	Matrix<std::complex<double> > W(3, 3);
	double c = cos(phi(a) - t13);
	double s = sin(phi(a) - t13);
	double coef = eps * c12 * s12 * Dmsqee;

	switch (order)
	{
		case 1:
			W(0, 1) += coef * c / Dl0m(a);
			W(1, 0) -= coef * c / Dl0m(a);
			W(1, 2) += coef * s / Dlp0(a);
			W(2, 1) -= coef * s / Dlp0(a);

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

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0x80(%rsp)
movq %rdi, %rax
movq %rax, 0x88(%rsp)
movq %rdi, 0xd0(%rsp)
movsd %xmm0, 0xc8(%rsp)
movl %esi, 0xc4(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xc4(%rsp)
movb %al, 0x93(%rsp)
jl 0x9b17
cmpl $0x1, 0xc4(%rsp)
setle %al
movb %al, 0x93(%rsp)
movb 0x93(%rsp), %al
testb $0x1, %al
jne 0x9b24
jmp 0x9b26
jmp 0x9b45
leaq 0x8a01(%rip), %rdi      # 0x1252e
leaq 0x8b06(%rip), %rsi      # 0x1263a
movl $0x5e, %edx
leaq 0x8b06(%rip), %rcx      # 0x12646
callq 0x20d0
movq 0x80(%rsp), %rdi
movb $0x0, 0xc3(%rsp)
movl $0x3, %edx
movq %rdx, %rsi
callq 0xcaa0
movsd 0xc8(%rsp), %xmm0
callq 0x94e0
movsd %xmm0, 0x78(%rsp)
jmp 0x9b78
movsd 0x78(%rsp), %xmm0
leaq 0xd66b(%rip), %rax      # 0x171f0
movsd (%rax), %xmm1
subsd %xmm1, %xmm0
callq 0x22d0
movsd %xmm0, 0xb8(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x94e0
movsd %xmm0, 0x70(%rsp)
jmp 0x9bb1
movsd 0x70(%rsp), %xmm0
leaq 0xd632(%rip), %rax      # 0x171f0
movsd (%rax), %xmm1
subsd %xmm1, %xmm0
callq 0x2060
movsd %xmm0, 0xa0(%rsp)
leaq 0xd62d(%rip), %rax      # 0x17208
movsd (%rax), %xmm0
leaq 0xd5e2(%rip), %rax      # 0x171c8
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
leaq 0xd5bb(%rip), %rax      # 0x171b0
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
leaq 0xd5fc(%rip), %rax      # 0x17200
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x6c(%rsp)
testl %eax, %eax
je 0x9e12
jmp 0x9c2a
movl 0x6c(%rsp), %eax
subl $0x1, %eax
je 0x9c5e
jmp 0x9e6f
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
callq 0xce00
jmp 0x9e9e
movsd 0x98(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x9560
movq 0x80(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0xce30
movq %rax, 0x60(%rsp)
jmp 0x9cb8
movsd 0x58(%rsp), %xmm0
movq 0x60(%rsp), %rdi
callq 0x4680
jmp 0x9cca
movsd 0x98(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x9560
movq 0x80(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x38(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %esi
callq 0xce30
movq %rax, 0x48(%rsp)
jmp 0x9d24
movsd 0x40(%rsp), %xmm0
movq 0x48(%rsp), %rdi
callq 0x91d0
jmp 0x9d36
movsd 0x98(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x95e0
movq 0x80(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, %esi
movl $0x2, %edx
callq 0xce30
movq %rax, 0x30(%rsp)
jmp 0x9d91
movsd 0x28(%rsp), %xmm0
movq 0x30(%rsp), %rdi
callq 0x4680
jmp 0x9da3
movsd 0x98(%rsp), %xmm0
movsd 0xa0(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x95e0
movq 0x80(%rsp), %rdi
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x2, %esi
movl $0x1, %edx
callq 0xce30
movq %rax, 0x18(%rsp)
jmp 0x9dfe
movsd 0x10(%rsp), %xmm0
movq 0x18(%rsp), %rdi
callq 0x91d0
jmp 0x9e10
jmp 0x9e12
movl $0x0, 0x94(%rsp)
cmpl $0x3, 0x94(%rsp)
jge 0x9e6d
movq 0x80(%rsp), %rdi
movslq 0x94(%rsp), %rdx
movq %rdx, %rsi
callq 0xce30
movq %rax, (%rsp)
jmp 0x9e45
movq (%rsp), %rdi
movsd 0x81c7(%rip), %xmm0     # 0x12018
callq 0x4680
jmp 0x9e58
jmp 0x9e5a
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x9e1d
jmp 0x9e6f
movb $0x1, 0xc3(%rsp)
testb $0x1, 0xc3(%rsp)
jne 0x9e8e
movq 0x80(%rsp), %rdi
callq 0xce00
movq 0x88(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0xb0(%rsp), %rdi
callq 0x22b0
nopl (%rax,%rax)