// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_source_tau_size
int transfer_source_tau_size(
                             struct precision * ppr,
                             struct background * pba,
                             struct perturbations * ppt,
                             struct transfer * ptr,
                             double tau_rec,
                             double tau0,
                             int index_md,
                             int index_tt,
                             int * tau_size) {

  /* values of conformal time */
  double tau_min,tau_mean,tau_max;

  /* minimum value of index_tt */
  int index_tau_min;

  /* value of l at which limber approximation is switched on */
  int l_limber;

  /* current redshift bin number */
  int bin=0;

  /* scalar mode */
  if (_scalars_) {

    /* scalar temperature */
    if ((ppt->has_cl_cmb_temperature == _TRUE_) &&
        ((index_tt == ptr->index_tt_t0) || (index_tt == ptr->index_tt_t1) || (index_tt == ptr->index_tt_t2)))
      *tau_size = ppt->tau_size;

    /* scalar polarization */
    if ((ppt->has_cl_cmb_polarization == _TRUE_) && (index_tt == ptr->index_tt_e))
      *tau_size = ppt->tau_size;

    /* cmb lensing potential */
    if ((ppt->has_cl_cmb_lensing_potential == _TRUE_) && (index_tt == ptr->index_tt_lcmb)) {

      /* find times before recombination, that will be thrown away */
      index_tau_min=0;
      while (ppt->tau_sampling[index_tau_min]<=tau_rec) index_tau_min++;

      /* infer number of time steps after removing early times */
      *tau_size = ppt->tau_size-index_tau_min;
    }

    /* density Cl's */
    if (_nonintegrated_ncl_) {

      /* bin number associated to particular redshift bin and selection function */
      if (_index_tt_in_range_(ptr->index_tt_density, ppt->selection_num, ppt->has_nc_density))
        bin = index_tt - ptr->index_tt_density;

      if (_index_tt_in_range_(ptr->index_tt_rsd,     ppt->selection_num, ppt->has_nc_rsd))
        bin = index_tt - ptr->index_tt_rsd;

      if (_index_tt_in_range_(ptr->index_tt_d0,      ppt->selection_num, ppt->has_nc_rsd))
        bin = index_tt - ptr->index_tt_d0;

      if (_index_tt_in_range_(ptr->index_tt_d1,      ppt->selection_num, ppt->has_nc_rsd))
        bin = index_tt - ptr->index_tt_d1;

      if (_index_tt_in_range_(ptr->index_tt_nc_g1,   ppt->selection_num, ppt->has_nc_gr))
        bin = index_tt - ptr->index_tt_nc_g1;

      if (_index_tt_in_range_(ptr->index_tt_nc_g2,   ppt->selection_num, ppt->has_nc_gr))
        bin = index_tt - ptr->index_tt_nc_g2;

      if (_index_tt_in_range_(ptr->index_tt_nc_g3,   ppt->selection_num, ppt->has_nc_gr))
        bin = index_tt - ptr->index_tt_nc_g3;

      /* time interval for this bin */
      class_call(transfer_selection_times(ppr,
                                          pba,
                                          ppt,
                                          ptr,
                                          bin,
                                          &tau_min,
                                          &tau_mean,
                                          &tau_max),
                 ptr->error_message,
                 ptr->error_message);

      /* case selection=dirac */
      if (tau_min == tau_max) {
        *tau_size = 1;
      }
      /* other cases (gaussian, top-hat...) */
      else {

        /* check that selection function well sampled */
        *tau_size = (int)ppr->selection_sampling;

        /* value of l at which the code switches to Limber approximation
           (necessary for next step) */
        l_limber=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[bin];
        /* check that bessel well sampled, if not define finer sampling
           overwriting the previous one.
           One Bessel oscillations corresponds to [Delta tau]=2pi/k.
           This is minimal for largest relevant k_max,
           namely k_max=l_limber/(tau0-tau_mean).
           We need to cut the interval (tau_max-tau_min) in pieces of size
           [Delta tau]=2pi/k_max. This gives the number below.
        */
        *tau_size=MAX(*tau_size,(int)((tau_max-tau_min)/((tau0-tau_mean)/MIN(l_limber,ppt->l_lss_max)))*ppr->selection_sampling_bessel);
      }
    }

    /* galaxy lensing Cl's, differs from density Cl's since the source
       function will spread from the selection function region up to
       tau0 */
    if (_integrated_ncl_) {

      /* bin number associated to particular redshift bin and selection function */
      if (_index_tt_in_range_(ptr->index_tt_lensing, ppt->selection_num, ppt->has_cl_lensing_potential))
        bin = index_tt - ptr->index_tt_lensing;

      if (_index_tt_in_range_(ptr->index_tt_nc_lens, ppt->selection_num, ppt->has_nc_lens))
        bin = index_tt - ptr->index_tt_nc_lens;

      if (_index_tt_in_range_(ptr->index_tt_nc_g4,   ppt->selection_num, ppt->has_nc_gr))
        bin = index_tt - ptr->index_tt_nc_g4;

      if (_index_tt_in_range_(ptr->index_tt_nc_g5,   ppt->selection_num, ppt->has_nc_gr))
        bin = index_tt - ptr->index_tt_nc_g5;

      /* time interval for this bin */
      class_call(transfer_selection_times(ppr,
                                          pba,
                                          ppt,
                                          ptr,
                                          bin,
                                          &tau_min,
                                          &tau_mean,
                                          &tau_max),
                 ptr->error_message,
                 ptr->error_message);

      /* check that selection function well sampled */
      *tau_size = (int)ppr->selection_sampling;

      /* value of l at which the code switches to Limber approximation
         (necessary for next step) */
      if (_index_tt_in_range_(ptr->index_tt_nc_g5,   ppt->selection_num, ppt->has_nc_gr)) {
        /* Even if G5 is integrated along the line-of-sight, we do not apply the same Limber criteria as for the other integrated terms, because here we have the derivative of the Bessel.  */
        l_limber=ppr->l_switch_limber_for_nc_local_over_z*ppt->selection_mean[bin];
        *tau_size=MAX(*tau_size,(int)((tau0-tau_min)/((tau0-tau_mean)/2./MIN(l_limber,ppt->l_lss_max)))*ppr->selection_sampling_bessel);
      }
      else {
        l_limber=ppr->l_switch_limber_for_nc_los_over_z*ppt->selection_mean[bin];
        /* check that bessel well sampled, if not define finer sampling
           overwriting the previous one.
           One Bessel oscillations corresponds to [Delta tau]=2pi/k.
           This is minimal for largest relevant k_max,
           namely k_max=l_limber/((tau0-tau_mean)/2).
           We need to cut the interval (tau_0-tau_min) in pieces of size
           [Delta tau]=2pi/k_max. This gives the number below.
        */
        *tau_size=MAX(*tau_size,(int)((tau0-tau_min)/((tau0-tau_mean)/2./MIN(l_limber,ppt->l_lss_max)))*ppr->selection_sampling_bessel_los);
      }
    }
  }

  /* tensor mode */
  if (_tensors_) {

    /* for all tensor types */
    *tau_size = ppt->tau_size;
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movl %r8d, %ebx
movq %rdx, %r14
movq %rdi, %r8
movq 0x870(%rsp), %rdi
cmpw $0x1, 0xe(%rdx)
jne 0xa539e
cmpl %ebx, 0x848(%r14)
jne 0xa539e
movl %r9d, %ebp
movq %rcx, %r12
cmpw $0x1, 0x28(%r14)
jne 0xa4e5b
cmpl %ebp, 0x8a8(%r12)
je 0xa4e52
cmpl %ebp, 0x8ac(%r12)
je 0xa4e52
cmpl %ebp, 0x8b0(%r12)
jne 0xa4e5b
movl 0x9f8(%r14), %eax
movl %eax, (%rdi)
cmpw $0x1, 0x2a(%r14)
jne 0xa4e76
cmpl %ebp, 0x8b4(%r12)
jne 0xa4e76
movl 0x9f8(%r14), %eax
movl %eax, (%rdi)
cmpw $0x1, 0x2c(%r14)
jne 0xa4ea7
cmpl %ebp, 0x8bc(%r12)
jne 0xa4ea7
movq 0x9f0(%r14), %rcx
pushq $0x1
popq %rax
decl %eax
ucomisd (%rcx), %xmm0
leaq 0x8(%rcx), %rcx
jae 0xa4e92
addl 0x9f8(%r14), %eax
movl %eax, (%rdi)
pushq $0x1
popq %r13
movzwl 0x3e(%r14), %ecx
cmpw $0x1, %cx
jne 0xa4ed3
movl 0x8c0(%r12), %edx
cmpl %ebp, %edx
jg 0xa4ed3
movl 0x64(%r14), %eax
leal (%rax,%rdx), %r9d
cmpl %ebp, %r9d
jg 0xa4f88
cmpw $0x1, 0x40(%r14)
jne 0xa4f21
movl 0x8c8(%r12), %edx
cmpl %ebp, %edx
jg 0xa4ef5
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa4f7a
movl 0x8cc(%r12), %edx
cmpl %ebp, %edx
jg 0xa4f0b
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa4f7a
movl 0x8d0(%r12), %edx
cmpl %ebp, %edx
jg 0xa4f21
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa4f7a
xorl %r15d, %r15d
cmpw $0x1, 0x44(%r14)
jne 0xa5183
movl 0x8d8(%r12), %edx
cmpl %ebp, %edx
jg 0xa4f46
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa4f7a
movl 0x8dc(%r12), %edx
cmpl %ebp, %edx
jg 0xa4f5c
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa4f7a
movl 0x8e0(%r12), %edx
cmpl %ebp, %edx
jg 0xa5183
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jle 0xa5183
cmpw $0x1, %cx
jne 0xa4f8e
movl 0x8c0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jge 0xa4f93
xorl %r15d, %r15d
jmp 0xa4f9e
addl %eax, %edx
xorl %r15d, %r15d
cmpl %ebp, %edx
cmovgl %ecx, %r15d
cmpw $0x1, 0x40(%r14)
jne 0xa4ff6
movl 0x8c8(%r12), %ecx
movl 0x8cc(%r12), %edx
movl %ebp, %r9d
subl %ecx, %r9d
leal (%rax,%rcx), %edi
cmpl %ebp, %edi
cmovlel %r15d, %r9d
cmpl %ecx, %ebp
cmovll %r15d, %r9d
movl %ebp, %r15d
subl %edx, %r15d
leal (%rax,%rdx), %ecx
cmpl %ebp, %ecx
cmovlel %r9d, %r15d
cmpl %edx, %ebp
cmovll %r9d, %r15d
movl 0x8d0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xa4ff6
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r15d
cmpw $0x1, 0x44(%r14)
movl %ebx, 0xc(%rsp)
movsd %xmm1, (%rsp)
jne 0xa5057
movl 0x8d8(%r12), %ecx
movl 0x8dc(%r12), %edx
movl %ebp, %r9d
subl %ecx, %r9d
leal (%rax,%rcx), %edi
cmpl %ebp, %edi
cmovlel %r15d, %r9d
cmpl %ecx, %ebp
cmovll %r15d, %r9d
movl %ebp, %r15d
subl %edx, %r15d
leal (%rax,%rdx), %ecx
cmpl %ebp, %ecx
cmovlel %r9d, %r15d
cmpl %edx, %ebp
cmovll %r9d, %r15d
movl 0x8e0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xa5057
addl %edx, %eax
cmpl %ebp, %eax
cmovgl %ecx, %r15d
leaq 0x20(%rsp), %rax
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r9
movq %r8, %rdi
movq %r14, %rdx
movq %r8, %rbx
movl %r15d, %r8d
pushq %rax
pushq %rcx
movq %rsi, %r13
callq 0xa53d0
popq %rcx
popq %rdx
testl %eax, %eax
je 0xa50d2
addq $0x96a, %r12            # imm = 0x96A
leaq 0x40360(%rip), %rsi     # 0xe53f0
leaq 0x71019(%rip), %rdx     # 0x1160b0
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3ff84(%rip), %rsi     # 0xe5034
leaq 0x7104a(%rip), %rdx     # 0x116101
movq %r12, %rdi
movl $0x6d9, %ecx            # imm = 0x6D9
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %r13
jmp 0xa53bb
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
ucomisd %xmm0, %xmm1
jne 0xa50ff
jp 0xa50ff
pushq $0x1
popq %rax
movq 0x870(%rsp), %rdi
movq %rbx, %r8
movl 0xc(%rsp), %ebx
movsd (%rsp), %xmm1
jmp 0xa517a
movq %rbx, %r8
movsd 0x810(%rbx), %xmm2
cvttsd2si %xmm2, %eax
movq 0x870(%rsp), %rdi
movl %eax, (%rdi)
movsd 0x7f8(%rbx), %xmm3
movslq %r15d, %rax
mulsd 0x70(%r14,%rax,8), %xmm3
cvttsd2si %xmm3, %eax
cvttpd2dq %xmm2, %xmm2
cvtdq2pd %xmm2, %xmm2
subsd %xmm1, %xmm0
movsd (%rsp), %xmm1
movapd %xmm1, %xmm4
subsd 0x10(%rsp), %xmm4
movl 0x54(%r14), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
cvtsi2sd %eax, %xmm3
divsd %xmm3, %xmm4
divsd %xmm4, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd 0x818(%rbx), %xmm0
maxsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
movl 0xc(%rsp), %ebx
movq %r13, %rsi
movl %eax, (%rdi)
pushq $0x1
popq %r13
movzwl 0x2e(%r14), %ecx
cmpw $0x1, %cx
jne 0xa51a7
movl 0x8c4(%r12), %edx
cmpl %ebp, %edx
jg 0xa51a7
movl 0x64(%r14), %eax
leal (%rax,%rdx), %r9d
cmpl %ebp, %r9d
jg 0xa5213
cmpw $0x1, 0x42(%r14)
jne 0xa51c5
movl 0x8d4(%r12), %edx
cmpl %ebp, %edx
jg 0xa51c5
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa5205
cmpw $0x1, 0x44(%r14)
jne 0xa539e
movl 0x8e4(%r12), %edx
cmpl %ebp, %edx
jg 0xa51e7
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xa5205
movl 0x8e8(%r12), %edx
cmpl %ebp, %edx
jg 0xa539e
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jle 0xa539e
cmpw $0x1, %cx
jne 0xa5221
movl 0x8c4(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xa5221
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r15d
cmpw $0x1, 0x42(%r14)
jne 0xa523f
movl 0x8d4(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xa523f
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r15d
cmpw $0x1, 0x44(%r14)
movsd %xmm1, (%rsp)
jne 0xa527f
movl 0x8e4(%r12), %edx
movl 0x8e8(%r12), %ecx
movl %ebp, %r9d
subl %edx, %r9d
leal (%rax,%rdx), %edi
cmpl %ebp, %edi
cmovlel %r15d, %r9d
cmpl %edx, %ebp
cmovgel %r9d, %r15d
movl %ebp, %edx
subl %ecx, %edx
jl 0xa527f
addl %ecx, %eax
cmpl %ebp, %eax
cmovgl %edx, %r15d
leaq 0x20(%rsp), %rax
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r9
movq %r8, %rdi
movq %r14, %rdx
movq %r8, 0x28(%rsp)
movl %r15d, %r8d
pushq %rax
pushq %rcx
callq 0xa53d0
popq %rcx
popq %rdx
testl %eax, %eax
je 0xa52f5
addq $0x96a, %r12            # imm = 0x96A
leaq 0x40139(%rip), %rsi     # 0xe53f0
leaq 0x70df2(%rip), %rdx     # 0x1160b0
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3fd5d(%rip), %rsi     # 0xe5034
leaq 0x70e23(%rip), %rdx     # 0x116101
movq %r12, %rdi
movl $0x710, %ecx            # imm = 0x710
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0xa53bb
movq 0x28(%rsp), %rsi
cvttsd2si 0x810(%rsi), %ecx
movq 0x870(%rsp), %rdi
movl %ecx, (%rdi)
cmpw $0x1, 0x44(%r14)
jne 0xa5334
movl 0x8e8(%r12), %eax
cmpl %ebp, %eax
jg 0xa5334
addl 0x64(%r14), %eax
cmpl %ebp, %eax
jle 0xa5334
movl $0x818, %eax            # imm = 0x818
movl $0x7f8, %edx            # imm = 0x7F8
jmp 0xa533e
movl $0x820, %eax            # imm = 0x820
movl $0x800, %edx            # imm = 0x800
movsd (%rsp), %xmm3
movsd (%rsi,%rdx), %xmm0
movslq %r15d, %rdx
mulsd 0x70(%r14,%rdx,8), %xmm0
cvtsi2sd %ecx, %xmm1
movapd %xmm3, %xmm2
subsd 0x18(%rsp), %xmm2
cvttsd2si %xmm0, %ecx
subsd 0x10(%rsp), %xmm3
mulsd 0x4093e(%rip), %xmm3    # 0xe5cb0
movl 0x54(%r14), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
cvtsi2sd %ecx, %xmm0
divsd %xmm0, %xmm3
divsd %xmm3, %xmm2
cvttpd2dq %xmm2, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd (%rsi,%rax), %xmm0
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, (%rdi)
xorl %r13d, %r13d
cmpw $0x1, 0x12(%r14)
jne 0xa53bb
cmpl %ebx, 0x84c(%r14)
jne 0xa53bb
movl 0x9f8(%r14), %eax
movl %eax, (%rdi)
movl %r13d, %eax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq