// File: /workspace/github_c_makefile_star2_O1/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 0x964d(%rip), %xmm1     # 0xf1260
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 0x47295(%rip), %xmm0    # 0x12eee0
movsd %xmm1, 0x10(%rsp)
divsd %xmm1, %xmm0
callq 0x82c0
movsd %xmm0, 0x28(%rsp)
movsd 0xdec0(%rip), %xmm1     # 0xf5b28
movsd 0x30(%rsp), %xmm0
callq 0x8620
mulsd 0x9b75(%rip), %xmm0     # 0xf17f0
addsd 0x95dd(%rip), %xmm0     # 0xf1260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xe7c93
sqrtsd %xmm0, %xmm0
jmp 0xe7c98
callq 0x82b0
movsd %xmm0, 0x50(%rsp)
movsd 0x4724a(%rip), %xmm0    # 0x12eef0
mulsd 0x10(%rsp), %xmm0
callq 0x82c0
movsd %xmm0, 0x70(%rsp)
movsd 0x47241(%rip), %xmm0    # 0x12ef00
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 0x9570(%rip), %xmm0     # 0xf1260
subsd %xmm3, %xmm0
subsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
addsd %xmm2, %xmm3
movsd %xmm3, 0x18(%rsp)
movsd 0x9588(%rip), %xmm1     # 0xf1298
callq 0x8620
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
divsd 0x40(%rsp), %xmm0
movsd 0xc781(%rip), %xmm1     # 0xf44b0
callq 0x8620
mulsd 0x471cc(%rip), %xmm0    # 0x12ef08
addsd 0x951c(%rip), %xmm0     # 0xf1260
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
divsd 0x40(%rsp), %xmm1
movsd (%r14), %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
mulsd 0xc6f3(%rip), %xmm1     # 0xf4460
movsd 0xc253(%rip), %xmm0     # 0xf3fc8
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd 0x4113b(%rip), %xmm1    # 0x128ec0
mulsd 0x20(%r15), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd (%r15), %xmm0
movsd 0x9a4a(%rip), %xmm1     # 0xf17e8
addsd 0x58(%rsp), %xmm1
callq 0x8620
testl %ebp, %ebp
movsd 0x28(%rsp), %xmm2
jle 0xe7f76
movsd 0x10(%rsp), %xmm1
movsd 0x30(%rsp), %xmm4
divsd %xmm1, %xmm4
mulsd 0x47119(%rip), %xmm2    # 0x12eee8
divsd 0x50(%rsp), %xmm2
movsd %xmm2, 0x28(%rsp)
movq 0xb0(%rsp), %r15
movsd 0x70(%rsp), %xmm5
mulsd 0x47107(%rip), %xmm5    # 0x12eef8
mulsd %xmm4, %xmm5
movsd 0x9463(%rip), %xmm3     # 0xf1260
addsd %xmm3, %xmm5
movsd 0x20(%rsp), %xmm2
mulsd 0x46f79(%rip), %xmm2    # 0x12ed88
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 0x471aa(%rip), %xmm1    # 0x12f000
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 0x47094(%rip), %xmm0    # 0x12ef10
mulsd 0x28(%rsp), %xmm0
movsd 0xc59e(%rip), %xmm1     # 0xf4428
callq 0x8620
movsd 0x93c9(%rip), %xmm1     # 0xf1260
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 0xc097(%rip), %xmm0     # 0xf3f80
addsd 0x47027(%rip), %xmm0    # 0x12ef18
callq 0x82c0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm2
mulsd 0x47018(%rip), %xmm2    # 0x12ef20
addsd 0x9350(%rip), %xmm2     # 0xf1260
movsd 0x47010(%rip), %xmm1    # 0x12ef28
divsd %xmm2, %xmm1
addsd 0x4700c(%rip), %xmm1    # 0x12ef30
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 0xe7e63
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq