// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
movl %r9d, %ebx
movq %r8, %r14
movq %rdx, %r12
movq %rsi, %r15
movsd 0x8efe(%rip), %xmm1     # 0xe5260
subsd 0x30(%rsi), %xmm1
movsd 0x8(%rsi), %xmm0
subsd 0x38(%rsi), %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x20(%rsi), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm0, 0x30(%rsp)
mulsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x469d9(%rip), %xmm0    # 0x122d80
movsd %xmm1, 0x8(%rsp)
divsd %xmm1, %xmm0
callq 0x82e0
mulsd 0x469ca(%rip), %xmm0    # 0x122d88
movsd %xmm0, 0x28(%rsp)
movsd 0xd64c(%rip), %xmm1     # 0xe9a18
movsd (%rsp), %xmm0
callq 0x8650
mulsd 0x9412(%rip), %xmm0     # 0xe57f0
addsd 0x8e7a(%rip), %xmm0     # 0xe5260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xdc3f6
sqrtsd %xmm0, %xmm0
jmp 0xdc3fb
callq 0x82d0
movsd 0x28(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movq 0x90(%rsp), %r13
movsd 0x46975(%rip), %xmm0    # 0x122d90
mulsd 0x8(%rsp), %xmm0
callq 0x82e0
movapd %xmm0, %xmm1
mulsd 0x46966(%rip), %xmm1    # 0x122d98
mulsd 0x10(%rsp), %xmm1
movsd 0x8e20(%rip), %xmm0     # 0xe5260
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd 0x4694f(%rip), %xmm0    # 0x122da0
mulsd 0x8(%rsp), %xmm0
callq 0x82e0
mulsd 0x467c4(%rip), %xmm0    # 0x122c28
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x28(%r12), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%r15), %xmm3
movsd 0x38(%r15), %xmm2
movsd 0x8dc2(%rip), %xmm0     # 0xe5260
subsd %xmm3, %xmm0
subsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd %xmm2, %xmm3
movsd %xmm3, 0x20(%rsp)
movsd 0x8dda(%rip), %xmm1     # 0xe5298
callq 0x8650
movsd %xmm0, (%rsp)
movsd 0x20(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd 0xbfa4(%rip), %xmm1     # 0xe8480
callq 0x8650
mulsd 0x468bf(%rip), %xmm0    # 0x122da8
addsd 0x8d6f(%rip), %xmm0     # 0xe5260
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
divsd 0x10(%rsp), %xmm1
movsd (%r15), %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
mulsd 0xbf17(%rip), %xmm1     # 0xe8430
movsd 0xba77(%rip), %xmm0     # 0xe7f98
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd 0xa19f(%rip), %xmm1     # 0xe66d0
mulsd 0x20(%r12), %xmm1
movsd %xmm1, (%rsp)
movsd (%r12), %xmm0
movsd 0x929d(%rip), %xmm1     # 0xe57e8
addsd 0x40(%rsp), %xmm1
callq 0x8650
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x30(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x8cde(%rip), %xmm1     # 0xe5260
subsd 0x48(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
xorl %r12d, %r12d
testl %ebx, %ebx
cmovlel %r12d, %ebx
movapd 0x46901(%rip), %xmm1    # 0x122ea0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x50(%rsp)
cmpq %r12, %rbx
je 0xdc6c1
movsd (%r14,%r12,8), %xmm0
callq 0x86a0
movapd %xmm0, 0x10(%rsp)
mulsd 0x467e5(%rip), %xmm0    # 0x122db0
mulsd 0x28(%rsp), %xmm0
movsd 0xbe1f(%rip), %xmm1     # 0xe83f8
callq 0x8650
movsd 0x8c7a(%rip), %xmm1     # 0xe5260
addsd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd 0x48(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
movsd 0x18(%r15), %xmm0
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
divpd 0x50(%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 0xb918(%rip), %xmm0     # 0xe7f50
addsd 0x46778(%rip), %xmm0    # 0x122db8
callq 0x82e0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm2
mulsd 0x46769(%rip), %xmm2    # 0x122dc0
addsd 0x8c01(%rip), %xmm2     # 0xe5260
movsd 0x46761(%rip), %xmm1    # 0x122dc8
divsd %xmm2, %xmm1
addsd 0x4675d(%rip), %xmm1    # 0x122dd0
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movapd 0x10(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
callq 0x8650
mulsd (%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm1, %xmm0
callq 0x82e0
movsd %xmm0, (%r13,%r12,8)
incq %r12
jmp 0xdc5a9
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq