// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/history.c
// Function: rec_get_xe_next1_H
void rec_get_xe_next1_H(HYREC_DATA *data, int model, double z_in, long iz, double xe_in, double Tm_in,
                        double *xe_out, double *Tm_out, double dxedlna_prev[2], double H, int flag) {

  REC_COSMOPARAMS *cosmo = data->cosmo;
  int *error = &data->error;
  long iz_rad = iz-1-data->rad->iz_rad_0;

  double dxedlna, z_out;
  double nH, TR, xH1, dEdtdV, DLNA;
  char sub_message[SIZE_ErrorM];
  if (flag==10) DLNA = cosmo->dlna;
  else DLNA = cosmo->dlna/10.;

  z_out   = (1.+z_in)*exp(-DLNA)-1.;
  nH = cosmo->nH0 *cube(1.+z_in);
  TR = kBoltz *cosmo->T0 *(1.+z_in);

  dEdtdV = cosmo->inj_params->ion*3*nH*EI / (1-xe_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) {
    xH1 = 1.-xe_in;
    rec_xH1_stiff(data, model, z_out, 0, &xH1, iz_rad+1, H);
    *xe_out = 1.-xH1;
    dxedlna_prev[1] = dxedlna_prev[0];
    dxedlna_prev[0] = (*xe_out-xe_in)/DLNA;
  }
    /* Otherwise use second-order explicit solver */
  else {
    dxedlna = rec_dxHIIdlna(data, model, xe_in, xe_in, nH, H, kBoltz*Tm_in, TR, iz_rad, z_in);
    *xe_out = xe_in + DLNA * hyrec_integrator(dxedlna, dxedlna_prev, z_in);
  }

  /* Quasi-steady state solution for Tm */
  *Tm_out = rec_Tmss(z_out, *xe_out, cosmo, dEdtdV, H);

  // Test that the outcome is sensible
  if (*xe_out > 1. || *xe_out < 0. || *xe_out != *xe_out) {
    sprintf(sub_message, "xe > 1 or xe < 0 in get_rec_next1_H at z = %E, xe = %E\n", z_out, *xe_out);
    strcat(data->error_message, sub_message);
    *error = 1;
  }
  if (*error == 1) {
    sprintf(sub_message, "  called from get_rec_next1_H at z = %f\n", z_out);
    strcat(data->error_message, sub_message);
    return;
  }
}

// Assembly:
subq $0x8c8, %rsp            # imm = 0x8C8
movl 0x8d0(%rsp), %eax
movq %rdi, 0x8c0(%rsp)
movl %esi, 0x8bc(%rsp)
movsd %xmm0, 0x8b0(%rsp)
movq %rdx, 0x8a8(%rsp)
movsd %xmm1, 0x8a0(%rsp)
movsd %xmm2, 0x898(%rsp)
movq %rcx, 0x890(%rsp)
movq %r8, 0x888(%rsp)
movq %r9, 0x880(%rsp)
movsd %xmm3, 0x878(%rsp)
movq 0x8c0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x870(%rsp)
movq 0x8c0(%rsp), %rax
addq $0x38, %rax
movq %rax, 0x868(%rsp)
movq 0x8a8(%rsp), %rax
subq $0x1, %rax
movq 0x8c0(%rsp), %rcx
movq 0x58(%rcx), %rcx
subq 0x8(%rcx), %rax
movq %rax, 0x860(%rsp)
cmpl $0xa, 0x8d0(%rsp)
jne 0x1b08d2
movq 0x870(%rsp), %rax
movsd 0xa8(%rax), %xmm0
movsd %xmm0, 0x828(%rsp)
jmp 0x1b08f7
movq 0x870(%rsp), %rax
movsd 0xa8(%rax), %xmm0
movsd 0x21ef6(%rip), %xmm1    # 0x1d27e0
divsd %xmm1, %xmm0
movsd %xmm0, 0x828(%rsp)
movsd 0x21949(%rip), %xmm0    # 0x1d2248
addsd 0x8b0(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x828(%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 0x21e88(%rip), %xmm1    # 0x1d27d0
addsd %xmm1, %xmm0
movsd %xmm0, 0x850(%rsp)
movq 0x870(%rsp), %rax
movsd 0x88(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x218d5(%rip), %xmm0    # 0x1d2248
addsd 0x8b0(%rsp), %xmm0
callq 0x1a5670
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x848(%rsp)
movq 0x870(%rsp), %rax
movsd 0x5df51(%rip), %xmm0    # 0x20e8f8
mulsd 0x8(%rax), %xmm0
movsd 0x21894(%rip), %xmm1    # 0x1d2248
addsd 0x8b0(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x840(%rsp)
movq 0x870(%rsp), %rax
movq 0xb8(%rax), %rax
movsd 0x22cb7(%rip), %xmm0    # 0x1d3698
mulsd 0x60(%rax), %xmm0
mulsd 0x848(%rsp), %xmm0
movsd 0x5e2d9(%rip), %xmm1    # 0x20ecd0
mulsd %xmm1, %xmm0
movsd 0x21845(%rip), %xmm1    # 0x1d2248
subsd 0x8a0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x830(%rsp)
movq 0x8c0(%rsp), %rax
cmpl $0x1, 0x3c(%rax)
jne 0x1b0ae9
movsd 0x21815(%rip), %xmm0    # 0x1d2248
subsd 0x8a0(%rsp), %xmm0
movsd %xmm0, 0x838(%rsp)
movq 0x8c0(%rsp), %rdi
movl 0x8bc(%rsp), %esi
movsd 0x850(%rsp), %xmm0
movq 0x860(%rsp), %rax
addq $0x1, %rax
movl %eax, %ecx
movsd 0x878(%rsp), %xmm2
xorps %xmm1, %xmm1
leaq 0x838(%rsp), %rdx
callq 0x1afbe0
movsd 0x217bc(%rip), %xmm0    # 0x1d2248
subsd 0x838(%rsp), %xmm0
movq 0x890(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x880(%rsp), %rax
movsd (%rax), %xmm0
movq 0x880(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movq 0x890(%rsp), %rax
movsd (%rax), %xmm0
subsd 0x8a0(%rsp), %xmm0
divsd 0x828(%rsp), %xmm0
movq 0x880(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x1b0bb5
movq 0x8c0(%rsp), %rdi
movl 0x8bc(%rsp), %esi
movsd 0x8a0(%rsp), %xmm0
movsd 0x8a0(%rsp), %xmm1
movsd 0x848(%rsp), %xmm2
movsd 0x878(%rsp), %xmm3
movsd 0x5ddd4(%rip), %xmm4    # 0x20e8f8
mulsd 0x898(%rsp), %xmm4
movsd 0x840(%rsp), %xmm5
movq 0x860(%rsp), %rax
movl %eax, %edx
movsd 0x8b0(%rsp), %xmm6
callq 0x1ad910
movsd %xmm0, 0x858(%rsp)
movsd 0x8a0(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x828(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x858(%rsp), %xmm0
movq 0x880(%rsp), %rdi
movsd 0x8b0(%rsp), %xmm1
callq 0x1af5c0
movsd (%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x890(%rsp), %rax
movsd %xmm0, (%rax)
movsd 0x850(%rsp), %xmm0
movq 0x890(%rsp), %rax
movsd (%rax), %xmm1
movq 0x870(%rsp), %rdi
movsd 0x830(%rsp), %xmm2
movsd 0x878(%rsp), %xmm3
callq 0x1aeff0
movq 0x888(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x890(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x2163f(%rip), %xmm1    # 0x1d2248
ucomisd %xmm1, %xmm0
ja 0x1b0c3e
movq 0x890(%rsp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
ja 0x1b0c3e
movq 0x890(%rsp), %rax
movsd (%rax), %xmm0
movq 0x890(%rsp), %rax
ucomisd (%rax), %xmm0
jne 0x1b0c3e
jp 0x1b0c3e
jmp 0x1b0c8a
leaq 0x20(%rsp), %rdi
movsd 0x850(%rsp), %xmm0
movq 0x890(%rsp), %rax
movsd (%rax), %xmm1
leaq 0x5ea87(%rip), %rsi     # 0x20f6e6
movb $0x2, %al
callq 0x8090
movq 0x8c0(%rsp), %rax
movq 0x48(%rax), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8660
movq 0x868(%rsp), %rax
movl $0x1, (%rax)
movq 0x868(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1b0cc9
leaq 0x20(%rsp), %rdi
movsd 0x850(%rsp), %xmm0
leaq 0x5ea72(%rip), %rsi     # 0x20f71e
movb $0x1, %al
callq 0x8090
movq 0x8c0(%rsp), %rax
movq 0x48(%rax), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8660
addq $0x8c8, %rsp            # imm = 0x8C8
retq
nopw %cs:(%rax,%rax)