// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_use_limber
int transfer_use_limber(
                        struct precision * ppr,
                        struct perturbations * ppt,
                        struct transfer * ptr,
                        double q_max_bessel,
                        int index_md,
                        int index_tt,
                        double q,
                        double l,
                        short * use_limber) {


  /* criteria for choosing between integration and Limber
     must be implemented here */

  *use_limber = _FALSE_;

  if (q>q_max_bessel) {
    *use_limber = _TRUE_;
  }
  else {

    if (_scalars_) {

      //TBC: in principle the Limber condition should be adapted to account for curvature effects

      if ((ppt->has_cl_cmb_lensing_potential == _TRUE_) && (index_tt == ptr->index_tt_lcmb) && (l>ppr->l_switch_limber)) {
        *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_density, ppt->selection_num, ppt->has_nc_density) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_density])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_rsd,     ppt->selection_num, ppt->has_nc_rsd) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_rsd])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_d0,      ppt->selection_num, ppt->has_nc_rsd) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_d0])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_d1,      ppt->selection_num, ppt->has_nc_rsd) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_d1])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_lens, ppt->selection_num, ppt->has_nc_lens) && (l>=ppr->l_switch_limber_for_nc_los_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_lens])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_g1, ppt->selection_num, ppt->has_nc_gr) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_g1])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_g2, ppt->selection_num, ppt->has_nc_gr) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_g2])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_g3, ppt->selection_num, ppt->has_nc_gr) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_g3])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_g4, ppt->selection_num, ppt->has_nc_gr) && (l>=ppr->l_switch_limber_for_nc_los_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_g4])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_nc_g5, ppt->selection_num, ppt->has_nc_gr) && (l>=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[index_tt-ptr->index_tt_nc_g5])) {
        if (ppt->selection != dirac) *use_limber = _TRUE_;
      }
      if (_index_tt_in_range_(ptr->index_tt_lensing, ppt->selection_num, ppt->has_cl_lensing_potential) && (l>=ppr->l_switch_limber_for_nc_los_over_z*ppt->selection_mean[index_tt-ptr->index_tt_lensing])) {
        *use_limber = _TRUE_;
      }
    }
  }

  return _SUCCESS_;
}

// Assembly:
movw $0x0, (%r9)
ucomisd %xmm0, %xmm1
jbe 0xb08c5
movw $0x1, (%r9)
jmp 0xb0b9e
cmpw $0x1, 0xe(%rsi)
jne 0xb0b9e
cmpl %ecx, 0x848(%rsi)
jne 0xb0b9e
cmpw $0x1, 0x2c(%rsi)
jne 0xb08fc
cmpl %r8d, 0x8bc(%rdx)
jne 0xb08fc
ucomisd 0x7f0(%rdi), %xmm2
jbe 0xb08fc
movw $0x1, (%r9)
cmpw $0x1, 0x3e(%rsi)
jne 0xb093a
movl 0x8c0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb093a
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb093a
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb093a
cmpl $0x2, 0x68(%rsi)
je 0xb093a
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xb0978
movl 0x8c8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0978
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0978
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0978
cmpl $0x2, 0x68(%rsi)
je 0xb0978
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xb09b6
movl 0x8cc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb09b6
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb09b6
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb09b6
cmpl $0x2, 0x68(%rsi)
je 0xb09b6
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xb09f4
movl 0x8d0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb09f4
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb09f4
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb09f4
cmpl $0x2, 0x68(%rsi)
je 0xb09f4
movw $0x1, (%r9)
cmpw $0x1, 0x42(%rsi)
jne 0xb0a32
movl 0x8d4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0a32
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0a32
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0a32
cmpl $0x2, 0x68(%rsi)
je 0xb0a32
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xb0a70
movl 0x8d8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0a70
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0a70
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0a70
cmpl $0x2, 0x68(%rsi)
je 0xb0a70
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xb0aae
movl 0x8dc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0aae
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0aae
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0aae
cmpl $0x2, 0x68(%rsi)
je 0xb0aae
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xb0aec
movl 0x8e0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0aec
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0aec
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0aec
cmpl $0x2, 0x68(%rsi)
je 0xb0aec
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xb0b2a
movl 0x8e4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0b2a
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0b2a
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0b2a
cmpl $0x2, 0x68(%rsi)
je 0xb0b2a
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xb0b68
movl 0x8e8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0b68
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0b68
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xb0b68
cmpl $0x2, 0x68(%rsi)
je 0xb0b68
movw $0x1, (%r9)
cmpw $0x1, 0x2e(%rsi)
jne 0xb0b9e
movl 0x8c4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xb0b9e
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xb0b9e
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jae 0xb08ba
xorl %eax, %eax
retq