// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hydrogen.c
// Function: rec_swift_hyrec_dxHIIdlna
double rec_swift_hyrec_dxHIIdlna(HYREC_DATA *data, double xe, double xHII, double nH, double H, double TM, double TR, double z){

  REC_COSMOPARAMS *cosmo = data-> cosmo;
  HYREC_ATOMIC *atomic = data->atomic;
  FIT_FUNC *fit = data->fit;
  int *error = &data->error;
  double fsR = cosmo->fsR, meR = cosmo->meR;
  double Alpha[2], DAlpha[2], Beta[2], R2p2s, RLya;
  double DK_K_fid=0., DK_K, fitted_RLya;
  double C_2s, C_2p, gamma_2s, gamma_2p, s, Dxe2;
  static double diff[3];
  unsigned i;
  double ratio;
  char sub_message[128];
  double T0fid_T0;
  if (*error == 1) return 0.;

  ratio = TM/TR;
  rescale_T(&TR, fsR, meR);
  TM = ratio * TR;   // This way ensure that TM<=TR is preserved
  T0fid_T0 = 2.7255 / (TR/kBoltz/(1.+z));

  /* The numbers in the following lines are fiducial parameters for correction function (Do not change) */
  diff[0] = (cosmo->ocbh2 - 0.14175)*pow(T0fid_T0,3);
  diff[1] = (cosmo->obh2*(1-cosmo->YHe) - 0.02242*(1-0.246738546372))*pow(T0fid_T0,3);
  diff[2] = cosmo->Neff-3.046;

  interpolate_rates(Alpha, DAlpha, Beta, &R2p2s, TR, TM/TR, atomic, fsR, meR, error, data->error_message);

  RLya = LYA_FACT(fsR, meR) *H/nH/(1.-xHII);   // 8 PI H/(3 nH x1s lambda_Lya^3)
  
  if (TR/kBoltz > fit->swift_func[0][DKK_SIZE-1]) DK_K = 0.;
  else {
    DK_K_fid = rec_interp1d(fit->swift_func[0][0], 10., fit->swift_func[1], DKK_SIZE, TR/kBoltz, error, data->error_message);

    for (i = 0; i < 3; i++) {
      DK_K_fid = DK_K_fid + diff[i]*rec_interp1d(fit->swift_func[0][0], 10., fit->swift_func[i+2],
                                                   DKK_SIZE, TR/kBoltz, error, data->error_message);
    }
  }

  DK_K = DK_K_fid;
  fitted_RLya = RLya / (1.+DK_K);
  gamma_2s = Beta[0] + 3.*R2p2s + L2s_rescaled(fsR, meR);
  gamma_2p = Beta[1] + R2p2s + fitted_RLya;
  C_2s = (L2s_rescaled(fsR, meR)+3.*R2p2s*fitted_RLya/gamma_2p)/(gamma_2s-3.*R2p2s*R2p2s/gamma_2p);
  C_2p = (fitted_RLya+R2p2s*L2s_rescaled(fsR, meR)/gamma_2s)/(gamma_2p-R2p2s*3.*R2p2s/gamma_2s);

  s    = SAHA_FACT(fsR, meR) *TR*sqrt(TR) *exp(-EI/TR)/nH;
  Dxe2 = xe*xHII - s*(1.-xHII); // xe^2 - xe^2[Saha eq with 1s] -- gives more compact expressions

  if (*error == 1) {
    sprintf(sub_message, "  called from rec_swift_hyrec_dxHIIdlna\n");
    strcat(data->error_message, sub_message);
    return 0.;
  }

  return -nH/H *( (s*(1.-xHII)*DAlpha[0] + Alpha[0]*Dxe2)*C_2s + (s*(1.-xHII)*DAlpha[1] + Alpha[1]*Dxe2)*C_2p)
          + (cosmo->inj_params->ion + (0.25*(1.-C_2s) + 0.75*(1.-C_2p))*cosmo->inj_params->exclya)/H ;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, 0x1e8(%rsp)
movsd %xmm0, 0x1e0(%rsp)
movsd %xmm1, 0x1d8(%rsp)
movsd %xmm2, 0x1d0(%rsp)
movsd %xmm3, 0x1c8(%rsp)
movsd %xmm4, 0x1c0(%rsp)
movsd %xmm5, 0x1b8(%rsp)
movsd %xmm6, 0x1b0(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x1a8(%rsp)
movq 0x1e8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x60(%rax), %rax
movq %rax, 0x198(%rsp)
movq 0x1e8(%rsp), %rax
addq $0x38, %rax
movq %rax, 0x190(%rsp)
movq 0x1a8(%rsp), %rax
movsd 0x98(%rax), %xmm0
movsd %xmm0, 0x188(%rsp)
movq 0x1a8(%rsp), %rax
movsd 0xa0(%rax), %xmm0
movsd %xmm0, 0x180(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x138(%rsp)
movq 0x190(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a93d9
xorps %xmm0, %xmm0
movsd %xmm0, 0x1f0(%rsp)
jmp 0x1a9b8c
movsd 0x1c0(%rsp), %xmm0
divsd 0x1b8(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
leaq 0x1b8(%rsp), %rdi
callq 0x1a7840
movsd 0xe8(%rsp), %xmm0
mulsd 0x1b8(%rsp), %xmm0
movsd %xmm0, 0x1c0(%rsp)
movsd 0x1b8(%rsp), %xmm1
movsd 0x654b9(%rip), %xmm0    # 0x20e8f8
divsd %xmm0, %xmm1
movsd 0x28dfd(%rip), %xmm0    # 0x1d2248
addsd 0x1b0(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd 0x2d210(%rip), %xmm0    # 0x1d6670
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x1a8(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x654a1(%rip), %xmm1    # 0x20e920
subsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x2a201(%rip), %xmm1    # 0x1d3698
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x48(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x9af7f(%rip)    # 0x244430
movq 0x1a8(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0x1a8(%rsp), %rax
movsd 0x28d7a(%rip), %xmm1    # 0x1d2248
subsd 0x90(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x65436(%rip), %xmm1    # 0x20e918
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x2a19e(%rip), %xmm1    # 0x1d3698
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x9af24(%rip)    # 0x244438
movq 0x1a8(%rsp), %rax
movsd 0x50(%rax), %xmm0
movsd 0x47fbf(%rip), %xmm1    # 0x1f14e8
subsd %xmm1, %xmm0
movsd %xmm0, 0x9af0b(%rip)    # 0x244440
leaq 0x170(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x150(%rsp), %rdx
movsd 0x1b8(%rsp), %xmm0
movsd 0x1c0(%rsp), %xmm1
divsd 0x1b8(%rsp), %xmm1
movq 0x1a0(%rsp), %r8
movsd 0x188(%rsp), %xmm2
movsd 0x180(%rsp), %xmm3
movq 0x190(%rsp), %r9
movq 0x1e8(%rsp), %rax
movq 0x48(%rax), %rax
leaq 0x148(%rsp), %rcx
movq %rax, (%rsp)
callq 0x1a8830
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
callq 0x1a77b0
mulsd 0x1c8(%rsp), %xmm0
divsd 0x1d0(%rsp), %xmm0
movsd 0x28c70(%rip), %xmm1    # 0x1d2248
subsd 0x1d8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x140(%rsp)
movsd 0x1b8(%rsp), %xmm0
movsd 0x652f9(%rip), %xmm1    # 0x20e8f8
divsd %xmm1, %xmm0
movq 0x198(%rsp), %rax
movq (%rax), %rax
ucomisd 0x840(%rax), %xmm0
jbe 0x1a9629
xorps %xmm0, %xmm0
movsd %xmm0, 0x130(%rsp)
jmp 0x1a9765
movq 0x198(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq 0x198(%rsp), %rax
movq 0x8(%rax), %rdi
movsd 0x1b8(%rsp), %xmm2
movsd 0x652a3(%rip), %xmm1    # 0x20e8f8
divsd %xmm1, %xmm2
movq 0x190(%rsp), %rdx
movq 0x1e8(%rsp), %rax
movq 0x48(%rax), %rcx
movsd 0x2916b(%rip), %xmm1    # 0x1d27e0
movl $0x109, %esi            # imm = 0x109
callq 0x1a5ae0
movsd %xmm0, 0x138(%rsp)
movl $0x0, 0xf4(%rsp)
cmpl $0x3, 0xf4(%rsp)
jae 0x1a9763
movsd 0x138(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, %ecx
leaq 0x9ad70(%rip), %rax     # 0x244430
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x198(%rsp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movq 0x198(%rsp), %rax
movl 0xf4(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
movsd 0x1b8(%rsp), %xmm2
movsd 0x651f5(%rip), %xmm1    # 0x20e8f8
divsd %xmm1, %xmm2
movq 0x190(%rsp), %rdx
movq 0x1e8(%rsp), %rax
movq 0x48(%rax), %rcx
movsd 0x290bd(%rip), %xmm1    # 0x1d27e0
movl $0x109, %esi            # imm = 0x109
callq 0x1a5ae0
movsd 0x38(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x40(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x138(%rsp)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x1a9693
jmp 0x1a9765
movsd 0x138(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
movsd 0x140(%rsp), %xmm0
movsd 0x28ac0(%rip), %xmm1    # 0x1d2248
addsd 0x130(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x150(%rsp), %xmm1
movsd 0x148(%rsp), %xmm0
movsd 0x29ee0(%rip), %xmm2    # 0x1d3698
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
callq 0x1a77f0
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x110(%rsp)
movsd 0x158(%rsp), %xmm0
addsd 0x148(%rsp), %xmm0
addsd 0x128(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
callq 0x1a77f0
movsd 0x29e62(%rip), %xmm1    # 0x1d3698
mulsd 0x148(%rsp), %xmm1
mulsd 0x128(%rsp), %xmm1
divsd 0x108(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x110(%rsp), %xmm1
movsd 0x29e32(%rip), %xmm2    # 0x1d3698
mulsd 0x148(%rsp), %xmm2
mulsd 0x148(%rsp), %xmm2
divsd 0x108(%rsp), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x120(%rsp)
movsd 0x128(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x148(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
callq 0x1a77f0
movsd 0x18(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x20(%rsp), %xmm0
mulsd %xmm2, %xmm1
divsd 0x110(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x108(%rsp), %xmm1
movsd 0x29da0(%rip), %xmm2    # 0x1d3698
mulsd 0x148(%rsp), %xmm2
mulsd 0x148(%rsp), %xmm2
divsd 0x110(%rsp), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x188(%rsp), %xmm0
movsd 0x180(%rsp), %xmm1
callq 0x1a7770
mulsd 0x1b8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x1b8(%rsp), %xmm0
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x64f8d(%rip), %xmm0    # 0x20e900
divsd 0x1b8(%rsp), %xmm0
callq 0x8670
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
mulsd %xmm1, %xmm0
divsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x100(%rsp)
movsd 0x1e0(%rsp), %xmm0
movsd 0x1d8(%rsp), %xmm2
movsd 0x100(%rsp), %xmm1
movsd 0x28885(%rip), %xmm3    # 0x1d2248
subsd 0x1d8(%rsp), %xmm3
mulsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xf8(%rsp)
movq 0x190(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a9a3f
leaq 0x60(%rsp), %rdi
leaq 0x650de(%rip), %rsi     # 0x20eaef
movb $0x0, %al
callq 0x8090
movq 0x1e8(%rsp), %rax
movq 0x48(%rax), %rdi
leaq 0x60(%rsp), %rsi
callq 0x8660
xorps %xmm0, %xmm0
movsd %xmm0, 0x1f0(%rsp)
jmp 0x1a9b8c
movsd 0x1d0(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd 0x1c8(%rsp), %xmm0
movsd 0x100(%rsp), %xmm2
movsd 0x287cf(%rip), %xmm1    # 0x1d2248
subsd 0x1d8(%rsp), %xmm1
mulsd %xmm1, %xmm2
movsd 0x160(%rsp), %xmm3
movsd 0x170(%rsp), %xmm1
mulsd 0xf8(%rsp), %xmm1
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd 0x120(%rsp), %xmm3
movsd 0x100(%rsp), %xmm1
movsd 0x28785(%rip), %xmm4    # 0x1d2248
subsd 0x1d8(%rsp), %xmm4
mulsd %xmm4, %xmm1
movsd 0x168(%rsp), %xmm5
movsd 0x178(%rsp), %xmm4
mulsd 0xf8(%rsp), %xmm4
mulsd %xmm5, %xmm1
addsd %xmm4, %xmm1
mulsd 0x118(%rsp), %xmm1
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movq 0x1a8(%rsp), %rax
movq 0xb8(%rax), %rax
movsd 0x60(%rax), %xmm3
movsd 0x28728(%rip), %xmm1    # 0x1d2248
subsd 0x120(%rsp), %xmm1
movsd 0x28717(%rip), %xmm5    # 0x1d2248
subsd 0x118(%rsp), %xmm5
movsd 0x29186(%rip), %xmm4    # 0x1d2cc8
mulsd %xmm5, %xmm4
movsd 0x29172(%rip), %xmm5    # 0x1d2cc0
mulsd %xmm5, %xmm1
addsd %xmm4, %xmm1
movq 0x1a8(%rsp), %rax
movq 0xb8(%rax), %rax
movsd 0x68(%rax), %xmm4
mulsd %xmm4, %xmm1
addsd %xmm3, %xmm1
divsd 0x1c8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1f0(%rsp), %xmm0
addq $0x1f8, %rsp            # imm = 0x1F8
retq
nopl (%rax)