// File: PeterDenton[P]Nu-Pert/src/Hyperbolas.cpp
// Function: Hyperbolas::Palphabeta(int, int, double, double, double)
double Palphabeta(int alpha, int beta, double a, double LE, double delta)
{
	assert (alpha >= 0 && alpha <= 2); // alpha valid for 0, 1, 2
	assert (beta >= 0 && beta <= 2); // beta 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) * std::complex<double>(cos(Hyperbolas::l1(a) * L2E), -sin(Hyperbolas::l1(a) * L2E));
	A += Talphabetai(alpha, beta, 1, a, delta) * std::complex<double>(cos(Hyperbolas::l2(a) * L2E), -sin(Hyperbolas::l2(a) * L2E));
	A += Talphabetai(alpha, beta, 2, a, delta) * std::complex<double>(cos(Hyperbolas::l3(a) * L2E), -sin(Hyperbolas::l3(a) * L2E));

	return std::norm(A);
}

// Assembly:
subq $0xe8, %rsp
movl %edi, 0xe4(%rsp)
movl %esi, 0xe0(%rsp)
movsd %xmm0, 0xd8(%rsp)
movsd %xmm1, 0xd0(%rsp)
movsd %xmm2, 0xc8(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xe4(%rsp)
movb %al, 0x1f(%rsp)
jl 0xbd0f
cmpl $0x2, 0xe4(%rsp)
setle %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xbd19
jmp 0xbd1b
jmp 0xbd3a
leaq 0x645d(%rip), %rdi      # 0x1217f
leaq 0x6a17(%rip), %rsi      # 0x12740
movl $0xb1, %edx
leaq 0x6a6a(%rip), %rcx      # 0x1279f
callq 0x20d0
xorl %eax, %eax
cmpl $0x0, 0xe0(%rsp)
movb %al, 0x1e(%rsp)
jl 0xbd59
cmpl $0x2, 0xe0(%rsp)
setle %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
testb $0x1, %al
jne 0xbd63
jmp 0xbd65
jmp 0xbd84
leaq 0x6478(%rip), %rdi      # 0x121e4
leaq 0x69cd(%rip), %rsi      # 0x12740
movl $0xb2, %edx
leaq 0x6a20(%rip), %rcx      # 0x1279f
callq 0x20d0
leaq 0x654d(%rip), %rax      # 0x122d8
movsd (%rax), %xmm0
mulsd 0xd0(%rsp), %xmm0
movsd 0x6268(%rip), %xmm1     # 0x12008
divsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
leaq 0xb0(%rsp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x4750
movl 0xe4(%rsp), %edi
movl 0xe0(%rsp), %esi
movsd 0xd8(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
xorl %edx, %edx
callq 0xbaa0
movsd %xmm0, 0x90(%rsp)
movsd %xmm1, 0x98(%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xa870
mulsd 0xc0(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, (%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xa870
mulsd 0xc0(%rsp), %xmm0
callq 0x2060
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
leaq 0x80(%rsp), %rdi
callq 0x4750
leaq 0x90(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0xa0(%rsp)
movsd %xmm1, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4780
movl 0xe4(%rsp), %edi
movl 0xe0(%rsp), %esi
movsd 0xd8(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
movl $0x1, %edx
callq 0xbaa0
movsd %xmm0, 0x60(%rsp)
movsd %xmm1, 0x68(%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xa940
mulsd 0xc0(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x8(%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xa940
mulsd 0xc0(%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 0x50(%rsp), %rdi
callq 0x4750
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0x70(%rsp)
movsd %xmm1, 0x78(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x4780
movl 0xe4(%rsp), %edi
movl 0xe0(%rsp), %esi
movsd 0xd8(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
movl $0x2, %edx
callq 0xbaa0
movsd %xmm0, 0x30(%rsp)
movsd %xmm1, 0x38(%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xab20
mulsd 0xc0(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x10(%rsp)
movsd 0xd8(%rsp), %xmm0
callq 0xab20
mulsd 0xc0(%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 0x20(%rsp), %rdi
callq 0x4750
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x46b0
movsd %xmm0, 0x40(%rsp)
movsd %xmm1, 0x48(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4780
leaq 0xb0(%rsp), %rdi
callq 0x47d0
addq $0xe8, %rsp
retq
nopl (%rax)