// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/RecfastCLASS/wrap_recfast.c
// Function: recfast_dx_H_dz
int recfast_dx_H_dz(struct thermodynamics* pth, struct thermorecfast * pre, double x_H, double x, double nH,
                    double z, double Hz, double Tmat, double Trad,
                    double* dxH_dz) {

  /** Define local variables */
  struct injection* pin = &(pth->in);
  /* new in recfast 1.4: */
  double Rup,Rdown,K,C,C_nofudge;
  double ion_H,ion_He,ion_lya;

  /* Einstein coefficient of 2s -> 1s transition in hydrogen */
  double A2s1sH = _Lambda_;

  /* Varying fundamental constants */
  if (pth->has_varconst == _TRUE_) {
    /** - Rescale temperatures by factor alpha^2 * m_e (see e.g. 1705.03925) */
    Tmat /= pre->fsR*pre->fsR*pre->meR;
    Trad /= pre->fsR*pre->fsR*pre->meR;
  }

  /** - Get necessary coefficients */
  Rdown = 1.e-19*_a_PPB_*pow((Tmat/1.e4),_b_PPB_)/(1.+_c_PPB_*pow((Tmat/1.e4),_d_PPB_));
  switch (pre->photoion_mode){
    case recfast_photoion_Tmat:
      Rup = Rdown * pow((pre->CR*Tmat),1.5)*exp(-pre->CDB/Tmat);
    break;
    default:
    case recfast_photoion_Trad:
      Rup = 1.e-19*_a_PPB_*pow((Trad/1.e4),_b_PPB_)/(1.+_c_PPB_*pow((Trad/1.e4),_d_PPB_)) * pow((pre->CR*Trad),1.5)*exp(-pre->CDB/Trad);
    break;
  }
  K = pre->CK/Hz;

  /* following is from recfast 1.5 */
  /** - Adjust the K constant with double gaussian fit */
  if (pre->Hswitch == _TRUE_ ){
    K *= 1.
      + pre->AGauss1*exp(-pow((log(1.+z)-pre->zGauss1)/pre->wGauss1,2))
      + pre->AGauss2*exp(-pow((log(1.+z)-pre->zGauss2)/pre->wGauss2,2));
  }
  /* end of new recfast 1.5 piece */

  /* Varying fundamental constants */
  if (pth->has_varconst == _TRUE_) {
    /** - Rescale by various powers of fsR = relative alpha and meR = relative m_e (see e.g. 1705.03925) */
    Rdown *= pre->fsR*pre->fsR/pre->meR/pre->meR;
    Rup *= pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->meR;
    K *= 1./pow(pre->fsR*pre->fsR*pre->meR,3);
    A2s1sH *= pow(pre->fsR, 8)*pre->meR;
  }

  /** - Calculate Peebles' coefficient */
  /* Peebles' coefficient (approximated as one when the Hydrogen
   * ionization fraction is very close to one) */
  if (x_H < pre->x_H0_trigger2 || z < pre->z_switch_late) {
    C = (1. + K*A2s1sH*nH*(1.-x_H))/(1./pre->fudge_H+K*A2s1sH*nH*(1.-x_H)/pre->fudge_H +K*Rup*nH*(1.-x_H));
    C_nofudge = (1. + K*A2s1sH*nH*(1.-x_H))/(1.+K*A2s1sH*nH*(1.-x_H) + K*Rup*nH*(1.-x_H));
  }
  else {
    C = 1.;
    C_nofudge = 1.;
  }

  /** - Evolve system by fudged Peebles' equation, use fudged Peebles' coefficient C */
  *dxH_dz = (x*x_H*nH*Rdown - Rup*(1.-x_H)*exp(-pre->CL/Tmat)) * C / (Hz*(1.+z));

  /** - Energy injection */
  if (pth->has_exotic_injection == _TRUE_) {
    ion_H = pin->pvecdeposition[pin->index_dep_ionH];
    ion_He = pin->pvecdeposition[pin->index_dep_ionHe];
    ion_lya = pin->pvecdeposition[pin->index_dep_lya];

    *dxH_dz += -1./nH*((ion_H+ion_He)/(_E_H_ion_*_eV_)+ion_lya*(1.-C_nofudge)/(_E_H_lya_*_eV_))/(Hz*(1.+z));
  }

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rdx, %rbx
movsd %xmm4, 0x58(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm1, 0x98(%rsp)
movq %rsi, %r15
movq %rdi, %r14
cmpw $0x1, 0xe78(%rdi)
unpcklpd %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0]
movsd %xmm0, 0x30(%rsp)
movaps %xmm2, 0x70(%rsp)
jne 0xcdc0e
movsd 0x120(%r15), %xmm0
mulsd %xmm0, %xmm0
mulsd 0x128(%r15), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm6
movapd %xmm6, (%rsp)
unpckhpd %xmm6, %xmm6            # xmm6 = xmm6[1,1]
movapd %xmm6, 0x40(%rsp)
movapd %xmm6, %xmm0
divsd 0x3fa9f(%rip), %xmm0    # 0x10d6c8
movapd %xmm0, 0x10(%rsp)
movsd 0x44891(%rip), %xmm1    # 0x1124c8
callq 0x8620
mulsd 0x5a72c(%rip), %xmm0    # 0x128370
movsd %xmm0, 0x20(%rsp)
movsd 0x44886(%rip), %xmm1    # 0x1124d8
movapd 0x10(%rsp), %xmm0
callq 0x8620
mulsd 0x4487b(%rip), %xmm0    # 0x1124e0
addsd 0x205f3(%rip), %xmm0    # 0xee260
movsd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
cmpl $0x0, 0x130(%r15)
movsd %xmm1, 0x20(%rsp)
je 0xcdcef
movapd (%rsp), %xmm0
divsd 0x3fa34(%rip), %xmm0    # 0x10d6c8
movapd %xmm0, 0x60(%rsp)
movsd 0x44826(%rip), %xmm1    # 0x1124c8
callq 0x8620
mulsd 0x5a6c1(%rip), %xmm0    # 0x128370
movsd %xmm0, 0x10(%rsp)
movsd 0x4481b(%rip), %xmm1    # 0x1124d8
movapd 0x60(%rsp), %xmm0
callq 0x8620
mulsd 0x44810(%rip), %xmm0    # 0x1124e0
addsd 0x20588(%rip), %xmm0    # 0xee260
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd (%rsp), %xmm1
jmp 0xcdcff
movapd %xmm1, %xmm0
movapd 0x40(%rsp), %xmm1
movsd %xmm0, 0x10(%rsp)
movapd %xmm1, (%rsp)
movsd 0x8(%r15), %xmm0
mulsd %xmm1, %xmm0
movsd 0x232b2(%rip), %xmm1    # 0xf0fc8
callq 0x8620
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
xorpd 0x204fc(%rip), %xmm0    # 0xee230
divsd (%rsp), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
movsd 0x10(%r15), %xmm2
divsd 0x58(%rsp), %xmm2
cmpl $0x1, 0xc4(%r15)
jne 0xcde3c
movsd 0x90(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x204e7(%rip), %xmm0    # 0xee260
movsd %xmm0, 0x90(%rsp)
movapd %xmm2, (%rsp)
movsd %xmm1, 0x60(%rsp)
callq 0x82c0
subsd 0xa0(%r15), %xmm0
divsd 0xb0(%r15), %xmm0
movapd %xmm0, %xmm1
xorpd 0x20480(%rip), %xmm1    # 0xee230
mulsd %xmm1, %xmm0
callq 0x8670
mulsd 0x38(%rsp), %xmm0
addsd 0x20499(%rip), %xmm0    # 0xee260
movsd %xmm0, 0x38(%rsp)
movsd 0x98(%r15), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x90(%rsp), %xmm0
callq 0x82c0
subsd 0xa8(%r15), %xmm0
divsd 0xb8(%r15), %xmm0
movapd 0x20429(%rip), %xmm1    # 0xee230
xorpd %xmm0, %xmm1
mulsd %xmm1, %xmm0
callq 0x8670
mulsd 0x88(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movapd (%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movsd 0x60(%rsp), %xmm1
movapd (%rsp), %xmm2
movapd %xmm2, (%rsp)
movsd 0x10(%rsp), %xmm5
mulsd %xmm1, %xmm5
cmpw $0x1, 0xe78(%r14)
jne 0xcdf02
movsd 0x120(%r15), %xmm1
movsd 0x128(%r15), %xmm2
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
divsd %xmm2, %xmm3
movsd 0x20(%rsp), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x20(%rsp)
movapd %xmm1, %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm3, %xmm5
movsd %xmm5, 0x10(%rsp)
mulsd %xmm2, %xmm0
movsd 0x217c6(%rip), %xmm1    # 0xef680
callq 0x8620
movsd 0x20399(%rip), %xmm1    # 0xee260
divsd %xmm0, %xmm1
movapd (%rsp), %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movsd 0x120(%r15), %xmm0
movsd 0x23586(%rip), %xmm1    # 0xf1470
callq 0x8620
mulsd 0x128(%r15), %xmm0
mulsd 0x5a478(%rip), %xmm0    # 0x128378
jmp 0xcdf10
movsd %xmm5, 0x10(%rsp)
movsd 0x5a468(%rip), %xmm0    # 0x128378
movsd 0x28(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
movapd 0x40(%rsp), %xmm4
movsd 0xc8(%r15), %xmm1
ucomisd %xmm3, %xmm1
ja 0xcdf44
movsd 0xd8(%r15), %xmm1
ucomisd %xmm2, %xmm1
jbe 0xcdfc7
movapd (%rsp), %xmm5
mulsd %xmm5, %xmm0
movapd 0x70(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x20301(%rip), %xmm6    # 0xee260
movapd %xmm6, %xmm7
subsd %xmm3, %xmm7
mulsd %xmm7, %xmm0
addsd %xmm0, %xmm6
movapd 0x3f889(%rip), %xmm1    # 0x10d800
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movsd 0xf0(%r15), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addpd %xmm1, %xmm0
mulsd 0x10(%rsp), %xmm5
mulsd %xmm2, %xmm5
unpcklpd %xmm6, %xmm0            # xmm0 = xmm0[0],xmm6[0]
movsd %xmm7, 0x40(%rsp)
mulsd %xmm7, %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
addpd %xmm0, %xmm5
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
divpd %xmm5, %xmm6
movapd %xmm6, (%rsp)
jmp 0xcdfec
movsd 0x20291(%rip), %xmm0    # 0xee260
subsd %xmm3, %xmm0
movsd %xmm0, 0x40(%rsp)
movapd 0x2394f(%rip), %xmm0    # 0xf1930
movapd %xmm0, (%rsp)
movapd 0x70(%rsp), %xmm2
mulsd 0x98(%rsp), %xmm3
mulsd %xmm2, %xmm3
mulsd 0x20(%rsp), %xmm3
movsd %xmm3, 0x30(%rsp)
movsd 0x18(%r15), %xmm0
xorpd 0x2021d(%rip), %xmm0    # 0xee230
divsd %xmm4, %xmm0
callq 0x8670
movsd 0x30(%rsp), %xmm4
movsd 0x40(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm4
movapd (%rsp), %xmm2
mulsd %xmm2, %xmm4
movsd 0x28(%rsp), %xmm3
addsd 0x20213(%rip), %xmm3    # 0xee260
mulsd 0x58(%rsp), %xmm3
divsd %xmm3, %xmm4
movsd %xmm4, (%rbx)
cmpw $0x1, 0xb8(%r14)
jne 0xce0e4
movq 0x610(%r14), %rax
movslq 0x5fc(%r14), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq 0x600(%r14), %rcx
addsd (%rax,%rcx,8), %xmm0
movslq 0x604(%r14), %rcx
movapd 0x3f76c(%rip), %xmm1    # 0x10d800
movapd 0x70(%rsp), %xmm5
shufpd $0x2, 0x5a27d(%rip), %xmm5 # xmm5 = xmm5[0],mem[1]
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
movsd 0x201ad(%rip), %xmm0    # 0xee260
subsd %xmm2, %xmm0
mulsd (%rax,%rcx,8), %xmm0
divsd 0x5a2bc(%rip), %xmm0    # 0x128380
divpd %xmm5, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
divsd %xmm3, %xmm2
subsd %xmm2, %xmm4
movsd %xmm4, (%rbx)
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq