// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HMcode/hmcode.c
// Function: hmcode_eisenstein_hu
int hmcode_eisenstein_hu(
                         struct precision *ppr,
                         struct background *pba,
                         struct primordial * ppm,
                         struct fourier *pfo,
                         double * ln_k,
                         int k_size,
                         double * ln_pk_nowiggle
                         ){

  int index_k;
  double h,wm,wb,rb;
  double s, alpha, Gamma, q,L,C,Tk_nw,Pk_nw;
  double k;
  double ns,Om,OL,g,coeff,norm;

  h = pba->h;
  wm = (1.-pba->Omega0_lambda-pba->Omega0_fld)*h*h;
  wb = pba->Omega0_b*h*h;
  rb = wb/wm;

  s = 44.5*log(9.83/wm)/sqrt(1.+10.*pow(wb,0.75));
  alpha = 1.-0.328*log(431.*wm)*rb+0.38*log(22.3*wm)*rb*rb;

  // ns was hard-coded as ns=0.95 in old HMcode implementation (this has no
  // significant impact since the analytic power spectrum is used only to
  // reduce the dynamical range before interpolation!)
  //ns = 0.95;
  ns = ppm->n_s;

  // added by JL for an approximate but realistic normalisation of the spectrum:
  // - factor g(Omega_M) defined and approximated like in Kofman et al. 1993 (valid in a flat Universe)
  // - factor norm refering to eq. (6.34, first line) in Neutrino Cosmology book (CUP 2013)
  //   (the original HMcode was using norm=1, which makes zero difference for the calculation of P_NL)
  Om = (1.-pba->Omega0_lambda-pba->Omega0_fld);
  OL = pba->Omega0_lambda+pba->Omega0_fld;
  g = pow(Om,0.2) / (1.+0.003*pow(OL/Om,4./3.));
  coeff = g/Om/pba->H0/pba->H0;
  // if {\cal P}_R = A_s (k/kp)^(ns-1), then [{\cal P}_R / k^(ns-1)] = A_s / kp^(ns-1)
  norm = pow(coeff,2)*8*_PI_*_PI_/25.*ppm->A_s/pow(ppm->k_pivot,ns-1.);

  for(index_k=0; index_k<k_size; index_k++){
    k = exp(ln_k[index_k]);
    Gamma = (wm/h)*(alpha+(1.-alpha)/(1.+pow(0.43*k*s,4)));
    q = k/h*(pba->T_cmb/2.7)*(pba->T_cmb/2.7)/Gamma;
    L = log(2.*exp(1.)+1.8*q);
    C = 14.2+731./(1.+62.5*q);
    Tk_nw = L/(L+C*q*q);
    // According to eq. (6.34, first line) in Neutrino Cosmology book (CUP 2013),
    // P(k) = norm * k^ns * T(k) where T(k) is noramlised to 1 for small k
    ln_pk_nowiggle[index_k] = log(norm*pow(k,ns)*pow(Tk_nw,2));
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, %ebp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r14
movsd 0x9b2b(%rip), %xmm1     # 0xee260
subsd 0x30(%rsi), %xmm1
subsd 0x38(%rsi), %xmm1
movsd 0x8(%rsi), %xmm0
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x20(%rsi), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm0, 0x60(%rsp)
mulsd %xmm0, %xmm2
movsd %xmm2, 0x30(%rsp)
movsd 0x477a3(%rip), %xmm0    # 0x12bf10
movsd %xmm1, 0x10(%rsp)
divsd %xmm1, %xmm0
callq 0x82c0
movsd %xmm0, 0x28(%rsp)
movsd 0xe3ce(%rip), %xmm1     # 0xf2b58
movsd 0x30(%rsp), %xmm0
callq 0x8620
mulsd 0xa053(%rip), %xmm0     # 0xee7f0
addsd 0x9abb(%rip), %xmm0     # 0xee260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xe47b5
sqrtsd %xmm0, %xmm0
jmp 0xe47ba
callq 0x82b0
movsd %xmm0, 0x50(%rsp)
movsd 0x47758(%rip), %xmm0    # 0x12bf20
mulsd 0x10(%rsp), %xmm0
callq 0x82c0
movsd %xmm0, 0x70(%rsp)
movsd 0x4774f(%rip), %xmm0    # 0x12bf30
mulsd 0x10(%rsp), %xmm0
callq 0x82c0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%r15), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x30(%r14), %xmm3
movsd 0x38(%r14), %xmm2
movsd 0x9a4e(%rip), %xmm0     # 0xee260
subsd %xmm3, %xmm0
subsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
addsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
movsd 0x9a66(%rip), %xmm1     # 0xee298
callq 0x8620
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
divsd 0x40(%rsp), %xmm0
movsd 0xcc6f(%rip), %xmm1     # 0xf14c0
callq 0x8620
mulsd 0x476da(%rip), %xmm0    # 0x12bf38
addsd 0x99fa(%rip), %xmm0     # 0xee260
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
divsd 0x40(%rsp), %xmm1
movsd (%r14), %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
mulsd 0xcbe1(%rip), %xmm1     # 0xf1470
movsd 0xc741(%rip), %xmm0     # 0xf0fd8
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd 0xae51(%rip), %xmm1     # 0xef6f8
mulsd 0x20(%r15), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd (%r15), %xmm0
movsd 0x9f28(%rip), %xmm1     # 0xee7e8
addsd 0x58(%rsp), %xmm1
callq 0x8620
testl %ebp, %ebp
movsd 0x28(%rsp), %xmm2
jle 0xe4a98
movsd 0x10(%rsp), %xmm1
movsd 0x30(%rsp), %xmm4
divsd %xmm1, %xmm4
mulsd 0x47627(%rip), %xmm2    # 0x12bf18
divsd 0x50(%rsp), %xmm2
movsd %xmm2, 0x28(%rsp)
movq 0xb0(%rsp), %r15
movsd 0x70(%rsp), %xmm5
mulsd 0x47615(%rip), %xmm5    # 0x12bf28
mulsd %xmm4, %xmm5
movsd 0x9941(%rip), %xmm3     # 0xee260
addsd %xmm3, %xmm5
movsd 0x20(%rsp), %xmm2
mulsd 0x47487(%rip), %xmm2    # 0x12bdb8
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm2
addsd %xmm5, %xmm2
movsd 0x8(%rsp), %xmm4
divsd %xmm0, %xmm4
movsd %xmm4, 0x8(%rsp)
movapd 0x60(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd %xmm2, 0x20(%rsp)
subsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
movl %ebp, %r12d
movapd 0x476b8(%rip), %xmm1    # 0x12c030
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x60(%rsp)
xorl %r13d, %r13d
movsd (%rbx,%r13,8), %xmm0
callq 0x8670
movapd %xmm0, 0x40(%rsp)
mulsd 0x475a2(%rip), %xmm0    # 0x12bf40
mulsd 0x28(%rsp), %xmm0
movsd 0xca8c(%rip), %xmm1     # 0xf1438
callq 0x8620
movsd 0x98a7(%rip), %xmm1     # 0xee260
addsd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd 0x20(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x18(%r14), %xmm0
unpcklpd 0x40(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
divpd 0x60(%rsp), %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movapd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm0
mulsd 0xc585(%rip), %xmm0     # 0xf0f90
addsd 0x47535(%rip), %xmm0    # 0x12bf48
callq 0x82c0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm2
mulsd 0x47526(%rip), %xmm2    # 0x12bf50
addsd 0x982e(%rip), %xmm2     # 0xee260
movsd 0x4751e(%rip), %xmm1    # 0x12bf58
divsd %xmm2, %xmm1
addsd 0x4751a(%rip), %xmm1    # 0x12bf60
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movapd 0x40(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
callq 0x8620
mulsd 0x8(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm1, %xmm0
callq 0x82c0
movsd %xmm0, (%r15,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0xe4985
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq