// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/heating/injection.c
// Function: injection_rate_PBH_accretion
int injection_rate_PBH_accretion(struct injection * pin,
                                 double z,
                                 double * energy_rate){

  /** - Define local variables */
  double L_ed, M_ed_dot, M_crit, v_B, v_l, v_eff, r_B, t_B;
  double lambda, M_b_dot;
  double Value_min, Value_med, Value_max, a=0, epsilon_0=0.1, epsilon;
  double L_acc;
  double beta_compton_drag, gamma_cooling, tau_cooling;
  double T_ion, T_s, Y_s, theta_s;
  double lambda_1, lambda_2, lambda_ad, lambda_iso, J;

  /** - Initialize local variables */
  /* Eddington luminosity */
  L_ed = 4.*_PI_*_G_*(pin->PBH_accretion_mass*_Sun_mass_)*_m_p_/_sigma_*_c_;                        // [W]
  M_ed_dot= 10.*L_ed/pow(_c_,2.);                                                                   // [kg/s]
  M_crit = 0.01*M_ed_dot;                                                                           // [kg/s]

  /* Boldi definitions */
  v_B = sqrt((1.+pin->x_e)*(pin->T_b*_k_B_)/(_m_p_*pow(_c_,2.)))*_c_;                               // [m/s]
  if(pin->PBH_accretion_relative_velocities < 0.){
    v_l = 30.*MIN(1.,(1.+z)/1.e3)*1.e3;                                                             // [m/s]
    if(v_B < v_l){
      v_eff = sqrt(v_B*v_l);                                                                        // [m/s]
    }
    else{
      v_eff = v_B;                                                                                  // [m/s]
    }
  }
  else{
    v_l = pin->PBH_accretion_relative_velocities*1.e3;                                              // [m/s]
    v_eff = pow(v_l*v_l+v_B*v_B,0.5);                                                               // [m/s]
  }
  r_B = _G_*(pin->PBH_accretion_mass*_Sun_mass_)/pow(v_eff,2.);                                     // [m]
  t_B = _G_*(pin->PBH_accretion_mass*_Sun_mass_)/pow(v_eff,3.);                                     // [s]

  switch(pin->PBH_accretion_recipe){
    /** - Disk accretion from Poulin et al. 1707.04206 */
    case disk_accretion:

    lambda = pin->PBH_accretion_eigenvalue;                                                         // [-]
    M_b_dot = 4.*_PI_*lambda*(pin->rho_b/pow(_c_,2.))*pow(r_B,2.)*v_eff;                            // [kg/s]

    if(pin->PBH_accretion_ADAF_delta == 1e-3){
      Value_min = 7.6e-5;
      Value_med = 4.5e-3;
      Value_max = 7.1e-3;
      if(M_b_dot/M_ed_dot <= Value_min){
        epsilon_0 = 0.065;
        a = 0.71;
      }
      else if(Value_min < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot  <= Value_med){
        epsilon_0 = 0.020;
        a = 0.47;
      }
      else if(Value_med < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot <= Value_max){
        epsilon_0 = 0.26;
        a = 3.67;
      }
      else{
        epsilon_0 = 0.1;
        a = 0.;
      }
    }
    else if(pin->PBH_accretion_ADAF_delta == 0.1){
      Value_min = 9.4e-5;
      Value_med = 5e-3;
      Value_max = 6.6e-3;
      if(M_b_dot/M_ed_dot <= Value_min){
        epsilon_0 = 0.12;
        a = 0.59;
      }
      else if(Value_min < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot  <= Value_med){
        epsilon_0 = 0.026;
        a = 0.27;
      }
      else if(Value_med < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot <= Value_max){
        epsilon_0 = 0.50;
        a = 4.53;
      }
      else{
        epsilon_0 = 0.1;
        a = 0.;
      }
    }
    else if (pin->PBH_accretion_ADAF_delta == 0.5){
      Value_min = 2.9e-5;
      Value_med = 3.3e-3;
      Value_max = 5.3e-3;
      if(M_b_dot/M_ed_dot <= Value_min){
        epsilon_0 = 1.58;
        a = 0.65;
      }
      else if(Value_min < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot  <= Value_med){
        epsilon_0 = 0.055;
        a = 0.076;
      }
      else if(Value_med < M_b_dot/M_ed_dot && M_b_dot/M_ed_dot <= Value_max){
        epsilon_0 = 0.17;
        a = 1.12;
      }
      else{
        epsilon_0 = 0.1;
        a = 0.;
      }
    }

    epsilon = epsilon_0*pow(M_b_dot/M_crit,a);                                                      // [-]
    L_acc = epsilon*M_b_dot*pow(_c_,2.);                                                            // [W]
  break;

    /** - Spherical accretion from Ali-Haimoud et al. 1612.05644 */
    case spherical_accretion:

    beta_compton_drag = 4./3.*pin->x_e*_sigma_*pin->rho_g*t_B/_m_p_/_c_;                            // [-] Eq. (7)
    gamma_cooling = 2.*(_m_p_/_m_e_)/(1+pin->x_e)*beta_compton_drag;                                // [-] Eq. (8)
    tau_cooling = 1.5/(5.+pow(gamma_cooling,2./3.));                                                // [-] Eq. (28)

    lambda_ad = 0.25*pow(3./5.,1.5);                                                                // [-] Eq. (15)
    lambda_iso = 0.25*exp(1.5);                                                                     // [-] Eq. (20)
    lambda_1 = lambda_ad+(lambda_iso-lambda_ad)*
                                pow(pow(gamma_cooling,2.)/(88.+pow(gamma_cooling,2.)),0.22);        // [-] Eq. (27)
    lambda_2 = exp(4.5/(3.+pow(beta_compton_drag,0.75)))/(pow(pow(1.+beta_compton_drag,0.5)+1.,2.));// [-] Eq. (32)
    lambda = lambda_1*lambda_2/lambda_iso;                                                          // [-] Eq. (33)

    T_ion = 1.5e4*_eV_over_Kelvin_;                                                                 // [eV] see line below Eq. (39)
    Y_s = pow((1.+pin->x_e)/2.,2./3.*13.6/T_ion)*
                  tau_cooling/4.*pow(1.-5./2.*tau_cooling,1./3.)*(_m_p_/_m_e_);                     // [-] Eq. (51)
    T_s = _m_e_*pow(_c_,2.)/_k_B_*Y_s*pow(1.+Y_s/0.27,-1./3.);                                      // [K] Eqs. (50) and (47)
    theta_s = (T_s*_k_B_)/(_m_e_*pow(_c_,2.));

    M_b_dot = 4.*_PI_*lambda*(pin->rho_b/pow(_c_,2.))*pow(r_B,2.)*v_eff;                            // [kg/s] Eq. (6)

    if(theta_s > 1.){                                                                               // Eq. (55)
      J = 27./(2.*_PI_)*(log(2.*theta_s*exp(-0.577)+0.08)+4./3.);                                   // [-]
    }
    else{
      J = 4./_PI_*sqrt(2./_PI_)*pow(theta_s,-0.5)*(1+5.5*pow(theta_s,1.25));                        // [-]
    }

    L_acc = 1./137.*(T_s*_k_B_)/(_m_p_*pow(_c_,2.))*J*pow(M_b_dot*_c_*_c_,2.)/L_ed;                 // [W] Eq. (57)
    break;
    default:
      class_stop(pin->error_message,"Invalid PBH_accretion_recipe");
  }

  *energy_rate = pin->rho_cdm*pin->PBH_accretion_fraction/
                      (pin->PBH_accretion_mass*_Sun_mass_)*L_acc/pow(_c_,2.);                       // [J/(m^3 s)]

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1040, %rsp           # imm = 0x1040
movq %rdi, %rbx
movsd 0x78(%rdi), %xmm3
mulsd 0x56a4d(%rip), %xmm3    # 0x128668
mulsd 0x56a4d(%rip), %xmm3    # 0x128670
mulsd 0x3baf5(%rip), %xmm3    # 0x10d720
movsd 0x438(%rdi), %xmm2
addsd 0x1c625(%rip), %xmm2    # 0xee260
movsd 0x430(%rdi), %xmm1
mulsd 0x20ff5(%rip), %xmm1    # 0xf2c40
movq %rsi, %r14
mulsd %xmm2, %xmm1
divsd 0x56a26(%rip), %xmm1    # 0x128680
movapd %xmm0, %xmm4
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm1
jb 0xd1c71
xorps %xmm2, %xmm2
sqrtsd %xmm1, %xmm2
jmp 0xd1c9a
movapd %xmm1, %xmm0
movsd %xmm3, 0x8(%rsp)
movsd %xmm4, 0x20(%rsp)
callq 0x82b0
xorpd %xmm5, %xmm5
movsd 0x20(%rsp), %xmm4
movsd 0x8(%rsp), %xmm3
movapd %xmm0, %xmm2
divsd 0x20fc6(%rip), %xmm3    # 0xf2c68
mulsd 0x20f46(%rip), %xmm2    # 0xf2bf0
movsd 0x88(%rbx), %xmm0
ucomisd %xmm0, %xmm5
jbe 0xd1d01
movsd 0x1c5a0(%rip), %xmm0    # 0xee260
addsd %xmm0, %xmm4
movsd 0x20f4c(%rip), %xmm1    # 0xf2c18
divsd %xmm1, %xmm4
minsd %xmm4, %xmm0
mulsd 0x20f34(%rip), %xmm0    # 0xf2c10
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xd1d32
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xd2243
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0xd1d32
mulsd 0x20f0f(%rip), %xmm0    # 0xf2c18
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
movsd 0x1cfb3(%rip), %xmm1    # 0xeecd0
movsd %xmm3, 0x8(%rsp)
callq 0x8620
movsd 0x8(%rsp), %xmm3
movapd %xmm0, %xmm2
mulsd 0x20eb6(%rip), %xmm3    # 0xf2bf0
movsd %xmm3, 0x8(%rsp)
movsd 0x78(%rbx), %xmm1
mulsd 0x5691b(%rip), %xmm1    # 0x128668
mulsd 0x20da3(%rip), %xmm1    # 0xf2af8
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm1, 0x10(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0x1d90b(%rip), %xmm1    # 0xef680
movsd %xmm2, 0x20(%rsp)
movapd %xmm2, %xmm0
callq 0x8620
movl 0x80(%rbx), %eax
testl %eax, %eax
je 0xd1e64
cmpl $0x1, %eax
jne 0xd20e8
movsd 0x8(%rsp), %xmm5
mulsd 0x1ca47(%rip), %xmm5    # 0xee7f0
divsd 0x568c7(%rip), %xmm5    # 0x128678
movsd 0x1f207(%rip), %xmm2    # 0xf0fc0
movsd 0x98(%rbx), %xmm1
mulsd 0x20ed7(%rip), %xmm1    # 0xf2ca0
mulsd %xmm5, %xmm2
movsd 0x408(%rbx), %xmm3
divsd 0x5689b(%rip), %xmm3    # 0x128678
movsd 0x90(%rbx), %xmm0
mulsd %xmm1, %xmm3
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm3, %xmm1
movsd 0x20(%rsp), %xmm4
mulsd %xmm1, %xmm4
ucomisd 0x1cf3f(%rip), %xmm0    # 0xeed48
jne 0xd21e0
jp 0xd21e0
movapd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd 0x5697b(%rip), %xmm1    # 0x1287a0
ucomisd %xmm0, %xmm1
jae 0xd2253
ucomisd 0x56969(%rip), %xmm0    # 0x1287a0
jbe 0xd2268
movsd 0x56973(%rip), %xmm1    # 0x1287b8
ucomisd %xmm0, %xmm1
jb 0xd2268
movsd 0x56951(%rip), %xmm1    # 0x1287a8
movsd 0x56951(%rip), %xmm0    # 0x1287b0
jmp 0xd235f
movsd 0x438(%rbx), %xmm1
movsd 0x1f64c(%rip), %xmm2    # 0xf14c0
mulsd %xmm1, %xmm2
mulsd 0x20de8(%rip), %xmm2    # 0xf2c68
mulsd 0x400(%rbx), %xmm2
movsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm3
mulsd %xmm3, %xmm2
divsd 0x3b882(%rip), %xmm2    # 0x10d720
divsd 0x20d4a(%rip), %xmm2    # 0xf2bf0
movsd %xmm2, 0x18(%rsp)
addsd 0x1c3ac(%rip), %xmm1    # 0xee260
movsd 0x567cc(%rip), %xmm0    # 0x128688
divsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1f61e(%rip), %xmm1    # 0xf14f0
callq 0x8620
addsd 0x1c391(%rip), %xmm0    # 0xee270
movsd 0x1f0e1(%rip), %xmm1    # 0xf0fc8
divsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x5678d(%rip), %xmm0    # 0x128690
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd 0x56781(%rip), %xmm1    # 0x128698
callq 0x8620
mulsd 0x5677c(%rip), %xmm0    # 0x1286a0
addsd 0x5677c(%rip), %xmm0    # 0x1286a8
movsd %xmm0, 0x30(%rsp)
movsd 0x20c1e(%rip), %xmm1    # 0xf2b58
movsd 0x18(%rsp), %xmm0
callq 0x8620
addsd 0x1d733(%rip), %xmm0    # 0xef680
movsd 0x4065b(%rip), %xmm1    # 0x1125b0
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x8670
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x1c2ea(%rip), %xmm0    # 0xee260
movsd 0x1cd52(%rip), %xmm1    # 0xeecd0
callq 0x8620
movsd 0x1c2d5(%rip), %xmm1    # 0xee260
addsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm2
divsd %xmm0, %xmm2
mulsd 0x30(%rsp), %xmm2
divsd 0x56705(%rip), %xmm2    # 0x1286b0
movsd %xmm2, 0x10(%rsp)
movsd 0x438(%rbx), %xmm0
addsd %xmm1, %xmm0
mulsd 0x1cd0b(%rip), %xmm0    # 0xeecd0
movsd 0x566eb(%rip), %xmm1    # 0x1286b8
callq 0x8620
movsd 0x38(%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd 0x1f59c(%rip), %xmm0    # 0xf1580
movsd %xmm0, 0x18(%rsp)
mulsd 0x566ce(%rip), %xmm1    # 0x1286c0
addsd 0x1c266(%rip), %xmm1    # 0xee260
movapd %xmm1, %xmm0
movsd 0x1f442(%rip), %xmm1    # 0xf1448
callq 0x8620
mulsd 0x18(%rsp), %xmm0
mulsd 0x566af(%rip), %xmm0    # 0x1286c8
movsd 0x566af(%rip), %xmm1    # 0x1286d0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
divsd 0x566a5(%rip), %xmm0    # 0x1286d8
addsd 0x1c225(%rip), %xmm0    # 0xee260
movsd 0x20afd(%rip), %xmm1    # 0xf2b40
callq 0x8620
movapd %xmm0, %xmm2
mulsd 0x18(%rsp), %xmm2
mulsd 0x20be6(%rip), %xmm2    # 0xf2c40
movsd %xmm2, 0x18(%rsp)
divsd 0x56678(%rip), %xmm2    # 0x1286e0
movsd 0x10(%rsp), %xmm1
mulsd 0x20c2a(%rip), %xmm1    # 0xf2ca0
movsd 0x408(%rbx), %xmm0
divsd 0x565f2(%rip), %xmm0    # 0x128678
mulsd %xmm1, %xmm0
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
ucomisd 0x1c1b0(%rip), %xmm2    # 0xee260
jbe 0xd214b
addsd %xmm2, %xmm2
mulsd 0x56636(%rip), %xmm2    # 0x1286f8
addsd 0x56636(%rip), %xmm2    # 0x128700
movapd %xmm2, %xmm0
callq 0x82c0
addsd 0x1f3e5(%rip), %xmm0    # 0xf14c0
mulsd 0x56625(%rip), %xmm0    # 0x128708
jmp 0xd2199
leaq 0x572bc(%rip), %rsi     # 0x1293ab
leaq 0x840(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x1c47d(%rip), %rsi     # 0xee585
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30af0
addq $0x570, %rbx            # imm = 0x570
leaq 0x1bf0c(%rip), %rsi     # 0xee034
leaq 0x57299(%rip), %rdx     # 0x1293c8
movq %rbx, %rdi
movl $0x45b, %ecx            # imm = 0x45B
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
jmp 0xd23c4
movsd 0x1f325(%rip), %xmm1    # 0xf1478
movapd %xmm2, %xmm0
movsd %xmm2, 0x10(%rsp)
callq 0x8620
mulsd 0x5657e(%rip), %xmm0    # 0x1286e8
movsd %xmm0, 0x28(%rsp)
movsd 0x1cb48(%rip), %xmm1    # 0xeecc0
movsd 0x10(%rsp), %xmm0
callq 0x8620
mulsd 0x56565(%rip), %xmm0    # 0x1286f0
addsd 0x1c0cd(%rip), %xmm0    # 0xee260
mulsd 0x28(%rsp), %xmm0
movsd 0x18(%rsp), %xmm2
mulsd 0x56569(%rip), %xmm2    # 0x128710
divsd 0x564d1(%rip), %xmm2    # 0x128680
mulsd %xmm0, %xmm2
movsd 0x20a35(%rip), %xmm0    # 0xf2bf0
movsd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm1
divsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
jmp 0xd238c
ucomisd 0x1c0a8(%rip), %xmm0    # 0xee290
jne 0xd229d
jp 0xd229d
movapd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd 0x56564(%rip), %xmm1    # 0x128768
ucomisd %xmm0, %xmm1
jae 0xd2305
ucomisd 0x56552(%rip), %xmm0    # 0x128768
jbe 0xd2317
movsd 0x56554(%rip), %xmm1    # 0x128778
ucomisd %xmm0, %xmm1
jb 0xd2317
movsd 0x564a2(%rip), %xmm1    # 0x1286d8
movsd 0x56532(%rip), %xmm0    # 0x128770
jmp 0xd235f
movsd %xmm3, 0x8(%rsp)
callq 0x82b0
jmp 0xd1d28
movsd 0x56535(%rip), %xmm1    # 0x128790
movsd 0x56535(%rip), %xmm0    # 0x128798
jmp 0xd235f
ucomisd 0x56548(%rip), %xmm0    # 0x1287b8
jbe 0xd2341
movsd 0x56552(%rip), %xmm1    # 0x1287d0
ucomisd %xmm0, %xmm1
jb 0xd2341
movsd 0x56530(%rip), %xmm1    # 0x1287c0
movsd 0x56530(%rip), %xmm0    # 0x1287c8
jmp 0xd235f
xorpd %xmm1, %xmm1
movsd 0x1bfe7(%rip), %xmm6    # 0xee290
ucomisd 0x1ca1f(%rip), %xmm0    # 0xeecd0
jne 0xd23fe
jp 0xd23fe
movapd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd 0x5645b(%rip), %xmm3    # 0x128728
ucomisd %xmm0, %xmm3
jae 0xd234f
ucomisd 0x5644d(%rip), %xmm0    # 0x128728
jbe 0xd23d1
movsd 0x56457(%rip), %xmm3    # 0x128740
ucomisd %xmm0, %xmm3
jb 0xd23d1
movsd 0x56435(%rip), %xmm1    # 0x128730
movsd 0x56435(%rip), %xmm0    # 0x128738
jmp 0xd235f
movsd 0x56453(%rip), %xmm1    # 0x128760
movsd 0x20983(%rip), %xmm0    # 0xf2c98
jmp 0xd235f
ucomisd 0x56459(%rip), %xmm0    # 0x128778
jbe 0xd2341
movsd 0x5645f(%rip), %xmm1    # 0x128788
ucomisd %xmm0, %xmm1
jb 0xd2341
movsd 0x56449(%rip), %xmm1    # 0x128780
movsd 0x1c991(%rip), %xmm0    # 0xeecd0
jmp 0xd235f
xorpd %xmm1, %xmm1
movsd 0x1bf43(%rip), %xmm0    # 0xee290
jmp 0xd235f
movsd 0x563c1(%rip), %xmm1    # 0x128718
movsd 0x563c1(%rip), %xmm0    # 0x128720
movsd %xmm0, 0x8(%rsp)
movapd %xmm4, %xmm0
divsd %xmm2, %xmm0
movsd %xmm4, 0x20(%rsp)
callq 0x8620
mulsd 0x8(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
mulsd 0x562ec(%rip), %xmm0    # 0x128678
movupd 0x70(%rbx), %xmm1
movapd 0x56447(%rip), %xmm2    # 0x1287e0
movlpd 0x410(%rbx), %xmm2      # xmm2 = mem[0],xmm2[1]
mulpd %xmm1, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
divsd 0x562bb(%rip), %xmm2    # 0x128678
movsd %xmm2, (%r14)
xorl %eax, %eax
addq $0x1040, %rsp           # imm = 0x1040
popq %rbx
popq %r14
popq %r15
retq
ucomisd 0x56367(%rip), %xmm0    # 0x128740
jbe 0xd23fe
movsd 0x56375(%rip), %xmm3    # 0x128758
ucomisd %xmm0, %xmm3
jb 0xd23fe
movsd 0x56357(%rip), %xmm1    # 0x128748
movsd 0x56357(%rip), %xmm0    # 0x128750
jmp 0xd235f
movsd %xmm6, 0x8(%rsp)
jmp 0xd2365