// File: /workspace/github_c_makefile_star2_O1/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 0x870(%rsp), %r8
cmpw $0x1, 0xe(%rdx)
jne 0xad8ae
cmpl %ebx, 0x848(%r14)
jne 0xad8ae
movl %r9d, %ebp
movq %rcx, %r12
cmpw $0x1, 0x28(%r14)
jne 0xad33f
cmpl %ebp, 0x8a8(%r12)
je 0xad335
cmpl %ebp, 0x8ac(%r12)
je 0xad335
cmpl %ebp, 0x8b0(%r12)
jne 0xad33f
movl 0x9f8(%r14), %eax
movl %eax, (%r8)
cmpw $0x1, 0x2a(%r14)
jne 0xad35b
cmpl %ebp, 0x8b4(%r12)
jne 0xad35b
movl 0x9f8(%r14), %eax
movl %eax, (%r8)
cmpw $0x1, 0x2c(%r14)
jne 0xad38f
cmpl %ebp, 0x8bc(%r12)
jne 0xad38f
movq 0x9f0(%r14), %rcx
movl $0x1, %eax
decl %eax
ucomisd (%rcx), %xmm0
leaq 0x8(%rcx), %rcx
jae 0xad379
addl 0x9f8(%r14), %eax
movl %eax, (%r8)
movzwl 0x3e(%r14), %eax
cmpw $0x1, %ax
jne 0xad3b2
movl 0x8c0(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad3b2
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jg 0xad477
movzwl 0x40(%r14), %ecx
cmpw $0x1, %cx
jne 0xad40d
movl 0x8c8(%r12), %edx
cmpl %ebp, %edx
jg 0xad3d5
addl 0x64(%r14), %edx
cmpl %ebp, %edx
jg 0xad477
cmpw $0x1, %cx
jne 0xad40d
movl 0x8cc(%r12), %edx
cmpl %ebp, %edx
jg 0xad3f3
addl 0x64(%r14), %edx
cmpl %ebp, %edx
jg 0xad477
cmpw $0x1, %cx
jne 0xad40d
movl 0x8d0(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad40d
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jg 0xad477
movzwl 0x44(%r14), %ecx
xorl %r13d, %r13d
cmpw $0x1, %cx
jne 0xad671
movl 0x8d8(%r12), %edx
cmpl %ebp, %edx
jg 0xad433
addl 0x64(%r14), %edx
cmpl %ebp, %edx
jg 0xad477
cmpw $0x1, %cx
jne 0xad671
movl 0x8dc(%r12), %edx
cmpl %ebp, %edx
jg 0xad451
addl 0x64(%r14), %edx
cmpl %ebp, %edx
jg 0xad477
cmpw $0x1, %cx
jne 0xad671
movl 0x8e0(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad671
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jle 0xad671
xorl %r8d, %r8d
cmpw $0x1, %ax
jne 0xad49b
movl 0x8c0(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad49b
addl 0x64(%r14), %ecx
xorl %r8d, %r8d
cmpl %ebp, %ecx
cmovgl %eax, %r8d
movzwl 0x40(%r14), %eax
cmpw $0x1, %ax
jne 0xad4be
movl 0x8c8(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xad4be
addl 0x64(%r14), %edx
cmpl %ebp, %edx
cmovgl %ecx, %r8d
cmpw $0x1, %ax
jne 0xad4dc
movl 0x8cc(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xad4dc
addl 0x64(%r14), %edx
cmpl %ebp, %edx
cmovgl %ecx, %r8d
cmpw $0x1, %ax
jne 0xad4fa
movl 0x8d0(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad4fa
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
cmovgl %eax, %r8d
movzwl 0x44(%r14), %eax
cmpw $0x1, %ax
jne 0xad51d
movl 0x8d8(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xad51d
addl 0x64(%r14), %edx
cmpl %ebp, %edx
cmovgl %ecx, %r8d
cmpw $0x1, %ax
jne 0xad53b
movl 0x8dc(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xad53b
addl 0x64(%r14), %edx
cmpl %ebp, %edx
cmovgl %ecx, %r8d
cmpw $0x1, %ax
movsd %xmm1, 0x8(%rsp)
movl %ebx, 0x24(%rsp)
jne 0xad563
movl 0x8e0(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad563
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
cmovgl %eax, %r8d
leaq 0x28(%rsp), %rax
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r9
movq %rdi, %r15
movq %r14, %rdx
movq %rsi, %r13
movl %r8d, %ebx
pushq %rax
pushq %rcx
callq 0xad8dd
addq $0x10, %rsp
testl %eax, %eax
je 0xad5cf
addq $0x96a, %r12            # imm = 0x96A
leaq 0x43e55(%rip), %rsi     # 0xf13f0
leaq 0x74c3e(%rip), %rdx     # 0x1221e0
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x43a79(%rip), %rsi     # 0xf1034
leaq 0x74c6f(%rip), %rdx     # 0x122231
movq %r12, %rdi
movl $0x6d9, %ecx            # imm = 0x6D9
jmp 0xad7de
movq %r13, %rsi
movsd 0x18(%rsp), %xmm4
movsd 0x28(%rsp), %xmm0
movl $0x1, %eax
ucomisd %xmm0, %xmm4
movq 0x870(%rsp), %r8
movq %r15, %rdi
movsd 0x8(%rsp), %xmm1
movl %ebx, %r13d
jne 0xad5ff
jnp 0xad66a
movsd 0x810(%rdi), %xmm2
cvttsd2si %xmm2, %eax
movl %eax, (%r8)
movsd 0x7f8(%rdi), %xmm3
movslq %r13d, %rax
mulsd 0x70(%r14,%rax,8), %xmm3
cvttsd2si %xmm3, %eax
cvttpd2dq %xmm2, %xmm2
cvtdq2pd %xmm2, %xmm2
subsd %xmm4, %xmm0
movapd %xmm1, %xmm4
subsd 0x10(%rsp), %xmm4
movl 0x54(%r14), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
divsd %xmm3, %xmm4
divsd %xmm4, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd 0x818(%rdi), %xmm0
maxsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, (%r8)
movl 0x24(%rsp), %ebx
movzwl 0x2e(%r14), %eax
cmpw $0x1, %ax
jne 0xad690
movl 0x8c4(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad690
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jg 0xad6f5
cmpw $0x1, 0x42(%r14)
jne 0xad6ac
movl 0x8d4(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad6ac
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jg 0xad6f5
movzwl 0x44(%r14), %ecx
cmpw $0x1, %cx
jne 0xad8ae
movl 0x8e4(%r12), %edx
cmpl %ebp, %edx
jg 0xad6cf
addl 0x64(%r14), %edx
cmpl %ebp, %edx
jg 0xad6f5
cmpw $0x1, %cx
jne 0xad8ae
movl 0x8e8(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad8ae
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jle 0xad8ae
cmpw $0x1, %ax
jne 0xad713
movl 0x8c4(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad713
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
cmovgl %eax, %r13d
cmpw $0x1, 0x42(%r14)
jne 0xad733
movl 0x8d4(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad733
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
cmovgl %eax, %r13d
movzwl 0x44(%r14), %eax
cmpw $0x1, %ax
jne 0xad756
movl 0x8e4(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xad756
addl 0x64(%r14), %edx
cmpl %ebp, %edx
cmovgl %ecx, %r13d
cmpw $0x1, %ax
movsd %xmm1, 0x8(%rsp)
jne 0xad77a
movl 0x8e8(%r12), %ecx
movl %ebp, %eax
subl %ecx, %eax
jl 0xad77a
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
cmovgl %eax, %r13d
leaq 0x28(%rsp), %rax
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r9
movq %rdi, %r15
movq %r14, %rdx
movl %r13d, %r8d
pushq %rax
pushq %rcx
callq 0xad8dd
addq $0x10, %rsp
testl %eax, %eax
je 0xad7f2
addq $0x96a, %r12            # imm = 0x96A
leaq 0x43c41(%rip), %rsi     # 0xf13f0
leaq 0x74a2a(%rip), %rdx     # 0x1221e0
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x43865(%rip), %rsi     # 0xf1034
leaq 0x74a5b(%rip), %rdx     # 0x122231
movq %r12, %rdi
movl $0x710, %ecx            # imm = 0x710
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0xad8cb
cvttsd2si 0x810(%r15), %eax
movq 0x870(%rsp), %r8
movl %eax, (%r8)
cmpw $0x1, 0x44(%r14)
jne 0xad83c
movl 0x8e8(%r12), %ecx
cmpl %ebp, %ecx
jg 0xad83c
addl 0x64(%r14), %ecx
cmpl %ebp, %ecx
jle 0xad83c
movsd 0x7f8(%r15), %xmm0
movslq %r13d, %rcx
mulsd 0x70(%r14,%rcx,8), %xmm0
movl $0x818, %ecx            # imm = 0x818
jmp 0xad854
movsd 0x800(%r15), %xmm0
movslq %r13d, %rcx
mulsd 0x70(%r14,%rcx,8), %xmm0
movl $0x820, %ecx            # imm = 0x820
movsd 0x8(%rsp), %xmm3
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movapd %xmm3, %xmm2
subsd 0x18(%rsp), %xmm2
cvttsd2si %xmm0, %eax
subsd 0x10(%rsp), %xmm3
mulsd 0x44453(%rip), %xmm3    # 0xf1cd0
movl 0x54(%r14), %edx
cmpl %eax, %edx
cmovll %edx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm3
divsd %xmm3, %xmm2
cvttpd2dq %xmm2, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd (%r15,%rcx), %xmm0
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, (%r8)
xorl %eax, %eax
cmpw $0x1, 0x12(%r14)
jne 0xad8cb
cmpl %ebx, 0x84c(%r14)
jne 0xad8cb
movl 0x9f8(%r14), %ecx
movl %ecx, (%r8)
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq