// File: /workspace/github_c_makefile_star2_O3/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 $0x68, %rsp
movsd 0x88(%rdi), %xmm2
movaps %xmm2, 0x40(%rsp)
movsd 0x98(%rdi), %xmm3
movsd 0xa0(%rdi), %xmm2
addsd 0x19f03(%rip), %xmm0    # 0xee260
movsd 0x8(%rdi), %xmm4
movapd %xmm0, 0x50(%rsp)
mulsd %xmm0, %xmm4
divsd %xmm3, %xmm4
divsd %xmm3, %xmm4
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
mulsd 0x55e34(%rip), %xmm0    # 0x12a1c8
movapd %xmm0, 0x30(%rsp)
divsd %xmm2, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
movaps %xmm1, (%rsp)
movapd %xmm4, 0x20(%rsp)
jb 0xd43bb
xorps %xmm0, %xmm0
sqrtsd %xmm4, %xmm0
jmp 0xd43ca
movapd %xmm4, %xmm0
callq 0x82b0
movapd 0x20(%rsp), %xmm4
movapd %xmm0, 0x10(%rsp)
movsd 0x55df8(%rip), %xmm0    # 0x12a1d0
divsd %xmm4, %xmm0
callq 0x8670
movapd 0x50(%rsp), %xmm1
movapd 0x30(%rsp), %xmm2
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
movapd 0x20(%rsp), %xmm3
unpcklpd 0x40(%rsp), %xmm3       # xmm3 = xmm3[0],mem[0]
mulpd %xmm2, %xmm3
movapd 0x10(%rsp), %xmm2
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
mulpd %xmm3, %xmm2
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
mulpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
divsd %xmm1, %xmm0
ucomisd 0x19e2d(%rip), %xmm0    # 0xee258
jne 0xd443c
jp 0xd443c
movsd 0x19e29(%rip), %xmm0    # 0xee260
jmp 0xd44f1
ucomisd 0x1e7a4(%rip), %xmm0    # 0xf2be8
jbe 0xd4491
movsd 0x1b232(%rip), %xmm1    # 0xef680
movapd (%rsp), %xmm3
mulsd %xmm3, %xmm1
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
addpd 0x55e41(%rip), %xmm3    # 0x12a2b0
movapd %xmm0, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
divpd %xmm1, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
divsd %xmm0, %xmm1
subsd %xmm1, %xmm3
movapd %xmm3, %xmm0
jmp 0xd44f1
movapd (%rsp), %xmm2
divsd %xmm0, %xmm2
addsd 0x19dbe(%rip), %xmm2    # 0xee260
movsd 0x1cf8e(%rip), %xmm1    # 0xf1438
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xd44ca
sqrtsd %xmm0, %xmm0
jmp 0xd44d9
movapd %xmm2, (%rsp)
callq 0x82b0
movapd (%rsp), %xmm2
addsd %xmm0, %xmm2
movsd 0x1b27b(%rip), %xmm0    # 0xef760
divsd %xmm2, %xmm0
addsd 0x19d6f(%rip), %xmm0    # 0xee260
addq $0x68, %rsp
retq