// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/thermodynamics.c
// Function: thermodynamics_idm_initial_temperature
int thermodynamics_idm_initial_temperature(
                                           struct background* pba,
                                           struct thermodynamics* pth,
                                           double z_ini,
                                           struct thermo_diffeq_workspace * ptdw
                                           ) {

  /** - define local parameters */
  double* pvecback;
  int last_index;
  /* idm-b special parameters */
  double m_b, FHe, T_diff_idm_b;
  /* steady state factors ( = prefactors in temperature evolution equation) */
  double alpha=0.,beta=0.,epsilon=0.;

  /** - obtain necessary background information */
  class_alloc(pvecback,pba->bg_size*sizeof(double),pba->error_message);
  class_call(background_at_z(pba,
                             z_ini,
                             long_info,
                             inter_normal,
                             &last_index,
                             pvecback),
             pba->error_message,
             pth->error_message);

  /* idm-idr steady state */
  if ((pth->has_idm_dr == _TRUE_) && (pth->n_index_idm_dr == 0)) {
    epsilon = 2*4./3.*pvecback[pba->index_bg_rho_idr]/pvecback[pba->index_bg_rho_idm]*
      pth->a_idm_dr*pow((1.+ z_ini)/1.e7,pth->n_index_idm_dr)*pba->Omega0_idm*pow(pba->h,2) / pvecback[pba->index_bg_H]*(1.+z_ini);
  }
  /* idm_g steady state */
  else if (pth->has_idm_g == _TRUE_ && pth->n_index_idm_g == -2) {
    ptdw->dmu_idm_dr = pth->a_idm_dr*pow((1.+ z_ini)/1.e7,pth->n_index_idm_dr)*pba->Omega0_idm*pow(pba->h,2);
    ptdw->Sinv_idm_dr  = 4./3.*pvecback[pba->index_bg_rho_idr]/pvecback[pba->index_bg_rho_idm];
    alpha = 2.* ptdw->dmu_idm_dr * ptdw->Sinv_idm_dr;
  }
  /* idm_b steady state */
  else if (pth->has_idm_b == _TRUE_ && pth->n_index_idm_b == -3) {
    FHe = 1-pth->YHe;
    m_b = _m_p_*_c_*_c_/_eV_;
    /* This is super-highly approximated, and will not usually be correct. However, the small error we incur should be corrected by the evolution equation */
    T_diff_idm_b = (pba->T_cmb*(1.+z_ini)*_k_B_/_eV_/m_b)+(pba->T_cmb*(1.+z_ini)*_k_B_/_eV_/pth->m_idm)+(1.e-8/3.0);
    ptdw->R_idm_b = (pvecback[pba->index_bg_a]*pvecback[pba->index_bg_rho_b]*pth->cross_idm_b*pth->n_coeff_idm_b/(m_b+pth->m_idm))
      *pow(T_diff_idm_b,(pth->n_index_idm_b+1.0)/2.0)*FHe
      *(3.e-4*pow(_c_,4.)/(8.*_PI_*_Mpc_over_m_*_G_*_eV_));
    alpha = 2.*pth->m_idm/(pth->m_idm + m_b)*ptdw->R_idm_b;
  }

  /* This formula (assuming alpha,beta,epsilon=const) approximates the steady-state solution of the IDM temperature evolution equation */
  ptdw->T_idm = (alpha + beta + epsilon * pba->T_idr/pba->T_cmb)/(1.+epsilon+alpha+beta) * pba->T_cmb * (1.+z_ini);

  free(pvecback);

  return _SUCCESS_;
}

// Assembly:
subq $0x10a8, %rsp           # imm = 0x10A8
movq %rdi, 0x1098(%rsp)
movq %rsi, 0x1090(%rsp)
movsd %xmm0, 0x1088(%rsp)
movq %rdx, 0x1080(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1050(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1048(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1040(%rsp)
movq 0x1098(%rsp), %rax
movslq 0x43c(%rax), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x1078(%rsp)
cmpq $0x0, 0x1078(%rsp)
jne 0xc3cf6
movq 0x1098(%rsp), %rax
movslq 0x43c(%rax), %rax
shlq $0x3, %rax
movl %eax, 0x103c(%rsp)
leaq 0x830(%rsp), %rdi
movl 0x103c(%rsp), %ecx
leaq 0x10e35d(%rip), %rsi    # 0x1d2004
leaq 0x1355c9(%rip), %rdx    # 0x1f9277
movb $0x0, %al
callq 0x5b9c0
movq 0x1098(%rsp), %rdi
addq $0xd1c, %rdi            # imm = 0xD1C
leaq 0x830(%rsp), %r8
leaq 0x10e361(%rip), %rsi    # 0x1d2034
leaq 0x1324eb(%rip), %rdx    # 0x1f61c5
movl $0x127c, %ecx           # imm = 0x127C
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x10a4(%rsp)
jmp 0xc4327
movq 0x1098(%rsp), %rdi
movsd 0x1088(%rsp), %xmm0
movq 0x1078(%rsp), %r8
movl $0x2, %esi
xorl %edx, %edx
leaq 0x1074(%rsp), %rcx
callq 0x9e4b0
cmpl $0x1, %eax
jne 0xc3d8f
leaq 0x30(%rsp), %rdi
movq 0x1098(%rsp), %rcx
addq $0xd1c, %rcx            # imm = 0xD1C
leaq 0x10e695(%rip), %rsi    # 0x1d23d8
leaq 0x1324a2(%rip), %rdx    # 0x1f61ec
movb $0x0, %al
callq 0x5b9c0
movq 0x1090(%rsp), %rdi
addq $0x1064, %rdi           # imm = 0x1064
leaq 0x30(%rsp), %r8
leaq 0x10e2c8(%rip), %rsi    # 0x1d2034
leaq 0x132452(%rip), %rdx    # 0x1f61c5
movl $0x1284, %ecx           # imm = 0x1284
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x10a4(%rsp)
jmp 0xc4327
movq 0x1090(%rsp), %rax
movswl 0x38(%rax), %eax
cmpl $0x1, %eax
jne 0xc3ed8
movq 0x1090(%rsp), %rax
movsd 0x1028(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc3ed8
jp 0xc3ed8
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x3b0(%rcx), %rcx
movsd 0x12d7c2(%rip), %xmm0   # 0x1f15a8
mulsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x398(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movq 0x1090(%rsp), %rax
mulsd 0x1018(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x10e423(%rip), %xmm0   # 0x1d2248
addsd 0x1088(%rsp), %xmm0
movsd 0x12d692(%rip), %xmm1   # 0x1f14c8
divsd %xmm1, %xmm0
movq 0x1090(%rsp), %rax
movsd 0x1028(%rax), %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
mulsd 0xf0(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x1098(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10edf9(%rip), %xmm1   # 0x1d2c80
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x384(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movsd 0x10e38b(%rip), %xmm1   # 0x1d2248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1040(%rsp)
jmp 0xc427d
movq 0x1090(%rsp), %rax
movswl 0x36(%rax), %eax
cmpl $0x1, %eax
jne 0xc401e
movq 0x1090(%rsp), %rax
cmpl $-0x2, 0x1058(%rax)
jne 0xc401e
movq 0x1090(%rsp), %rax
movsd 0x1018(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10e328(%rip), %xmm0   # 0x1d2248
addsd 0x1088(%rsp), %xmm0
movsd 0x12d597(%rip), %xmm1   # 0x1f14c8
divsd %xmm1, %xmm0
movq 0x1090(%rsp), %rax
movsd 0x1028(%rax), %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
mulsd 0xf0(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x1098(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10ecfe(%rip), %xmm1   # 0x1d2c80
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x58(%rax)
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x3b0(%rcx), %rcx
movsd 0x111550(%rip), %xmm0   # 0x1d5510
mulsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x398(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x68(%rax)
movq 0x1080(%rsp), %rax
movsd 0x10ec82(%rip), %xmm0   # 0x1d2c80
mulsd 0x58(%rax), %xmm0
movq 0x1080(%rsp), %rax
mulsd 0x68(%rax), %xmm0
movsd %xmm0, 0x1050(%rsp)
jmp 0xc427b
movq 0x1090(%rsp), %rax
movswl 0x34(%rax), %eax
cmpl $0x1, %eax
jne 0xc4279
movq 0x1090(%rsp), %rax
cmpl $-0x3, 0x1038(%rax)
jne 0xc4279
movq 0x1090(%rsp), %rax
movsd 0x10e1f0(%rip), %xmm0   # 0x1d2248
subsd (%rax), %xmm0
movsd %xmm0, 0x1060(%rsp)
movsd 0x12d453(%rip), %xmm0   # 0x1f14c0
movsd %xmm0, 0x1068(%rsp)
movq 0x1098(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x10e1bd(%rip), %xmm1   # 0x1d2248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x1125a0(%rip), %xmm1   # 0x1d6640
mulsd %xmm1, %xmm0
movsd 0x11274c(%rip), %xmm1   # 0x1d67f8
divsd %xmm1, %xmm0
divsd 0x1068(%rsp), %xmm0
movq 0x1098(%rsp), %rax
movsd 0x18(%rax), %xmm1
movsd 0x10e17a(%rip), %xmm2   # 0x1d2248
addsd 0x1088(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x11255d(%rip), %xmm2   # 0x1d6640
mulsd %xmm2, %xmm1
movsd 0x112709(%rip), %xmm2   # 0x1d67f8
divsd %xmm2, %xmm1
movq 0x1090(%rsp), %rax
divsd 0x1010(%rax), %xmm1
addsd %xmm1, %xmm0
movsd 0x12d491(%rip), %xmm1   # 0x1f15a0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1058(%rsp)
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x380(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x390(%rcx), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq 0x1090(%rsp), %rax
mulsd 0x1030(%rax), %xmm0
movq 0x1090(%rsp), %rax
mulsd 0x1040(%rax), %xmm0
movsd 0x1068(%rsp), %xmm1
movq 0x1090(%rsp), %rax
addsd 0x1010(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd 0x1058(%rsp), %xmm0
movq 0x1090(%rsp), %rax
cvtsi2sdl 0x1038(%rax), %xmm1
movsd 0x10e091(%rip), %xmm2   # 0x1d2248
addsd %xmm2, %xmm1
movsd 0x10eabd(%rip), %xmm2   # 0x1d2c80
divsd %xmm2, %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd 0x1060(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x112441(%rip), %xmm0   # 0x1d6630
movsd 0x1112d1(%rip), %xmm1   # 0x1d54c8
callq 0x8610
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
movsd 0x12d2a3(%rip), %xmm1   # 0x1f14b0
mulsd %xmm2, %xmm1
movsd 0x12d28f(%rip), %xmm2   # 0x1f14a8
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movq 0x1090(%rsp), %rax
movsd 0x10ea42(%rip), %xmm0   # 0x1d2c80
mulsd 0x1010(%rax), %xmm0
movq 0x1090(%rsp), %rax
movsd 0x1010(%rax), %xmm1
addsd 0x1068(%rsp), %xmm1
divsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
mulsd 0x30(%rax), %xmm0
movsd %xmm0, 0x1050(%rsp)
jmp 0xc427b
jmp 0xc427d
movsd 0x1050(%rsp), %xmm0
addsd 0x1048(%rsp), %xmm0
movsd 0x1040(%rsp), %xmm1
movq 0x1098(%rsp), %rax
mulsd 0x100(%rax), %xmm1
movq 0x1098(%rsp), %rax
divsd 0x18(%rax), %xmm1
addsd %xmm1, %xmm0
movsd 0x10df87(%rip), %xmm1   # 0x1d2248
addsd 0x1040(%rsp), %xmm1
addsd 0x1050(%rsp), %xmm1
addsd 0x1048(%rsp), %xmm1
divsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
mulsd 0x18(%rax), %xmm0
movsd 0x10df53(%rip), %xmm1   # 0x1d2248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x38(%rax)
movq 0x1078(%rsp), %rdi
callq 0x8420
movl $0x0, 0x10a4(%rsp)
movl 0x10a4(%rsp), %eax
addq $0x10a8, %rsp           # imm = 0x10A8
retq
nopw %cs:(%rax,%rax)