// File: PeterDenton[P]Nu-Pert/src/Mixed.cpp
// Function: Mixed::Palphabeta(int, int, double, double, double, int)
double Palphabeta(int alpha, int beta, double a, double LE, double delta, int order)
{
	assert (alpha >= 0 && alpha <= 2); // alpha valid for 0, 1, 2
	assert (beta >= 0 && beta <= 2); // beta valid for 0, 1, 2
	assert (order >= 0 && order <= 2); // order valid for 0, (1), 2

	double L2E = km_per_GeV_to_per_eV2 * LE / 2; // in eV^-2 now

	// See eq. 4.0.1 or eq. 3.12 in arXiv:1505.01826
	std::complex<double> A(0, 0);
	A += Talphabetai(alpha, beta, 0, a, delta, order) * std::complex<double>(cos(Check::l1(a, order) * L2E), -sin(Check::l1(a, order) * L2E));
	A += Talphabetai(alpha, beta, 1, a, delta, order) * std::complex<double>(cos(Check::l2(a, order) * L2E), -sin(Check::l2(a, order) * L2E));
	A += Talphabetai(alpha, beta, 2, a, delta, order) * std::complex<double>(cos(Check::l3(a, order) * L2E), -sin(Check::l3(a, order) * L2E));

	return std::norm(A);
}

// Assembly:
subq $0xf8, %rsp
movl %edi, 0xf4(%rsp)
movl %esi, 0xf0(%rsp)
movsd %xmm0, 0xe8(%rsp)
movsd %xmm1, 0xe0(%rsp)
movsd %xmm2, 0xd8(%rsp)
movl %edx, 0xd4(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xf4(%rsp)
movb %al, 0x27(%rsp)
jl 0xf1a6
cmpl $0x2, 0xf4(%rsp)
setle %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xf1b0
jmp 0xf1b2
jmp 0xf1d1
leaq 0x2fc6(%rip), %rdi      # 0x1217f
leaq 0x38eb(%rip), %rsi      # 0x12aab
movl $0x7f, %edx
leaq 0x3939(%rip), %rcx      # 0x12b05
callq 0x20d0
xorl %eax, %eax
cmpl $0x0, 0xf0(%rsp)
movb %al, 0x26(%rsp)
jl 0xf1f0
cmpl $0x2, 0xf0(%rsp)
setle %al
movb %al, 0x26(%rsp)
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0xf1fa
jmp 0xf1fc
jmp 0xf21b
leaq 0x2fe1(%rip), %rdi      # 0x121e4
leaq 0x38a1(%rip), %rsi      # 0x12aab
movl $0x80, %edx
leaq 0x38ef(%rip), %rcx      # 0x12b05
callq 0x20d0
xorl %eax, %eax
cmpl $0x0, 0xd4(%rsp)
movb %al, 0x25(%rsp)
jl 0xf23a
cmpl $0x2, 0xd4(%rsp)
setle %al
movb %al, 0x25(%rsp)
movb 0x25(%rsp), %al
testb $0x1, %al
jne 0xf244
jmp 0xf246
jmp 0xf265
leaq 0x2de3(%rip), %rdi      # 0x12030
leaq 0x3857(%rip), %rsi      # 0x12aab
movl $0x81, %edx
leaq 0x38a5(%rip), %rcx      # 0x12b05
callq 0x20d0
leaq 0x306c(%rip), %rax      # 0x122d8
movsd (%rax), %xmm0
mulsd 0xe0(%rsp), %xmm0
movsd 0x2d87(%rip), %xmm1     # 0x12008
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0xb8(%rsp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x4750
movl 0xf4(%rsp), %edi
movl 0xf0(%rsp), %esi
movsd 0xe8(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
movl 0xd4(%rsp), %ecx
xorl %edx, %edx
callq 0xef30
movsd %xmm0, 0x98(%rsp)
movsd %xmm1, 0xa0(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2810
mulsd 0xc8(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x8(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2810
mulsd 0xc8(%rsp), %xmm0
callq 0x2060
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
leaq 0x88(%rsp), %rdi
callq 0x4750
leaq 0x98(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0xa8(%rsp)
movsd %xmm1, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x4780
movl 0xf4(%rsp), %edi
movl 0xf0(%rsp), %esi
movsd 0xe8(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
movl 0xd4(%rsp), %ecx
movl $0x1, %edx
callq 0xef30
movsd %xmm0, 0x68(%rsp)
movsd %xmm1, 0x70(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2a80
mulsd 0xc8(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x10(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2a80
mulsd 0xc8(%rsp), %xmm0
callq 0x2060
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
leaq 0x58(%rsp), %rdi
callq 0x4750
leaq 0x68(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0x78(%rsp)
movsd %xmm1, 0x80(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x4780
movl 0xf4(%rsp), %edi
movl 0xf0(%rsp), %esi
movsd 0xe8(%rsp), %xmm0
movsd 0xd8(%rsp), %xmm1
movl 0xd4(%rsp), %ecx
movl $0x2, %edx
callq 0xef30
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2cf0
mulsd 0xc8(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x18(%rsp)
movsd 0xe8(%rsp), %xmm0
movl 0xd4(%rsp), %edi
callq 0x2cf0
mulsd 0xc8(%rsp), %xmm0
callq 0x2060
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
leaq 0x28(%rsp), %rdi
callq 0x4750
leaq 0x38(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0x48(%rsp)
movsd %xmm1, 0x50(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x4780
leaq 0xb8(%rsp), %rdi
callq 0x47d0
addq $0xf8, %rsp
retq
nop