// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../external/HyRec2020/helium.c
// Function: rec_helium_dxHeIIdlna
double rec_helium_dxHeIIdlna(HYREC_DATA *data, double z, double xH1, double xHeII, double H) {
  double nH0 = data->cosmo->nH0, Tr0 = data->cosmo->T0, fHe = data->cosmo->fHe;
  double fsR = data->cosmo->fsR, meR = data->cosmo->meR;
  int *error = &data->error;
  double Tr, nH, ainv, s, s0;
  double xe, xHeI, y2s, y2p, ydown;
  double etacinv, g2pinc, dnuline, tau2p, pesc, tauc, enh;
  char sub_message[256];
  if (*error == 1) return 0.;

  xe   = xHeII + (1.-xH1);
  xHeI = fHe - xHeII;
  /* First catch potential errors */
  if (xHeI < 0.){
    sprintf(sub_message, "xHeI = %E < 0 at z = %f in rec_helium_dxHeIIdlna.\nYou should try and extend the hydrogen post-saha phase by increasing DXHII_MAX in history.h\n", xHeI, z);
    strcat(data->error_message, sub_message);
    *error = 1;
  }

  /* Current conditions */
  Tr = Tr0*(ainv=1+z) /fsR/fsR/meR;  /* Rescaled temperature to account for different alpha or me */
  nH = nH0*ainv*ainv*ainv;

  /* Saha abundance ratio, and ratio for zero ionization potential */
  s0 = fsR*fsR*fsR*meR*meR*meR *2.414194e15*Tr*sqrt(Tr)/nH * 4.;
  s = s0 * exp(-285325./Tr);

  /* Abundances of excited levels.  y is defined as x_i = y_i * xe * xHeII */
  y2s = exp(46090./Tr)/s0;
  y2p = exp(39101./Tr)/s0 * 3.;

  /* Continuum opacity */
  /* coeff is 1/(sigma lambda) in cm^(-3). Result is in s^{-1}  */

  etacinv = fsR*fsR*fsR *meR*meR*meR* 9.15776e22 * H/nH/xH1;

  /* Incoherent width of 2(1)P incl. ->2s, 3s, 3d, 4s, 4d, 5s, 5d */
  g2pinc = 1.976e6 / (1.-exp(-6989./Tr))
          + 6.03e6 / (exp(19754./Tr)-1.)
          + 1.06e8 / (exp(21539./Tr)-1.)
          + 2.18e6 / (exp(28496./Tr)-1.)
          + 3.37e7 / (exp(29224./Tr)-1.)
          + 1.04e6 / (exp(32414./Tr)-1.)
          + 1.51e7 / (exp(32781./Tr)-1.);

  g2pinc *= fsR*fsR*fsR*fsR*fsR*meR ;

  /* Optical depth, escape prob in x2p */
  tau2p   = 4.277e-8 * nH/H * xHeI /(fsR*meR*meR);
  dnuline = g2pinc * tau2p / (4.*M_PI*M_PI);
  tauc    = dnuline/etacinv;
  enh     = sqrt(1.+M_PI*M_PI*tauc) + 7.74*tauc/(1.+70.*tauc);
  pesc    = enh / tau2p;


  /* Effective increase in escape probability via intercombination line
    * ratio of optical depth to allowed line = 1.023e-7
    * 1-e^-tau23 = absorption prob. in intercom line
    * e^[(E21P-E23P)/T] - e^[-(E21P-E23P)*eta_c] = step in intercom line
    *   relative to N_line in 21P
    * divide by tau2p to get effective increase in escape prob.
    * factor of 0.964525 is phase space factor for intercom vs allowed line -- (584/591)^3
  */
  pesc = pesc + (1.-exp(-1.023e-7*tau2p))*(0.964525*exp(2947./Tr)-enh*exp(-6.14e13*fsR*fsR*meR/etacinv))/tau2p;

  /* Total decay rate */

  ydown = fsR*fsR*fsR*fsR*fsR*fsR*fsR*fsR*meR *50.94*y2s  /*prefactor correcting 2-photon decay rate given alpha, me*/
        + fsR*fsR*fsR*fsR*fsR*meR* 1.7989e9*y2p*pesc;     /*prefactor correcting 1-photon dipole rate */


  return  ydown*(xHeI*s - xHeII*xe)/H;   /* Excitation is obtained by detailed balance */

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movapd %xmm3, 0xb0(%rsp)
movapd %xmm0, %xmm6
xorpd %xmm0, %xmm0
cmpl $0x1, 0x38(%rdi)
je 0xd82ef
movapd %xmm1, %xmm4
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movsd 0x88(%rax), %xmm0
movaps %xmm0, 0xa0(%rsp)
movsd 0x8(%rax), %xmm5
movsd 0x80(%rax), %xmm0
movsd 0x98(%rax), %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0xa0(%rax), %xmm1
movapd %xmm1, 0x90(%rsp)
subsd %xmm2, %xmm0
movsd %xmm0, 0x58(%rsp)
xorpd %xmm7, %xmm7
ucomisd %xmm0, %xmm7
movsd %xmm2, 0x50(%rsp)
movsd %xmm4, 0x80(%rsp)
jbe 0xd7de2
leaq 0x55508(%rip), %rsi     # 0x12d290
leaq 0xd0(%rsp), %r14
movq %r14, %rdi
movsd 0x58(%rsp), %xmm0
movapd %xmm6, %xmm1
movb $0x2, %al
movsd %xmm5, 0x8(%rsp)
movapd %xmm6, 0x30(%rsp)
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8660
xorpd %xmm7, %xmm7
movapd 0x30(%rsp), %xmm6
movsd 0x80(%rsp), %xmm4
movsd 0x8(%rsp), %xmm5
movsd 0x50(%rsp), %xmm2
movl $0x1, 0x38(%rbx)
movsd 0x19476(%rip), %xmm3    # 0xf1260
subsd %xmm4, %xmm3
addsd 0x1946a(%rip), %xmm6    # 0xf1260
movapd %xmm6, 0x30(%rsp)
mulsd %xmm6, %xmm5
movsd 0x28(%rsp), %xmm1
divsd %xmm1, %xmm5
divsd %xmm1, %xmm5
movapd 0x90(%rsp), %xmm0
divsd %xmm0, %xmm5
movapd %xmm1, %xmm4
mulsd %xmm1, %xmm4
mulsd %xmm1, %xmm4
movapd %xmm0, %xmm1
movsd %xmm4, 0x78(%rsp)
mulsd %xmm4, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
ucomisd %xmm7, %xmm5
movsd %xmm5, 0x8(%rsp)
jb 0xd7e54
xorps %xmm0, %xmm0
sqrtsd %xmm5, %xmm0
jmp 0xd7e75
movapd %xmm5, %xmm0
movsd %xmm3, 0x48(%rsp)
callq 0x82b0
movsd 0x8(%rsp), %xmm5
movsd 0x48(%rsp), %xmm3
movsd 0x50(%rsp), %xmm2
movsd %xmm0, 0x20(%rsp)
addsd %xmm2, %xmm3
movsd %xmm3, 0x48(%rsp)
movsd 0x55303(%rip), %xmm0    # 0x12d190
divsd %xmm5, %xmm0
callq 0x8670
movsd %xmm0, 0x70(%rsp)
movsd 0x55304(%rip), %xmm0    # 0x12d1a8
divsd 0x8(%rsp), %xmm0
callq 0x8670
movsd %xmm0, 0x68(%rsp)
movsd 0x552f3(%rip), %xmm0    # 0x12d1b0
divsd 0x8(%rsp), %xmm0
callq 0x8670
movapd 0x90(%rsp), %xmm1
unpcklpd 0xa0(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movapd 0x30(%rsp), %xmm5
movapd 0x10(%rsp), %xmm3
unpcklpd %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0]
mulpd %xmm1, %xmm3
movsd 0x5528a(%rip), %xmm2    # 0x12d180
mulsd %xmm3, %xmm2
movsd 0x8(%rsp), %xmm4
mulsd %xmm4, %xmm2
mulsd 0x20(%rsp), %xmm2
movsd 0x552a6(%rip), %xmm1    # 0x12d1b8
unpcklpd %xmm5, %xmm1            # xmm1 = xmm1[0],xmm5[0]
mulpd %xmm3, %xmm1
movapd 0xb0(%rsp), %xmm3
unpcklpd %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0]
mulpd %xmm1, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
divsd %xmm1, %xmm2
movapd %xmm1, 0x30(%rsp)
mulsd 0x1c4e3(%rip), %xmm2    # 0xf4428
movsd 0x70(%rsp), %xmm5
mulsd %xmm2, %xmm5
movsd %xmm5, 0x70(%rsp)
movsd 0x68(%rsp), %xmm5
divsd %xmm2, %xmm5
movsd %xmm5, 0x68(%rsp)
divsd %xmm2, %xmm0
mulsd 0x1a70f(%rip), %xmm0    # 0xf2680
movsd %xmm0, 0xa0(%rsp)
divsd %xmm1, %xmm3
divsd 0x80(%rsp), %xmm3
movapd %xmm3, 0x80(%rsp)
movsd 0x55228(%rip), %xmm0    # 0x12d1c0
divsd %xmm4, %xmm0
callq 0x8670
movsd 0x192b7(%rip), %xmm1    # 0xf1260
subsd %xmm0, %xmm1
movsd 0x55213(%rip), %xmm0    # 0x12d1c8
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x55209(%rip), %xmm0    # 0x12d1d0
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x1980e(%rip), %xmm0    # 0xf17e8
movsd 0x551f6(%rip), %xmm1    # 0x12d1d8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x551e6(%rip), %xmm0    # 0x12d1e0
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x197db(%rip), %xmm0    # 0xf17e8
movsd 0x551d3(%rip), %xmm1    # 0x12d1e8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x551c3(%rip), %xmm0    # 0x12d1f0
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x197a8(%rip), %xmm0    # 0xf17e8
movsd 0x551b0(%rip), %xmm1    # 0x12d1f8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x551a0(%rip), %xmm0    # 0x12d200
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19775(%rip), %xmm0    # 0xf17e8
movsd 0x5518d(%rip), %xmm1    # 0x12d208
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x5517d(%rip), %xmm0    # 0x12d210
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19742(%rip), %xmm0    # 0xf17e8
movsd 0x5516a(%rip), %xmm1    # 0x12d218
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x5515a(%rip), %xmm0    # 0x12d220
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x1970f(%rip), %xmm0    # 0xf17e8
movsd 0x55147(%rip), %xmm4    # 0x12d228
divsd %xmm0, %xmm4
addsd 0x10(%rsp), %xmm4
movsd 0x28(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movapd 0x90(%rsp), %xmm2
movapd %xmm2, %xmm3
movsd %xmm1, 0x78(%rsp)
mulsd %xmm1, %xmm3
movapd %xmm3, 0x10(%rsp)
mulsd %xmm3, %xmm4
movapd 0x30(%rsp), %xmm1
mulsd 0x55102(%rip), %xmm1    # 0x12d230
divsd 0xb0(%rsp), %xmm1
mulsd 0x58(%rsp), %xmm1
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
mulsd %xmm1, %xmm4
divsd 0x550dd(%rip), %xmm4    # 0x12d238
divsd 0x80(%rsp), %xmm4
movsd 0x550d4(%rip), %xmm0    # 0x12d240
mulsd %xmm4, %xmm0
addsd 0x190e8(%rip), %xmm0    # 0xf1260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xd8188
sqrtsd %xmm0, %xmm0
jmp 0xd8199
movsd %xmm4, 0x20(%rsp)
callq 0x82b0
movsd 0x20(%rsp), %xmm4
movsd 0x550a7(%rip), %xmm2    # 0x12d248
mulsd %xmm4, %xmm2
mulsd 0x50d5b(%rip), %xmm4    # 0x128f08
movsd 0x190ab(%rip), %xmm1    # 0xf1260
movsd %xmm1, 0x60(%rsp)
addsd %xmm1, %xmm4
divsd %xmm4, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0xc8(%rsp)
movapd %xmm2, %xmm0
movapd 0x30(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x55064(%rip), %xmm0    # 0x12d250
mulsd %xmm1, %xmm0
callq 0x8670
movsd 0x60(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
movsd 0x5504b(%rip), %xmm0    # 0x12d258
divsd 0x8(%rsp), %xmm0
callq 0x8670
movsd %xmm0, 0x8(%rsp)
movsd 0x5503a(%rip), %xmm0    # 0x12d260
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x90(%rsp), %xmm0
divsd 0x80(%rsp), %xmm0
callq 0x8670
mulsd 0xc8(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
mulsd 0x55006(%rip), %xmm1    # 0x12d268
subsd %xmm0, %xmm1
mulsd 0x60(%rsp), %xmm1
divsd 0x30(%rsp), %xmm1
movsd 0x78(%rsp), %xmm0
movsd 0x28(%rsp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm0
mulsd 0x90(%rsp), %xmm0
mulsd 0x54fd5(%rip), %xmm0    # 0x12d270
addsd 0x20(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm0
movapd 0x10(%rsp), %xmm2
mulsd 0x54fc3(%rip), %xmm2    # 0x12d278
mulsd 0xa0(%rsp), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd 0x48(%rsp), %xmm1
mulsd 0x50(%rsp), %xmm1
movsd 0x58(%rsp), %xmm0
mulsd 0x70(%rsp), %xmm0
subsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
divsd 0xb0(%rsp), %xmm0
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r14
retq
nop