// File: /workspace/github_c_makefile_star2_O0/lesgourg[P]class_public/build/../source/background.c
// Function: background_derivs
int background_derivs(
                      double loga,
                      double* y, /* vector with argument y[index_bi] (must be already allocated with size pba->bi_size) */
                      double* dy, /* vector with argument dy[index_bi]
                                     (must be already allocated with
                                     size pba->bi_size) */
                      void * parameters_and_workspace,
                      ErrorMsg error_message
                      ) {

  /** Summary: */

  /** - define local variables */

  struct background_parameters_and_workspace * pbpaw;
  struct background * pba;
  double * pvecback, a, H, rho_M;

  pbpaw = parameters_and_workspace;
  pba =  pbpaw->pba;
  pvecback = pbpaw->pvecback;

  /** - scale factor a (in fact, given our normalisation conventions, this stands for a/a_0) */
  a = exp(loga);

  /** - calculate functions of \f$ a \f$ with background_functions() */
  class_call(background_functions(pba, a, y, normal_info, pvecback),
             pba->error_message,
             error_message);

  /** - Short hand notation for Hubble */
  H = pvecback[pba->index_bg_H];

  /** - calculate derivative of cosmological time \f$ dt/dloga = 1/H \f$ */
  dy[pba->index_bi_time] = 1./H;

  /** - calculate derivative of conformal time \f$ d\tau/dloga = 1/aH \f$ */
  dy[pba->index_bi_tau] = 1./a/H;

  class_test(pvecback[pba->index_bg_rho_g] <= 0.,
             error_message,
             "rho_g = %e instead of strictly positive",pvecback[pba->index_bg_rho_g]);

  /** - calculate detivative of sound horizon \f$ drs/dloga = drs/dtau * dtau/dloga = c_s/aH \f$*/
  dy[pba->index_bi_rs] = 1./a/H/sqrt(3.*(1.+3.*pvecback[pba->index_bg_rho_b]/4./pvecback[pba->index_bg_rho_g]))*sqrt(1.-pba->K*y[pba->index_bi_rs]*y[pba->index_bi_rs]); // TBC: curvature correction

  /** - solve second order growth equation \f$ [D''(\tau)=-aHD'(\tau)+3/2 a^2 \rho_M D(\tau) \f$
      written as \f$ dD/dloga = D' / (aH) \f$ and \f$ dD'/dloga = -D' + (3/2) (a/H) \rho_M D \f$ */
  rho_M = pvecback[pba->index_bg_rho_b];
  if (pba->has_cdm == _TRUE_) {
    rho_M += pvecback[pba->index_bg_rho_cdm];
  }
  if (pba->has_idm == _TRUE_){
    rho_M += pvecback[pba->index_bg_rho_idm];
  }

  dy[pba->index_bi_D] = y[pba->index_bi_D_prime]/a/H;
  dy[pba->index_bi_D_prime] = -y[pba->index_bi_D_prime] + 1.5*a*rho_M*y[pba->index_bi_D]/H;

  if (pba->has_dcdm == _TRUE_) {
    /** - compute dcdm density \f$ d\rho/dloga = -3 \rho - \Gamma/H \rho \f$*/
    dy[pba->index_bi_rho_dcdm] = -3.*y[pba->index_bi_rho_dcdm] - pba->Gamma_dcdm/H*y[pba->index_bi_rho_dcdm];
  }

  if ((pba->has_dcdm == _TRUE_) && (pba->has_dr == _TRUE_)) {
    /** - Compute dr density \f$ d\rho/dloga = -4\rho - \Gamma/H \rho \f$ */
    dy[pba->index_bi_rho_dr] = -4.*y[pba->index_bi_rho_dr]+pba->Gamma_dcdm/H*y[pba->index_bi_rho_dcdm];
  }

  if (pba->has_fld == _TRUE_) {
    /** - Compute fld density \f$ d\rho/dloga = -3 (1+w_{fld}(a)) \rho \f$ */
    dy[pba->index_bi_rho_fld] = -3.*(1.+pvecback[pba->index_bg_w_fld])*y[pba->index_bi_rho_fld];
  }

  if (pba->has_scf == _TRUE_) {
    /** - Scalar field equation: \f$ \phi'' + 2 a H \phi' + a^2 dV = 0 \f$  (note H is wrt cosmological time)
        written as \f$ d\phi/dlna = phi' / (aH) \f$ and \f$ d\phi'/dlna = -2*phi' - (a/H) dV \f$ */
    dy[pba->index_bi_phi_scf] = y[pba->index_bi_phi_prime_scf]/a/H;
    dy[pba->index_bi_phi_prime_scf] = - 2*y[pba->index_bi_phi_prime_scf] - a*dV_scf(pba,y[pba->index_bi_phi_scf])/H ;
  }

  return _SUCCESS_;

}

// Assembly:
subq $0x1888, %rsp           # imm = 0x1888
movsd %xmm0, 0x1878(%rsp)
movq %rdi, 0x1870(%rsp)
movq %rsi, 0x1868(%rsp)
movq %rdx, 0x1860(%rsp)
movq %rcx, 0x1858(%rsp)
movq 0x1860(%rsp), %rax
movq %rax, 0x1850(%rsp)
movq 0x1850(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1848(%rsp)
movq 0x1850(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x1840(%rsp)
movsd 0x1878(%rsp), %xmm0
callq 0x8670
movsd %xmm0, 0x1838(%rsp)
movq 0x1848(%rsp), %rdi
movsd 0x1838(%rsp), %xmm0
movq 0x1870(%rsp), %rsi
movq 0x1840(%rsp), %rcx
movl $0x1, %edx
callq 0x93ab0
cmpl $0x1, %eax
jne 0x9e484
leaq 0x1020(%rsp), %rdi
movq 0x1848(%rsp), %rcx
addq $0xb84, %rcx            # imm = 0xB84
leaq 0x118f9c(%rip), %rsi    # 0x1b73d8
leaq 0x133fac(%rip), %rdx    # 0x1d23ef
movb $0x0, %al
callq 0x5b9c0
movq 0x1858(%rsp), %rdi
leaq 0x1020(%rsp), %r8
leaq 0x118bd3(%rip), %rsi    # 0x1b7034
leaq 0x133fbe(%rip), %rdx    # 0x1d2426
movl $0xa33, %ecx            # imm = 0xA33
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1884(%rsp)
jmp 0x9eb61
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x20c(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x1830(%rsp)
movsd 0x118d97(%rip), %xmm0   # 0x1b7248
divsd 0x1830(%rsp), %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x304(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x118d6a(%rip), %xmm0   # 0x1b7248
divsd 0x1838(%rsp), %xmm0
divsd 0x1830(%rsp), %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x30c(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x214(%rcx), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jb 0x9e5bc
leaq 0x820(%rsp), %rdi
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x214(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x133edc(%rip), %rsi    # 0x1d2438
movb $0x1, %al
callq 0x5b9c0
leaq 0x20(%rsp), %rdi
leaq 0x820(%rsp), %rcx
leaq 0x118b0b(%rip), %rsi    # 0x1b7082
leaq 0x133ee2(%rip), %rdx    # 0x1d2460
movb $0x0, %al
callq 0x5b9c0
movq 0x1858(%rsp), %rdi
leaq 0x20(%rsp), %r8
leaq 0x118a9b(%rip), %rsi    # 0x1b7034
leaq 0x133e86(%rip), %rdx    # 0x1d2426
movl $0xa40, %ecx            # imm = 0xA40
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1884(%rsp)
jmp 0x9eb61
movsd 0x118c84(%rip), %xmm0   # 0x1b7248
divsd 0x1838(%rsp), %xmm0
divsd 0x1830(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x218(%rcx), %rcx
movsd 0x11a09d(%rip), %xmm0   # 0x1b8698
mulsd (%rax,%rcx,8), %xmm0
movsd 0x11bec0(%rip), %xmm1   # 0x1ba4c8
divsd %xmm1, %xmm0
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x214(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movsd 0x118c18(%rip), %xmm1   # 0x1b7248
addsd %xmm0, %xmm1
movsd 0x11a05c(%rip), %xmm0   # 0x1b8698
mulsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x1848(%rsp), %rax
movsd 0x1a0(%rax), %xmm0
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x308(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x308(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm1, %xmm0
movsd 0x118b85(%rip), %xmm1   # 0x1b7248
addsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x308(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x218(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x1828(%rsp)
movq 0x1848(%rsp), %rax
movswl 0x320(%rax), %eax
cmpl $0x1, %eax
jne 0x9e75c
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x21c(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd 0x1828(%rsp), %xmm0
movsd %xmm0, 0x1828(%rsp)
movq 0x1848(%rsp), %rax
movswl 0x322(%rax), %eax
cmpl $0x1, %eax
jne 0x9e79e
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x220(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd 0x1828(%rsp), %xmm0
movsd %xmm0, 0x1828(%rsp)
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x314(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd 0x1838(%rsp), %xmm0
divsd 0x1830(%rsp), %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x310(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x314(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x11942d(%rip), %xmm1   # 0x1b7c50
mulsd 0x1838(%rsp), %xmm1
mulsd 0x1828(%rsp), %xmm1
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x310(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm1
divsd 0x1830(%rsp), %xmm1
addsd %xmm1, %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x314(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1848(%rsp), %rax
movswl 0x324(%rax), %eax
cmpl $0x1, %eax
jne 0x9e923
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f0(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1848(%rsp), %rax
movsd 0x60(%rax), %xmm1
divsd 0x1830(%rsp), %xmm1
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f0(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x11c0a9(%rip), %xmm2   # 0x1ba9a8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f0(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1848(%rsp), %rax
movswl 0x324(%rax), %eax
cmpl $0x1, %eax
jne 0x9e9c9
movq 0x1848(%rsp), %rax
movswl 0x326(%rax), %eax
cmpl $0x1, %eax
jne 0x9e9c9
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f4(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1848(%rsp), %rax
movsd 0x60(%rax), %xmm1
divsd 0x1830(%rsp), %xmm1
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f0(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm1
movsd 0x11bb1b(%rip), %xmm2   # 0x1ba4c0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f4(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1848(%rsp), %rax
movswl 0x32e(%rax), %eax
cmpl $0x1, %eax
jne 0x9ea45
movq 0x1840(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x22c(%rcx), %rcx
movsd 0x11884c(%rip), %xmm1   # 0x1b7248
addsd (%rax,%rcx,8), %xmm1
movsd 0x11bf9f(%rip), %xmm0   # 0x1ba9a8
mulsd %xmm1, %xmm0
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f8(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2f8(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1848(%rsp), %rax
movswl 0x328(%rax), %eax
cmpl $0x1, %eax
jne 0x9eb56
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x300(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd 0x1838(%rsp), %xmm0
divsd 0x1830(%rsp), %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2fc(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x300(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rsp)
movsd 0x1838(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x1848(%rsp), %rdi
movq 0x1870(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x2fc(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x95410
movsd (%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
divsd 0x1830(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
addsd %xmm1, %xmm1
subsd %xmm1, %xmm0
movq 0x1868(%rsp), %rax
movq 0x1848(%rsp), %rcx
movslq 0x300(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, 0x1884(%rsp)
movl 0x1884(%rsp), %eax
addq $0x1888, %rsp           # imm = 0x1888
retq