// File: /workspace/github_c_makefile_star2_O2/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, 0x48(%rsp)
movsd %xmm2, 0x40(%rsp)
movsd %xmm1, 0x38(%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, 0x10(%rsp)
movq 0x30(%rdi), %rax
movq %rdx, 0x30(%rsp)
movsd -0x8(%rax,%rdx,8), %xmm1
movsd %xmm1, 0x18(%rsp)
movq 0x58(%rdi), %rax
subq 0x8(%rax), %rbp
movsd 0x88(%r13), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0xa8(%r13), %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0x1276b(%rip), %xmm1    # 0xe5260
movsd %xmm0, 0x20(%rsp)
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
callq 0xcbe4d
movsd 0x10(%rsp), %xmm8
movsd 0x18(%rsp), %xmm3
movapd %xmm0, %xmm2
mulsd 0x8(%rsp), %xmm2
movsd 0x4e6e0(%rip), %xmm4    # 0x121208
movsd 0x8(%r13), %xmm5
mulsd %xmm4, %xmm5
mulsd (%rsp), %xmm5
movq 0xb8(%r13), %rax
movsd 0x60(%rax), %xmm7
mulsd 0x13bfd(%rip), %xmm7    # 0xe6748
mulsd %xmm2, %xmm7
mulsd 0x4eb09(%rip), %xmm7    # 0x121660
movsd 0x12701(%rip), %xmm0    # 0xe5260
subsd %xmm8, %xmm0
divsd %xmm0, %xmm7
movsd 0x98(%r13), %xmm0
movapd %xmm5, %xmm1
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
divsd 0xa0(%r13), %xmm1
movsd 0x4e6aa(%rip), %xmm0    # 0x121238
ucomisd %xmm1, %xmm0
mulsd %xmm3, %xmm4
movsd %xmm7, 0x8(%rsp)
jae 0xd2bb4
movapd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd 0x126e2(%rip), %xmm1    # 0xe5290
ucomisd %xmm0, %xmm1
jb 0xd2bb7
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
movapd %xmm8, %xmm0
movapd %xmm8, %xmm1
movsd 0x38(%rsp), %xmm3
movl %ebp, %edx
movsd 0x20(%rsp), %xmm6
callq 0xd0930
movsd %xmm0, (%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movq %r13, %rdi
movsd 0x8(%rsp), %xmm3
movsd 0x38(%rsp), %xmm4
callq 0xd19e2
movl $0x1, 0x44(%rbx)
movsd (%r15), %xmm1
divsd %xmm0, %xmm1
movsd 0x12643(%rip), %xmm2    # 0xe5260
subsd %xmm1, %xmm2
andpd 0x12617(%rip), %xmm2    # 0xe5240
movsd 0x13087(%rip), %xmm1    # 0xe5cb8
ucomisd %xmm2, %xmm1
jbe 0xd2ce6
andl $0x0, 0x44(%rbx)
movsd (%r12), %xmm1
movsd 0x2ecf3(%rip), %xmm2    # 0x101940
movsd 0x8(%r12), %xmm3
movsd %xmm1, 0x8(%r12)
mulsd %xmm2, %xmm1
movsd 0x4e9d9(%rip), %xmm4    # 0x121640
movsd (%rsp), %xmm6
movapd %xmm6, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm1, %xmm5
movsd 0x4e9c8(%rip), %xmm1    # 0x121648
mulsd %xmm1, %xmm3
addsd %xmm5, %xmm3
movsd %xmm6, (%r12)
movsd 0x28(%rsp), %xmm6
mulsd %xmm6, %xmm3
addsd 0x10(%rsp), %xmm3
movq 0x28(%rbx), %rax
movq 0x30(%rsp), %r14
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 0x18(%rsp), %xmm1
jmp 0xd2d7b
movsd %xmm0, (%r15)
movsd %xmm0, 0x8(%r15)
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x2ec3a(%rip), %xmm2    # 0x101940
mulsd %xmm0, %xmm2
movsd (%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd 0x4e925(%rip), %xmm3    # 0x121640
mulsd 0x4e925(%rip), %xmm1    # 0x121648
addsd %xmm2, %xmm3
addsd %xmm3, %xmm1
movsd %xmm0, 0x8(%r12)
movsd %xmm4, (%r12)
movsd 0x28(%rsp), %xmm5
mulsd %xmm5, %xmm1
addsd 0x10(%rsp), %xmm1
movq 0x28(%rbx), %rax
movq 0x30(%rsp), %r14
movsd %xmm1, (%rax,%r14,8)
movsd 0x40(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
movq %r13, %rdi
movsd 0x8(%rsp), %xmm3
movsd 0x48(%rsp), %xmm4
callq 0xd1b47
movapd %xmm0, %xmm1
movq 0x30(%rbx), %rax
movsd %xmm1, (%rax,%r14,8)
cmpl $0x1, 0x38(%rbx)
jne 0xd2db3
leaq 0x4f365(%rip), %rsi     # 0x1220f7
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movsd 0x20(%rsp), %xmm0
movb $0x1, %al
callq 0x8090
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x8690
addq $0x858, %rsp            # imm = 0x858
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq