// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/helium.c
// Function: rec_saha_xH1s
double rec_saha_xH1s(REC_COSMOPARAMS *cosmo, double z, double xHeII) {

  double s, Tr, nH, ainv;
  double nH0 = cosmo->nH0, T0 = cosmo->T0;
  double fsR = cosmo->fsR, meR = cosmo->meR;

  Tr = T0 * (ainv=1.+z) /fsR/fsR/meR; /* current (rescaled) radiation temperature */
  nH = nH0*ainv*ainv*ainv;

  /* Obtain Saha ratio, xe xHII/xH1s, with xe = xHII + xHeII and xHII = 1-xH1s
   * Constants:
   * reduced mass Rydberg = 157801.37882 Kelvin (no relativistic corrections)
   * prefactor = (2*pi*m*k/h^2)^1.5  */

  s = fsR*fsR*fsR*meR*meR*meR *2.4127161187130e15*Tr*sqrt(Tr)*exp(-157801.37882/Tr)/nH;
  if      (s == 0.) return 1.;
  else if (s > 1e5) return (1.+xHeII)/s - (xHeII*xHeII + 3.*xHeII + 2.)/s/s;  /* Second-order value for xHII ~ 1 */
  else              return 1.-2./(1.+ xHeII/s + sqrt((1.+ xHeII/s)*(1.+ xHeII/s) +4./s));

}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movsd %xmm0, 0x60(%rsp)
movsd %xmm1, 0x58(%rsp)
movq 0x68(%rsp), %rax
movsd 0x88(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x68(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x68(%rsp), %rax
movsd 0x98(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x68(%rsp), %rax
movsd 0xa0(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x2b5bc(%rip), %xmm1    # 0x1d2248
addsd 0x60(%rsp), %xmm1
movsd %xmm1, 0x38(%rsp)
mulsd %xmm1, %xmm0
divsd 0x20(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x30(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x20(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd 0x67a6a(%rip), %xmm1    # 0x20e768
mulsd %xmm1, %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x48(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x67a2c(%rip), %xmm0    # 0x20e760
divsd 0x48(%rsp), %xmm0
callq 0x8670
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
divsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1a6d7c
jp 0x1a6d7c
movsd 0x2b4d7(%rip), %xmm0    # 0x1d2248
movsd %xmm0, 0x70(%rsp)
jmp 0x1a6e7f
movsd 0x50(%rsp), %xmm0
movsd 0x2f966(%rip), %xmm1    # 0x1d66f0
ucomisd %xmm1, %xmm0
jbe 0x1a6ded
movsd 0x2b4b0(%rip), %xmm0    # 0x1d2248
addsd 0x58(%rsp), %xmm0
divsd 0x50(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x58(%rsp), %xmm3
movsd 0x2c8e0(%rip), %xmm2    # 0x1d3698
mulsd 0x58(%rsp), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x2beb2(%rip), %xmm2    # 0x1d2c80
addsd %xmm2, %xmm1
divsd 0x50(%rsp), %xmm1
divsd 0x50(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x1a6e7f
movsd 0x58(%rsp), %xmm1
divsd 0x50(%rsp), %xmm1
movsd 0x2b447(%rip), %xmm0    # 0x1d2248
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd 0x58(%rsp), %xmm1
divsd 0x50(%rsp), %xmm1
movsd 0x2b42a(%rip), %xmm0    # 0x1d2248
addsd %xmm1, %xmm0
movsd 0x58(%rsp), %xmm1
divsd 0x50(%rsp), %xmm1
movsd 0x2b412(%rip), %xmm2    # 0x1d2248
addsd %xmm1, %xmm2
movsd 0x2e686(%rip), %xmm1    # 0x1d54c8
divsd 0x50(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
movsd 0x2be17(%rip), %xmm1    # 0x1d2c80
divsd %xmm0, %xmm1
movsd 0x2b3d3(%rip), %xmm0    # 0x1d2248
subsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x70(%rsp), %xmm0
addq $0x78, %rsp
retq
nopw (%rax,%rax)