// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: hyperspherical_WKB
int hyperspherical_WKB(int K,int l,double beta,double y, double *Phi){
  double e, w, w2, alpha, alpha2, CscK, ytp, t;
  double S, Q, C, argu, Ai;
  int airy_sign = 1, phisign = 1, dphisign = 1, intbeta;
  double ldbl = l;

  if (K==1){
    //Limit range to [0; pi/2]:
    intbeta = (int)(beta+0.4); //Round to nearest integer (just to be sure)
    ClosedModY(l, intbeta, &y, &phisign, &dphisign);
  }
  e = 1.0/sqrt(ldbl*(ldbl+1.0));
  alpha = beta*e;
  if (K==-1){
    CscK = 1.0/sinh(y);
    ytp = asinh(1.0/alpha);
  }
  else if (K==1){
    CscK = 1.0/sin(y);
    ytp = asin(1.0/alpha);
  }
  else{
    return _FAILURE_;
  }
  w = alpha/CscK;
  w2 = w*w;
  alpha2 = alpha*alpha;
  if (K==-1){
    if (y>ytp){
      S = alpha*log((sqrt(w2-1.0)+sqrt(w2+alpha2))/sqrt(1.0+alpha2))+
        atan(1.0/alpha*sqrt((w2+alpha2)/(w2-1.0)))-0.5*_PI_;
      airy_sign = -1;
    }
    else{
      t = sqrt(1.0-w2)/sqrt(1.0+w2/alpha2);
      S = atanh(t)-alpha*atan(t/alpha);
      airy_sign = 1;
    }
  }
  else if (K==1){
    if (y>ytp){
      t = sqrt(1-w2/alpha2)/sqrt(w2-1.0);
        S = atan(t)+alpha*atan(1.0/(t*alpha))-0.5*_PI_;
        airy_sign = -1;
    }
    else{
      S = atanh(sqrt(1.0-w2)/sqrt(1.0-w2/alpha2))-
        alpha*log((sqrt(alpha2-w2)+sqrt(1.0-w2))/sqrt(alpha2-1.0));
      airy_sign = 1;
    }
  }
  else{
    return _FAILURE_;
  }
  argu = 3.0*S/(2.0*e);
  Q = CscK*CscK-alpha2;
  C = 0.5*sqrt(alpha)/beta;
  Ai = airy_cheb_approx(airy_sign*pow(argu,2.0/3.0));
  *Phi = phisign*2.0*sqrt(_PI_)*C*pow(argu,1.0/6.0)*pow(fabs(Q),-0.25)*Ai*CscK;
  return _SUCCESS_;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movl %edi, 0x140(%rsp)
movl %esi, 0x13c(%rsp)
movsd %xmm0, 0x130(%rsp)
movsd %xmm1, 0x128(%rsp)
movq %rdx, 0x120(%rsp)
movl $0x1, 0xb4(%rsp)
movl $0x1, 0xb0(%rsp)
movl $0x1, 0xac(%rsp)
cvtsi2sdl 0x13c(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
cmpl $0x1, 0x140(%rsp)
jne 0x43843
movsd 0x191d2c(%rip), %xmm0   # 0x1d5530
addsd 0x130(%rsp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0xa8(%rsp)
movl 0x13c(%rsp), %edi
movl 0xa8(%rsp), %esi
leaq 0x128(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0xac(%rsp), %r8
callq 0x419a0
movsd 0xa0(%rsp), %xmm0
movsd 0x18e9f4(%rip), %xmm1   # 0x1d2248
addsd 0xa0(%rsp), %xmm1
mulsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x18e9d7(%rip), %xmm0   # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x130(%rsp), %xmm0
mulsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x100(%rsp)
cmpl $-0x1, 0x140(%rsp)
jne 0x438ea
movsd 0x128(%rsp), %xmm0
callq 0x8390
movaps %xmm0, %xmm1
movsd 0x18e98c(%rip), %xmm0   # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0x18e977(%rip), %xmm0   # 0x1d2248
divsd 0x100(%rsp), %xmm0
callq 0x8480
movsd %xmm0, 0xe8(%rsp)
jmp 0x4394d
cmpl $0x1, 0x140(%rsp)
jne 0x4393b
movsd 0x128(%rsp), %xmm0
callq 0x80a0
movaps %xmm0, %xmm1
movsd 0x18e93b(%rip), %xmm0   # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0x18e926(%rip), %xmm0   # 0x1d2248
divsd 0x100(%rsp), %xmm0
callq 0x8590
movsd %xmm0, 0xe8(%rsp)
jmp 0x4394b
movl $0x1, 0x144(%rsp)
jmp 0x43fa0
jmp 0x4394d
movsd 0x100(%rsp), %xmm0
divsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
mulsd 0x110(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x100(%rsp), %xmm0
mulsd 0x100(%rsp), %xmm0
movsd %xmm0, 0xf8(%rsp)
cmpl $-0x1, 0x140(%rsp)
jne 0x43bce
movsd 0x128(%rsp), %xmm0
ucomisd 0xe8(%rsp), %xmm0
jbe 0x43af8
movsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0x18e861(%rip), %xmm1   # 0x1d2248
subsd %xmm1, %xmm0
callq 0x82e0
movsd %xmm0, 0x78(%rsp)
movsd 0x108(%rsp), %xmm0
addsd 0xf8(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x78(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x18e81d(%rip), %xmm0   # 0x1d2248
addsd 0xf8(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x80(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x82f0
movsd %xmm0, 0x90(%rsp)
movsd 0x18e7e9(%rip), %xmm0   # 0x1d2248
divsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x108(%rsp), %xmm0
addsd 0xf8(%rsp), %xmm0
movsd 0x108(%rsp), %xmm1
movsd 0x18e7b4(%rip), %xmm2   # 0x1d2248
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x88(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x8310
movsd 0x90(%rsp), %xmm2
movaps %xmm0, %xmm1
movsd 0x98(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x191a15(%rip), %xmm1   # 0x1d54f0
subsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x43bc9
movsd 0x18e748(%rip), %xmm0   # 0x1d2248
subsd 0x108(%rsp), %xmm0
callq 0x82e0
movsd %xmm0, 0x60(%rsp)
movsd 0x108(%rsp), %xmm1
divsd 0xf8(%rsp), %xmm1
movsd 0x18e71a(%rip), %xmm0   # 0x1d2248
addsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x60(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm0
callq 0x8630
movsd %xmm0, 0x68(%rsp)
movsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0xe0(%rsp), %xmm0
divsd 0x100(%rsp), %xmm0
callq 0x8310
movsd 0x68(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x70(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
movl $0x1, 0xb4(%rsp)
jmp 0x43dfd
cmpl $0x1, 0x140(%rsp)
jne 0x43deb
movsd 0x128(%rsp), %xmm0
ucomisd 0xe8(%rsp), %xmm0
jbe 0x43ccf
movsd 0x108(%rsp), %xmm1
divsd 0xf8(%rsp), %xmm1
movsd 0x18e63a(%rip), %xmm0   # 0x1d2248
subsd %xmm1, %xmm0
callq 0x82e0
movsd %xmm0, 0x48(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0x18e61a(%rip), %xmm1   # 0x1d2248
subsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x48(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm0
callq 0x8310
movsd %xmm0, 0x50(%rsp)
movsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0xe0(%rsp), %xmm1
mulsd 0x100(%rsp), %xmm1
movsd 0x18e5be(%rip), %xmm0   # 0x1d2248
divsd %xmm1, %xmm0
callq 0x8310
movsd 0x50(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x58(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x19183e(%rip), %xmm1   # 0x1d54f0
subsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x43de9
movsd 0x18e571(%rip), %xmm0   # 0x1d2248
subsd 0x108(%rsp), %xmm0
callq 0x82e0
movsd %xmm0, 0x20(%rsp)
movsd 0x108(%rsp), %xmm1
divsd 0xf8(%rsp), %xmm1
movsd 0x18e543(%rip), %xmm0   # 0x1d2248
subsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x8630
movsd %xmm0, 0x38(%rsp)
movsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0xf8(%rsp), %xmm0
subsd 0x108(%rsp), %xmm0
callq 0x82e0
movsd %xmm0, 0x28(%rsp)
movsd 0x18e4ee(%rip), %xmm0   # 0x1d2248
subsd 0x108(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0xf8(%rsp), %xmm0
movsd 0x18e4bc(%rip), %xmm1   # 0x1d2248
subsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x82f0
movsd 0x38(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x40(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
movl $0x1, 0xb4(%rsp)
jmp 0x43dfb
movl $0x1, 0x144(%rsp)
jmp 0x43fa0
jmp 0x43dfd
movsd 0x18f893(%rip), %xmm0   # 0x1d3698
mulsd 0xd8(%rsp), %xmm0
movsd 0x18ee6a(%rip), %xmm1   # 0x1d2c80
mulsd 0x118(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0xf0(%rsp), %xmm0
movsd 0xf0(%rsp), %xmm2
movsd 0xf8(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0x100(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x18ee00(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
divsd 0x130(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
cvtsi2sdl 0xb4(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0xc0(%rsp), %xmm0
movsd 0x19167b(%rip), %xmm1   # 0x1d5538
callq 0x8610
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x436d0
movsd %xmm0, 0xb8(%rsp)
cvtsi2sdl 0xb0(%rsp), %xmm0
movsd 0x18ed93(%rip), %xmm1   # 0x1d2c80
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1910e1(%rip), %xmm0   # 0x1d4fe0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd 0xc8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0xc0(%rsp), %xmm0
movsd 0x1915ef(%rip), %xmm1   # 0x1d5520
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0xd0(%rsp), %xmm0
movaps 0x18e2d7(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movsd 0x18e2eb(%rip), %xmm1   # 0x1d2250
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd 0xb8(%rsp), %xmm0
mulsd 0xf0(%rsp), %xmm0
movq 0x120(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, 0x144(%rsp)
movl 0x144(%rsp), %eax
addq $0x148, %rsp            # imm = 0x148
retq
nop