// File: /workspace/github_c_makefile_star2_O2/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
movq %rdx, 0x38(%rsp)
movl %esi, %r15d
cvtsi2sd %esi, %xmm2
movapd %xmm0, %xmm3
subsd %xmm2, %xmm0
addsd 0xc61dd(%rip), %xmm0    # 0xe8468
mulsd %xmm3, %xmm3
cvttsd2si %xmm0, %eax
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
leal 0x1(%r15), %ebp
movl %ebp, %ebx
imull %edi, %ebx
movl %ebx, %edx
imull %ebp, %edx
incl %eax
pushq $0x1
popq %rsi
cmpl %esi, %edi
movsd %xmm1, 0x50(%rsp)
mulsd %xmm1, %xmm2
movq %rcx, 0x48(%rsp)
movl %esi, (%rcx)
cvtsi2sd %edx, %xmm0
movsd %xmm3, 0x18(%rsp)
subsd %xmm0, %xmm3
movl $0xf4241, %ecx          # imm = 0xF4241
cmovel %eax, %ecx
subl %ecx, %esi
movl %esi, 0xc(%rsp)
leal 0x3(,%r15,2), %r14d
addl $0x2, %r15d
movl %edi, 0x8(%rsp)
imull %edi, %r15d
xorpd %xmm4, %xmm4
movsd %xmm3, 0x10(%rsp)
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x40(%rsp)
movapd %xmm2, 0x60(%rsp)
xorpd %xmm3, %xmm3
cmpl %r13d, 0xc(%rsp)
je 0x224b5
leal 0x1(%rbp), %r12d
movl %r15d, %eax
imull %r12d, %eax
cvtsi2sd %eax, %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
ucomisd %xmm4, %xmm0
movapd %xmm3, 0x20(%rsp)
movsd %xmm2, 0x58(%rsp)
jb 0x2234c
sqrtsd %xmm0, %xmm2
jmp 0x22359
callq 0x82d0
xorpd %xmm4, %xmm4
movapd %xmm0, %xmm2
imull %ebx, %ebp
cvtsi2sd %ebp, %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
ucomisd %xmm4, %xmm0
jb 0x22376
sqrtsd %xmm0, %xmm5
jmp 0x2238d
movsd %xmm2, (%rsp)
callq 0x82d0
movsd (%rsp), %xmm2
xorpd %xmm4, %xmm4
movapd %xmm0, %xmm5
movapd 0x20(%rsp), %xmm3
xorpd 0xc2e95(%rip), %xmm5    # 0xe5230
divsd %xmm2, %xmm5
subl $0x1, %r13d
jae 0x223e6
movsd 0x10(%rsp), %xmm0
ucomisd %xmm4, %xmm0
movsd 0x40(%rsp), %xmm0
jae 0x223e2
movsd 0x10(%rsp), %xmm0
movapd %xmm5, 0x70(%rsp)
movsd %xmm2, (%rsp)
callq 0x82d0
movsd (%rsp), %xmm2
movapd 0x70(%rsp), %xmm5
movapd 0x20(%rsp), %xmm3
xorpd %xmm4, %xmm4
mulsd %xmm0, %xmm5
cvtsi2sd %r14d, %xmm0
divsd %xmm2, %xmm0
mulsd 0x50(%rsp), %xmm0
mulsd %xmm5, %xmm3
addsd %xmm0, %xmm3
movsd 0xc2e5b(%rip), %xmm1    # 0xe5260
divsd %xmm3, %xmm1
cmpeqsd %xmm4, %xmm3
movapd %xmm3, %xmm2
andnpd %xmm1, %xmm2
movsd 0xc6052(%rip), %xmm1    # 0xe8470
andpd %xmm1, %xmm3
orpd %xmm2, %xmm3
ucomisd %xmm3, %xmm4
jbe 0x22433
movq 0x48(%rsp), %rax
negl (%rax)
divsd 0x60(%rsp), %xmm5
addsd %xmm5, %xmm0
movapd %xmm0, %xmm2
cmpeqsd %xmm4, %xmm2
movapd %xmm2, %xmm1
andnpd %xmm0, %xmm1
movsd 0xc5b22(%rip), %xmm0    # 0xe7f78
andpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm2, 0x60(%rsp)
movapd %xmm2, %xmm0
mulsd %xmm3, %xmm0
movsd 0x58(%rsp), %xmm2
mulsd %xmm0, %xmm2
addsd 0xc336a(%rip), %xmm0    # 0xe57e8
andpd 0xc2dba(%rip), %xmm0    # 0xe5240
addl $0x2, %r14d
movl 0x8(%rsp), %eax
addl %eax, %ebx
addl %eax, %r15d
movsd 0xc5fdd(%rip), %xmm1    # 0xe8478
ucomisd %xmm0, %xmm1
movl %r12d, %ebp
jbe 0x22310
movq 0x38(%rsp), %rax
movsd %xmm2, (%rax)
xorl %eax, %eax
jmp 0x224b8
pushq $0x1
popq %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq