// File: /workspace/github_c_makefile_star2_O1/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), %r12
movsd 0x30(%rdi), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x8a952
jp 0x8a952
leaq 0x6844f(%rip), %rsi     # 0xf2d2d
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x6678e(%rip), %rsi     # 0xf1082
leaq 0x8fdc7(%rip), %rdx     # 0x11a6c2
leaq 0x830(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x66716(%rip), %rsi     # 0xf1034
leaq 0x8fdac(%rip), %rdx     # 0x11a6d1
movq %r12, %rdi
movl $0x1a3a, %ecx           # imm = 0x1A3A
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %r15d
movl %r15d, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movsd %xmm2, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x8(%rdi), %r13
movq 0x10(%rdi), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rdi), %r14
movq 0x30(%r14), %rbp
movq 0x38(%r14), %rax
movq %rax, (%rsp)
movswl 0x154(%r14), %edx
leaq 0x158(%r14), %rcx
movl $0x1, %r15d
movq %r13, %rdi
movl $0x1, %esi
movq %rbp, %r8
callq 0x5ed53
cmpl $0x1, %eax
jne 0x8a9fa
addq $0xd1c, %r13            # imm = 0xD1C
leaq 0x66a36(%rip), %rsi     # 0xf13f0
leaq 0x8fd28(%rip), %rdx     # 0x11a6e9
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x6665a(%rip), %rsi     # 0xf1034
leaq 0x8fcf0(%rip), %rdx     # 0x11a6d1
movq 0x10(%rsp), %rdi
movl $0x1a43, %ecx           # imm = 0x1A43
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
jmp 0x8a93d
movslq 0x384(%r13), %rax
movsd (%rbp,%rax,8), %xmm0
movslq 0x380(%r13), %rax
mulsd (%rbp,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8aa76
jp 0x8aa76
leaq 0x8f951(%rip), %rsi     # 0x11a378
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x66645(%rip), %rsi     # 0xf1082
leaq 0x8fd17(%rip), %rdx     # 0x11a75b
leaq 0x830(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x665d4(%rip), %rsi     # 0xf1034
leaq 0x8fc6a(%rip), %rdx     # 0x11a6d1
movq 0x10(%rsp), %rdi
movl $0x1a47, %ecx           # imm = 0x1A47
jmp 0x8a92d
movsd 0x667e2(%rip), %xmm2    # 0xf1260
movapd %xmm2, %xmm3
divsd 0x8(%rsp), %xmm3
movapd %xmm2, %xmm4
divsd %xmm0, %xmm4
cmpw $0x1, 0xe(%r12)
movq 0x18(%rsp), %rsi
jne 0x8abc5
movl 0x20(%rbx), %ecx
cmpl 0x848(%r12), %ecx
jne 0x8abc5
movsd %xmm4, (%rsi)
movq 0x180(%r14), %rcx
movslq 0x164(%r14), %rdx
cmpl $0x0, (%rcx,%rdx,4)
je 0x8aad6
cmpw $0x1, 0x4be(%r13)
jne 0x8aae2
movapd %xmm3, %xmm0
minsd %xmm4, %xmm0
movsd %xmm0, (%rsi)
movslq 0x160(%r14), %rdx
cmpl $0x1, (%rcx,%rdx,4)
jne 0x8abc5
movsd %xmm4, 0x20(%rsp)
movsd %xmm3, 0x8(%rsp)
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x66cd7(%rip), %xmm0    # 0xf17e8
movswl 0x154(%r14), %edx
leaq 0x15c(%r14), %rcx
movq %r13, %rdi
movq 0x28(%rsp), %r15
movq %r15, %rsi
movq %rbp, %r8
movq (%rsp), %r9
callq 0x68bbc
cmpl $0x1, %eax
jne 0x8ab80
addq $0x1064, %r15           # imm = 0x1064
leaq 0x668a6(%rip), %rsi     # 0xf13f0
leaq 0x8fc44(%rip), %rdx     # 0x11a795
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x664ca(%rip), %rsi     # 0xf1034
leaq 0x8fb60(%rip), %rdx     # 0x11a6d1
movq 0x10(%rsp), %rdi
movl $0x1a5e, %ecx           # imm = 0x1A5E
jmp 0x8adaa
movslq 0xe80(%r15), %rax
movq (%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x18(%rsp), %rsi
movsd 0x666bb(%rip), %xmm2    # 0xf1260
movsd 0x8(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
jne 0x8abb5
jnp 0x8abc5
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
cmpw $0x1, 0x10(%r12)
jne 0x8ace0
movl 0x20(%rbx), %eax
cmpl 0x850(%r12), %eax
jne 0x8ace0
movapd %xmm4, %xmm0
minsd %xmm3, %xmm0
movsd %xmm0, (%rsi)
movq 0x180(%r14), %rax
movslq 0x160(%r14), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x8ace0
movsd %xmm4, 0x20(%rsp)
movsd %xmm3, 0x8(%rsp)
movslq 0x380(%r13), %rax
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x66bbc(%rip), %xmm0    # 0xf17e8
movswl 0x154(%r14), %edx
leaq 0x15c(%r14), %rcx
movq %r13, %rdi
movq 0x28(%rsp), %r15
movq %r15, %rsi
movq %rbp, %r8
movq (%rsp), %r9
callq 0x68bbc
cmpl $0x1, %eax
jne 0x8ac9b
addq $0x1064, %r15           # imm = 0x1064
leaq 0x6678b(%rip), %rsi     # 0xf13f0
leaq 0x8fb29(%rip), %rdx     # 0x11a795
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x663af(%rip), %rsi     # 0xf1034
leaq 0x8fa45(%rip), %rdx     # 0x11a6d1
movq 0x10(%rsp), %rdi
movl $0x1a7d, %ecx           # imm = 0x1A7D
jmp 0x8adaa
movslq 0xe80(%r15), %rax
movq (%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x18(%rsp), %rsi
movsd 0x665a0(%rip), %xmm2    # 0xf1260
movsd 0x8(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
jne 0x8acd0
jnp 0x8ace0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
xorl %r15d, %r15d
cmpw $0x1, 0x12(%r12)
jne 0x8a93d
movl 0x20(%rbx), %eax
cmpl 0x84c(%r12), %eax
jne 0x8a93d
minsd %xmm3, %xmm4
movsd %xmm4, (%rsi)
movq 0x180(%r14), %rax
movslq 0x160(%r14), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x8a93d
movslq 0x380(%r13), %rax
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x66aae(%rip), %xmm0    # 0xf17e8
movswl 0x154(%r14), %edx
addq $0x15c, %r14            # imm = 0x15C
movq %r13, %rdi
movq 0x28(%rsp), %r12
movq %r12, %rsi
movq %r14, %rcx
movq %rbp, %r8
movq (%rsp), %rbx
movq %rbx, %r9
callq 0x68bbc
cmpl $0x1, %eax
jne 0x8adb2
addq $0x1064, %r12           # imm = 0x1064
leaq 0x66677(%rip), %rsi     # 0xf13f0
leaq 0x8fa15(%rip), %rdx     # 0x11a795
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x6629b(%rip), %rsi     # 0xf1034
leaq 0x8f931(%rip), %rdx     # 0x11a6d1
movq 0x10(%rsp), %rdi
movl $0x1a9b, %ecx           # imm = 0x1A9B
movq %rbx, %r8
jmp 0x8a930
movslq 0xe80(%r12), %rax
movsd (%rbx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8adcf
jnp 0x8a93d
movsd 0x66489(%rip), %xmm1    # 0xf1260
divsd %xmm0, %xmm1
movq 0x18(%rsp), %rax
minsd (%rax), %xmm1
movsd %xmm1, (%rax)
jmp 0x8a93d