// File: /workspace/github_c_makefile_star2_O2/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:
andw $0x0, (%r9)
ucomisd %xmm0, %xmm1
jbe 0xa8078
movw $0x1, (%r9)
jmp 0xa8361
cmpw $0x1, 0xe(%rsi)
jne 0xa8361
cmpl %ecx, 0x848(%rsi)
jne 0xa8361
cmpw $0x1, 0x2c(%rsi)
jne 0xa80af
cmpl %r8d, 0x8bc(%rdx)
jne 0xa80af
ucomisd 0x7f0(%rdi), %xmm2
jbe 0xa80af
movw $0x1, (%r9)
cmpw $0x1, 0x3e(%rsi)
jne 0xa80ed
movl 0x8c0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa80ed
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa80ed
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa80ed
cmpl $0x2, 0x68(%rsi)
je 0xa80ed
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xa81ab
movl 0x8c8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa8136
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa8136
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa8136
cmpl $0x2, 0x68(%rsi)
je 0xa8136
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xa81ab
movl 0x8cc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa8174
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa8174
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa8174
cmpl $0x2, 0x68(%rsi)
je 0xa8174
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xa81ab
movl 0x8d0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa81ab
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa81ab
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa81ab
cmpl $0x2, 0x68(%rsi)
je 0xa81ab
movw $0x1, (%r9)
cmpw $0x1, 0x42(%rsi)
jne 0xa81e9
movl 0x8d4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa81e9
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa81e9
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa81e9
cmpl $0x2, 0x68(%rsi)
je 0xa81e9
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xa832b
movl 0x8d8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa8236
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa8236
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa8236
cmpl $0x2, 0x68(%rsi)
je 0xa8236
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xa832b
movl 0x8dc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa8278
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa8278
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa8278
cmpl $0x2, 0x68(%rsi)
je 0xa8278
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xa832b
movl 0x8e0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa82b6
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa82b6
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa82b6
cmpl $0x2, 0x68(%rsi)
je 0xa82b6
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xa832b
movl 0x8e4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa82f4
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa82f4
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa82f4
cmpl $0x2, 0x68(%rsi)
je 0xa82f4
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xa832b
movl 0x8e8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa832b
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa832b
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xa832b
cmpl $0x2, 0x68(%rsi)
je 0xa832b
movw $0x1, (%r9)
cmpw $0x1, 0x2e(%rsi)
jne 0xa8361
movl 0x8c4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xa8361
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xa8361
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jae 0xa806d
xorl %eax, %eax
retq