// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../external/HyRec2020/history.c
// Function: rec_get_xe_next2_HTm
void rec_get_xe_next2_HTm(HYREC_DATA *data, int model, double z_in, long iz, double dxedlna_prev[2],
                          double dTmdlna_prev[2], double H, double z_out, double H_next) {

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

  double dxedlna, dTmdlna, nH, TR, dEdtdV, DLNA;
  char sub_message[SIZE_ErrorM];
  DLNA = cosmo->dlna;

  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);
  /*For low redshifts (z < 20 or so) use Peeble's model.
    The precise model does not metter much here as
    1) the free electron fraction is basically zero (~1e-4) in any case and
    2) the universe is going to be reionized around that epoch */

  if (TR/cosmo->fsR/cosmo->fsR/cosmo->meR <= TR_MIN
     || kBoltz*Tm_in/TR <= T_RATIO_MIN) model = PEEBLES;
    dxedlna = rec_dxHIIdlna(data, model, xe_in, xe_in, nH, H, kBoltz*Tm_in, TR, iz_rad, z_in);

  dTmdlna = rec_dTmdlna(z_in, xe_in, Tm_in, cosmo, dEdtdV, H);

  data->Tm_evolve_implicit = 1;
  if (fabs(1-dTmdlna_prev[0]/dTmdlna)<DTM_DIFF_MAX) data->Tm_evolve_implicit = 0;
  if (data->Tm_evolve_implicit == 1){
    dTmdlna_prev[0] = dTmdlna;
    dTmdlna_prev[1] = dTmdlna_prev[0];
    data->xe_output[iz] = xe_in + DLNA *hyrec_integrator(dxedlna, dxedlna_prev, z_in);
    data->Tm_output[iz] = Tm_implicit(z_out, data->xe_output[iz], Tm_in, cosmo, dEdtdV, H_next, DLNA);
  }
  else {
    data->xe_output[iz] = xe_in + DLNA *hyrec_integrator(dxedlna, dxedlna_prev, z_in);
    data->Tm_output[iz] = Tm_in + DLNA *hyrec_integrator(dTmdlna, dTmdlna_prev, z_in);
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x858, %rsp            # imm = 0x858
movsd %xmm3, 0x40(%rsp)
movsd %xmm2, 0x38(%rsp)
movsd %xmm1, 0x30(%rsp)
movq %r8, %r15
movq %rcx, %r12
movl %esi, %r14d
movq %rdi, %rbx
movq 0x8(%rdi), %r13
movq 0x28(%rdi), %rax
leaq -0x1(%rdx), %rbp
movsd -0x8(%rax,%rdx,8), %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x30(%rdi), %rax
movq %rdx, 0x48(%rsp)
movsd -0x8(%rax,%rdx,8), %xmm1
movsd %xmm1, (%rsp)
movq 0x58(%rdi), %rax
subq 0x8(%rax), %rbp
movsd 0x88(%r13), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0xa8(%r13), %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0x13232(%rip), %xmm1    # 0xf1260
movsd %xmm0, 0x20(%rsp)
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0xd6f51
movapd %xmm0, %xmm2
mulsd 0x10(%rsp), %xmm2
movsd 0x8(%r13), %xmm5
mulsd 0x4f2dd(%rip), %xmm5    # 0x12d338
movq 0xb8(%r13), %rax
movsd 0x60(%rax), %xmm3
mulsd 0x14611(%rip), %xmm3    # 0xf2680
movsd 0x98(%r13), %xmm0
mulsd %xmm2, %xmm3
mulsd 0x4f73c(%rip), %xmm3    # 0x12d7c0
mulsd 0x18(%rsp), %xmm5
movapd %xmm5, %xmm1
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
movsd 0x131c2(%rip), %xmm0    # 0xf1260
subsd 0x8(%rsp), %xmm0
divsd 0xa0(%r13), %xmm1
divsd %xmm0, %xmm3
movsd %xmm3, 0x18(%rsp)
movsd 0x4f2a9(%rip), %xmm0    # 0x12d368
ucomisd %xmm1, %xmm0
jae 0xde0e4
movsd 0x4f26b(%rip), %xmm0    # 0x12d338
mulsd (%rsp), %xmm0
divsd %xmm5, %xmm0
movsd 0x131b2(%rip), %xmm1    # 0xf1290
ucomisd %xmm0, %xmm1
jb 0xde0e7
xorl %r14d, %r14d
movsd 0x4f249(%rip), %xmm4    # 0x12d338
mulsd (%rsp), %xmm4
movq %rbx, %rdi
movl %r14d, %esi
movsd 0x8(%rsp), %xmm0
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm3
movl %ebp, %edx
movsd 0x20(%rsp), %xmm6
callq 0xdbd61
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd (%rsp), %xmm2
movq %r13, %rdi
movsd 0x18(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
callq 0xdcf2c
movl $0x1, 0x44(%rbx)
movsd (%r15), %xmm1
divsd %xmm0, %xmm1
movsd 0x13107(%rip), %xmm2    # 0xf1260
subsd %xmm1, %xmm2
andpd 0x130db(%rip), %xmm2    # 0xf1240
movsd 0x13b6b(%rip), %xmm1    # 0xf1cd8
ucomisd %xmm2, %xmm1
jbe 0xde17a
movl $0x0, 0x44(%rbx)
cmpl $0x1, 0x44(%rbx)
movq 0x48(%rsp), %r14
jne 0xde21e
movsd %xmm0, (%r15)
movsd %xmm0, 0x8(%r15)
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x2f8a7(%rip), %xmm2    # 0x10da50
mulsd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd 0x4f5e1(%rip), %xmm3    # 0x12d7a0
mulsd 0x4f5e1(%rip), %xmm1    # 0x12d7a8
addsd %xmm2, %xmm3
addsd %xmm3, %xmm1
movsd %xmm0, 0x8(%r12)
movsd %xmm4, (%r12)
movsd 0x28(%rsp), %xmm5
mulsd %xmm5, %xmm1
addsd 0x8(%rsp), %xmm1
movq 0x28(%rbx), %rax
movsd %xmm1, (%rax,%r14,8)
movsd 0x38(%rsp), %xmm0
movsd (%rsp), %xmm2
movq %r13, %rdi
movsd 0x18(%rsp), %xmm3
movsd 0x40(%rsp), %xmm4
callq 0xdd091
movapd %xmm0, %xmm1
jmp 0xde2bb
movsd (%r12), %xmm1
movsd 0x2f824(%rip), %xmm2    # 0x10da50
movsd 0x8(%r12), %xmm3
movsd %xmm1, 0x8(%r12)
mulsd %xmm2, %xmm1
movsd 0x4f55a(%rip), %xmm4    # 0x12d7a0
movsd 0x10(%rsp), %xmm6
movapd %xmm6, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm1, %xmm5
movsd 0x4f548(%rip), %xmm1    # 0x12d7a8
mulsd %xmm1, %xmm3
addsd %xmm5, %xmm3
movsd %xmm6, (%r12)
movsd 0x28(%rsp), %xmm6
mulsd %xmm6, %xmm3
addsd 0x8(%rsp), %xmm3
movq 0x28(%rbx), %rax
movsd %xmm3, (%rax,%r14,8)
movsd (%r15), %xmm3
mulsd %xmm3, %xmm2
movapd %xmm0, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm2, %xmm5
mulsd 0x8(%r15), %xmm1
addsd %xmm5, %xmm1
movsd %xmm3, 0x8(%r15)
movsd %xmm0, (%r15)
mulsd %xmm6, %xmm1
addsd (%rsp), %xmm1
movq 0x30(%rbx), %rax
movsd %xmm1, (%rax,%r14,8)
cmpl $0x1, 0x38(%rbx)
jne 0xde2f3
leaq 0x4ff85(%rip), %rsi     # 0x12e257
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movsd 0x20(%rsp), %xmm0
movb $0x1, %al
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8660
addq $0x858, %rsp            # imm = 0x858
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq