// File: /workspace/github_c_makefile_star2_O2/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 0xcd0ef
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 0xccbe5
leaq 0x545d5(%rip), %rsi     # 0x121160
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 0x8690
xorpd %xmm7, %xmm7
movapd 0x30(%rsp), %xmm6
movsd 0x80(%rsp), %xmm4
movsd 0x8(%rsp), %xmm5
movsd 0x50(%rsp), %xmm2
movl $0x1, 0x38(%rbx)
movsd 0x18673(%rip), %xmm3    # 0xe5260
subsd %xmm4, %xmm3
addsd 0x18667(%rip), %xmm6    # 0xe5260
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 0xccc54
sqrtsd %xmm5, %xmm0
jmp 0xccc75
movapd %xmm5, %xmm0
movsd %xmm3, 0x48(%rsp)
callq 0x82d0
movsd 0x8(%rsp), %xmm5
movsd 0x48(%rsp), %xmm3
movsd 0x50(%rsp), %xmm2
movsd %xmm0, 0x20(%rsp)
addsd %xmm2, %xmm3
movsd %xmm3, 0x48(%rsp)
movsd 0x543d3(%rip), %xmm0    # 0x121060
divsd %xmm5, %xmm0
callq 0x86a0
movsd %xmm0, 0x70(%rsp)
movsd 0x543d4(%rip), %xmm0    # 0x121078
divsd 0x8(%rsp), %xmm0
callq 0x86a0
movsd %xmm0, 0x68(%rsp)
movsd 0x543c3(%rip), %xmm0    # 0x121080
divsd 0x8(%rsp), %xmm0
callq 0x86a0
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 0x5435a(%rip), %xmm2    # 0x121050
mulsd %xmm3, %xmm2
movsd 0x8(%rsp), %xmm4
mulsd %xmm4, %xmm2
mulsd 0x20(%rsp), %xmm2
movsd 0x54376(%rip), %xmm1    # 0x121088
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 0x1b6b3(%rip), %xmm2    # 0xe83f8
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 0x199d7(%rip), %xmm0    # 0xe6748
movsd %xmm0, 0xa0(%rsp)
divsd %xmm1, %xmm3
divsd 0x80(%rsp), %xmm3
movapd %xmm3, 0x80(%rsp)
movsd 0x542f8(%rip), %xmm0    # 0x121090
divsd %xmm4, %xmm0
callq 0x86a0
movsd 0x184b7(%rip), %xmm1    # 0xe5260
subsd %xmm0, %xmm1
movsd 0x542e3(%rip), %xmm0    # 0x121098
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x542d9(%rip), %xmm0    # 0x1210a0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x18a0e(%rip), %xmm0    # 0xe57e8
movsd 0x542c6(%rip), %xmm1    # 0x1210a8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x542b6(%rip), %xmm0    # 0x1210b0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x189db(%rip), %xmm0    # 0xe57e8
movsd 0x542a3(%rip), %xmm1    # 0x1210b8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x54293(%rip), %xmm0    # 0x1210c0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x189a8(%rip), %xmm0    # 0xe57e8
movsd 0x54280(%rip), %xmm1    # 0x1210c8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x54270(%rip), %xmm0    # 0x1210d0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x18975(%rip), %xmm0    # 0xe57e8
movsd 0x5425d(%rip), %xmm1    # 0x1210d8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x5424d(%rip), %xmm0    # 0x1210e0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x18942(%rip), %xmm0    # 0xe57e8
movsd 0x5423a(%rip), %xmm1    # 0x1210e8
divsd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x5422a(%rip), %xmm0    # 0x1210f0
divsd 0x8(%rsp), %xmm0
callq 0x86a0
addsd 0x1890f(%rip), %xmm0    # 0xe57e8
movsd 0x54217(%rip), %xmm4    # 0x1210f8
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 0x541d2(%rip), %xmm1    # 0x121100
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 0x541ad(%rip), %xmm4    # 0x121108
divsd 0x80(%rsp), %xmm4
movsd 0x541a4(%rip), %xmm0    # 0x121110
mulsd %xmm4, %xmm0
addsd 0x182e8(%rip), %xmm0    # 0xe5260
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xccf88
sqrtsd %xmm0, %xmm0
jmp 0xccf99
movsd %xmm4, 0x20(%rsp)
callq 0x82d0
movsd 0x20(%rsp), %xmm4
movsd 0x54177(%rip), %xmm2    # 0x121118
mulsd %xmm4, %xmm2
mulsd 0x4fe33(%rip), %xmm4    # 0x11cde0
movsd 0x182ab(%rip), %xmm1    # 0xe5260
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 0x54134(%rip), %xmm0    # 0x121120
mulsd %xmm1, %xmm0
callq 0x86a0
movsd 0x60(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
movsd 0x5411b(%rip), %xmm0    # 0x121128
divsd 0x8(%rsp), %xmm0
callq 0x86a0
movsd %xmm0, 0x8(%rsp)
movsd 0x5410a(%rip), %xmm0    # 0x121130
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x90(%rsp), %xmm0
divsd 0x80(%rsp), %xmm0
callq 0x86a0
mulsd 0xc8(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
mulsd 0x540d6(%rip), %xmm1    # 0x121138
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 0x540a5(%rip), %xmm0    # 0x121140
addsd 0x20(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm0
movapd 0x10(%rsp), %xmm2
mulsd 0x54093(%rip), %xmm2    # 0x121148
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