// File: /workspace/github_c_makefile_star2_O0/lesgourg[P]class_public/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)) {
    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); // constant
    ptdw->Sinv_idm_dr  = 4./3.*pvecback[pba->index_bg_rho_idr]/pvecback[pba->index_bg_rho_idm]; // propto (1+z_ini)
    epsilon = 2*ptdw->Sinv_idm_dr*ptdw->dmu_idm_dr / pvecback[pba->index_bg_H]*(1.+z_ini); // constant
  }
  /* idm_g steady state */
  else if (pth->has_idm_g == _TRUE_ && pth->n_index_idm_g == -2) {
    ptdw->dmu_idm_g =  3./8./_PI_/_G_*pow(1.+z_ini, 2+pth->n_index_idm_g)*pba->Omega0_idm*pba->H0*pba->H0*pth->u_idm_g*pow(_c_,4)*_sigma_/1.e11/_eV_/_Mpc_over_m_; // constant
    beta = 2.*4./3. * pvecback[pba->index_bg_rho_g]/pvecback[pba->index_bg_rho_idm] * ptdw->dmu_idm_g / pvecback[pba->index_bg_H] * (1+z_ini); // constant
  }
  /* 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; // approximately constant
  }

  /* 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 0x2b0(%rax), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x1078(%rsp)
cmpq $0x0, 0x1078(%rsp)
jne 0xb37e6
movq 0x1098(%rsp), %rax
movslq 0x2b0(%rax), %rax
shlq $0x3, %rax
movl %eax, 0x103c(%rsp)
leaq 0x830(%rsp), %rdi
movl 0x103c(%rsp), %ecx
leaq 0x10386d(%rip), %rsi    # 0x1b7004
leaq 0x126dbe(%rip), %rdx    # 0x1da55c
movb $0x0, %al
callq 0x5b9c0
movq 0x1098(%rsp), %rdi
addq $0xb84, %rdi            # imm = 0xB84
leaq 0x830(%rsp), %r8
leaq 0x103871(%rip), %rsi    # 0x1b7034
leaq 0x123e4b(%rip), %rdx    # 0x1d7615
movl $0x127d, %ecx           # imm = 0x127D
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x10a4(%rsp)
jmp 0xb3e93
movq 0x1098(%rsp), %rdi
movsd 0x1088(%rsp), %xmm0
movq 0x1078(%rsp), %r8
movl $0x2, %esi
xorl %edx, %edx
leaq 0x1074(%rsp), %rcx
callq 0x92e90
cmpl $0x1, %eax
jne 0xb387f
leaq 0x30(%rsp), %rdi
movq 0x1098(%rsp), %rcx
addq $0xb84, %rcx            # imm = 0xB84
leaq 0x103ba5(%rip), %rsi    # 0x1b73d8
leaq 0x123e02(%rip), %rdx    # 0x1d763c
movb $0x0, %al
callq 0x5b9c0
movq 0x1090(%rsp), %rdi
addq $0x1064, %rdi           # imm = 0x1064
leaq 0x30(%rsp), %r8
leaq 0x1037d8(%rip), %rsi    # 0x1b7034
leaq 0x123db2(%rip), %rdx    # 0x1d7615
movl $0x1285, %ecx           # imm = 0x1285
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x10a4(%rsp)
jmp 0xb3e93
movq 0x1090(%rsp), %rax
movswl 0x38(%rax), %eax
cmpl $0x1, %eax
jne 0xb3a01
movq 0x1090(%rsp), %rax
movsd 0x1028(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb3a01
jp 0xb3a01
movq 0x1090(%rsp), %rax
movsd 0x1018(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x103973(%rip), %xmm0   # 0x1b7248
addsd 0x1088(%rsp), %xmm0
movsd 0x11f02a(%rip), %xmm1   # 0x1d2910
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 0x38(%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x1098(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10434c(%rip), %xmm1   # 0x1b7c80
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x58(%rax)
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x230(%rcx), %rcx
movsd 0x106b9e(%rip), %xmm0   # 0x1ba510
mulsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x220(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x68(%rax)
movq 0x1080(%rsp), %rax
movsd 0x1042d0(%rip), %xmm0   # 0x1b7c80
mulsd 0x68(%rax), %xmm0
movq 0x1080(%rsp), %rax
mulsd 0x58(%rax), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x20c(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movsd 0x103862(%rip), %xmm1   # 0x1b7248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1040(%rsp)
jmp 0xb3dec
movq 0x1090(%rsp), %rax
movswl 0x36(%rax), %eax
cmpl $0x1, %eax
jne 0xb3b8b
movq 0x1090(%rsp), %rax
cmpl $-0x2, 0x1058(%rax)
jne 0xb3b8b
movsd 0x103815(%rip), %xmm0   # 0x1b7248
addsd 0x1088(%rsp), %xmm0
movq 0x1090(%rsp), %rax
movl 0x1058(%rax), %eax
addl $0x2, %eax
cvtsi2sd %eax, %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x11ee87(%rip), %xmm0   # 0x1d28e8
mulsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
mulsd 0x38(%rax), %xmm0
movq 0x1098(%rsp), %rax
mulsd (%rax), %xmm0
movq 0x1098(%rsp), %rax
mulsd (%rax), %xmm0
movq 0x1090(%rsp), %rax
mulsd 0x1050(%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x107bc8(%rip), %xmm0   # 0x1bb670
movsd 0x106a18(%rip), %xmm1   # 0x1ba4c8
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd 0x107cc6(%rip), %xmm1   # 0x1bb790
mulsd %xmm1, %xmm0
movsd 0x107cb2(%rip), %xmm1   # 0x1bb788
divsd %xmm1, %xmm0
movsd 0x107cbe(%rip), %xmm1   # 0x1bb7a0
divsd %xmm1, %xmm0
movsd 0x107bf2(%rip), %xmm1   # 0x1bb6e0
divsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x48(%rax)
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x214(%rcx), %rcx
movsd 0x11eeda(%rip), %xmm0   # 0x1d29f8
mulsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x220(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movq 0x1080(%rsp), %rax
mulsd 0x48(%rax), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x20c(%rcx), %rcx
divsd (%rax,%rcx,8), %xmm0
movsd 0x1036d8(%rip), %xmm1   # 0x1b7248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1048(%rsp)
jmp 0xb3dea
movq 0x1090(%rsp), %rax
movswl 0x34(%rax), %eax
cmpl $0x1, %eax
jne 0xb3de8
movq 0x1090(%rsp), %rax
cmpl $-0x3, 0x1038(%rax)
jne 0xb3de8
movq 0x1090(%rsp), %rax
movsd 0x103683(%rip), %xmm0   # 0x1b7248
subsd (%rax), %xmm0
movsd %xmm0, 0x1060(%rsp)
movsd 0x11ed2e(%rip), %xmm0   # 0x1d2908
movsd %xmm0, 0x1068(%rsp)
movq 0x1098(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd 0x103650(%rip), %xmm1   # 0x1b7248
addsd 0x1088(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x107b0b(%rip), %xmm1   # 0x1bb718
mulsd %xmm1, %xmm0
movsd 0x107b87(%rip), %xmm1   # 0x1bb7a0
divsd %xmm1, %xmm0
divsd 0x1068(%rsp), %xmm0
movq 0x1098(%rsp), %rax
movsd 0x18(%rax), %xmm1
movsd 0x10360d(%rip), %xmm2   # 0x1b7248
addsd 0x1088(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x107ac8(%rip), %xmm2   # 0x1bb718
mulsd %xmm2, %xmm1
movsd 0x107b44(%rip), %xmm2   # 0x1bb7a0
divsd %xmm2, %xmm1
movq 0x1090(%rsp), %rax
divsd 0x1010(%rax), %xmm1
addsd %xmm1, %xmm0
movsd 0x11ed74(%rip), %xmm1   # 0x1d29f0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1058(%rsp)
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x208(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
movq 0x1098(%rsp), %rcx
movslq 0x218(%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, 0x8(%rsp)
movsd 0x1058(%rsp), %xmm0
movq 0x1090(%rsp), %rax
cvtsi2sdl 0x1038(%rax), %xmm1
movsd 0x103523(%rip), %xmm2   # 0x1b7248
addsd %xmm2, %xmm1
movsd 0x103f4f(%rip), %xmm2   # 0x1b7c80
divsd %xmm2, %xmm1
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
mulsd 0x1060(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x107912(%rip), %xmm0   # 0x1bb670
movsd 0x106762(%rip), %xmm1   # 0x1ba4c8
callq 0x8610
movaps %xmm0, %xmm2
movsd 0x10(%rsp), %xmm0
movsd 0x11eb7c(%rip), %xmm1   # 0x1d28f8
mulsd %xmm2, %xmm1
movsd 0x11eb68(%rip), %xmm2   # 0x1d28f0
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x1080(%rsp), %rax
movsd %xmm0, 0x30(%rax)
movq 0x1090(%rsp), %rax
movsd 0x103ed3(%rip), %xmm0   # 0x1b7c80
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 0xb3dea
jmp 0xb3dec
movsd 0x1050(%rsp), %xmm0
addsd 0x1048(%rsp), %xmm0
movsd 0x1040(%rsp), %xmm1
movq 0x1098(%rsp), %rax
mulsd 0x48(%rax), %xmm1
movq 0x1098(%rsp), %rax
divsd 0x18(%rax), %xmm1
addsd %xmm1, %xmm0
movsd 0x10341b(%rip), %xmm1   # 0x1b7248
addsd 0x1040(%rsp), %xmm1
addsd 0x1050(%rsp), %xmm1
addsd 0x1048(%rsp), %xmm1
divsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
mulsd 0x18(%rax), %xmm0
movsd 0x1033e7(%rip), %xmm1   # 0x1b7248
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)