// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hydrogen.c
// Function: rec_dxHIIdlna
double rec_dxHIIdlna(HYREC_DATA *data, int model, double xe, double xHII, double nH, double H, double TM, double TR,
                     unsigned iz, double z){

  REC_COSMOPARAMS * cosmo = data->cosmo;
  FIT_FUNC *fit = data->fit;
  int *error = &data->error;
  double Pion, RLya, four_betaB, result;
  char sub_message[128];

  if (*error == 1) return 0.;
  if      (model == PEEBLES)  result = rec_TLA_dxHIIdlna(cosmo, xe, xHII, nH, H, TM, TR, 1.00);
  else if (model == RECFAST)  result = rec_TLA_dxHIIdlna(cosmo, xe, xHII, nH, H, TM, TR, 1.14);
  else if (model == EMLA2s2p) result = rec_HMLA_dxHIIdlna(data, xe, xHII, nH, H, TM, TR);
  else if (model == FULL || model == SWIFT) {

    /*  When the full two-photon rate is required for z < 900, makes a simple estimate of the probability of
        photoionization from n = 2. If less than PION_MAX, just use the effective 4-level atom.*/
    Pion = 1.;
    if (z < 900.) {
      RLya       = LYA_FACT(1.,1.) *H/nH/(1.-xHII);
      four_betaB = SAHA_FACT(1.,1.) *TR*sqrt(TR) *exp(-0.25*EI/TR) *alphaB_PPB(TR, 1.,1.);
      Pion       = four_betaB/(3.*RLya + L2s1s + four_betaB);
    }
    if (Pion < PION_MAX) result = rec_HMLA_dxHIIdlna(data, xe, xHII, nH, H, TM, TR);
    else {
      if (model == FULL) result = rec_HMLA_2photon_dxHIIdlna(data, xe, xHII, nH, H, TM, TR, iz, z);
      else if (model == SWIFT) {
        if (TR/kBoltz/cosmo->fsR/cosmo->fsR/cosmo->meR < fit->swift_func[0][0]) result = rec_HMLA_dxHIIdlna(data, xe, xHII, nH, H, TM, TR);
        else result = rec_swift_hyrec_dxHIIdlna(data, xe, xHII, nH, H, TM, TR, z);
      }
    }
  }

  else {
    sprintf(sub_message, "Error in rec_dxedlna: model = %i is undefined.\n", model);
    strcat(data->error_message, sub_message);
    *error = 1;
    return 0.;
  }

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

// Assembly:
movapd %xmm0, %xmm8
xorpd %xmm0, %xmm0
cmpl $0x1, 0x38(%rdi)
je 0xd0bcc
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movl %esi, %r15d
movq %rdi, %rbx
cmpl $0x2, %esi
je 0xd0b81
movq 0x8(%rbx), %r14
cmpl $0x1, %r15d
je 0xd097a
testl %r15d, %r15d
jne 0xd0994
movsd 0x148e8(%rip), %xmm6    # 0xe5260
jmp 0xd0982
movsd 0x50956(%rip), %xmm6    # 0x1212d8
movq %r14, %rdi
movapd %xmm8, %xmm0
callq 0xcd1f5
jmp 0xd0b8e
leal -0x3(%r15), %eax
cmpl $0x1, %eax
ja 0xd0a50
movl %edx, %ebp
movq 0x60(%rbx), %r12
movsd 0x50931(%rip), %xmm0    # 0x1212e0
ucomisd %xmm6, %xmm0
jbe 0xd0b36
movsd %xmm8, 0x38(%rsp)
movsd %xmm6, 0x40(%rsp)
movsd %xmm4, 0x48(%rsp)
movsd 0x1488c(%rip), %xmm0    # 0xe5260
movsd %xmm5, 0x10(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
callq 0xcbe4d
mulsd 0x507ff(%rip), %xmm0    # 0x1211f8
mulsd 0x28(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movsd 0x14853(%rip), %xmm2    # 0xe5260
movapd %xmm2, %xmm1
subsd 0x18(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movapd %xmm2, %xmm0
callq 0xcbe4d
movsd 0x10(%rsp), %xmm1
movapd %xmm0, %xmm2
mulsd 0x507b4(%rip), %xmm2    # 0x1211f0
mulsd %xmm1, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0xd0a81
sqrtsd %xmm1, %xmm0
jmp 0xd0a9c
leaq 0x50a69(%rip), %rsi     # 0x1214c0
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8690
movl $0x1, 0x38(%rbx)
jmp 0xd0bb9
movapd %xmm1, %xmm0
movsd %xmm2, 0x8(%rsp)
callq 0x82d0
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
mulsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x5076a(%rip), %xmm0    # 0x121218
divsd %xmm1, %xmm0
callq 0x86a0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x14795(%rip), %xmm1    # 0xe5260
movsd 0x10(%rsp), %xmm0
movaps %xmm1, %xmm2
callq 0xcd167
movsd 0x10(%rsp), %xmm5
movsd 0x30(%rsp), %xmm1
mulsd 0x15c5b(%rip), %xmm1    # 0xe6748
mulsd 0x8(%rsp), %xmm0
addsd 0x50705(%rip), %xmm1    # 0x121200
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0x17475(%rip), %xmm1    # 0xe7f80
ucomisd %xmm0, %xmm1
movsd 0x48(%rsp), %xmm4
movsd 0x28(%rsp), %xmm3
movsd 0x20(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
movsd 0x40(%rsp), %xmm6
movsd 0x38(%rsp), %xmm8
ja 0xd0b81
cmpl $0x3, %r15d
jne 0xd0b4d
movq %rbx, %rdi
movapd %xmm8, %xmm0
movl %ebp, %esi
callq 0xd00a9
jmp 0xd0b8e
movapd %xmm5, %xmm0
divsd 0x506af(%rip), %xmm0    # 0x121208
movsd 0x98(%r14), %xmm7
divsd %xmm7, %xmm0
divsd %xmm7, %xmm0
divsd 0xa0(%r14), %xmm0
movq (%r12), %rax
movsd (%rax), %xmm7
ucomisd %xmm0, %xmm7
jbe 0xd0bcd
movq %rbx, %rdi
movapd %xmm8, %xmm0
callq 0xce6b7
cmpl $0x1, 0x38(%rbx)
jne 0xd0bbd
movups 0x50962(%rip), %xmm0    # 0x1214fd
leaq 0x50(%rsp), %rsi
movups %xmm0, 0xd(%rsi)
movupd 0x50944(%rip), %xmm0    # 0x1214f0
movapd %xmm0, (%rsi)
movq 0x48(%rbx), %rdi
callq 0x8690
xorpd %xmm0, %xmm0
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movapd %xmm8, %xmm0
callq 0xce17c
jmp 0xd0b8e