// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/perturbations.c
// Function: perturbations_timescale
int perturbations_timescale(
                            double tau,
                            void * parameters_and_workspace,
                            double * timescale,
                            ErrorMsg error_message
                            ) {
  /** Summary: */

  /** - define local variables */

  /* (a) time scale of Fourier mode, \f$ \tau_k = 1/k \f$ */
  double tau_k;
  /* (b) time scale of expansion, \f$ \tau_h = a/a' \f$ */
  double tau_h;
  /* (c) time scale of recombination, \f$ \tau_{\gamma} = 1/\kappa' \f$ */
  double tau_c;

  /* various pointers allowing to extract the fields of the
     parameter_and_workspace input structure */
  struct perturbations_parameters_and_workspace * pppaw;
  struct background * pba;
  struct thermodynamics * pth;
  struct perturbations * ppt;
  struct perturbations_workspace * ppw;
  double * pvecback;
  double * pvecthermo;

  /** - extract the fields of the parameter_and_workspace input structure */
  pppaw = (struct perturbations_parameters_and_workspace *)parameters_and_workspace;
  pba = pppaw->pba;
  pth = pppaw->pth;
  ppt = pppaw->ppt;
  ppw = pppaw->ppw;
  pvecback = ppw->pvecback;
  pvecthermo = ppw->pvecthermo;

  /** - compute Fourier mode time scale = \f$ \tau_k = 1/k \f$ */

  class_test(pppaw->k == 0.,
             ppt->error_message,
             "stop to avoid division by zero");

  tau_k = 1./pppaw->k;

  /** - evaluate background quantities with background_at_tau() and
      Hubble time scale \f$ \tau_h = a/a' \f$ */

  class_call(background_at_tau(pba,tau, normal_info, (interpolation_method)ppw->inter_mode, &(ppw->last_index_back), pvecback),
             pba->error_message,
             error_message);

  class_test(pvecback[pba->index_bg_H]*pvecback[pba->index_bg_a] == 0.,
             error_message,
             "aH=0, stop to avoid division by zero");

  tau_h = 1./(pvecback[pba->index_bg_H]*pvecback[pba->index_bg_a]);

  /** - for scalars modes: */

  if ((ppt->has_scalars == _TRUE_) && (pppaw->index_md == ppt->index_md_scalars)) {

    *timescale = tau_h;

    if ((ppw->approx[ppw->index_ap_rsa] == (int)rsa_off) || (pba->has_ncdm == _TRUE_))
      *timescale = MIN(tau_k,*timescale);

    if (ppw->approx[ppw->index_ap_tca] == (int)tca_off) {

      class_call(thermodynamics_at_z(pba,
                                     pth,
                                     1./pvecback[pba->index_bg_a]-1.,  /* redshift z=1/a-1 */
                                     (interpolation_method)ppw->inter_mode,
                                     &(ppw->last_index_thermo),
                                     pvecback,
                                     pvecthermo),
                 pth->error_message,
                 error_message);

      if (pvecthermo[pth->index_th_dkappa] != 0.) {

        /** - -->  compute recombination time scale for photons, \f$ \tau_{\gamma} = 1/ \kappa' \f$ */

        tau_c = 1./pvecthermo[pth->index_th_dkappa];

        *timescale = MIN(tau_c,*timescale);

      }
    }

  }

  /** - for vector modes: */

  if ((ppt->has_vectors == _TRUE_) && (pppaw->index_md == ppt->index_md_vectors)) {

    *timescale = MIN(tau_h,tau_k);

    if (ppw->approx[ppw->index_ap_tca] == (int)tca_off) {

      class_call(thermodynamics_at_z(pba,
                                     pth,
                                     1./pvecback[pba->index_bg_a]-1.,  /* redshift z=1/a-1 */
                                     (interpolation_method)ppw->inter_mode,
                                     &(ppw->last_index_thermo),
                                     pvecback,
                                     pvecthermo),
                 pth->error_message,
                 error_message);

      if (pvecthermo[pth->index_th_dkappa] != 0.) {

        /** - -->  compute recombination time scale for photons, \f$ \tau_{\gamma} = 1/ \kappa' \f$ */

        tau_c = 1./pvecthermo[pth->index_th_dkappa];

        *timescale = MIN(tau_c,*timescale);

      }
    }
  }

  /** - for tensor modes: */

  if ((ppt->has_tensors == _TRUE_) && (pppaw->index_md == ppt->index_md_tensors)) {

    *timescale = MIN(tau_h,tau_k);

    if (ppw->approx[ppw->index_ap_tca] == (int)tca_off) {

      class_call(thermodynamics_at_z(pba,
                                     pth,
                                     1./pvecback[pba->index_bg_a]-1.,  /* redshift z=1/a-1 */
                                     (interpolation_method)ppw->inter_mode,
                                     &(ppw->last_index_thermo),
                                     pvecback,
                                     pvecthermo),
                 pth->error_message,
                 error_message);

      if (pvecthermo[pth->index_th_dkappa] != 0.) {

        /** - --> compute recombination time scale for photons, \f$ \tau_{\gamma} = 1/ \kappa' \f$ */

        tau_c = 1./pvecthermo[pth->index_th_dkappa];

        *timescale = MIN(tau_c,*timescale);

      }
    }
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
movq 0x18(%rdi), %r13
movsd 0x30(%rdi), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x82d38
jp 0x82d38
leaq 0x64026(%rip), %rsi     # 0xe6cfd
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x62395(%rip), %rsi     # 0xe5082
leaq 0x8b8ae(%rip), %rdx     # 0x10e5a2
leaq 0x830(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x6c8a, %r13           # imm = 0x6C8A
leaq 0x6231d(%rip), %rsi     # 0xe5034
leaq 0x8b893(%rip), %rdx     # 0x10e5b1
movq %r13, %rdi
movl $0x1a3a, %ecx           # imm = 0x1A3A
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbx
jmp 0x82e51
movq %rdi, %r12
movsd %xmm2, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x8(%rdi), %rbp
movq 0x10(%rdi), %rax
movq %rax, (%rsp)
movq 0x38(%rdi), %r15
movq 0x30(%r15), %r14
movq 0x38(%r15), %rax
movq %rax, 0x8(%rsp)
movswl 0x154(%r15), %edx
leaq 0x158(%r15), %rcx
pushq $0x1
popq %rbx
movq %rbp, %rdi
movl %ebx, %esi
movq %r14, %r8
callq 0x5887d
cmpl $0x1, %eax
jne 0x82dd0
addq $0xd1c, %rbp            # imm = 0xD1C
leaq 0x62656(%rip), %rsi     # 0xe53f0
leaq 0x8b828(%rip), %rdx     # 0x10e5c9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x6227a(%rip), %rsi     # 0xe5034
leaq 0x8b7f0(%rip), %rdx     # 0x10e5b1
movq 0x18(%rsp), %rdi
movl $0x1a43, %ecx           # imm = 0x1A43
movq %r14, %r8
jmp 0x82e4a
movslq 0x384(%rbp), %rax
movsd (%r14,%rax,8), %xmm0
movslq 0x380(%rbp), %rax
mulsd (%r14,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x82e65
jp 0x82e65
leaq 0x8b45b(%rip), %rsi     # 0x10e258
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x6226f(%rip), %rsi     # 0xe5082
leaq 0x8b821(%rip), %rdx     # 0x10e63b
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x621fe(%rip), %rsi     # 0xe5034
leaq 0x8b774(%rip), %rdx     # 0x10e5b1
movq 0x18(%rsp), %rdi
movl $0x1a47, %ecx           # imm = 0x1A47
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
movl %ebx, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x623f3(%rip), %xmm2    # 0xe5260
movapd %xmm2, %xmm3
divsd 0x10(%rsp), %xmm3
movapd %xmm2, %xmm4
divsd %xmm0, %xmm4
cmpw $0x1, 0xe(%r13)
movq 0x20(%rsp), %rsi
jne 0x82fb6
movl 0x20(%r12), %ecx
cmpl 0x848(%r13), %ecx
jne 0x82fb6
movsd %xmm4, (%rsi)
movq 0x180(%r15), %rcx
movslq 0x164(%r15), %rdx
cmpl $0x0, (%rcx,%rdx,4)
je 0x82ec4
cmpw $0x1, 0x4be(%rbp)
jne 0x82ed0
movapd %xmm3, %xmm0
minsd %xmm4, %xmm0
movsd %xmm0, (%rsi)
movslq 0x160(%r15), %rdx
cmpl $0x1, (%rcx,%rdx,4)
jne 0x82fb6
movsd %xmm4, 0x28(%rsp)
movsd %xmm3, 0x10(%rsp)
movapd %xmm2, %xmm0
divsd (%r14,%rax,8), %xmm0
addsd 0x628e9(%rip), %xmm0    # 0xe57e8
movswl 0x154(%r15), %edx
leaq 0x15c(%r15), %rcx
movq %rbp, %rdi
movq (%rsp), %rsi
movq %r14, %r8
movq 0x8(%rsp), %r9
callq 0x61ff8
cmpl $0x1, %eax
jne 0x82f6c
movq (%rsp), %rcx
addq $0x1064, %rcx           # imm = 0x1064
leaq 0x624b7(%rip), %rsi     # 0xe53f0
leaq 0x8b735(%rip), %rdx     # 0x10e675
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x620de(%rip), %rsi     # 0xe5034
leaq 0x8b654(%rip), %rdx     # 0x10e5b1
movq 0x18(%rsp), %rdi
movl $0x1a5e, %ecx           # imm = 0x1A5E
jmp 0x82dcb
movq (%rsp), %rax
movslq 0xe80(%rax), %rax
movq 0x8(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x20(%rsp), %rsi
movsd 0x622ca(%rip), %xmm2    # 0xe5260
movsd 0x10(%rsp), %xmm3
movsd 0x28(%rsp), %xmm4
jne 0x82fa6
jnp 0x82fb6
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
cmpw $0x1, 0x10(%r13)
jne 0x830d4
movl 0x20(%r12), %eax
cmpl 0x850(%r13), %eax
jne 0x830d4
movapd %xmm4, %xmm0
minsd %xmm3, %xmm0
movsd %xmm0, (%rsi)
movq 0x180(%r15), %rax
movslq 0x160(%r15), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x830d4
movsd %xmm4, 0x28(%rsp)
movsd %xmm3, 0x10(%rsp)
movslq 0x380(%rbp), %rax
movapd %xmm2, %xmm0
divsd (%r14,%rax,8), %xmm0
addsd 0x627cb(%rip), %xmm0    # 0xe57e8
movswl 0x154(%r15), %edx
leaq 0x15c(%r15), %rcx
movq %rbp, %rdi
movq (%rsp), %rsi
movq %r14, %r8
movq 0x8(%rsp), %r9
callq 0x61ff8
cmpl $0x1, %eax
jne 0x8308a
movq (%rsp), %rcx
addq $0x1064, %rcx           # imm = 0x1064
leaq 0x62399(%rip), %rsi     # 0xe53f0
leaq 0x8b617(%rip), %rdx     # 0x10e675
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x61fc0(%rip), %rsi     # 0xe5034
leaq 0x8b536(%rip), %rdx     # 0x10e5b1
movq 0x18(%rsp), %rdi
movl $0x1a7d, %ecx           # imm = 0x1A7D
jmp 0x82dcb
movq (%rsp), %rax
movslq 0xe80(%rax), %rax
movq 0x8(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x20(%rsp), %rsi
movsd 0x621ac(%rip), %xmm2    # 0xe5260
movsd 0x10(%rsp), %xmm3
movsd 0x28(%rsp), %xmm4
jne 0x830c4
jnp 0x830d4
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
cmpw $0x1, 0x12(%r13)
jne 0x831d3
movl 0x20(%r12), %eax
cmpl 0x84c(%r13), %eax
jne 0x831d3
minsd %xmm3, %xmm4
movsd %xmm4, (%rsi)
movq 0x180(%r15), %rax
movslq 0x160(%r15), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x831d3
movslq 0x380(%rbp), %rax
movapd %xmm2, %xmm0
divsd (%r14,%rax,8), %xmm0
addsd 0x626bd(%rip), %xmm0    # 0xe57e8
movswl 0x154(%r15), %edx
addq $0x15c, %r15            # imm = 0x15C
movq %rbp, %rdi
movq (%rsp), %r12
movq %r12, %rsi
movq %r15, %rcx
movq %r14, %r8
movq 0x8(%rsp), %r14
movq %r14, %r9
callq 0x61ff8
cmpl $0x1, %eax
jne 0x831a0
addq $0x1064, %r12           # imm = 0x1064
leaq 0x62286(%rip), %rsi     # 0xe53f0
leaq 0x8b504(%rip), %rdx     # 0x10e675
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x61eaa(%rip), %rsi     # 0xe5034
leaq 0x8b420(%rip), %rdx     # 0x10e5b1
movq 0x18(%rsp), %rdi
movl $0x1a9b, %ecx           # imm = 0x1A9B
jmp 0x82dcb
movslq 0xe80(%r12), %rax
movsd (%r14,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x831ba
jnp 0x831d3
movsd 0x6209e(%rip), %xmm1    # 0xe5260
divsd %xmm0, %xmm1
movq 0x20(%rsp), %rax
minsd (%rax), %xmm1
movsd %xmm1, (%rax)
xorl %ebx, %ebx
jmp 0x82e51