// File: /workspace/github_c_makefile_star2_O3/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
movq %rdx, %r14
movq 0x870(%rsp), %r11
cmpw $0x1, 0xe(%rdx)
jne 0xaa810
cmpl %r8d, 0x848(%r14)
jne 0xaa810
movl %r9d, %ebp
movq %rcx, %r12
cmpw $0x1, 0x28(%r14)
jne 0xaa2ce
cmpl %ebp, 0x8a8(%r12)
je 0xaa2c4
cmpl %ebp, 0x8ac(%r12)
je 0xaa2c4
cmpl %ebp, 0x8b0(%r12)
jne 0xaa2ce
movl 0x9f8(%r14), %eax
movl %eax, (%r11)
cmpw $0x1, 0x2a(%r14)
jne 0xaa2ea
cmpl %ebp, 0x8b4(%r12)
jne 0xaa2ea
movl 0x9f8(%r14), %eax
movl %eax, (%r11)
cmpw $0x1, 0x2c(%r14)
jne 0xaa31e
cmpl %ebp, 0x8bc(%r12)
jne 0xaa31e
movq 0x9f0(%r14), %rcx
movl $0x1, %eax
decl %eax
ucomisd (%rcx), %xmm0
leaq 0x8(%rcx), %rcx
jae 0xaa308
addl 0x9f8(%r14), %eax
movl %eax, (%r11)
movzwl 0x3e(%r14), %ecx
cmpw $0x1, %cx
jne 0xaa346
movl 0x8c0(%r12), %edx
cmpl %ebp, %edx
jg 0xaa346
movl 0x64(%r14), %eax
leal (%rax,%rdx), %r9d
cmpl %ebp, %r9d
jg 0xaa3fb
cmpw $0x1, 0x40(%r14)
jne 0xaa394
movl 0x8c8(%r12), %edx
cmpl %ebp, %edx
jg 0xaa368
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa3ed
movl 0x8cc(%r12), %edx
cmpl %ebp, %edx
jg 0xaa37e
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa3ed
movl 0x8d0(%r12), %edx
cmpl %ebp, %edx
jg 0xaa394
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa3ed
xorl %r13d, %r13d
cmpw $0x1, 0x44(%r14)
jne 0xaa5dc
movl 0x8d8(%r12), %edx
cmpl %ebp, %edx
jg 0xaa3b9
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa3ed
movl 0x8dc(%r12), %edx
cmpl %ebp, %edx
jg 0xaa3cf
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa3ed
movl 0x8e0(%r12), %edx
cmpl %ebp, %edx
jg 0xaa5dc
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jle 0xaa5dc
cmpw $0x1, %cx
jne 0xaa401
movl 0x8c0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jge 0xaa406
xorl %r13d, %r13d
jmp 0xaa411
addl %eax, %edx
xorl %r13d, %r13d
cmpl %ebp, %edx
cmovgl %ecx, %r13d
cmpw $0x1, 0x40(%r14)
jne 0xaa46b
movl 0x8c8(%r12), %ecx
movl 0x8cc(%r12), %edx
movl %ebp, %r10d
subl %ecx, %r10d
leal (%rax,%rcx), %r9d
cmpl %ebp, %r9d
cmovlel %r13d, %r10d
cmpl %ecx, %ebp
cmovll %r13d, %r10d
movl %ebp, %r13d
subl %edx, %r13d
leal (%rax,%rdx), %ecx
cmpl %ebp, %ecx
cmovlel %r10d, %r13d
cmpl %edx, %ebp
cmovll %r10d, %r13d
movl 0x8d0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xaa46b
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r13d
cmpw $0x1, 0x44(%r14)
movl %r8d, 0xc(%rsp)
movsd %xmm1, 0x10(%rsp)
jne 0xaa4d0
movl 0x8d8(%r12), %ecx
movl 0x8dc(%r12), %edx
movl %ebp, %r10d
subl %ecx, %r10d
leal (%rax,%rcx), %r9d
cmpl %ebp, %r9d
cmovlel %r13d, %r10d
cmpl %ecx, %ebp
cmovll %r13d, %r10d
movl %ebp, %r13d
subl %edx, %r13d
leal (%rax,%rdx), %ecx
cmpl %ebp, %ecx
cmovlel %r10d, %r13d
cmpl %edx, %ebp
cmovll %r10d, %r13d
movl 0x8e0(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xaa4d0
addl %edx, %eax
cmpl %ebp, %eax
cmovgl %ecx, %r13d
leaq 0x28(%rsp), %rax
leaq 0x18(%rsp), %rcx
leaq 0x20(%rsp), %r9
movq %r14, %rdx
movl %r13d, %r8d
pushq %rax
pushq %rcx
movq %rdi, %rbx
movq %rsi, %r15
callq 0xaa83f
addq $0x10, %rsp
testl %eax, %eax
je 0xaa53c
addq $0x96a, %r12            # imm = 0x96A
leaq 0x43ee8(%rip), %rsi     # 0xee3f0
leaq 0x74d11(%rip), %rdx     # 0x11f220
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x43b0c(%rip), %rsi     # 0xee034
leaq 0x74d42(%rip), %rdx     # 0x11f271
movq %r12, %rdi
movl $0x6d9, %ecx            # imm = 0x6D9
jmp 0xaa74c
movsd 0x20(%rsp), %xmm4
movsd 0x28(%rsp), %xmm0
movl $0x1, %eax
ucomisd %xmm0, %xmm4
movq 0x870(%rsp), %r11
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm1
jne 0xaa566
jnp 0xaa5d1
movsd 0x810(%rdi), %xmm2
cvttsd2si %xmm2, %eax
movl %eax, (%r11)
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 0x18(%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, (%r11)
movl 0xc(%rsp), %r8d
movq %r15, %rsi
movzwl 0x2e(%r14), %ecx
cmpw $0x1, %cx
jne 0xaa600
movl 0x8c4(%r12), %edx
cmpl %ebp, %edx
jg 0xaa600
movl 0x64(%r14), %eax
leal (%rax,%rdx), %r9d
cmpl %ebp, %r9d
jg 0xaa66c
cmpw $0x1, 0x42(%r14)
jne 0xaa61e
movl 0x8d4(%r12), %edx
cmpl %ebp, %edx
jg 0xaa61e
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa65e
cmpw $0x1, 0x44(%r14)
jne 0xaa810
movl 0x8e4(%r12), %edx
cmpl %ebp, %edx
jg 0xaa640
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jg 0xaa65e
movl 0x8e8(%r12), %edx
cmpl %ebp, %edx
jg 0xaa810
movl 0x64(%r14), %eax
addl %eax, %edx
cmpl %ebp, %edx
jle 0xaa810
cmpw $0x1, %cx
jne 0xaa67a
movl 0x8c4(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xaa67a
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r13d
cmpw $0x1, 0x42(%r14)
jne 0xaa698
movl 0x8d4(%r12), %edx
movl %ebp, %ecx
subl %edx, %ecx
jl 0xaa698
addl %eax, %edx
cmpl %ebp, %edx
cmovgl %ecx, %r13d
cmpw $0x1, 0x44(%r14)
movl %r8d, 0xc(%rsp)
movsd %xmm1, 0x10(%rsp)
jne 0xaa6d8
movl 0x8e4(%r12), %edx
movl 0x8e8(%r12), %ecx
movl %ebp, %r10d
subl %edx, %r10d
leal (%rax,%rdx), %r9d
cmpl %ebp, %r9d
cmovlel %r13d, %r10d
cmpl %edx, %ebp
cmovgel %r10d, %r13d
movl %ebp, %edx
subl %ecx, %edx
jge 0xaa6dd
movq %r11, %r15
jmp 0xaa6e8
movq %r11, %r15
addl %ecx, %eax
cmpl %ebp, %eax
cmovgl %edx, %r13d
leaq 0x28(%rsp), %rax
leaq 0x18(%rsp), %rcx
leaq 0x20(%rsp), %r9
movq %r14, %rdx
movl %r13d, %r8d
pushq %rax
pushq %rcx
movq %rdi, %rbx
callq 0xaa83f
addq $0x10, %rsp
testl %eax, %eax
je 0xaa760
addq $0x96a, %r12            # imm = 0x96A
leaq 0x43cd3(%rip), %rsi     # 0xee3f0
leaq 0x74afc(%rip), %rdx     # 0x11f220
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x438f7(%rip), %rsi     # 0xee034
leaq 0x74b2d(%rip), %rdx     # 0x11f271
movq %r12, %rdi
movl $0x710, %ecx            # imm = 0x710
movq %rbx, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
jmp 0xaa82d
cvttsd2si 0x810(%rbx), %ecx
movq %r15, %r11
movl %ecx, (%r15)
cmpw $0x1, 0x44(%r14)
movq %rbx, %rsi
jne 0xaa799
movl 0x8e8(%r12), %eax
cmpl %ebp, %eax
jg 0xaa799
addl 0x64(%r14), %eax
cmpl %ebp, %eax
jle 0xaa799
movl $0x818, %eax            # imm = 0x818
movl $0x7f8, %edx            # imm = 0x7F8
jmp 0xaa7a3
movl $0x820, %eax            # imm = 0x820
movl $0x800, %edx            # imm = 0x800
movl 0xc(%rsp), %r8d
movsd 0x10(%rsp), %xmm3
movsd (%rsi,%rdx), %xmm0
movslq %r13d, %rdx
mulsd 0x70(%r14,%rdx,8), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movapd %xmm3, %xmm2
subsd 0x20(%rsp), %xmm2
cvttsd2si %xmm0, %ecx
subsd 0x18(%rsp), %xmm3
mulsd 0x444f0(%rip), %xmm3    # 0xeecd0
movl 0x54(%r14), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
xorps %xmm0, %xmm0
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, (%r11)
xorl %eax, %eax
cmpw $0x1, 0x12(%r14)
jne 0xaa82d
cmpl %r8d, 0x84c(%r14)
jne 0xaa82d
movl 0x9f8(%r14), %ecx
movl %ecx, (%r11)
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq