// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HyRec2020/history.c
// Function: get_rec_next2_HHe
void get_rec_next2_HHe(HYREC_DATA *data, int model, double z_in, long iz, double *xH1, double *xHeII,
                       double dxHIIdlna_prev[2], double dxHeIIdlna_prev[2], double H) {

  REC_COSMOPARAMS *cosmo = data->cosmo;
  int *error = &data->error;
  double Tm = data->Tm_output[iz-1];
  long iz_rad = iz-1-data->rad->iz_rad_0;

  double dxHeIIdlna, dxHIIdlna=0., z_out, xe;
  double nH, TR, DLNA;
  char sub_message[SIZE_ErrorM];
  DLNA = cosmo->dlna;
  xe = *xHeII + 1.- (*xH1);
  nH = cosmo->nH0 *cube(1.+z_in);
  TR = kBoltz * cosmo->T0 *(1.+z_in);
  /* Evolve HeII by solving ODE */
  dxHeIIdlna  = rec_helium_dxHeIIdlna(data, z_in, *xH1, *xHeII, H);
  *xHeII     += DLNA * hyrec_integrator(dxHeIIdlna, dxHeIIdlna_prev, z_in);

  /* Compute dxHII/dlna. This also correctly updates the radiation field at z_in,
     which is required even when using the stiff approximation */

  /* If system is stiff use the quasi-equilibrium solution */
  if(data->quasi_eq == 1){
    z_out = (1.+z_in)*exp(-DLNA)-1.;
    rec_xH1_stiff(data, model, z_out, *xHeII, xH1, iz_rad+1, H);
    hyrec_integrator(dxHIIdlna, dxHIIdlna_prev, z_in);
  }

    /* Otherwise use second-order explicit solver */
  else {
    dxHIIdlna = rec_dxHIIdlna(data, model, xe, 1.-(*xH1), nH, H, kBoltz*Tm, TR, iz_rad, z_in);
    *xH1 -= DLNA * hyrec_integrator(dxHIIdlna, dxHIIdlna_prev, z_in);
  }

    /* Checking for errors */
  if (*xH1 < 0. || *xH1 > 1. || *xH1 != *xH1) {
    sprintf(sub_message, "xH1 < 0 or xH1 > 1 in get_rec_next2_HHe: at z = %f, xH1 = %E\n", z_out, *xH1);
    strcat(data->error_message, sub_message);
    *error = 1;
  }
  if (*error == 1) {
    sprintf(sub_message, "  called from get_rec_next2_HHe at z = %f\n", z_out);
    strcat(data->error_message, sub_message);
    return;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x878, %rsp            # imm = 0x878
movsd %xmm1, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movq %r8, %r13
movq %rcx, %r14
movq %rdx, %r12
movapd %xmm0, %xmm1
movsd %xmm0, 0x28(%rsp)
movl %esi, 0x14(%rsp)
movq %rdi, %rbx
movq 0x8b0(%rsp), %rbp
movq 0x8(%rdi), %r15
movq 0x30(%rdi), %rax
movsd -0x8(%rax,%rdx,8), %xmm0
movsd %xmm0, 0x68(%rsp)
decq %r12
movq 0x58(%rdi), %rax
subq 0x8(%rax), %r12
movsd 0x88(%r15), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0xa8(%r15), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd (%r8), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd (%rcx), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x13d52(%rip), %xmm0    # 0xee260
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0xd3759
movsd %xmm0, 0x48(%rsp)
movsd 0x8(%r15), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd (%r14), %xmm1
movsd (%r13), %xmm2
movq %rbx, %rdi
movsd 0x28(%rsp), %xmm0
movsd 0x18(%rsp), %xmm3
callq 0xd44f6
movsd (%rbp), %xmm1
movsd 0x8(%rbp), %xmm2
movsd 0x30518(%rip), %xmm3    # 0x10aa78
mulsd %xmm1, %xmm3
movsd 0x50264(%rip), %xmm4    # 0x12a7d0
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
mulsd 0x5025c(%rip), %xmm2    # 0x12a7d8
addsd %xmm4, %xmm2
movsd %xmm1, 0x8(%rbp)
movsd %xmm0, (%rbp)
mulsd 0x30(%rsp), %xmm2
addsd (%r13), %xmm2
movsd %xmm2, (%r13)
cmpl $0x1, 0x3c(%rbx)
jne 0xda611
movapd 0x30(%rsp), %xmm0
xorpd 0x13c80(%rip), %xmm0    # 0xee230
callq 0x8670
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
addsd 0x14221(%rip), %xmm2    # 0xee7e8
movsd (%r13), %xmm1
incl %r12d
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movsd %xmm2, 0x8(%rsp)
movapd %xmm2, %xmm0
movq %r14, %rdx
movl %r12d, %ecx
movsd 0x18(%rsp), %xmm2
callq 0xda007
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq $0x0, (%rax)
movsd (%r14), %xmm1
jmp 0xda6d2
movsd 0x4fd4f(%rip), %xmm3    # 0x12a368
movsd 0x40(%rsp), %xmm0
mulsd %xmm3, %xmm0
movsd 0x8(%rsp), %xmm5
mulsd %xmm0, %xmm5
movsd 0x60(%rsp), %xmm2
mulsd 0x48(%rsp), %xmm2
movsd 0x13c1f(%rip), %xmm1    # 0xee260
movsd 0x58(%rsp), %xmm0
addsd %xmm1, %xmm0
subsd 0x50(%rsp), %xmm0
subsd (%r14), %xmm1
movsd 0x68(%rsp), %xmm4
mulsd %xmm3, %xmm4
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movsd 0x18(%rsp), %xmm3
movl %r12d, %edx
movsd 0x28(%rsp), %xmm6
callq 0xd85d7
movq 0x20(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm2
movsd 0x303e7(%rip), %xmm3    # 0x10aa78
mulsd %xmm1, %xmm3
movsd 0x50133(%rip), %xmm4    # 0x12a7d0
mulsd %xmm0, %xmm4
mulsd 0x5012f(%rip), %xmm2    # 0x12a7d8
addsd %xmm3, %xmm4
addsd %xmm4, %xmm2
movsd %xmm1, 0x8(%rax)
movsd %xmm0, (%rax)
movsd (%r14), %xmm1
movapd 0x30(%rsp), %xmm0
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r14)
ucomisd %xmm1, %xmm1
jp 0xda6fa
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0xda6fa
ucomisd 0x13b76(%rip), %xmm1    # 0xee260
ja 0xda6fa
cmpl $0x1, 0x38(%rbx)
movsd 0x8(%rsp), %xmm0
je 0xda72f
jmp 0xda751
leaq 0x50abc(%rip), %rsi     # 0x12b1bd
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8660
movsd 0x8(%rsp), %xmm0
movl $0x1, 0x38(%rbx)
leaq 0x50ac5(%rip), %rsi     # 0x12b1fb
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movb $0x1, %al
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8660
addq $0x878, %rsp            # imm = 0x878
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq