// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/background.c
// Function: background_ncdm_M_from_Omega
int background_ncdm_M_from_Omega(
                                 struct precision *ppr,
                                 struct background *pba,
                                 int n_ncdm
                                 ) {
  double rho0,rho,n,M,deltaM,drhodM;
  int iter,maxiter=50;

  rho0 = pba->H0*pba->H0*pba->Omega0_ncdm[n_ncdm]; /*Remember that rho is defined such that H^2=sum(rho_i) */
  M = 0.0;

  background_ncdm_momenta(pba->q_ncdm_bg[n_ncdm],
                          pba->w_ncdm_bg[n_ncdm],
                          pba->q_size_ncdm_bg[n_ncdm],
                          M,
                          pba->factor_ncdm[n_ncdm],
                          0.,
                          &n,
                          &rho,
                          NULL,
                          NULL,
                          NULL);

  /* Is the value of Omega less than a massless species?*/
  class_test(rho0<rho,pba->error_message,
             "The value of Omega for the %dth species, %g, is less than for a massless species! It should be atleast %g. Check your input.",
             n_ncdm,pba->Omega0_ncdm[n_ncdm],pba->Omega0_ncdm[n_ncdm]*rho/rho0);

  /* In the strict NR limit we have rho = n*(M) today, giving a zeroth order guess: */
  M = rho0/n; /* This is our guess for M. */
  for (iter=1; iter<=maxiter; iter++) {

    /* Newton iteration. First get relevant quantities at M: */
    background_ncdm_momenta(pba->q_ncdm_bg[n_ncdm],
                            pba->w_ncdm_bg[n_ncdm],
                            pba->q_size_ncdm_bg[n_ncdm],
                            M,
                            pba->factor_ncdm[n_ncdm],
                            0.,
                            NULL,
                            &rho,
                            NULL,
                            &drhodM,
                            NULL);

    deltaM = (rho0-rho)/drhodM; /* By definition of the derivative */
    if ((M+deltaM)<0.0) deltaM = -M/2.0; /* Avoid overshooting to negative M value. */
    M += deltaM; /* Update value of M.. */
    if (fabs(deltaM/M)<ppr->tol_M_ncdm) {
      /* Accuracy reached.. */
      pba->M_ncdm[n_ncdm] = M;
      break;
    }
  }
  class_test(iter>=maxiter,pba->error_message,
             "Newton iteration could not converge on a mass for some reason.");
  return _SUCCESS_;
}

// Assembly:
subq $0x2068, %rsp           # imm = 0x2068
movq %rdi, 0x2058(%rsp)
movq %rsi, 0x2050(%rsp)
movl %edx, 0x204c(%rsp)
movl $0x32, 0x2010(%rsp)
movq 0x2050(%rsp), %rax
movsd (%rax), %xmm0
movq 0x2050(%rsp), %rax
mulsd (%rax), %xmm0
movq 0x2050(%rsp), %rax
movq 0x280(%rax), %rax
movslq 0x204c(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x2040(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x2028(%rsp)
movq 0x2050(%rsp), %rax
movq 0x4d8(%rax), %rax
movslq 0x204c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x2050(%rsp), %rax
movq 0x4e0(%rax), %rax
movslq 0x204c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x2050(%rsp), %rax
movq 0x500(%rax), %rax
movslq 0x204c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movsd 0x2028(%rsp), %xmm0
movq 0x2050(%rsp), %rax
movq 0x510(%rax), %rax
movslq 0x204c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorps %xmm2, %xmm2
leaq 0x2030(%rsp), %rcx
leaq 0x2038(%rsp), %r8
xorl %eax, %eax
movl %eax, %r9d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0xa15d0
movsd 0x2040(%rsp), %xmm1
movsd 0x2038(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xac04e
leaq 0x1810(%rsp), %rdi
movl 0x204c(%rsp), %edx
movq 0x2050(%rsp), %rax
movq 0x280(%rax), %rax
movslq 0x204c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x2050(%rsp), %rax
movq 0x280(%rax), %rax
movslq 0x204c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd 0x2038(%rsp), %xmm1
divsd 0x2040(%rsp), %xmm1
leaq 0x143a7a(%rip), %rsi    # 0x1efa5b
movb $0x2, %al
callq 0x5b9c0
leaq 0x1010(%rsp), %rdi
leaq 0x1810(%rsp), %rcx
leaq 0x126083(%rip), %rsi    # 0x1d2082
leaq 0x143ad2(%rip), %rdx    # 0x1efad8
movb $0x0, %al
callq 0x5b9c0
movq 0x2050(%rsp), %rdi
addq $0xd1c, %rdi            # imm = 0xD1C
leaq 0x1010(%rsp), %r8
leaq 0x126009(%rip), %rsi    # 0x1d2034
leaq 0x143aaf(%rip), %rdx    # 0x1efae1
movl $0x80a, %ecx            # imm = 0x80A
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x2064(%rsp)
jmp 0xac2b6
movsd 0x2040(%rsp), %xmm0
divsd 0x2030(%rsp), %xmm0
movsd %xmm0, 0x2028(%rsp)
movl $0x1, 0x2014(%rsp)
movl 0x2014(%rsp), %eax
cmpl 0x2010(%rsp), %eax
jg 0xac228
movq 0x2050(%rsp), %rax
movq 0x4d8(%rax), %rax
movslq 0x204c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x2050(%rsp), %rax
movq 0x4e0(%rax), %rax
movslq 0x204c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x2050(%rsp), %rax
movq 0x500(%rax), %rax
movslq 0x204c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movsd 0x2028(%rsp), %xmm0
movq 0x2050(%rsp), %rax
movq 0x510(%rax), %rax
movslq 0x204c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorps %xmm2, %xmm2
xorl %eax, %eax
movl %eax, %r9d
leaq 0x2038(%rsp), %r8
leaq 0x2018(%rsp), %rax
movq %r9, %rcx
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0xa15d0
movsd 0x2040(%rsp), %xmm0
subsd 0x2038(%rsp), %xmm0
divsd 0x2018(%rsp), %xmm0
movsd %xmm0, 0x2020(%rsp)
movsd 0x2028(%rsp), %xmm1
addsd 0x2020(%rsp), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xac19e
movsd 0x2028(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x126aef(%rip), %xmm1   # 0x1d2c80
divsd %xmm1, %xmm0
movsd %xmm0, 0x2020(%rsp)
movsd 0x2020(%rsp), %xmm0
addsd 0x2028(%rsp), %xmm0
movsd %xmm0, 0x2028(%rsp)
movsd 0x2020(%rsp), %xmm1
divsd 0x2028(%rsp), %xmm1
movaps 0x12605e(%rip), %xmm0   # 0x1d2230
pand %xmm0, %xmm1
movq 0x2058(%rsp), %rax
movsd 0x28(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xac210
movsd 0x2028(%rsp), %xmm0
movq 0x2050(%rsp), %rax
movq 0x270(%rax), %rax
movslq 0x204c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0xac228
jmp 0xac212
movl 0x2014(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2014(%rsp)
jmp 0xac074
movl 0x2014(%rsp), %eax
cmpl 0x2010(%rsp), %eax
jl 0xac2ab
leaq 0x810(%rsp), %rdi
leaq 0x1438b7(%rip), %rsi    # 0x1efafe
movb $0x0, %al
callq 0x5b9c0
leaq 0x10(%rsp), %rdi
leaq 0x810(%rsp), %rcx
leaq 0x125e20(%rip), %rsi    # 0x1d2082
leaq 0x1438d4(%rip), %rdx    # 0x1efb3d
movb $0x0, %al
callq 0x5b9c0
movq 0x2050(%rsp), %rdi
addq $0xd1c, %rdi            # imm = 0xD1C
leaq 0x10(%rsp), %r8
leaq 0x125da9(%rip), %rsi    # 0x1d2034
leaq 0x14384f(%rip), %rdx    # 0x1efae1
movl $0x827, %ecx            # imm = 0x827
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x2064(%rsp)
jmp 0xac2b6
movl $0x0, 0x2064(%rsp)
movl 0x2064(%rsp), %eax
addq $0x2068, %rsp           # imm = 0x2068
retq
nopw %cs:(%rax,%rax)