// File: /workspace/github_c_makefile_star2_O1/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 0xcfc6a(%rip), %xmm0    # 0xf4498
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 0x24a98
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 0x248fe
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0x24911
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 0x24932
xorps %xmm6, %xmm6
sqrtsd %xmm0, %xmm6
jmp 0x24951
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 0xcc8d1(%rip), %xmm6    # 0xf1230
divsd %xmm2, %xmm6
subl $0x1, %r14d
jae 0x249b2
movsd 0x28(%rsp), %xmm0
ucomisd %xmm4, %xmm0
movsd 0x48(%rsp), %xmm0
jae 0x249ae
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 0xcc88c(%rip), %xmm1    # 0xf1260
divsd %xmm5, %xmm1
cmpeqsd %xmm4, %xmm5
movapd %xmm5, %xmm2
andnpd %xmm1, %xmm2
movsd 0xcfab3(%rip), %xmm1    # 0xf44a0
andpd %xmm1, %xmm5
orpd %xmm2, %xmm5
ucomisd %xmm5, %xmm4
jbe 0x24a02
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 0xcf583(%rip), %xmm0    # 0xf3fa8
andpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm5, %xmm0
mulsd %xmm2, %xmm0
movsd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
addsd 0xccd9b(%rip), %xmm0    # 0xf17e8
andpd 0xcc7eb(%rip), %xmm0    # 0xf1240
movsd 0xcfa4b(%rip), %xmm1    # 0xf44a8
ucomisd %xmm0, %xmm1
ja 0x24a87
addl $0x2, %r12d
movl 0x24(%rsp), %eax
addl %eax, %ebx
addl %eax, %r15d
movl %r13d, %ebp
movl 0x20(%rsp), %esi
cmpl %r14d, %esi
jne 0x248c9
movl $0x1, %eax
jmp 0x24a98
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