// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/background.c
// Function: background_ncdm_momenta
int background_ncdm_momenta(
                            /* Only calculate for non-NULL pointers: */
                            double * qvec,
                            double * wvec,
                            int qsize,
                            double M,
                            double factor,
                            double z,
                            double * n,
                            double * rho, // density
                            double * p,   // pressure
                            double * drho_dM,  // d rho / d M used in next function
                            double * pseudo_p  // pseudo-p used in ncdm fluid approx
                            ) {

  int index_q;
  double epsilon;
  double q2;
  double factor2;
  /** Summary: */

  /** - rescale normalization at given redshift */
  factor2 = factor*pow(1+z,4);

  /** - initialize quantities */
  if (n!=NULL) *n = 0.;
  if (rho!=NULL) *rho = 0.;
  if (p!=NULL) *p = 0.;
  if (drho_dM!=NULL) *drho_dM = 0.;
  if (pseudo_p!=NULL) *pseudo_p = 0.;

  /** - loop over momenta */
  for (index_q=0; index_q<qsize; index_q++) {

    /* squared momentum */
    q2 = qvec[index_q]*qvec[index_q];

    /* energy */
    epsilon = sqrt(q2+M*M/(1.+z)/(1.+z));

    /* integrand of the various quantities */
    if (n!=NULL) *n += q2*wvec[index_q];
    if (rho!=NULL) *rho += q2*epsilon*wvec[index_q];
    if (p!=NULL) *p += q2*q2/3./epsilon*wvec[index_q];
    if (drho_dM!=NULL) *drho_dM += q2*M/(1.+z)/(1.+z)/epsilon*wvec[index_q];
    if (pseudo_p!=NULL) *pseudo_p += pow(q2/epsilon,3)/3.0*wvec[index_q];
  }

  /** - adjust normalization */

  if (n!=NULL) *n *= factor2/(1.+z);
  if (rho!=NULL) *rho *= factor2;
  if (p!=NULL) *p *= factor2;
  if (drho_dM!=NULL) *drho_dM *= factor2;
  if (pseudo_p!=NULL) *pseudo_p *=factor2;

  return _SUCCESS_;
}

// Assembly:
subq $0x78, %rsp
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rax
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movl %edx, 0x64(%rsp)
movsd %xmm0, 0x58(%rsp)
movsd %xmm1, 0x50(%rsp)
movsd %xmm2, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movq %r9, 0x30(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x130c21(%rip), %xmm0   # 0x1d2248
addsd 0x48(%rsp), %xmm0
movsd 0x133e93(%rip), %xmm1   # 0x1d54c8
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0xa1661
movq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x38(%rsp)
je 0xa1675
movq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x30(%rsp)
je 0xa1689
movq 0x30(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x80(%rsp)
je 0xa16a3
movq 0x80(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x88(%rsp)
je 0xa16bd
movq 0x88(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0xa18c1
movq 0x70(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x70(%rsp), %rax
movslq 0x2c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
movsd 0x130b37(%rip), %xmm2   # 0x1d2248
addsd 0x48(%rsp), %xmm2
divsd %xmm2, %xmm1
movsd 0x130b25(%rip), %xmm2   # 0x1d2248
addsd 0x48(%rsp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
callq 0x82e0
movsd %xmm0, 0x20(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0xa176e
movsd 0x18(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x40(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x38(%rsp)
je 0xa17a6
movsd 0x18(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x38(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x30(%rsp)
je 0xa17f0
movsd 0x18(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd 0x131ed6(%rip), %xmm1   # 0x1d3698
divsd %xmm1, %xmm0
divsd 0x20(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x80(%rsp)
je 0xa1858
movsd 0x18(%rsp), %xmm0
mulsd 0x58(%rsp), %xmm0
movsd 0x130a39(%rip), %xmm1   # 0x1d2248
addsd 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x130a27(%rip), %xmm1   # 0x1d2248
addsd 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
divsd 0x20(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x80(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x88(%rsp)
je 0xa18af
movsd 0x18(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movsd 0x131e21(%rip), %xmm1   # 0x1d3698
callq 0x8610
movsd 0x131e14(%rip), %xmm1   # 0x1d3698
divsd %xmm1, %xmm0
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x88(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0xa18b1
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0xa16c5
cmpq $0x0, 0x40(%rsp)
je 0xa18ee
movsd 0x10(%rsp), %xmm0
movsd 0x130971(%rip), %xmm1   # 0x1d2248
addsd 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
movq 0x40(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x38(%rsp)
je 0xa1909
movsd 0x10(%rsp), %xmm0
movq 0x38(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x30(%rsp)
je 0xa1924
movsd 0x10(%rsp), %xmm0
movq 0x30(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x80(%rsp)
je 0xa1945
movsd 0x10(%rsp), %xmm0
movq 0x80(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
cmpq $0x0, 0x88(%rsp)
je 0xa1966
movsd 0x10(%rsp), %xmm0
movq 0x88(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
addq $0x78, %rsp
retq
nopl (%rax)