// File: /workspace/github_c_makefile_star2_O3/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 0x13792(%rip), %xmm1    # 0xee260
movsd %xmm0, 0x20(%rsp)
addsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
callq 0xd3759
movsd 0x10(%rsp), %xmm8
movsd 0x18(%rsp), %xmm3
movapd %xmm0, %xmm2
mulsd 0x8(%rsp), %xmm2
movsd 0x4f867(%rip), %xmm4    # 0x12a368
movsd 0x8(%r13), %xmm5
mulsd %xmm4, %xmm5
mulsd (%rsp), %xmm5
movq 0xb8(%r13), %rax
movsd 0x60(%rax), %xmm7
mulsd 0x14b5c(%rip), %xmm7    # 0xef680
mulsd %xmm2, %xmm7
mulsd 0x4fcc0(%rip), %xmm7    # 0x12a7f0
movsd 0x13728(%rip), %xmm0    # 0xee260
subsd %xmm8, %xmm0
divsd %xmm0, %xmm7
movsd 0x98(%r13), %xmm0
movapd %xmm5, %xmm1
divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
divsd 0xa0(%r13), %xmm1
movsd 0x4f831(%rip), %xmm0    # 0x12a398
ucomisd %xmm1, %xmm0
mulsd %xmm3, %xmm4
movsd %xmm7, 0x8(%rsp)
jae 0xdab8d
movapd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd 0x13709(%rip), %xmm1    # 0xee290
ucomisd %xmm0, %xmm1
jb 0xdab90
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 0xd85d7
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 0xd99a7
movl $0x1, 0x44(%rbx)
movsd (%r15), %xmm1
divsd %xmm0, %xmm1
movsd 0x1366a(%rip), %xmm2    # 0xee260
subsd %xmm1, %xmm2
andpd 0x1363e(%rip), %xmm2    # 0xee240
movsd 0x140ce(%rip), %xmm1    # 0xeecd8
ucomisd %xmm2, %xmm1
jbe 0xdacc2
movl $0x0, 0x44(%rbx)
movsd (%r12), %xmm1
movsd 0x2fe4f(%rip), %xmm2    # 0x10aa78
movsd 0x8(%r12), %xmm3
movsd %xmm1, 0x8(%r12)
mulsd %xmm2, %xmm1
movsd 0x4fb8d(%rip), %xmm4    # 0x12a7d0
movsd (%rsp), %xmm6
movapd %xmm6, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm1, %xmm5
movsd 0x4fb7c(%rip), %xmm1    # 0x12a7d8
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 0xdad57
movsd %xmm0, (%r15)
movsd %xmm0, 0x8(%r15)
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x2fd96(%rip), %xmm2    # 0x10aa78
mulsd %xmm0, %xmm2
movsd (%rsp), %xmm4
movapd %xmm4, %xmm3
mulsd 0x4fad9(%rip), %xmm3    # 0x12a7d0
mulsd 0x4fad9(%rip), %xmm1    # 0x12a7d8
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 0xd9b0c
movapd %xmm0, %xmm1
movq 0x30(%rbx), %rax
movsd %xmm1, (%rax,%r14,8)
cmpl $0x1, 0x38(%rbx)
jne 0xdad8f
leaq 0x50519(%rip), %rsi     # 0x12b287
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