// File: /workspace/github_c_makefile_star2_O1/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, 0x38(%rsp)
movq %rsi, %r15
movq %rdi, %r14
cmpw $0x1, 0xe78(%rdi)
unpcklpd %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0]
movsd %xmm1, 0x48(%rsp)
movaps %xmm2, 0x80(%rsp)
movsd %xmm0, 0x50(%rsp)
jne 0xd14aa
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, 0x70(%rsp)
movapd %xmm6, %xmm0
divsd 0x3f1e3(%rip), %xmm0    # 0x1106a8
movapd %xmm0, 0x20(%rsp)
movsd 0x43fb5(%rip), %xmm1    # 0x115488
callq 0x8620
mulsd 0x59e60(%rip), %xmm0    # 0x12b340
movsd %xmm0, 0x18(%rsp)
movsd 0x43faa(%rip), %xmm1    # 0x115498
movapd 0x20(%rsp), %xmm0
callq 0x8620
mulsd 0x43f9f(%rip), %xmm0    # 0x1154a0
addsd 0x1fd57(%rip), %xmm0    # 0xf1260
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
cmpl $0x0, 0x130(%r15)
movsd %xmm1, 0x18(%rsp)
je 0xd158b
movapd (%rsp), %xmm0
divsd 0x3f178(%rip), %xmm0    # 0x1106a8
movapd %xmm0, 0x60(%rsp)
movsd 0x43f4a(%rip), %xmm1    # 0x115488
callq 0x8620
mulsd 0x59df5(%rip), %xmm0    # 0x12b340
movsd %xmm0, 0x20(%rsp)
movsd 0x43f3f(%rip), %xmm1    # 0x115498
movapd 0x60(%rsp), %xmm0
callq 0x8620
mulsd 0x43f34(%rip), %xmm0    # 0x1154a0
addsd 0x1fcec(%rip), %xmm0    # 0xf1260
movsd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movapd (%rsp), %xmm1
jmp 0xd159b
movapd %xmm1, %xmm0
movapd 0x70(%rsp), %xmm1
movsd %xmm0, 0x20(%rsp)
movapd %xmm1, (%rsp)
movsd 0x8(%r15), %xmm0
mulsd %xmm1, %xmm0
movsd 0x22a06(%rip), %xmm1    # 0xf3fb8
callq 0x8620
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd (%r15), %xmm0
xorpd 0x1fc60(%rip), %xmm0    # 0xf1230
divsd (%rsp), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
movsd 0x10(%r15), %xmm2
divsd 0x58(%rsp), %xmm2
cmpl $0x1, 0xc4(%r15)
jne 0xd16d8
movsd 0x90(%r15), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x38(%rsp), %xmm0
addsd 0x1fc4b(%rip), %xmm0    # 0xf1260
movsd %xmm0, 0x98(%rsp)
movapd %xmm2, (%rsp)
movsd %xmm1, 0x60(%rsp)
callq 0x82c0
subsd 0xa0(%r15), %xmm0
divsd 0xb0(%r15), %xmm0
movapd %xmm0, %xmm1
xorpd 0x1fbe4(%rip), %xmm1    # 0xf1230
mulsd %xmm1, %xmm0
callq 0x8670
mulsd 0x40(%rsp), %xmm0
addsd 0x1fbfd(%rip), %xmm0    # 0xf1260
movsd %xmm0, 0x40(%rsp)
movsd 0x98(%r15), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x98(%rsp), %xmm0
callq 0x82c0
subsd 0xa8(%r15), %xmm0
divsd 0xb8(%r15), %xmm0
movapd 0x1fb8d(%rip), %xmm1    # 0xf1230
xorpd %xmm0, %xmm1
mulsd %xmm1, %xmm0
callq 0x8670
mulsd 0x90(%rsp), %xmm0
addsd 0x40(%rsp), %xmm0
movapd (%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movsd 0x60(%rsp), %xmm1
movapd (%rsp), %xmm2
movapd %xmm2, (%rsp)
movsd 0x20(%rsp), %xmm5
mulsd %xmm1, %xmm5
cmpw $0x1, 0xe78(%r14)
jne 0xd179e
movsd 0x120(%r15), %xmm1
movsd 0x128(%r15), %xmm2
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
divsd %xmm2, %xmm3
movsd 0x18(%rsp), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x18(%rsp)
movapd %xmm1, %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
mulsd %xmm3, %xmm5
movsd %xmm5, 0x20(%rsp)
mulsd %xmm2, %xmm0
movsd 0x20f2a(%rip), %xmm1    # 0xf2680
callq 0x8620
movsd 0x1fafd(%rip), %xmm1    # 0xf1260
divsd %xmm0, %xmm1
movapd (%rsp), %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movsd 0x120(%r15), %xmm0
movsd 0x22cda(%rip), %xmm1    # 0xf4460
callq 0x8620
mulsd 0x128(%r15), %xmm0
mulsd 0x59bac(%rip), %xmm0    # 0x12b348
jmp 0xd17ac
movsd %xmm5, 0x20(%rsp)
movsd 0x59b9c(%rip), %xmm0    # 0x12b348
movsd 0x38(%rsp), %xmm2
movapd 0x80(%rsp), %xmm3
movsd 0x50(%rsp), %xmm4
movapd 0x70(%rsp), %xmm5
movsd 0xc8(%r15), %xmm1
ucomisd %xmm4, %xmm1
ja 0xd17e5
movsd 0xd8(%r15), %xmm1
ucomisd %xmm2, %xmm1
jbe 0xd185c
movapd (%rsp), %xmm6
mulsd %xmm6, %xmm0
mulsd %xmm3, %xmm0
movsd 0x1fa66(%rip), %xmm7    # 0xf1260
movapd %xmm7, %xmm1
subsd %xmm4, %xmm1
mulsd %xmm1, %xmm0
addsd %xmm0, %xmm7
movapd 0x3ef9e(%rip), %xmm2    # 0x1107b0
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movsd 0xf0(%r15), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
addpd %xmm2, %xmm0
mulsd 0x20(%rsp), %xmm6
mulsd %xmm3, %xmm6
unpcklpd %xmm7, %xmm0            # xmm0 = xmm0[0],xmm7[0]
mulsd %xmm1, %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
addpd %xmm0, %xmm6
unpcklpd %xmm7, %xmm7            # xmm7 = xmm7[0,0]
divpd %xmm6, %xmm7
movapd %xmm7, (%rsp)
jmp 0xd1869
movapd 0x230bc(%rip), %xmm0    # 0xf4920
movapd %xmm0, (%rsp)
movsd 0x48(%rsp), %xmm0
mulsd %xmm4, %xmm0
mulsd %xmm3, %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x1f9d5(%rip), %xmm0    # 0xf1260
subsd %xmm4, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%r15), %xmm0
xorpd 0x1f98d(%rip), %xmm0    # 0xf1230
divsd %xmm5, %xmm0
callq 0x8670
movsd 0x1f9ac(%rip), %xmm5    # 0xf1260
movsd 0x48(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
mulsd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
subsd %xmm1, %xmm2
movapd (%rsp), %xmm4
mulsd %xmm4, %xmm2
movsd 0x38(%rsp), %xmm3
addsd %xmm5, %xmm3
mulsd 0x58(%rsp), %xmm3
divsd %xmm3, %xmm2
movsd %xmm2, (%rbx)
cmpw $0x1, 0xb8(%r14)
jne 0xd1973
movq 0x610(%r14), %rax
movslq 0x5fc(%r14), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq 0x600(%r14), %rcx
movslq 0x604(%r14), %rdx
addsd (%rax,%rcx,8), %xmm0
movapd 0x3ee88(%rip), %xmm1    # 0x1107b0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd 0x80(%rsp), %xmm0
shufpd $0x2, 0x599b2(%rip), %xmm0 # xmm0 = xmm0[0],mem[1]
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
subsd %xmm4, %xmm5
mulsd (%rax,%rdx,8), %xmm5
divsd 0x599fd(%rip), %xmm5    # 0x12b350
divpd %xmm0, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm5, %xmm0
mulsd %xmm1, %xmm0
divsd %xmm3, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, (%rbx)
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq