// File: /workspace/github_c_makefile_star2_O2/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 0x18901(%rip), %xmm0    # 0xe5260
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 0x546d2(%rip), %xmm0    # 0x121068
movapd %xmm0, 0x30(%rsp)
divsd %xmm2, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
movaps %xmm1, (%rsp)
movapd %xmm4, 0x20(%rsp)
jb 0xcc9ba
sqrtsd %xmm4, %xmm0
jmp 0xcc9c9
movapd %xmm4, %xmm0
callq 0x82d0
movapd 0x20(%rsp), %xmm4
movapd %xmm0, 0x10(%rsp)
movsd 0x54699(%rip), %xmm0    # 0x121070
divsd %xmm4, %xmm0
callq 0x86a0
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 0x1882e(%rip), %xmm0    # 0xe5258
jne 0xcca3b
jp 0xcca3b
movsd 0x1882a(%rip), %xmm0    # 0xe5260
jmp 0xccaf0
ucomisd 0x1d065(%rip), %xmm0    # 0xe9aa8
jbe 0xcca90
movsd 0x19cfb(%rip), %xmm1    # 0xe6748
movapd (%rsp), %xmm3
mulsd %xmm3, %xmm1
movapd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
addpd 0x546e2(%rip), %xmm3    # 0x121150
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 0xccaf0
movapd (%rsp), %xmm2
divsd %xmm0, %xmm2
addsd 0x187bf(%rip), %xmm2    # 0xe5260
movsd 0x1b94f(%rip), %xmm1    # 0xe83f8
divsd %xmm0, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xccac9
sqrtsd %xmm0, %xmm0
jmp 0xccad8
movapd %xmm2, (%rsp)
callq 0x82d0
movapd (%rsp), %xmm2
addsd %xmm0, %xmm2
movsd 0x19c54(%rip), %xmm0    # 0xe6738
divsd %xmm2, %xmm0
addsd 0x18770(%rip), %xmm0    # 0xe5260
addq $0x68, %rsp
retq