// File: /workspace/github_c_makefile_star2_O2/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 0xc650c
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 0x3e061(%rip), %xmm0    # 0x104588
movapd %xmm0, 0x10(%rsp)
movsd 0x42e33(%rip), %xmm1    # 0x109368
callq 0x8650
mulsd 0x58cde(%rip), %xmm0    # 0x11f220
movsd %xmm0, 0x20(%rsp)
movsd 0x42e28(%rip), %xmm1    # 0x109378
movapd 0x10(%rsp), %xmm0
callq 0x8650
mulsd 0x42e1d(%rip), %xmm0    # 0x109380
addsd 0x1ecf5(%rip), %xmm0    # 0xe5260
movsd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
cmpl $0x0, 0x130(%r15)
movsd %xmm1, 0x20(%rsp)
je 0xc65ed
movapd (%rsp), %xmm0
divsd 0x3dff6(%rip), %xmm0    # 0x104588
movapd %xmm0, 0x60(%rsp)
movsd 0x42dc8(%rip), %xmm1    # 0x109368
callq 0x8650
mulsd 0x58c73(%rip), %xmm0    # 0x11f220
movsd %xmm0, 0x10(%rsp)
movsd 0x42dbd(%rip), %xmm1    # 0x109378
movapd 0x60(%rsp), %xmm0
callq 0x8650
mulsd 0x42db2(%rip), %xmm0    # 0x109380
addsd 0x1ec8a(%rip), %xmm0    # 0xe5260
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd (%rsp), %xmm1
jmp 0xc65fd
movapd %xmm1, %xmm0
movapd 0x40(%rsp), %xmm1
movsd %xmm0, 0x10(%rsp)
movapd %xmm1, (%rsp)
movsd 0x8(%r15), %xmm0
mulsd %xmm1, %xmm0
movsd 0x21974(%rip), %xmm1    # 0xe7f88
callq 0x8650
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
xorpd 0x1ebfe(%rip), %xmm0    # 0xe5230
divsd (%rsp), %xmm0
callq 0x86a0
movapd %xmm0, %xmm1
movsd 0x10(%r15), %xmm2
divsd 0x58(%rsp), %xmm2
cmpl $0x1, 0xc4(%r15)
jne 0xc673a
movsd 0x90(%r15), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x1ebe9(%rip), %xmm0    # 0xe5260
movsd %xmm0, 0x90(%rsp)
movapd %xmm2, (%rsp)
movsd %xmm1, 0x60(%rsp)
callq 0x82e0
subsd 0xa0(%r15), %xmm0
divsd 0xb0(%r15), %xmm0
movapd %xmm0, %xmm1
xorpd 0x1eb82(%rip), %xmm1    # 0xe5230
mulsd %xmm1, %xmm0
callq 0x86a0
mulsd 0x38(%rsp), %xmm0
addsd 0x1eb9b(%rip), %xmm0    # 0xe5260
movsd %xmm0, 0x38(%rsp)
movsd 0x98(%r15), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x90(%rsp), %xmm0
callq 0x82e0
subsd 0xa8(%r15), %xmm0
divsd 0xb8(%r15), %xmm0
movapd 0x1eb2b(%rip), %xmm1    # 0xe5230
xorpd %xmm0, %xmm1
mulsd %xmm1, %xmm0
callq 0x86a0
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 0xc6800
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 0x1ff90(%rip), %xmm1    # 0xe6748
callq 0x8650
movsd 0x1ea9b(%rip), %xmm1    # 0xe5260
divsd %xmm0, %xmm1
movapd (%rsp), %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, (%rsp)
movsd 0x120(%r15), %xmm0
movsd 0x21c48(%rip), %xmm1    # 0xe8430
callq 0x8650
mulsd 0x128(%r15), %xmm0
mulsd 0x58a2a(%rip), %xmm0    # 0x11f228
jmp 0xc680e
movsd %xmm5, 0x10(%rsp)
movsd 0x58a1a(%rip), %xmm0    # 0x11f228
movsd 0x28(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
movapd 0x40(%rsp), %xmm4
movsd 0xc8(%r15), %xmm1
ucomisd %xmm3, %xmm1
ja 0xc6842
movsd 0xd8(%r15), %xmm1
ucomisd %xmm2, %xmm1
jbe 0xc68c5
movapd (%rsp), %xmm5
mulsd %xmm5, %xmm0
movapd 0x70(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x1ea03(%rip), %xmm6    # 0xe5260
movapd %xmm6, %xmm7
subsd %xmm3, %xmm7
mulsd %xmm7, %xmm0
addsd %xmm0, %xmm6
movapd 0x3de2b(%rip), %xmm1    # 0x1046a0
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 0xc68ea
movsd 0x1e993(%rip), %xmm0    # 0xe5260
subsd %xmm3, %xmm0
movsd %xmm0, 0x40(%rsp)
movapd 0x21f71(%rip), %xmm0    # 0xe8850
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 0x1e91f(%rip), %xmm0    # 0xe5230
divsd %xmm4, %xmm0
callq 0x86a0
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 0x1e915(%rip), %xmm3    # 0xe5260
mulsd 0x58(%rsp), %xmm3
divsd %xmm3, %xmm4
movsd %xmm4, (%rbx)
cmpw $0x1, 0xb8(%r14)
jne 0xc69e2
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 0x3dd0e(%rip), %xmm1    # 0x1046a0
movapd 0x70(%rsp), %xmm5
shufpd $0x2, 0x5882f(%rip), %xmm5 # xmm5 = xmm5[0],mem[1]
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
movsd 0x1e8af(%rip), %xmm0    # 0xe5260
subsd %xmm2, %xmm0
mulsd (%rax,%rcx,8), %xmm0
divsd 0x5886e(%rip), %xmm0    # 0x11f230
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