// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HyRec2020/history.c
// Function: rec_get_xe_next1_He
void rec_get_xe_next1_He(HYREC_DATA *data, double z_in, double *xHeII, double dxHeIIdlna_prev[2],
                         double *hubble_array, int flag) {

  REC_COSMOPARAMS *cosmo = data->cosmo;
  double Nz = data->Nz, dz = data->zmax/Nz;
  int *error = &data->error;

  double xH1, xH1_p, xH1_m, xHeIISaha, dxHeIISaha_dlna, DdxHeIIdlna_Dxe, dxHeIIdlna, z_out, Dxe, DLNA;
  char sub_message[SIZE_ErrorM];
  double H;
  if (flag==10) DLNA = cosmo->dlna;
  else DLNA = cosmo->dlna/10.;

  if (hubble_array[0]==-1.) H  = rec_HubbleRate(cosmo, z_in);
  else H = rec_interp1d(.0, dz, hubble_array, Nz, z_in, error, sub_message);

  xH1        = rec_saha_xH1s(cosmo, z_in, *xHeII);
  dxHeIIdlna = rec_helium_dxHeIIdlna(data, z_in, xH1, *xHeII, H);
  /* Post-Saha approximation during the early phase of HeII->HeI recombination */
  if (data->quasi_eq == 1) {
    z_out     = (1.+z_in)*exp(-DLNA)-1.;
    xHeIISaha = rec_saha_xHeII(cosmo, z_out);

    dxHeIISaha_dlna  = (1.+z_out)*(rec_saha_xHeII(cosmo, z_out-0.5)
                                  -rec_saha_xHeII(cosmo, z_out+0.5));

    Dxe    = 0.01*(cosmo->fHe - xHeIISaha);
    xH1_p = rec_saha_xH1s(cosmo, z_out, xHeIISaha+Dxe);
    xH1_m = rec_saha_xH1s(cosmo, z_out, xHeIISaha-Dxe);

    if (hubble_array[0]==-1.) H  = rec_HubbleRate(cosmo, z_out);
    else H = rec_interp1d(.0, dz, hubble_array, Nz, z_out, error, sub_message);

    DdxHeIIdlna_Dxe  = (rec_helium_dxHeIIdlna(data, z_out, xH1_p, xHeIISaha+Dxe, H)
                       -rec_helium_dxHeIIdlna(data, z_out, xH1_m, xHeIISaha-Dxe, H))/2./Dxe;

    *xHeII = xHeIISaha + dxHeIISaha_dlna/DdxHeIIdlna_Dxe;
    /* Check that the post-Saha approximation is still valid. If not, switch it off for future iterations */
    if (fabs(*xHeII - xHeIISaha) > DXHEII_MAX) data->quasi_eq = 0;
  }

  /* Otherwise integrate ODE */
  else *xHeII += DLNA * hyrec_integrator(dxHeIIdlna, dxHeIIdlna_prev,z_in);

  if (*error == 1) {
    sprintf(sub_message, "  called from rec_get_xe_next1_He at z = %f\n", z_in);
    strcat(data->error_message, sub_message);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x888, %rsp            # imm = 0x888
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r14
movapd %xmm0, %xmm2
movq %rdi, %rbx
movq 0x20(%rdi), %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
movq 0x8(%rdi), %rbp
movsd 0x10(%rdi), %xmm1
movsd 0xa8(%rbp), %xmm3
cmpl $0xa, %r8d
je 0xd9cdb
divsd 0x14b15(%rip), %xmm3    # 0xee7f0
movapd %xmm3, 0x10(%rsp)
divsd %xmm0, %xmm1
leaq 0x38(%rbx), %rdx
movsd (%r12), %xmm0
ucomisd 0x14af1(%rip), %xmm0    # 0xee7e8
movsd %xmm2, 0x28(%rsp)
movq %rdx, 0x38(%rsp)
movsd %xmm1, 0x30(%rsp)
jne 0xd9d1a
jp 0xd9d1a
movq %rbp, %rdi
movapd %xmm2, %xmm0
callq 0xd88f4
jmp 0xd9d31
leaq 0x80(%rsp), %rcx
xorpd %xmm0, %xmm0
movq %r12, %rdi
movl %r13d, %esi
callq 0xd3a85
movsd %xmm0, (%rsp)
movsd (%r14), %xmm1
movq %rbp, %rdi
movsd 0x28(%rsp), %xmm0
callq 0xd4334
movaps %xmm0, %xmm1
movsd (%r14), %xmm2
movq %rbx, %rdi
movsd 0x28(%rsp), %xmm0
movsd (%rsp), %xmm3
callq 0xd44f6
cmpl $0x1, 0x3c(%rbx)
jne 0xd9ea1
movsd 0x144ea(%rip), %xmm0    # 0xee260
movsd %xmm0, 0x8(%rsp)
movsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm0
xorpd 0x14497(%rip), %xmm0    # 0xee230
callq 0x8670
mulsd (%rsp), %xmm0
addsd 0x14a3d(%rip), %xmm0    # 0xee7e8
movsd %xmm0, 0x10(%rsp)
movq %rbp, %rdi
callq 0xd41c0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1769c(%rip), %xmm0    # 0xf1478
addsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0xd41c0
movapd %xmm0, 0x40(%rsp)
movsd 0x14eda(%rip), %xmm0    # 0xeecd0
addsd 0x10(%rsp), %xmm0
movq %rbp, %rdi
callq 0xd41c0
movapd 0x40(%rsp), %xmm1
subsd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
movapd %xmm1, 0x40(%rsp)
movsd 0x80(%rbp), %xmm0
movsd (%rsp), %xmm1
subsd %xmm1, %xmm0
mulsd 0x1718d(%rip), %xmm0    # 0xf0fc0
movsd %xmm0, 0x8(%rsp)
addsd %xmm0, %xmm1
movq %rbp, %rdi
movsd 0x10(%rsp), %xmm0
movsd %xmm1, 0x78(%rsp)
callq 0xd4334
movsd %xmm0, 0x68(%rsp)
movsd (%rsp), %xmm1
subsd 0x8(%rsp), %xmm1
movq %rbp, %rdi
movsd 0x10(%rsp), %xmm0
movsd %xmm1, 0x70(%rsp)
callq 0xd4334
movsd %xmm0, 0x60(%rsp)
movsd (%r12), %xmm0
ucomisd 0x1495e(%rip), %xmm0    # 0xee7e8
jne 0xd9efd
jp 0xd9efd
movq %rbp, %rdi
movsd 0x10(%rsp), %xmm0
callq 0xd88f4
jmp 0xd9f25
movsd (%r15), %xmm1
movsd 0x8(%r15), %xmm2
movsd 0x30bc4(%rip), %xmm3    # 0x10aa78
mulsd %xmm1, %xmm3
movapd %xmm0, %xmm4
mulsd 0x5090c(%rip), %xmm4    # 0x12a7d0
mulsd 0x5090c(%rip), %xmm2    # 0x12a7d8
addsd %xmm3, %xmm4
addsd %xmm4, %xmm2
movsd %xmm1, 0x8(%r15)
movsd %xmm0, (%r15)
movapd 0x10(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd (%r14), %xmm0
movsd %xmm0, (%r14)
movq 0x38(%rsp), %rax
jmp 0xd9fc5
leaq 0x80(%rsp), %rcx
xorpd %xmm0, %xmm0
movsd 0x30(%rsp), %xmm1
movq %r12, %rdi
movl %r13d, %esi
movsd 0x10(%rsp), %xmm2
movq 0x38(%rsp), %rdx
callq 0xd3a85
movapd %xmm0, %xmm3
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd %xmm3, 0x58(%rsp)
callq 0xd44f6
movsd %xmm0, 0x30(%rsp)
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
movsd 0x58(%rsp), %xmm3
callq 0xd44f6
movsd 0x30(%rsp), %xmm1
subsd %xmm0, %xmm1
mulsd 0x14d4f(%rip), %xmm1    # 0xeecd0
divsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
movapd 0x40(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd (%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, (%r14)
subsd %xmm0, %xmm1
andpd 0x14291(%rip), %xmm1    # 0xee240
ucomisd 0x50829(%rip), %xmm1    # 0x12a7e0
movq 0x38(%rsp), %rax
jbe 0xd9fc5
movl $0x0, 0x3c(%rbx)
cmpl $0x1, (%rax)
movsd 0x28(%rsp), %xmm0
jne 0xd9ff5
leaq 0x51163(%rip), %rsi     # 0x12b13a
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movb $0x1, %al
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8660
addq $0x888, %rsp            # imm = 0x888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq