// File: /workspace/github_c_makefile_star2_O3/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 0xad82f
movw $0x1, (%r9)
jmp 0xadb18
cmpw $0x1, 0xe(%rsi)
jne 0xadb18
cmpl %ecx, 0x848(%rsi)
jne 0xadb18
cmpw $0x1, 0x2c(%rsi)
jne 0xad866
cmpl %r8d, 0x8bc(%rdx)
jne 0xad866
ucomisd 0x7f0(%rdi), %xmm2
jbe 0xad866
movw $0x1, (%r9)
cmpw $0x1, 0x3e(%rsi)
jne 0xad8a4
movl 0x8c0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad8a4
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad8a4
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad8a4
cmpl $0x2, 0x68(%rsi)
je 0xad8a4
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xad962
movl 0x8c8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad8ed
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad8ed
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad8ed
cmpl $0x2, 0x68(%rsi)
je 0xad8ed
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xad962
movl 0x8cc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad92b
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad92b
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad92b
cmpl $0x2, 0x68(%rsi)
je 0xad92b
movw $0x1, (%r9)
cmpw $0x1, 0x40(%rsi)
jne 0xad962
movl 0x8d0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad962
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad962
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad962
cmpl $0x2, 0x68(%rsi)
je 0xad962
movw $0x1, (%r9)
cmpw $0x1, 0x42(%rsi)
jne 0xad9a0
movl 0x8d4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad9a0
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad9a0
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad9a0
cmpl $0x2, 0x68(%rsi)
je 0xad9a0
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xadae2
movl 0x8d8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xad9ed
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xad9ed
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xad9ed
cmpl $0x2, 0x68(%rsi)
je 0xad9ed
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xadae2
movl 0x8dc(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xada2f
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xada2f
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xada2f
cmpl $0x2, 0x68(%rsi)
je 0xada2f
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xadae2
movl 0x8e0(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xada6d
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xada6d
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xada6d
cmpl $0x2, 0x68(%rsi)
je 0xada6d
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xadae2
movl 0x8e4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xadaab
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xadaab
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xadaab
cmpl $0x2, 0x68(%rsi)
je 0xadaab
movw $0x1, (%r9)
cmpw $0x1, 0x44(%rsi)
jne 0xadae2
movl 0x8e8(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xadae2
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xadae2
movsd 0x7f8(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jb 0xadae2
cmpl $0x2, 0x68(%rsi)
je 0xadae2
movw $0x1, (%r9)
cmpw $0x1, 0x2e(%rsi)
jne 0xadb18
movl 0x8c4(%rdx), %ecx
movl %r8d, %eax
subl %ecx, %eax
jl 0xadb18
addl 0x64(%rsi), %ecx
cmpl %r8d, %ecx
jle 0xadb18
movsd 0x800(%rdi), %xmm0
cltq
mulsd 0x70(%rsi,%rax,8), %xmm0
ucomisd %xmm0, %xmm2
jae 0xad824
xorl %eax, %eax
retq