// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: hyperspherical_get_xmin_from_Airy
int hyperspherical_get_xmin_from_Airy(int K,
                                      int l,
                                      double beta,
                                      double xtol,
                                      double phiminabs,
                                      double *xmin,
                                      int *fevals){
  double xold, xtp=0, xleft, xright, xnew;
  double Fnew, Fold, Fleft, Fright;
  double delx, lambda;
  double AIRY_SAFETY = 1e-6;
  struct WKB_parameters wkbstruct;
  //Start searching from turning point:
  switch (K){
  case -1:
    xtp = asinh(sqrt(l*(l+1.))/beta);
    break;
  case 0:
    xtp = sqrt(l*(l+1.))/beta;
    break;
  case 1:
    xtp = asin(sqrt(l*(l+1.))/beta);
    break;
  }
  wkbstruct.K = K;
  wkbstruct.l = l;
  wkbstruct.beta = beta;
  wkbstruct.phiminabs = phiminabs;

  xnew = 0.99*xtp;

  Fnew = PhiWKB_minus_phiminabs(xnew,&wkbstruct);
  *fevals = (*fevals)+1;

  lambda = 2*_PI_/(beta+5.0);
  if (Fnew>0)
    delx = -lambda;
  else
    delx = 0.25*lambda;

  do {
    //printf("In the loop: xnew = %g, Fnew=%g, Fold=%g\n",xnew,Fnew,Fold);
    xold = xnew;
    Fold = Fnew;
    xnew += delx;
    if (xnew<AIRY_SAFETY){
      xnew = AIRY_SAFETY;
      Fnew = PhiWKB_minus_phiminabs(xnew,&wkbstruct);
      *fevals = (*fevals)+1;
      if (Fnew>=0.0){
        *xmin = xnew;
        return _SUCCESS_;
      }
      else{
        break;
      }
    }
    Fnew = PhiWKB_minus_phiminabs(xnew,&wkbstruct);
    *fevals = (*fevals)+1;
  } while (SIGN(Fnew)==(SIGN(Fold)));

  if (Fnew<=0.0){
    xleft = xnew;
    Fleft = Fnew;
    xright = xold;
    Fright = Fold;
  }
  else{
    xleft = xold;
    Fleft = Fold;
    xright = xnew;
    Fright = Fnew;
  }

  fzero_ridder(PhiWKB_minus_phiminabs,
               xleft,
               xright,
               xtol,
               &wkbstruct,
               &Fleft,
               &Fright,
               xmin,
               fevals);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movsd %xmm1, 0x48(%rsp)
movapd %xmm0, %xmm3
movl %esi, %ebp
movl %edi, %r15d
cmpl $0x1, %edi
movsd %xmm0, 0x10(%rsp)
je 0x26451
testl %r15d, %r15d
je 0x26427
xorpd %xmm1, %xmm1
cmpl $-0x1, %r15d
jne 0x264d9
movsd %xmm2, 0x8(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xcae58(%rip), %xmm0    # 0xf1260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x264b5
sqrtsd %xmm0, %xmm0
jmp 0x264c0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xcae2a(%rip), %xmm0    # 0xf1260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2647e
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x26499
movsd %xmm2, 0x8(%rsp)
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xcadfa(%rip), %xmm0    # 0xf1260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2649f
sqrtsd %xmm0, %xmm0
jmp 0x264aa
movsd %xmm2, 0x8(%rsp)
callq 0x82b0
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm1
divsd %xmm3, %xmm1
jmp 0x264d9
callq 0x82b0
movsd 0x10(%rsp), %xmm3
divsd %xmm3, %xmm0
callq 0x85a0
jmp 0x264c9
callq 0x82b0
movsd 0x10(%rsp), %xmm3
divsd %xmm3, %xmm0
callq 0x8470
movsd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm2
movl %r15d, 0x20(%rsp)
movl %ebp, 0x24(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, 0x30(%rsp)
mulsd 0xce072(%rip), %xmm1    # 0xf4568
movsd %xmm1, 0x8(%rsp)
leaq 0x38(%rsp), %r12
movl %r15d, %edi
movl %ebp, %esi
movapd %xmm3, %xmm0
movq %r12, %rdx
callq 0x25567
movsd 0x8(%rsp), %xmm0
movsd (%r12), %xmm4
andpd 0xcad1a(%rip), %xmm4    # 0xf1240
subsd 0x30(%rsp), %xmm4
incl (%r14)
movsd 0x10(%rsp), %xmm2
addsd 0xcad33(%rip), %xmm2    # 0xf1270
movsd 0xcded3(%rip), %xmm1    # 0xf4418
divsd %xmm2, %xmm1
movapd 0xcacdf(%rip), %xmm2    # 0xf1230
xorpd %xmm1, %xmm2
mulsd 0xce013(%rip), %xmm1    # 0xf4570
xorpd %xmm3, %xmm3
cmpltsd %xmm4, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, 0x50(%rsp)
movapd %xmm4, 0x10(%rsp)
movapd 0x50(%rsp), %xmm1
movsd %xmm0, 0x40(%rsp)
addsd %xmm0, %xmm1
movsd 0xcb75a(%rip), %xmm0    # 0xf1cf0
ucomisd %xmm1, %xmm0
ja 0x26633
movl 0x20(%rsp), %edi
movl 0x24(%rsp), %esi
movsd 0x28(%rsp), %xmm0
movq %r12, %rdx
movsd %xmm1, 0x8(%rsp)
callq 0x25567
movsd 0x38(%rsp), %xmm4
andpd 0xcac76(%rip), %xmm4    # 0xf1240
subsd 0x30(%rsp), %xmm4
incl (%r14)
xorpd %xmm1, %xmm1
cmpltsd %xmm4, %xmm1
movapd %xmm1, %xmm2
movsd 0xcac78(%rip), %xmm0    # 0xf1260
andpd %xmm0, %xmm2
movsd 0xcb1f4(%rip), %xmm6    # 0xf17e8
andnpd %xmm6, %xmm1
orpd %xmm2, %xmm1
xorpd %xmm2, %xmm2
movapd 0x10(%rsp), %xmm5
cmpltsd %xmm5, %xmm2
movapd %xmm2, %xmm3
andpd %xmm0, %xmm3
andnpd %xmm6, %xmm2
orpd %xmm3, %xmm2
movsd 0x8(%rsp), %xmm0
ucomisd %xmm2, %xmm1
movapd %xmm5, %xmm3
jne 0x26684
jnp 0x26578
jmp 0x26684
movl 0x20(%rsp), %edi
movl 0x24(%rsp), %esi
movsd 0x28(%rsp), %xmm0
leaq 0x38(%rsp), %r15
movsd 0xcb6a2(%rip), %xmm1    # 0xf1cf0
movq %r15, %rdx
callq 0x25567
movsd (%r15), %xmm4
andpd 0xcabdd(%rip), %xmm4    # 0xf1240
subsd 0x30(%rsp), %xmm4
incl (%r14)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm4
movsd 0xcb674(%rip), %xmm0    # 0xf1cf0
movapd 0x10(%rsp), %xmm3
jae 0x266ee
xorpd %xmm1, %xmm1
ucomisd %xmm4, %xmm1
movapd %xmm4, %xmm2
cmpnlesd %xmm1, %xmm2
movapd %xmm2, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm4, %xmm2
orpd %xmm1, %xmm2
jb 0x266af
movsd 0x40(%rsp), %xmm1
jmp 0x266bd
movapd %xmm4, %xmm3
movapd %xmm0, %xmm1
movsd 0x40(%rsp), %xmm0
leaq 0x38(%rsp), %rdx
movlpd %xmm2, (%rdx)
leaq 0x68(%rsp), %rcx
movsd %xmm3, (%rcx)
leaq 0x34(%rip), %rdi        # 0x2670a
leaq 0x20(%rsp), %rsi
movsd 0x48(%rsp), %xmm2
movq %rbx, %r8
movq %r14, %r9
callq 0x26743
jmp 0x266fb
movabsq $0x3eb0c6f7a0b5ed8d, %rax # imm = 0x3EB0C6F7A0B5ED8D
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq