// File: /workspace/github_c_makefile_star2_O3/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 0x87f4b
jp 0x87f4b
leaq 0x67e66(%rip), %rsi     # 0xefd3d
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x66195(%rip), %rsi     # 0xee082
leaq 0x8f80e(%rip), %rdx     # 0x117702
leaq 0x830(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x6611d(%rip), %rsi     # 0xee034
leaq 0x8f7f3(%rip), %rdx     # 0x117711
movq %r12, %rdi
movl $0x1a3a, %ecx           # imm = 0x1A3A
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
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 0x5c63f
cmpl $0x1, %eax
jne 0x87ff3
addq $0xd1c, %r13            # imm = 0xD1C
leaq 0x6643d(%rip), %rsi     # 0xee3f0
leaq 0x8f76f(%rip), %rdx     # 0x117729
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x66061(%rip), %rsi     # 0xee034
leaq 0x8f737(%rip), %rdx     # 0x117711
movq 0x10(%rsp), %rdi
movl $0x1a43, %ecx           # imm = 0x1A43
movq %rbx, %r8
xorl %eax, %eax
callq 0x30af0
jmp 0x87f36
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 0x8806f
jp 0x8806f
leaq 0x8f398(%rip), %rsi     # 0x1173b8
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x6604c(%rip), %rsi     # 0xee082
leaq 0x8f75e(%rip), %rdx     # 0x11779b
leaq 0x830(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x65fdb(%rip), %rsi     # 0xee034
leaq 0x8f6b1(%rip), %rdx     # 0x117711
movq 0x10(%rsp), %rdi
movl $0x1a47, %ecx           # imm = 0x1A47
jmp 0x87f26
movsd 0x661e9(%rip), %xmm2    # 0xee260
movapd %xmm2, %xmm3
divsd 0x8(%rsp), %xmm3
movapd %xmm2, %xmm4
divsd %xmm0, %xmm4
cmpw $0x1, 0xe(%r12)
movq 0x18(%rsp), %rsi
jne 0x881be
movl 0x20(%rbx), %ecx
cmpl 0x848(%r12), %ecx
jne 0x881be
movsd %xmm4, (%rsi)
movq 0x180(%r14), %rcx
movslq 0x164(%r14), %rdx
cmpl $0x0, (%rcx,%rdx,4)
je 0x880cf
cmpw $0x1, 0x4be(%r13)
jne 0x880db
movapd %xmm3, %xmm0
minsd %xmm4, %xmm0
movsd %xmm0, (%rsi)
movslq 0x160(%r14), %rdx
cmpl $0x1, (%rcx,%rdx,4)
jne 0x881be
movsd %xmm4, 0x20(%rsp)
movsd %xmm3, 0x8(%rsp)
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x666de(%rip), %xmm0    # 0xee7e8
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 0x662ac
cmpl $0x1, %eax
jne 0x88179
addq $0x1064, %r15           # imm = 0x1064
leaq 0x662ad(%rip), %rsi     # 0xee3f0
leaq 0x8f68b(%rip), %rdx     # 0x1177d5
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x65ed1(%rip), %rsi     # 0xee034
leaq 0x8f5a7(%rip), %rdx     # 0x117711
movq 0x10(%rsp), %rdi
movl $0x1a5e, %ecx           # imm = 0x1A5E
jmp 0x883a3
movslq 0xe80(%r15), %rax
movq (%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x18(%rsp), %rsi
movsd 0x660c2(%rip), %xmm2    # 0xee260
movsd 0x8(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
jne 0x881ae
jnp 0x881be
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
cmpw $0x1, 0x10(%r12)
jne 0x882d9
movl 0x20(%rbx), %eax
cmpl 0x850(%r12), %eax
jne 0x882d9
movapd %xmm4, %xmm0
minsd %xmm3, %xmm0
movsd %xmm0, (%rsi)
movq 0x180(%r14), %rax
movslq 0x160(%r14), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x882d9
movsd %xmm4, 0x20(%rsp)
movsd %xmm3, 0x8(%rsp)
movslq 0x380(%r13), %rax
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x665c3(%rip), %xmm0    # 0xee7e8
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 0x662ac
cmpl $0x1, %eax
jne 0x88294
addq $0x1064, %r15           # imm = 0x1064
leaq 0x66192(%rip), %rsi     # 0xee3f0
leaq 0x8f570(%rip), %rdx     # 0x1177d5
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x65db6(%rip), %rsi     # 0xee034
leaq 0x8f48c(%rip), %rdx     # 0x117711
movq 0x10(%rsp), %rdi
movl $0x1a7d, %ecx           # imm = 0x1A7D
jmp 0x883a3
movslq 0xe80(%r15), %rax
movq (%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x18(%rsp), %rsi
movsd 0x65fa7(%rip), %xmm2    # 0xee260
movsd 0x8(%rsp), %xmm3
movsd 0x20(%rsp), %xmm4
jne 0x882c9
jnp 0x882d9
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
minsd (%rsi), %xmm1
movsd %xmm1, (%rsi)
xorl %r15d, %r15d
cmpw $0x1, 0x12(%r12)
jne 0x87f36
movl 0x20(%rbx), %eax
cmpl 0x84c(%r12), %eax
jne 0x87f36
minsd %xmm3, %xmm4
movsd %xmm4, (%rsi)
movq 0x180(%r14), %rax
movslq 0x160(%r14), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x87f36
movslq 0x380(%r13), %rax
movapd %xmm2, %xmm0
divsd (%rbp,%rax,8), %xmm0
addsd 0x664b5(%rip), %xmm0    # 0xee7e8
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 0x662ac
cmpl $0x1, %eax
jne 0x883ab
addq $0x1064, %r12           # imm = 0x1064
leaq 0x6607e(%rip), %rsi     # 0xee3f0
leaq 0x8f45c(%rip), %rdx     # 0x1177d5
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x65ca2(%rip), %rsi     # 0xee034
leaq 0x8f378(%rip), %rdx     # 0x117711
movq 0x10(%rsp), %rdi
movl $0x1a9b, %ecx           # imm = 0x1A9B
movq %rbx, %r8
jmp 0x87f29
movslq 0xe80(%r12), %rax
movsd (%rbx,%rax,8), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x883c8
jnp 0x87f36
movsd 0x65e90(%rip), %xmm1    # 0xee260
divsd %xmm0, %xmm1
movq 0x18(%rsp), %rax
minsd (%rax), %xmm1
movsd %xmm1, (%rax)
jmp 0x87f36