// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HyRec2020/wrap_hyrec.c
// Function: hyrec_dx_H_dz
int hyrec_dx_H_dz(struct thermodynamics* pth, struct thermohyrec* phy, double x_H, double x_He, double xe, double nH, double z, double Hz, double Tmat, double Trad, double alpha, double me, double *dx_H_dz) {

  /** Summary: */

  /** - define local variables */
  struct injection* pin = &(pth->in);
  long iz = 0;
  int model;
  double Trad_phys;

  /** - do tests */
  class_test(MODEL == FULL, phy->error_message, "FULL mode is currently not allowed for HyRec-2");

  /** - assign variables */
  if (pth->has_exotic_injection == _TRUE_) {
    phy->data->cosmo->inj_params->ion = pin->pvecdeposition[pin->index_dep_ionH]/nH/(_E_H_ion_*_eV_);
    phy->data->cosmo->inj_params->exclya = pin->pvecdeposition[pin->index_dep_lya]/nH/(_E_H_lya_*_eV_);
  }
  else{
    phy->data->cosmo->inj_params->ion = 0.;
    phy->data->cosmo->inj_params->exclya = 0.;
  }
  if (pth->has_varconst == _TRUE_) {
    phy->data->cosmo->fsR = alpha;
    phy->data->cosmo->meR = me;
  }

  Trad_phys = Trad*kBoltz;
  if (pth->has_varconst == _TRUE_) {
    Trad_phys /= phy->data->cosmo->fsR*phy->data->cosmo->fsR*phy->data->cosmo->meR; //According to 1705.03925
  }

  if (Trad_phys <= TR_MIN || Tmat/Trad <= T_RATIO_MIN) { model = PEEBLES; }
  else { model = MODEL; }

  /** - convert to correct units, and retrieve derivative */
  *dx_H_dz = -1./(1.+z)* rec_dxHIIdlna(phy->data, model, xe, x_H, nH*1e-6, Hz, Tmat*kBoltz, Trad*kBoltz, iz, z);

  /** - do error management */
  if(phy->data->error != 0){
    class_call_message(phy->error_message,"rec_dxHIIdlna",phy->data->error_message);
    return _FAILURE_;
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x810, %rsp            # imm = 0x810
movq %rdx, %r14
movapd %xmm6, %xmm8
movaps %xmm5, %xmm9
movapd %xmm4, %xmm6
movapd %xmm0, %xmm1
movq %rsi, %rbx
movq %rdi, %rax
cmpw $0x1, 0xb8(%rdi)
jne 0xd468a
movq 0x610(%rax), %rdx
movslq 0x5fc(%rax), %rcx
movsd (%rdx,%rcx,8), %xmm0
divsd %xmm3, %xmm0
divsd 0x4db89(%rip), %xmm0    # 0x1221e0
movq (%rbx), %rdi
movq 0x8(%rdi), %rcx
movq 0xb8(%rcx), %rsi
movsd %xmm0, 0x60(%rsi)
movslq 0x604(%rax), %r8
movsd (%rdx,%r8,8), %xmm0
divsd %xmm3, %xmm0
divsd 0x4abad(%rip), %xmm0    # 0x11f230
movsd %xmm0, 0x68(%rsi)
jmp 0xd46a1
movq (%rbx), %rdi
movq 0x8(%rdi), %rcx
movq 0xb8(%rcx), %rdx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x60(%rdx)
cmpw $0x1, 0xe78(%rax)
jne 0xd46eb
movsd 0x838(%rsp), %xmm0
movsd 0x830(%rsp), %xmm4
movsd %xmm4, 0x98(%rcx)
movsd %xmm0, 0xa0(%rcx)
movsd 0x4cb33(%rip), %xmm5    # 0x121208
mulsd %xmm7, %xmm5
mulsd %xmm4, %xmm4
mulsd %xmm0, %xmm4
movapd %xmm5, %xmm0
divsd %xmm4, %xmm0
jmp 0xd46fb
movsd 0x4cb15(%rip), %xmm5    # 0x121208
mulsd %xmm7, %xmm5
movapd %xmm5, %xmm0
movapd %xmm8, %xmm4
divsd %xmm7, %xmm4
movsd 0x4cb2c(%rip), %xmm7    # 0x121238
cmpnlepd %xmm7, %xmm0
movsd 0x10b77(%rip), %xmm7    # 0xe5290
cmpnlepd %xmm7, %xmm4
andpd %xmm0, %xmm4
movd %xmm4, %esi
andl $0x1, %esi
shll $0x2, %esi
movsd 0x10b2c(%rip), %xmm0    # 0xe5260
addsd %xmm6, %xmm0
movsd 0x110a8(%rip), %xmm4    # 0xe57e8
divsd %xmm0, %xmm4
movsd %xmm4, 0x8(%rsp)
mulsd 0x1157e(%rip), %xmm3    # 0xe5cd0
mulsd 0x4caad(%rip), %xmm8    # 0x121208
xorl %ebp, %ebp
movapd %xmm2, %xmm0
movapd %xmm3, %xmm2
movaps %xmm9, %xmm3
movapd %xmm8, %xmm4
xorl %edx, %edx
callq 0xd0930
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xd47d1
movq 0x48(%rax), %rcx
leaq 0x10c5c(%rip), %rsi     # 0xe53f0
leaq 0x4dab1(%rip), %rdx     # 0x12224c
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x20, %rbx
leaq 0x1087f(%rip), %rsi     # 0xe5034
leaq 0x4da9e(%rip), %rdx     # 0x12225a
movq %rbx, %rdi
movl $0x8f, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x810, %rsp            # imm = 0x810
popq %rbx
popq %r14
popq %rbp
retq