// File: /workspace/github_c_makefile_star2_O1/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
cmpw $0x1, 0xb8(%rdi)
jne 0xdfc2a
movq 0x610(%rdi), %rax
movslq 0x5fc(%rdi), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm3, %xmm0
divsd 0x4e748(%rip), %xmm0    # 0x12e340
movq (%rbx), %rcx
movq 0x8(%rcx), %rcx
movq 0xb8(%rcx), %rcx
movsd %xmm0, 0x60(%rcx)
movslq 0x604(%rdi), %rdx
movsd (%rax,%rdx,8), %xmm0
divsd %xmm3, %xmm0
divsd 0x4b72d(%rip), %xmm0    # 0x12b350
movsd %xmm0, 0x68(%rcx)
jmp 0xdfc41
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x60(%rax)
movzwl 0xe78(%rdi), %eax
cmpw $0x1, %ax
jne 0xdfc77
movsd 0x838(%rsp), %xmm0
movsd 0x830(%rsp), %xmm4
movq (%rbx), %rcx
movq 0x8(%rcx), %rcx
movsd %xmm4, 0x98(%rcx)
movsd %xmm0, 0xa0(%rcx)
movsd 0x4d6b9(%rip), %xmm5    # 0x12d338
mulsd %xmm7, %xmm5
movapd %xmm5, %xmm0
cmpw $0x1, %ax
jne 0xdfcb0
movq (%rbx), %rax
movq 0x8(%rax), %rax
movsd 0x98(%rax), %xmm4
mulsd %xmm4, %xmm4
mulsd 0xa0(%rax), %xmm4
movapd %xmm5, %xmm0
divsd %xmm4, %xmm0
movapd %xmm8, %xmm4
divsd %xmm7, %xmm4
movsd 0x4d6a7(%rip), %xmm7    # 0x12d368
cmpnlepd %xmm7, %xmm0
movsd 0x115c2(%rip), %xmm7    # 0xf1290
cmpnlepd %xmm7, %xmm4
andpd %xmm0, %xmm4
movd %xmm4, %esi
andl $0x1, %esi
shll $0x2, %esi
movsd 0x11577(%rip), %xmm0    # 0xf1260
addsd %xmm6, %xmm0
movsd 0x11af3(%rip), %xmm4    # 0xf17e8
divsd %xmm0, %xmm4
movsd %xmm4, 0x8(%rsp)
movq (%rbx), %rdi
mulsd 0x11fe6(%rip), %xmm3    # 0xf1cf0
mulsd 0x4d625(%rip), %xmm8    # 0x12d338
xorl %ebp, %ebp
movapd %xmm2, %xmm0
movapd %xmm3, %xmm2
movaps %xmm9, %xmm3
movapd %xmm8, %xmm4
xorl %edx, %edx
callq 0xdbd61
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xdfd8b
movq 0x48(%rax), %rcx
leaq 0x116a4(%rip), %rsi     # 0xf13f0
leaq 0x4e659(%rip), %rdx     # 0x12e3ac
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x20, %rbx
leaq 0x112c7(%rip), %rsi     # 0xf1034
leaq 0x4e646(%rip), %rdx     # 0x12e3ba
movq %rbx, %rdi
movl $0x8f, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
movl %ebp, %eax
addq $0x810, %rsp            # imm = 0x810
popq %rbx
popq %r14
popq %rbp
retq