// File: /workspace/github_c_makefile_star2_O0/lesgourg[P]class_public/build/../source/background.c
// Function: background_w_fld
int background_w_fld(
                     struct background * pba,
                     double a,
                     double * w_fld,
                     double * dw_over_da_fld,
                     double * integral_fld
                     ) {

  double Omega_ede = 0.;
  double dOmega_ede_over_da = 0.;
  double d2Omega_ede_over_da2 = 0.;
  double a_eq, Omega_r, Omega_m;

  /** - first, define the function w(a) */
  switch (pba->fluid_equation_of_state) {
  case CLP:
    *w_fld = pba->w0_fld + pba->wa_fld * (1. - a);
    break;
  case EDE:
    // Omega_ede(a) taken from eq. (10) in 1706.00730
    Omega_ede = (pba->Omega0_fld - pba->Omega_EDE*(1.-pow(a,-3.*pba->w0_fld)))
      /(pba->Omega0_fld+(1.-pba->Omega0_fld)*pow(a,3.*pba->w0_fld))
      + pba->Omega_EDE*(1.-pow(a,-3.*pba->w0_fld));

    // d Omega_ede / d a taken analytically from the above
    dOmega_ede_over_da = - pba->Omega_EDE* 3.*pba->w0_fld*pow(a,-3.*pba->w0_fld-1.)/(pba->Omega0_fld+(1.-pba->Omega0_fld)*pow(a,3.*pba->w0_fld))
      - (pba->Omega0_fld - pba->Omega_EDE*(1.-pow(a,-3.*pba->w0_fld)))*(1.-pba->Omega0_fld)*3.*pba->w0_fld*pow(a,3.*pba->w0_fld-1.)/pow(pba->Omega0_fld+(1.-pba->Omega0_fld)*pow(a,3.*pba->w0_fld),2)
      + pba->Omega_EDE*3.*pba->w0_fld*pow(a,-3.*pba->w0_fld-1.);

    // find a_equality (needed because EDE tracks first radiation, then matter)
    Omega_r = pba->Omega0_g * (1. + 3.044 * 7./8.*pow(4./11.,4./3.)); // assumes LambdaCDM + eventually massive neutrinos so light that they are relativistic at equality; needs to be generalised later on.
    Omega_m = pba->Omega0_b;
    if (pba->has_cdm == _TRUE_) Omega_m += pba->Omega0_cdm;
    if (pba->has_idm == _TRUE_) Omega_m += pba->Omega0_idm;
    if (pba->has_dcdm == _TRUE_)
      class_stop(pba->error_message,"Early Dark Energy not compatible with decaying Dark Matter because we omitted to code the calculation of a_eq in that case, but it would not be difficult to add it if necessary, should be a matter of 5 minutes");
    a_eq = Omega_r/Omega_m; // assumes a flat universe with a=1 today

    // w_ede(a) taken from eq. (11) in 1706.00730
    *w_fld = - dOmega_ede_over_da*a/Omega_ede/3./(1.-Omega_ede)+a_eq/3./(a+a_eq);
    break;
  }


  /** - then, give the corresponding analytic derivative dw/da (used
      by perturbation equations; we could compute it numerically,
      but with a loss of precision; as long as there is a simple
      analytic expression of the derivative of the previous
      function, let's use it! */
  switch (pba->fluid_equation_of_state) {
  case CLP:
    *dw_over_da_fld = - pba->wa_fld;
    break;
  case EDE:
    d2Omega_ede_over_da2 = 0.;
    *dw_over_da_fld = - d2Omega_ede_over_da2*a/3./(1.-Omega_ede)/Omega_ede
      - dOmega_ede_over_da/3./(1.-Omega_ede)/Omega_ede
      + dOmega_ede_over_da*dOmega_ede_over_da*a/3./(1.-Omega_ede)/(1.-Omega_ede)/Omega_ede
      + a_eq/3./(a+a_eq)/(a+a_eq);
    break;
  }

  /** - finally, give the analytic solution of the following integral:
      \f$ \int_{a}^{a0} da 3(1+w_{fld})/a \f$. This is used in only
      one place, in the initial conditions for the background, and
      with a=a_ini. If your w(a) does not lead to a simple analytic
      solution of this integral, no worry: instead of writing
      something here, the best would then be to leave it equal to
      zero, and then in background_initial_conditions() you should
      implement a numerical calculation of this integral only for
      a=a_ini, using for instance Romberg integration. It should be
      fast, simple, and accurate enough. */
  switch (pba->fluid_equation_of_state) {
  case CLP:
    *integral_fld = 3.*((1.+pba->w0_fld+pba->wa_fld)*log(1./a) + pba->wa_fld*(a-1.));
    break;
  case EDE:
    class_stop(pba->error_message,"EDE implementation not finished: to finish it, read the comments in background.c just before this line\n");
    break;
  }

  /** note: of course you can generalise these formulas to anything,
      defining new parameters pba->w..._fld. Just remember that so
      far, HyRec explicitely assumes that w(a)= w0 + wa (1-a/a0); but
      Recfast does not assume anything */

  return _SUCCESS_;
}

// Assembly:
subq $0x2128, %rsp           # imm = 0x2128
movq %rdi, 0x2118(%rsp)
movsd %xmm0, 0x2110(%rsp)
movq %rsi, 0x2108(%rsp)
movq %rdx, 0x2100(%rsp)
movq %rcx, 0x20f8(%rsp)
movq $0x0, 0x20f0(%rsp)
movq $0x0, 0x20e8(%rsp)
movq $0x0, 0x20e0(%rsp)
movq 0x2118(%rsp), %rax
movl 0x120(%rax), %eax
movl %eax, 0xbc(%rsp)
testl %eax, %eax
je 0x959a0
jmp 0x9598f
movl 0xbc(%rsp), %eax
subl $0x1, %eax
je 0x959ea
jmp 0x960d8
movq 0x2118(%rsp), %rax
movsd 0x128(%rax), %xmm1
movq 0x2118(%rsp), %rax
movsd 0x130(%rax), %xmm0
movsd 0x121880(%rip), %xmm2   # 0x1b7248
subsd 0x2110(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x2108(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x960d8
movq 0x2118(%rsp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x140(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x124f79(%rip), %xmm1   # 0x1ba9a8
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x10(%rsp), %xmm1
movaps %xmm0, %xmm3
movsd 0x18(%rsp), %xmm0
movsd 0x1217f5(%rip), %xmm2   # 0x1b7248
subsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x1217a6(%rip), %xmm0   # 0x1b7248
subsd 0x100(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x122bcf(%rip), %xmm1   # 0x1b8698
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
movaps %xmm0, %xmm3
movsd 0x30(%rsp), %xmm0
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x140(%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x124e7c(%rip), %xmm1   # 0x1ba9a8
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x38(%rsp), %xmm1
movaps %xmm0, %xmm3
movsd 0x40(%rsp), %xmm0
movsd 0x1216f8(%rip), %xmm2   # 0x1b7248
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20f0(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x140(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x122b04(%rip), %xmm1   # 0x1b8698
mulsd %xmm1, %xmm0
movq 0x2118(%rsp), %rax
mulsd 0x128(%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x128(%rax), %xmm1
movsd 0x124dd9(%rip), %xmm2   # 0x1ba9a8
mulsd %xmm2, %xmm1
movsd 0x121bf5(%rip), %xmm2   # 0x1b77d0
addsd %xmm2, %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x48(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x12162b(%rip), %xmm0   # 0x1b7248
subsd 0x100(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x122a54(%rip), %xmm1   # 0x1b8698
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x50(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movaps %xmm0, %xmm3
movsd 0x60(%rsp), %xmm0
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x140(%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x124ce8(%rip), %xmm1   # 0x1ba9a8
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x68(%rsp), %xmm1
movaps %xmm0, %xmm3
movsd 0x70(%rsp), %xmm0
movsd 0x121564(%rip), %xmm2   # 0x1b7248
subsd %xmm3, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x2118(%rsp), %rax
movsd 0x121531(%rip), %xmm1   # 0x1b7248
subsd 0x100(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x12296d(%rip), %xmm1   # 0x1b8698
mulsd %xmm1, %xmm0
movq 0x2118(%rsp), %rax
mulsd 0x128(%rax), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x128(%rax), %xmm1
movsd 0x122932(%rip), %xmm2   # 0x1b8698
mulsd %xmm2, %xmm1
movsd 0x121a5e(%rip), %xmm2   # 0x1b77d0
addsd %xmm2, %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x78(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x12148e(%rip), %xmm0   # 0x1b7248
subsd 0x100(%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x1228b4(%rip), %xmm1   # 0x1b8698
mulsd 0x128(%rax), %xmm1
callq 0x8610
movsd 0x80(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x88(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x121e6a(%rip), %xmm1   # 0x1b7c80
callq 0x8610
movsd 0x90(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x98(%rsp), %xmm0
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xa0(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x122847(%rip), %xmm0   # 0x1b8698
mulsd 0x140(%rax), %xmm0
movq 0x2118(%rsp), %rax
mulsd 0x128(%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd 0x2110(%rsp), %xmm0
movq 0x2118(%rsp), %rax
movsd 0x128(%rax), %xmm1
movsd 0x124b15(%rip), %xmm2   # 0x1ba9a8
mulsd %xmm2, %xmm1
movsd 0x121931(%rip), %xmm2   # 0x1b77d0
addsd %xmm2, %xmm1
callq 0x8610
movsd 0xa0(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0xa8(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20e8(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x1257dc(%rip), %xmm0   # 0x1bb6c8
movsd 0x12461c(%rip), %xmm1   # 0x1ba510
callq 0x8610
movaps %xmm0, %xmm1
movsd 0xb0(%rsp), %xmm0
movsd 0x1257b3(%rip), %xmm2   # 0x1bb6c0
mulsd %xmm2, %xmm1
movsd 0x12132f(%rip), %xmm2   # 0x1b7248
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20d0(%rsp)
movq 0x2118(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20c8(%rsp)
movq 0x2118(%rsp), %rax
movswl 0x320(%rax), %eax
cmpl $0x1, %eax
jne 0x95f73
movq 0x2118(%rsp), %rax
movsd 0x30(%rax), %xmm0
addsd 0x20c8(%rsp), %xmm0
movsd %xmm0, 0x20c8(%rsp)
movq 0x2118(%rsp), %rax
movswl 0x322(%rax), %eax
cmpl $0x1, %eax
jne 0x95fa6
movq 0x2118(%rsp), %rax
movsd 0x38(%rax), %xmm0
addsd 0x20c8(%rsp), %xmm0
movsd %xmm0, 0x20c8(%rsp)
movq 0x2118(%rsp), %rax
movswl 0x324(%rax), %eax
cmpl $0x1, %eax
jne 0x9602f
leaq 0x18c0(%rsp), %rdi
leaq 0x13a8c3(%rip), %rsi    # 0x1d088c
movb $0x0, %al
callq 0x5b9c0
leaq 0x10c0(%rsp), %rdi
leaq 0x18c0(%rsp), %rdx
leaq 0x121586(%rip), %rsi    # 0x1b756d
movb $0x0, %al
callq 0x5b9c0
movq 0x2118(%rsp), %rdi
addq $0xb84, %rdi            # imm = 0xB84
leaq 0x10c0(%rsp), %r8
leaq 0x121028(%rip), %rsi    # 0x1b7034
leaq 0x13a94b(%rip), %rdx    # 0x1d095e
movl $0x2bb, %ecx            # imm = 0x2BB
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x2124(%rsp)
jmp 0x963b8
movsd 0x20d0(%rsp), %xmm0
divsd 0x20c8(%rsp), %xmm0
movsd %xmm0, 0x20d8(%rsp)
movsd 0x20e8(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0x2110(%rsp), %xmm0
divsd 0x20f0(%rsp), %xmm0
movsd 0x122614(%rip), %xmm1   # 0x1b8698
divsd %xmm1, %xmm0
movsd 0x1211b8(%rip), %xmm1   # 0x1b7248
subsd 0x20f0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x20d8(%rsp), %xmm1
movsd 0x1225ea(%rip), %xmm2   # 0x1b8698
divsd %xmm2, %xmm1
movsd 0x2110(%rsp), %xmm2
addsd 0x20d8(%rsp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0x2108(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x2118(%rsp), %rax
movl 0x120(%rax), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x960fe
jmp 0x960f0
movl 0xc(%rsp), %eax
subl $0x1, %eax
je 0x96136
jmp 0x9627b
movq 0x2118(%rsp), %rax
movsd 0x130(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq 0x2100(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x9627b
xorps %xmm0, %xmm0
movsd %xmm0, 0x20e0(%rsp)
movsd 0x20e0(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0x2110(%rsp), %xmm0
movsd 0x122525(%rip), %xmm1   # 0x1b8698
divsd %xmm1, %xmm0
movsd 0x1210c9(%rip), %xmm1   # 0x1b7248
subsd 0x20f0(%rsp), %xmm1
divsd %xmm1, %xmm0
divsd 0x20f0(%rsp), %xmm0
movsd 0x20e8(%rsp), %xmm1
movsd 0x1224f2(%rip), %xmm2   # 0x1b8698
divsd %xmm2, %xmm1
movsd 0x121096(%rip), %xmm2   # 0x1b7248
subsd 0x20f0(%rsp), %xmm2
divsd %xmm2, %xmm1
divsd 0x20f0(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd 0x20e8(%rsp), %xmm1
mulsd 0x20e8(%rsp), %xmm1
mulsd 0x2110(%rsp), %xmm1
movsd 0x1224a9(%rip), %xmm2   # 0x1b8698
divsd %xmm2, %xmm1
movsd 0x12104d(%rip), %xmm2   # 0x1b7248
subsd 0x20f0(%rsp), %xmm2
divsd %xmm2, %xmm1
movsd 0x121038(%rip), %xmm2   # 0x1b7248
subsd 0x20f0(%rsp), %xmm2
divsd %xmm2, %xmm1
divsd 0x20f0(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x20d8(%rsp), %xmm1
movsd 0x12245d(%rip), %xmm2   # 0x1b8698
divsd %xmm2, %xmm1
movsd 0x2110(%rsp), %xmm2
addsd 0x20d8(%rsp), %xmm2
divsd %xmm2, %xmm1
movsd 0x2110(%rsp), %xmm2
addsd 0x20d8(%rsp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0x2100(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x2118(%rsp), %rax
movl 0x120(%rax), %eax
movl %eax, 0x8(%rsp)
testl %eax, %eax
je 0x962a5
jmp 0x96293
movl 0x8(%rsp), %eax
subl $0x1, %eax
je 0x9633b
jmp 0x963ad
movq 0x2118(%rsp), %rax
movsd 0x120f93(%rip), %xmm0   # 0x1b7248
addsd 0x128(%rax), %xmm0
movq 0x2118(%rsp), %rax
addsd 0x130(%rax), %xmm0
movsd %xmm0, (%rsp)
movsd 0x120f6e(%rip), %xmm0   # 0x1b7248
divsd 0x2110(%rsp), %xmm0
callq 0x82f0
movsd (%rsp), %xmm1
movaps %xmm0, %xmm2
movq 0x2118(%rsp), %rax
movsd 0x130(%rax), %xmm0
movsd 0x2110(%rsp), %xmm3
movsd 0x120f37(%rip), %xmm4   # 0x1b7248
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x12236f(%rip), %xmm0   # 0x1b8698
mulsd %xmm1, %xmm0
movq 0x20f8(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x963ad
leaq 0x8c0(%rsp), %rdi
leaq 0x13a625(%rip), %rsi    # 0x1d096f
movb $0x0, %al
callq 0x5b9c0
leaq 0xc0(%rsp), %rdi
leaq 0x8c0(%rsp), %rdx
leaq 0x121205(%rip), %rsi    # 0x1b756d
movb $0x0, %al
callq 0x5b9c0
movq 0x2118(%rsp), %rdi
addq $0xb84, %rdi            # imm = 0xB84
leaq 0xc0(%rsp), %r8
leaq 0x120ca7(%rip), %rsi    # 0x1b7034
leaq 0x13a5ca(%rip), %rdx    # 0x1d095e
movl $0x2e5, %ecx            # imm = 0x2E5
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x2124(%rsp)
jmp 0x963b8
movl $0x0, 0x2124(%rsp)
movl 0x2124(%rsp), %eax
addq $0x2128, %rsp           # imm = 0x2128
retq
nopw (%rax,%rax)