// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: get_CF1
int get_CF1(int K,int l,double beta, double cotK, double *CF, int *isign){
  int maxiter = 1000000;
  double tiny = 1e-100;
  double reltol = DBL_EPSILON;
  double aj,bj,fj,Cj,Dj,Delj;
  double beta2 = beta*beta;
  double sqrttmp;
  int j;

  if (K==1) maxiter = (int)(beta-l-10);
  bj = l*cotK; //This is b_0
  fj = bj;
  Cj = bj;
  Dj = 0.0;
  *isign = 1;
  for(j=1; j<=maxiter; j++){
    sqrttmp = sqrt(beta2-K*(l+j+1)*(l+j+1));
    aj = -sqrt(beta2-K*(l+j)*(l+j))/sqrttmp;
    if (j==1)
      aj = sqrt(beta2-K*(l+1)*(l+1))*aj;
    bj = (2*(l+j)+1)/sqrttmp*cotK;
    Dj = bj+aj*Dj;
    if (Dj==0.0)
      Dj = tiny;
    Cj = bj+aj/Cj;
    if (Cj==0.0)
      Cj = tiny;
    Dj = 1.0/Dj;
    Delj = Cj*Dj;
    fj = fj*Delj;
    if (Dj<0)
      *isign *= -1;
    if (fabs(Delj-1.0)<reltol){
      *CF = fj;
      //printf("iter:%d, %g, %g\n",j,sqrttmp,fj);
      return _SUCCESS_;
    }
  }
  return _FAILURE_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movapd %xmm0, %xmm3
movl %esi, %r15d
cvtsi2sd %esi, %xmm2
subsd %xmm2, %xmm0
addsd 0xccdd4(%rip), %xmm0    # 0xf14a8
cvttsd2si %xmm0, %eax
cmpl $0x1, %edi
movl $0xf4240, %esi          # imm = 0xF4240
cmovel %eax, %esi
movq %rcx, 0x50(%rsp)
movl $0x1, (%rcx)
movl $0x1, %eax
testl %esi, %esi
jle 0x2493e
movq %rdx, 0x40(%rsp)
mulsd %xmm3, %xmm3
movsd %xmm1, 0x58(%rsp)
mulsd %xmm1, %xmm2
leal 0x1(%r15), %ebp
movl %ebp, %ebx
imull %edi, %ebx
movl %ebx, %eax
imull %ebp, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
negl %esi
leal 0x3(,%r15,2), %r12d
addl $0x2, %r15d
movl %edi, 0x24(%rsp)
imull %edi, %r15d
xorpd %xmm4, %xmm4
xorl %r14d, %r14d
movsd %xmm1, 0x28(%rsp)
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
xorpd %xmm5, %xmm5
movsd %xmm2, 0x18(%rsp)
movsd %xmm3, 0x8(%rsp)
movl %esi, 0x20(%rsp)
movapd %xmm5, 0x30(%rsp)
leal 0x1(%rbp), %r13d
movl %r15d, %eax
imull %r13d, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
ucomisd %xmm4, %xmm0
movapd %xmm2, 0x70(%rsp)
jb 0x247a4
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0x247b7
callq 0x82b0
xorpd %xmm4, %xmm4
movsd 0x8(%rsp), %xmm3
movapd %xmm0, %xmm2
imull %ebx, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movapd %xmm3, %xmm0
subsd %xmm1, %xmm0
ucomisd %xmm4, %xmm0
jb 0x247d8
xorps %xmm6, %xmm6
sqrtsd %xmm0, %xmm6
jmp 0x247f7
movsd %xmm2, 0x10(%rsp)
callq 0x82b0
movsd 0x10(%rsp), %xmm2
xorpd %xmm4, %xmm4
movsd 0x8(%rsp), %xmm3
movapd %xmm0, %xmm6
movapd 0x30(%rsp), %xmm5
xorpd 0xc9a2b(%rip), %xmm6    # 0xee230
divsd %xmm2, %xmm6
subl $0x1, %r14d
jae 0x24858
movsd 0x28(%rsp), %xmm0
ucomisd %xmm4, %xmm0
movsd 0x48(%rsp), %xmm0
jae 0x24854
movsd 0x28(%rsp), %xmm0
movapd %xmm6, 0x60(%rsp)
movsd %xmm2, 0x10(%rsp)
callq 0x82b0
movsd 0x10(%rsp), %xmm2
movapd 0x60(%rsp), %xmm6
movapd 0x30(%rsp), %xmm5
xorpd %xmm4, %xmm4
movsd 0x8(%rsp), %xmm3
mulsd %xmm0, %xmm6
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd %xmm2, %xmm0
mulsd 0x58(%rsp), %xmm0
mulsd %xmm6, %xmm5
addsd %xmm0, %xmm5
movsd 0xc99e6(%rip), %xmm1    # 0xee260
divsd %xmm5, %xmm1
cmpeqsd %xmm4, %xmm5
movapd %xmm5, %xmm2
andnpd %xmm1, %xmm2
movsd 0xccc1d(%rip), %xmm1    # 0xf14b0
andpd %xmm1, %xmm5
orpd %xmm2, %xmm5
ucomisd %xmm5, %xmm4
jbe 0x248a8
movq 0x50(%rsp), %rax
negl (%rax)
divsd 0x70(%rsp), %xmm6
addsd %xmm6, %xmm0
movapd %xmm0, %xmm2
cmpeqsd %xmm4, %xmm2
movapd %xmm2, %xmm1
andnpd %xmm0, %xmm1
movsd 0xcc6ed(%rip), %xmm0    # 0xf0fb8
andpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm5, %xmm0
mulsd %xmm2, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
addsd 0xc9ef5(%rip), %xmm0    # 0xee7e8
andpd 0xc9945(%rip), %xmm0    # 0xee240
movsd 0xccbb5(%rip), %xmm1    # 0xf14b8
ucomisd %xmm0, %xmm1
ja 0x2492d
addl $0x2, %r12d
movl 0x24(%rsp), %eax
addl %eax, %ebx
addl %eax, %r15d
movl %r13d, %ebp
movl 0x20(%rsp), %esi
cmpl %r14d, %esi
jne 0x2476f
movl $0x1, %eax
jmp 0x2493e
movq 0x40(%rsp), %rax
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq