// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/hyperspherical.c
// Function: hyperspherical_backwards_recurrence_chunk
int hyperspherical_backwards_recurrence_chunk(int K,
                                              int lmax,
                                              double beta,
                                              double * __restrict__ x,
                                              double * __restrict__ sinK,
                                              double * __restrict__ cotK,
                                              int chunk,
                                              double * __restrict__ sqrtK,
                                              double * __restrict__ one_over_sqrtK,
                                              double * __restrict__ PhiL){
  double phi0, phi1, phipr1;
  int l, k, isign;
  int funcreturn = _FAILURE_;
  int index_x;
  double scalevec[_HYPER_CHUNK_]={0};

  for (index_x=0; index_x<chunk; index_x++){
    if (K==1){
      if (beta > 1.5*lmax) {
        funcreturn = get_CF1(K,lmax,beta,cotK[index_x], &phipr1, &isign);
      }
      if (funcreturn == _FAILURE_) {
        CF1_from_Gegenbauer(lmax,(int) (beta+0.2),sinK[index_x],cotK[index_x], &phipr1);
      }
      phi1 = 1.0;
    }
    else{
      get_CF1(K,lmax,beta,cotK[index_x], &phipr1, &isign);
      phi1 = isign;
      phipr1 *=phi1;
    }

    PhiL[lmax*chunk+index_x] = phi1;
    PhiL[(lmax-1)*chunk+index_x] = one_over_sqrtK[lmax]*
      ((lmax+1)*cotK[index_x]*phi1+phipr1);

  }
  for (l=lmax-2; l>=0; l--){
    //Use recurrence Phi_{l} = --Phi_{l+1} + -- Phi_{l+2}
    for (index_x=0; index_x<chunk; index_x++){
      PhiL[l*chunk+index_x] = one_over_sqrtK[l+1]*
        ((2*l+3)*cotK[index_x]*PhiL[(l+1)*chunk+index_x]-
         sqrtK[l+2]*PhiL[(l+2)*chunk+index_x]);
    }

    if (fabs(PhiL[l*chunk])>_HYPER_OVERFLOW_){
      //Rescale whole Phi vector until this point.
      //Create scale vector:
      for (index_x=0; index_x<chunk; index_x++)
        scalevec[index_x] = fabs(1.0/PhiL[l*chunk+index_x]);
      //Now do the scaling: (We do it this way to access elements in order)
      for (k=l; k<=lmax; k++){
        for (index_x=0; index_x<chunk; index_x++){
          PhiL[k*chunk+index_x] *= scalevec[index_x];
        }
      }
    }
  }
  for(index_x=0; index_x<chunk; index_x++){
    phi0 = sin(beta*x[index_x])/(beta*sinK[index_x]);
    scalevec[index_x] = phi0/PhiL[index_x];
  }
  for (k=0; k<=lmax; k++){
    for (index_x=0; index_x<chunk; index_x++){
      PhiL[k*chunk+index_x] *= scalevec[index_x];
    }
  }

  return _SUCCESS_;
}

// Assembly:
subq $0xe8, %rsp
movq 0x100(%rsp), %rax
movq 0xf8(%rsp), %rax
movq 0xf0(%rsp), %rax
movl %edi, 0xe4(%rsp)
movl %esi, 0xe0(%rsp)
movsd %xmm0, 0xd8(%rsp)
movq %rdx, 0xd0(%rsp)
movq %rcx, 0xc8(%rsp)
movq %r8, 0xc0(%rsp)
movl %r9d, 0xbc(%rsp)
movl $0x1, 0x90(%rsp)
movq %rsp, %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x8210
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x42dab
cmpl $0x1, 0xe4(%rsp)
jne 0x42c79
movsd 0xd8(%rsp), %xmm0
cvtsi2sdl 0xe0(%rsp), %xmm2
movsd 0x190099(%rip), %xmm1   # 0x1d2c50
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x42c09
movl 0xe4(%rsp), %edi
movl 0xe0(%rsp), %esi
movsd 0xd8(%rsp), %xmm0
movq 0xc0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0xa0(%rsp), %rdx
leaq 0x94(%rsp), %rcx
callq 0x42350
movl %eax, 0x90(%rsp)
cmpl $0x1, 0x90(%rsp)
jne 0x42c66
movl 0xe0(%rsp), %edi
movsd 0x18f65e(%rip), %xmm0   # 0x1d2280
addsd 0xd8(%rsp), %xmm0
cvttsd2si %xmm0, %esi
movq 0xc8(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0xc0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0xa0(%rsp), %rdx
callq 0x42690
movsd 0x18f5da(%rip), %xmm0   # 0x1d2248
movsd %xmm0, 0xa8(%rsp)
jmp 0x42ce7
movl 0xe4(%rsp), %edi
movl 0xe0(%rsp), %esi
movsd 0xd8(%rsp), %xmm0
movq 0xc0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0xa0(%rsp), %rdx
leaq 0x94(%rsp), %rcx
callq 0x42350
cvtsi2sdl 0x94(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd 0xa8(%rsp), %xmm0
mulsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0xa8(%rsp), %xmm0
movq 0x100(%rsp), %rax
movl 0xe0(%rsp), %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0xf8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movl 0xe0(%rsp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
movq 0xc0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm1
movsd 0xa8(%rsp), %xmm3
movsd 0xa0(%rsp), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x100(%rsp), %rax
movl 0xe0(%rsp), %ecx
subl $0x1, %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x42b7b
movl 0xe0(%rsp), %eax
subl $0x2, %eax
movl %eax, 0x9c(%rsp)
cmpl $0x0, 0x9c(%rsp)
jl 0x43059
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x42ef3
movq 0xf8(%rsp), %rax
movl 0x9c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movl 0x9c(%rsp), %eax
shll %eax
addl $0x3, %eax
cvtsi2sd %eax, %xmm1
movq 0xc0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm1
movq 0x100(%rsp), %rax
movl 0x9c(%rsp), %ecx
addl $0x1, %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm3
movq 0xf0(%rsp), %rax
movl 0x9c(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x100(%rsp), %rax
movl 0x9c(%rsp), %ecx
addl $0x2, %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x100(%rsp), %rax
movl 0x9c(%rsp), %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x42dd5
movq 0x100(%rsp), %rax
movl 0x9c(%rsp), %ecx
imull 0xbc(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x18f317(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movsd 0x1925d3(%rip), %xmm1   # 0x1d54f8
ucomisd %xmm1, %xmm0
jbe 0x43041
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x42fa3
movq 0x100(%rsp), %rax
movl 0x9c(%rsp), %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
movsd 0x18f2d5(%rip), %xmm0   # 0x1d2248
divsd (%rax,%rcx,8), %xmm0
movaps 0x18f2b1(%rip), %xmm1   # 0x1d2230
pand %xmm1, %xmm0
movslq 0x8c(%rsp), %rax
movsd %xmm0, (%rsp,%rax,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x42f3a
movl 0x9c(%rsp), %eax
movl %eax, 0x98(%rsp)
movl 0x98(%rsp), %eax
cmpl 0xe0(%rsp), %eax
jg 0x4303f
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x43027
movslq 0x8c(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movq 0x100(%rsp), %rax
movl 0x98(%rsp), %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x42fcc
jmp 0x43029
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x42fb1
jmp 0x43041
jmp 0x43043
movl 0x9c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x42dbc
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x43107
movsd 0xd8(%rsp), %xmm0
movq 0xd0(%rsp), %rax
movslq 0x8c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
callq 0x80a0
movsd 0xd8(%rsp), %xmm1
movq 0xc8(%rsp), %rax
movslq 0x8c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0xb0(%rsp), %xmm0
movq 0x100(%rsp), %rax
movslq 0x8c(%rsp), %rcx
divsd (%rax,%rcx,8), %xmm0
movslq 0x8c(%rsp), %rax
movsd %xmm0, (%rsp,%rax,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x43064
movl $0x0, 0x98(%rsp)
movl 0x98(%rsp), %eax
cmpl 0xe0(%rsp), %eax
jg 0x431a0
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xbc(%rsp), %eax
jge 0x43188
movslq 0x8c(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movq 0x100(%rsp), %rax
movl 0x98(%rsp), %ecx
imull 0xbc(%rsp), %ecx
addl 0x8c(%rsp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x4312d
jmp 0x4318a
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x43112
xorl %eax, %eax
addq $0xe8, %rsp
retq
nopw (%rax,%rax)