// File: /workspace/github_c_makefile_star2_O3/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 $0x80, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x30(%rsp)
movapd %xmm0, %xmm2
movl %esi, %ebp
movl %edi, %r15d
cmpl $0x1, %edi
movsd %xmm0, 0x8(%rsp)
je 0x262ec
testl %r15d, %r15d
je 0x262c2
xorpd %xmm1, %xmm1
cmpl $-0x1, %r15d
jne 0x2635c
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xc7fbd(%rip), %xmm0    # 0xee260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2633e
sqrtsd %xmm0, %xmm0
jmp 0x26349
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xc7f8f(%rip), %xmm0    # 0xee260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x26313
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x26322
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0xc7f65(%rip), %xmm0    # 0xee260
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x26328
sqrtsd %xmm0, %xmm0
jmp 0x26333
callq 0x82b0
movsd 0x8(%rsp), %xmm2
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
jmp 0x2635c
callq 0x82b0
movsd 0x8(%rsp), %xmm2
divsd %xmm2, %xmm0
callq 0x85a0
jmp 0x26352
callq 0x82b0
movsd 0x8(%rsp), %xmm2
divsd %xmm2, %xmm0
callq 0x8470
movsd 0x8(%rsp), %xmm2
movapd %xmm0, %xmm1
movl %r15d, 0x38(%rsp)
movl %ebp, 0x3c(%rsp)
movsd %xmm2, 0x40(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
mulsd 0xcb1f9(%rip), %xmm1    # 0xf1578
movsd %xmm1, 0x18(%rsp)
leaq 0x20(%rsp), %r12
movl %r15d, %edi
movl %ebp, %esi
movapd %xmm2, %xmm0
movq %r12, %rdx
callq 0x25432
movsd 0x18(%rsp), %xmm0
movsd (%r12), %xmm4
andpd 0xc7e91(%rip), %xmm4    # 0xee240
subsd 0x10(%rsp), %xmm4
incl (%r14)
movsd 0xc7eb0(%rip), %xmm1    # 0xee270
addsd 0x8(%rsp), %xmm1
movsd 0xcb05a(%rip), %xmm2    # 0xf1428
divsd %xmm1, %xmm2
movapd 0xc7e56(%rip), %xmm1    # 0xee230
xorpd %xmm2, %xmm1
mulsd 0xcb19a(%rip), %xmm2    # 0xf1580
xorpd %xmm3, %xmm3
cmpltsd %xmm4, %xmm3
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm3
orpd %xmm1, %xmm3
movapd %xmm3, 0x60(%rsp)
movapd %xmm4, 0x50(%rsp)
movapd 0x60(%rsp), %xmm1
movsd %xmm0, 0x28(%rsp)
addsd %xmm0, %xmm1
movsd 0xc88d1(%rip), %xmm0    # 0xeecf0
ucomisd %xmm1, %xmm0
ja 0x264b9
movl %r15d, %edi
movl %ebp, %esi
movsd 0x8(%rsp), %xmm0
movq %r12, %rdx
movsd %xmm1, 0x18(%rsp)
callq 0x25432
movsd 0x20(%rsp), %xmm4
incl (%r14)
andpd 0xc7ded(%rip), %xmm4    # 0xee240
subsd 0x10(%rsp), %xmm4
xorpd %xmm1, %xmm1
cmpltsd %xmm4, %xmm1
movapd %xmm1, %xmm2
movsd 0xc7df2(%rip), %xmm0    # 0xee260
andpd %xmm0, %xmm2
movsd 0xc836e(%rip), %xmm6    # 0xee7e8
andnpd %xmm6, %xmm1
orpd %xmm2, %xmm1
xorpd %xmm2, %xmm2
movapd 0x50(%rsp), %xmm5
cmpltsd %xmm5, %xmm2
movapd %xmm2, %xmm3
andpd %xmm0, %xmm3
andnpd %xmm6, %xmm2
orpd %xmm3, %xmm2
movsd 0x18(%rsp), %xmm0
ucomisd %xmm2, %xmm1
movapd %xmm5, %xmm3
jne 0x26508
jnp 0x26401
jmp 0x26508
leaq 0x20(%rsp), %r12
movl %r15d, %edi
movl %ebp, %esi
movsd 0x8(%rsp), %xmm0
movsd 0xc881f(%rip), %xmm1    # 0xeecf0
movq %r12, %rdx
callq 0x25432
movsd (%r12), %xmm4
andpd 0xc7d59(%rip), %xmm4    # 0xee240
subsd 0x10(%rsp), %xmm4
incl (%r14)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm4
movsd 0xc87f0(%rip), %xmm0    # 0xeecf0
movapd 0x50(%rsp), %xmm3
jae 0x26572
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 0x26533
movsd 0x28(%rsp), %xmm1
jmp 0x26541
movapd %xmm4, %xmm3
movapd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
leaq 0x20(%rsp), %rdx
movlpd %xmm2, (%rdx)
leaq 0x78(%rsp), %rcx
movsd %xmm3, (%rcx)
leaq 0x37(%rip), %rdi        # 0x26591
leaq 0x38(%rsp), %rsi
movsd 0x30(%rsp), %xmm2
movq %rbx, %r8
movq %r14, %r9
callq 0x265ca
jmp 0x2657f
movabsq $0x3eb0c6f7a0b5ed8d, %rax # imm = 0x3EB0C6F7A0B5ED8D
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq