// File: /workspace/github_c_makefile_star2_O3/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 0xd4af3
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 0xd45e6
leaq 0x55d34(%rip), %rsi     # 0x12a2c0
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 0x19c72(%rip), %xmm3    # 0xee260
subsd %xmm4, %xmm3
addsd 0x19c66(%rip), %xmm6    # 0xee260
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 0xd4658
xorps %xmm0, %xmm0
sqrtsd %xmm5, %xmm0
jmp 0xd4679
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 0x55b2f(%rip), %xmm0    # 0x12a1c0
divsd %xmm5, %xmm0
callq 0x8670
movsd %xmm0, 0x70(%rsp)
movsd 0x55b30(%rip), %xmm0    # 0x12a1d8
divsd 0x8(%rsp), %xmm0
callq 0x8670
movsd %xmm0, 0x68(%rsp)
movsd 0x55b1f(%rip), %xmm0    # 0x12a1e0
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 0x55ab6(%rip), %xmm2    # 0x12a1b0
mulsd %xmm3, %xmm2
movsd 0x8(%rsp), %xmm4
mulsd %xmm4, %xmm2
mulsd 0x20(%rsp), %xmm2
movsd 0x55ad2(%rip), %xmm1    # 0x12a1e8
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 0x1ccef(%rip), %xmm2    # 0xf1438
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 0x1af0b(%rip), %xmm0    # 0xef680
movsd %xmm0, 0xa0(%rsp)
divsd %xmm1, %xmm3
divsd 0x80(%rsp), %xmm3
movapd %xmm3, 0x80(%rsp)
movsd 0x55a54(%rip), %xmm0    # 0x12a1f0
divsd %xmm4, %xmm0
callq 0x8670
movsd 0x19ab3(%rip), %xmm1    # 0xee260
subsd %xmm0, %xmm1
movsd 0x55a3f(%rip), %xmm0    # 0x12a1f8
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x55a35(%rip), %xmm0    # 0x12a200
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x1a00a(%rip), %xmm0    # 0xee7e8
movsd 0x55a22(%rip), %xmm1    # 0x12a208
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x55a12(%rip), %xmm0    # 0x12a210
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19fd7(%rip), %xmm0    # 0xee7e8
movsd 0x559ff(%rip), %xmm1    # 0x12a218
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x559ef(%rip), %xmm0    # 0x12a220
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19fa4(%rip), %xmm0    # 0xee7e8
movsd 0x559dc(%rip), %xmm1    # 0x12a228
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x559cc(%rip), %xmm0    # 0x12a230
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19f71(%rip), %xmm0    # 0xee7e8
movsd 0x559b9(%rip), %xmm1    # 0x12a238
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x559a9(%rip), %xmm0    # 0x12a240
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19f3e(%rip), %xmm0    # 0xee7e8
movsd 0x55996(%rip), %xmm1    # 0x12a248
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x55986(%rip), %xmm0    # 0x12a250
divsd 0x8(%rsp), %xmm0
callq 0x8670
addsd 0x19f0b(%rip), %xmm0    # 0xee7e8
movsd 0x55973(%rip), %xmm4    # 0x12a258
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 0x5592e(%rip), %xmm1    # 0x12a260
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 0x55909(%rip), %xmm4    # 0x12a268
divsd 0x80(%rsp), %xmm4
movsd 0x55900(%rip), %xmm0    # 0x12a270
mulsd %xmm4, %xmm0
addsd 0x198e4(%rip), %xmm0    # 0xee260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xd498c
sqrtsd %xmm0, %xmm0
jmp 0xd499d
movsd %xmm4, 0x20(%rsp)
callq 0x82b0
movsd 0x20(%rsp), %xmm4
movsd 0x558d3(%rip), %xmm2    # 0x12a278
mulsd %xmm4, %xmm2
mulsd 0x5157f(%rip), %xmm4    # 0x125f30
movsd 0x198a7(%rip), %xmm1    # 0xee260
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 0x55890(%rip), %xmm0    # 0x12a280
mulsd %xmm1, %xmm0
callq 0x8670
movsd 0x60(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
movsd 0x55877(%rip), %xmm0    # 0x12a288
divsd 0x8(%rsp), %xmm0
callq 0x8670
movsd %xmm0, 0x8(%rsp)
movsd 0x55866(%rip), %xmm0    # 0x12a290
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 0x55832(%rip), %xmm1    # 0x12a298
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 0x55801(%rip), %xmm0    # 0x12a2a0
addsd 0x20(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm0
movapd 0x10(%rsp), %xmm2
mulsd 0x557ef(%rip), %xmm2    # 0x12a2a8
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