// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xb8, %rsp
movl %edi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movsd %xmm0, 0xa0(%rsp)
movsd %xmm1, 0x98(%rsp)
movsd %xmm2, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rcx, 0x80(%rsp)
movq $0x0, 0x70(%rsp)
movabsq $0x3eb0c6f7a0b5ed8d, %rax # imm = 0x3EB0C6F7A0B5ED8D
movq %rax, 0x20(%rsp)
movl 0xb0(%rsp), %eax
movl %eax, 0x4(%rsp)
subl $-0x1, %eax
je 0x44b42
jmp 0x44b2a
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x44b7f
jmp 0x44b34
movl 0x4(%rsp), %eax
subl $0x1, %eax
je 0x44bb7
jmp 0x44bf2
cvtsi2sdl 0xac(%rsp), %xmm0
cvtsi2sdl 0xac(%rsp), %xmm1
movsd 0x18d6ec(%rip), %xmm2   # 0x1d2248
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x82e0
divsd 0xa0(%rsp), %xmm0
callq 0x8480
movsd %xmm0, 0x70(%rsp)
jmp 0x44bf2
cvtsi2sdl 0xac(%rsp), %xmm0
cvtsi2sdl 0xac(%rsp), %xmm1
movsd 0x18d6af(%rip), %xmm2   # 0x1d2248
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x82e0
divsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x44bf2
cvtsi2sdl 0xac(%rsp), %xmm0
cvtsi2sdl 0xac(%rsp), %xmm1
movsd 0x18d677(%rip), %xmm2   # 0x1d2248
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x82e0
divsd 0xa0(%rsp), %xmm0
callq 0x8590
movsd %xmm0, 0x70(%rsp)
movl 0xb0(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0xac(%rsp), %eax
movl %eax, 0xc(%rsp)
movsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x190982(%rip), %xmm0   # 0x1d55b0
mulsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
leaq 0x8(%rsp), %rdi
callq 0x44ee0
movsd %xmm0, 0x50(%rsp)
movq 0x80(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
movsd 0x18d601(%rip), %xmm1   # 0x1d2270
addsd 0xa0(%rsp), %xmm1
movsd 0x190808(%rip), %xmm0   # 0x1d5488
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x44cbe
movsd 0x28(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x44cd2
movsd 0x18dffa(%rip), %xmm0   # 0x1d2cc0
mulsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
jmp 0x44cd4
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x30(%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x44d7f
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x58(%rsp), %xmm0
leaq 0x8(%rsp), %rdi
callq 0x44ee0
movsd %xmm0, 0x50(%rsp)
movq 0x80(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
movsd 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x44d7a
movsd 0x58(%rsp), %xmm0
movq 0x88(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, 0xb4(%rsp)
jmp 0x44ecb
jmp 0x44e13
movsd 0x58(%rsp), %xmm0
leaq 0x8(%rsp), %rdi
callq 0x44ee0
movsd %xmm0, 0x50(%rsp)
movq 0x80(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
movsd 0x50(%rsp), %xmm1
movsd 0x18d48e(%rip), %xmm3   # 0x1d2248
movsd 0x18da0e(%rip), %xmm2   # 0x1d27d0
xorps %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movsd 0x48(%rsp), %xmm2
movsd 0x18d461(%rip), %xmm4   # 0x1d2248
movsd 0x18d9e1(%rip), %xmm3   # 0x1d27d0
xorps %xmm1, %xmm1
cmpltsd %xmm2, %xmm1
movaps %xmm1, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jne 0x44e13
jp 0x44e13
jmp 0x44cd4
xorps %xmm0, %xmm0
ucomisd 0x50(%rsp), %xmm0
jb 0x44e50
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0x44e80
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x98(%rsp), %xmm2
movq 0x88(%rsp), %r8
movq 0x80(%rsp), %r9
leaq 0x34(%rip), %rdi        # 0x44ee0
leaq 0x8(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq 0x44f50
movl $0x0, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
addq $0xb8, %rsp
retq
nopw (%rax,%rax)