// File: /workspace/github_c_makefile_star2_O3/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 0xdc6e3
movq 0x610(%rax), %rdx
movslq 0x5fc(%rax), %rcx
movsd (%rdx,%rcx,8), %xmm0
divsd %xmm3, %xmm0
divsd 0x4ecc0(%rip), %xmm0    # 0x12b370
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 0x4bca4(%rip), %xmm0    # 0x128380
movsd %xmm0, 0x68(%rsi)
jmp 0xdc6fa
movq (%rbx), %rdi
movq 0x8(%rdi), %rcx
movq 0xb8(%rcx), %rdx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x60(%rdx)
cmpw $0x1, 0xe78(%rax)
jne 0xdc744
movsd 0x838(%rsp), %xmm0
movsd 0x830(%rsp), %xmm4
movsd %xmm4, 0x98(%rcx)
movsd %xmm0, 0xa0(%rcx)
movsd 0x4dc3a(%rip), %xmm5    # 0x12a368
mulsd %xmm7, %xmm5
mulsd %xmm4, %xmm4
mulsd %xmm0, %xmm4
movapd %xmm5, %xmm0
divsd %xmm4, %xmm0
jmp 0xdc754
movsd 0x4dc1c(%rip), %xmm5    # 0x12a368
mulsd %xmm7, %xmm5
movapd %xmm5, %xmm0
movapd %xmm8, %xmm4
divsd %xmm7, %xmm4
movsd 0x4dc33(%rip), %xmm7    # 0x12a398
cmpnlepd %xmm7, %xmm0
movsd 0x11b1e(%rip), %xmm7    # 0xee290
cmpnlepd %xmm7, %xmm4
andpd %xmm0, %xmm4
movd %xmm4, %esi
andl $0x1, %esi
shll $0x2, %esi
movsd 0x11ad3(%rip), %xmm0    # 0xee260
addsd %xmm6, %xmm0
movsd 0x1204f(%rip), %xmm4    # 0xee7e8
divsd %xmm0, %xmm4
movsd %xmm4, 0x8(%rsp)
mulsd 0x12545(%rip), %xmm3    # 0xeecf0
mulsd 0x4dbb4(%rip), %xmm8    # 0x12a368
xorl %ebp, %ebp
movapd %xmm2, %xmm0
movapd %xmm3, %xmm2
movaps %xmm9, %xmm3
movapd %xmm8, %xmm4
xorl %edx, %edx
callq 0xd85d7
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xdc82c
movq 0x48(%rax), %rcx
leaq 0x11c03(%rip), %rsi     # 0xee3f0
leaq 0x4ebe8(%rip), %rdx     # 0x12b3dc
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x20, %rbx
leaq 0x11826(%rip), %rsi     # 0xee034
leaq 0x4ebd5(%rip), %rdx     # 0x12b3ea
movq %rbx, %rdi
movl $0x8f, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x810, %rsp            # imm = 0x810
popq %rbx
popq %r14
popq %rbp
retq