// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x8d8, %rsp            # imm = 0x8D8
movq %rdi, 0x8d0(%rsp)
movsd %xmm0, 0x8c8(%rsp)
movq %rsi, 0x8c0(%rsp)
movq %rdx, 0x8b8(%rsp)
movq %rcx, 0x8b0(%rsp)
movl %r8d, 0x8ac(%rsp)
movq 0x8d0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8a0(%rsp)
movq 0x8d0(%rsp), %rax
cvtsi2sdq 0x20(%rax), %xmm0
movsd %xmm0, 0x898(%rsp)
movq 0x8d0(%rsp), %rax
movsd 0x10(%rax), %xmm0
divsd 0x898(%rsp), %xmm0
movsd %xmm0, 0x890(%rsp)
movq 0x8d0(%rsp), %rax
addq $0x38, %rax
movq %rax, 0x888(%rsp)
cmpl $0xa, 0x8ac(%rsp)
jne 0x1af71b
movq 0x8a0(%rsp), %rax
movsd 0xa8(%rax), %xmm0
movsd %xmm0, 0x838(%rsp)
jmp 0x1af740
movq 0x8a0(%rsp), %rax
movsd 0xa8(%rax), %xmm0
movsd 0x230ad(%rip), %xmm1    # 0x1d27e0
divsd %xmm1, %xmm0
movsd %xmm0, 0x838(%rsp)
movq 0x8b0(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x2307c(%rip), %xmm1    # 0x1d27d0
ucomisd %xmm1, %xmm0
jne 0x1af77a
jp 0x1af77a
movq 0x8a0(%rsp), %rdi
movsd 0x8c8(%rsp), %xmm0
callq 0x1adee0
movsd %xmm0, 0x28(%rsp)
jmp 0x1af7bb
movsd 0x890(%rsp), %xmm1
movq 0x8b0(%rsp), %rdi
cvttsd2si 0x898(%rsp), %rax
movl %eax, %esi
movsd 0x8c8(%rsp), %xmm2
movq 0x888(%rsp), %rdx
leaq 0x30(%rsp), %rcx
xorps %xmm0, %xmm0
callq 0x1a5ae0
movsd %xmm0, 0x28(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x8c8(%rsp), %xmm0
movq 0x8c0(%rsp), %rax
movsd (%rax), %xmm1
callq 0x1a6c20
movsd %xmm0, 0x880(%rsp)
movq 0x8d0(%rsp), %rdi
movsd 0x8c8(%rsp), %xmm0
movsd 0x880(%rsp), %xmm1
movq 0x8c0(%rsp), %rax
movsd (%rax), %xmm2
movsd 0x28(%rsp), %xmm3
callq 0x1a6e90
movsd %xmm0, 0x850(%rsp)
movq 0x8d0(%rsp), %rax
cmpl $0x1, 0x3c(%rax)
jne 0x1afb40
movsd 0x22a0e(%rip), %xmm0    # 0x1d2248
addsd 0x8c8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x838(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x8670
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x22f4d(%rip), %xmm1    # 0x1d27d0
addsd %xmm1, %xmm0
movsd %xmm0, 0x848(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
callq 0x1a6a30
movsd %xmm0, 0x868(%rsp)
movsd 0x22991(%rip), %xmm0    # 0x1d2248
addsd 0x848(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
movsd 0x233a9(%rip), %xmm1    # 0x1d2c88
subsd %xmm1, %xmm0
callq 0x1a6a30
movsd %xmm0, 0x18(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x2338a(%rip), %xmm0    # 0x1d2c88
addsd 0x848(%rsp), %xmm0
callq 0x1a6a30
movsd 0x18(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x20(%rsp), %xmm0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x860(%rsp)
movq 0x8a0(%rsp), %rax
movsd 0x80(%rax), %xmm1
subsd 0x868(%rsp), %xmm1
movsd 0x25683(%rip), %xmm0    # 0x1d4fd0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x840(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
movsd 0x868(%rsp), %xmm1
addsd 0x840(%rsp), %xmm1
callq 0x1a6c20
movsd %xmm0, 0x878(%rsp)
movq 0x8a0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
movsd 0x868(%rsp), %xmm1
subsd 0x840(%rsp), %xmm1
callq 0x1a6c20
movsd %xmm0, 0x870(%rsp)
movq 0x8b0(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x22e00(%rip), %xmm1    # 0x1d27d0
ucomisd %xmm1, %xmm0
jne 0x1af9f6
jp 0x1af9f6
movq 0x8a0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
callq 0x1adee0
movsd %xmm0, 0x28(%rsp)
jmp 0x1afa37
movsd 0x890(%rsp), %xmm1
movq 0x8b0(%rsp), %rdi
cvttsd2si 0x898(%rsp), %rax
movl %eax, %esi
movsd 0x848(%rsp), %xmm2
movq 0x888(%rsp), %rdx
leaq 0x30(%rsp), %rcx
xorps %xmm0, %xmm0
callq 0x1a5ae0
movsd %xmm0, 0x28(%rsp)
movq 0x8d0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
movsd 0x878(%rsp), %xmm1
movsd 0x868(%rsp), %xmm2
addsd 0x840(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
callq 0x1a6e90
movsd %xmm0, 0x8(%rsp)
movq 0x8d0(%rsp), %rdi
movsd 0x848(%rsp), %xmm0
movsd 0x870(%rsp), %xmm1
movsd 0x868(%rsp), %xmm2
subsd 0x840(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
callq 0x1a6e90
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd 0x231c0(%rip), %xmm1    # 0x1d2c80
divsd %xmm1, %xmm0
divsd 0x840(%rsp), %xmm0
movsd %xmm0, 0x858(%rsp)
movsd 0x868(%rsp), %xmm0
movsd 0x860(%rsp), %xmm1
divsd 0x858(%rsp), %xmm1
addsd %xmm1, %xmm0
movq 0x8c0(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x8c0(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x868(%rsp), %xmm0
movaps 0x22713(%rip), %xmm1    # 0x1d2230
pand %xmm1, %xmm0
movsd 0x2697f(%rip), %xmm1    # 0x1d64a8
ucomisd %xmm1, %xmm0
jbe 0x1afb3e
movq 0x8d0(%rsp), %rax
movl $0x0, 0x3c(%rax)
jmp 0x1afb8d
movsd 0x838(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x850(%rsp), %xmm0
movq 0x8b8(%rsp), %rdi
movsd 0x8c8(%rsp), %xmm1
callq 0x1af5c0
movaps %xmm0, %xmm2
movsd (%rsp), %xmm0
movq 0x8c0(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x888(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1afbcc
leaq 0x30(%rsp), %rdi
movsd 0x8c8(%rsp), %xmm0
leaq 0x5fa4b(%rip), %rsi     # 0x20f5fa
movb $0x1, %al
callq 0x8090
movq 0x8d0(%rsp), %rax
movq 0x48(%rax), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8660
addq $0x8d8, %rsp            # imm = 0x8D8
retq
nopw %cs:(%rax,%rax)