// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: CF1_from_Gegenbauer
int CF1_from_Gegenbauer(int l,
                        int beta,
                        double sinK,
                        double cotK,
                        double *CF){
  int n, alpha, k;
  double x, G, dG, Gkm1, Gkm2;
  n = beta-l-1;
  if (n<0)
    return _FAILURE_;
  alpha = l+1;
  x = sinK*cotK; //cos(x)
  switch (n){
  case 0:
    G = 1;
    dG = 0;
    break;
  case 1:
    G = 2*alpha*x;
    dG = 2*alpha;
    break;
  case 2:
    G = -alpha + 2*alpha*(1+alpha)*x*x;
    dG = 4*x*alpha*(1+alpha);
    break;
  case 3:
    G = -2*alpha*(1+alpha)*x+4.0/3.0*alpha*(1+alpha)*(2+alpha)*x*x*x;
    dG = 2*alpha*(1+alpha)*(2*(2+alpha)*x*x-1);
    break;
  default:
    G = 0.0;
    Gkm2 = -alpha + 2*alpha*(1+alpha)*x*x;
    Gkm1 = -2*alpha*(1+alpha)*x+4.0/3.0*alpha*(1+alpha)*(2+alpha)*x*x*x;
    for (k=4; k<=n; k++){
      G = (2*(k+alpha-1)*x*Gkm1 - (k+2*alpha-2)*Gkm2) / k;
      if (fabs(G)>_HYPER_OVERFLOW_){
                Gkm2 = Gkm1/_HYPER_OVERFLOW_;
                G = G/_HYPER_OVERFLOW_;
                Gkm1 = G;
      }
      else{
        Gkm2 = Gkm1;
        Gkm1 = G;
      }
    }
    //Derivative. Gkm2 is in fact Gkm1..
    dG = (-n*x*G+(n+2*alpha-1)*Gkm2)/(1.0-x*x);
  }
  //%Phi = G;
  //%dPhi = l*coty.*G-siny.*dG;
  *CF = l*cotK-sinK*dG/G;
  return _SUCCESS_;
}

// Assembly:
movl %edi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movsd %xmm0, -0x18(%rsp)
movsd %xmm1, -0x20(%rsp)
movq %rdx, -0x28(%rsp)
movl -0xc(%rsp), %eax
subl -0x8(%rsp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rsp)
cmpl $0x0, -0x2c(%rsp)
jge 0x426cc
movl $0x1, -0x4(%rsp)
jmp 0x42aee
movl -0x8(%rsp), %eax
incl %eax
movl %eax, -0x30(%rsp)
movsd -0x18(%rsp), %xmm0
movsd -0x20(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rsp)
movl -0x2c(%rsp), %eax
movq %rax, -0x68(%rsp)
subq $0x3, %rax
ja 0x4287d
movq -0x68(%rsp), %rax
leaq 0x1932a5(%rip), %rcx    # 0x1d59b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x18fb2c(%rip), %xmm0   # 0x1d2248
movsd %xmm0, -0x48(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rsp)
jmp 0x42aa0
movl -0x30(%rsp), %eax
shll %eax
cvtsi2sd %eax, %xmm0
mulsd -0x40(%rsp), %xmm0
movsd %xmm0, -0x48(%rsp)
movl -0x30(%rsp), %eax
shll %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x50(%rsp)
jmp 0x42aa0
xorl %eax, %eax
subl -0x30(%rsp), %eax
cvtsi2sd %eax, %xmm1
movl -0x30(%rsp), %eax
shll %eax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd -0x40(%rsp), %xmm0
movsd -0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rsp)
movsd 0x192d2d(%rip), %xmm0   # 0x1d54c8
mulsd -0x40(%rsp), %xmm0
cvtsi2sdl -0x30(%rsp), %xmm1
mulsd %xmm1, %xmm0
movl -0x30(%rsp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rsp)
jmp 0x42aa0
imull $0xfffffffe, -0x30(%rsp), %eax # imm = 0xFFFFFFFE
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd -0x40(%rsp), %xmm2
cvtsi2sdl -0x30(%rsp), %xmm3
movsd 0x192d21(%rip), %xmm1   # 0x1d5510
mulsd %xmm3, %xmm1
movl -0x30(%rsp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm3
mulsd %xmm3, %xmm1
movl -0x30(%rsp), %eax
addl $0x2, %eax
cvtsi2sd %eax, %xmm3
mulsd %xmm3, %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rsp)
movl -0x30(%rsp), %eax
shll %eax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movl -0x30(%rsp), %eax
addl $0x2, %eax
shll %eax
cvtsi2sd %eax, %xmm1
mulsd -0x40(%rsp), %xmm1
movsd -0x40(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x18ff66(%rip), %xmm2   # 0x1d27d0
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rsp)
jmp 0x42aa0
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rsp)
xorl %eax, %eax
subl -0x30(%rsp), %eax
cvtsi2sd %eax, %xmm1
movl -0x30(%rsp), %eax
shll %eax
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd -0x40(%rsp), %xmm0
movsd -0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rsp)
imull $0xfffffffe, -0x30(%rsp), %eax # imm = 0xFFFFFFFE
movl -0x30(%rsp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd -0x40(%rsp), %xmm2
cvtsi2sdl -0x30(%rsp), %xmm3
movsd 0x192c28(%rip), %xmm1   # 0x1d5510
mulsd %xmm3, %xmm1
movl -0x30(%rsp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm3
mulsd %xmm3, %xmm1
movl -0x30(%rsp), %eax
addl $0x2, %eax
cvtsi2sd %eax, %xmm3
mulsd %xmm3, %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd -0x40(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rsp)
movl $0x4, -0x34(%rsp)
movl -0x34(%rsp), %eax
cmpl -0x2c(%rsp), %eax
jg 0x42a2c
movl -0x34(%rsp), %eax
addl -0x30(%rsp), %eax
subl $0x1, %eax
shll %eax
cvtsi2sd %eax, %xmm0
mulsd -0x40(%rsp), %xmm0
movsd -0x58(%rsp), %xmm2
movl -0x34(%rsp), %eax
movl -0x30(%rsp), %ecx
shll %ecx
addl %ecx, %eax
subl $0x2, %eax
cvtsi2sd %eax, %xmm1
mulsd -0x60(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x34(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rsp)
movsd -0x48(%rsp), %xmm0
movaps 0x18f87e(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movsd 0x192b3a(%rip), %xmm1   # 0x1d54f8
ucomisd %xmm1, %xmm0
jbe 0x42a02
movsd -0x58(%rsp), %xmm0
movsd 0x192b26(%rip), %xmm1   # 0x1d54f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rsp)
movsd -0x48(%rsp), %xmm0
movsd 0x192b0e(%rip), %xmm1   # 0x1d54f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rsp)
movsd -0x48(%rsp), %xmm0
movsd %xmm0, -0x58(%rsp)
jmp 0x42a1a
movsd -0x58(%rsp), %xmm0
movsd %xmm0, -0x60(%rsp)
movsd -0x48(%rsp), %xmm0
movsd %xmm0, -0x58(%rsp)
jmp 0x42a1c
movl -0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rsp)
jmp 0x42932
xorl %eax, %eax
subl -0x2c(%rsp), %eax
cvtsi2sd %eax, %xmm0
mulsd -0x40(%rsp), %xmm0
movsd -0x48(%rsp), %xmm2
movl -0x2c(%rsp), %eax
movl -0x30(%rsp), %ecx
shll %ecx
addl %ecx, %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
mulsd -0x60(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x40(%rsp), %xmm1
movsd -0x40(%rsp), %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
movsd 0x18f7b6(%rip), %xmm2   # 0x1d2248
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rsp)
cvtsi2sdl -0x8(%rsp), %xmm0
movsd -0x20(%rsp), %xmm2
movsd -0x18(%rsp), %xmm1
mulsd -0x50(%rsp), %xmm1
divsd -0x48(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x28(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopw %cs:(%rax,%rax)