// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HyRec2020/energy_injection.c
// Function: dEdtdV_DM_ann
double dEdtdV_DM_ann(double z, INJ_PARAMS *params){

  double pann_tot, u_min, erfc;
  double zp1, zp1_ann, zp1_max, zp1_min, var, zp1_halo;                        
   
  var       = params->ann_var;
  zp1       = z + 1.; 
  zp1_ann   = params->ann_z + 1.;
  zp1_max   = params->ann_zmax + 1.; 
  zp1_halo  = params->ann_z_halo + 1.; 
  zp1_min   = params->ann_zmin + 1.; 
  
  pann_tot = 0.;
  
  /* Dark matter annihilation in the smooth background */
  if (params->pann > 0.) {

    /* Parametrized variation of pann */
    if (zp1 > zp1_max) pann_tot = params->pann *exp(-var *square(log(zp1_ann/zp1_max)));
    else if (zp1 > zp1_min) {
      pann_tot = params->pann *exp(var*(-square(log(zp1_ann/zp1_max))
				+square(log(zp1/zp1_max))));
    }
    else {
      pann_tot = params->pann *exp(var*(-square(log(zp1_ann/zp1_max))
				+square(log(zp1_min/zp1_max))));
    }
	pann_tot = pann_tot*pow(zp1,3.);
  }
  
  /* Dark matter annihilation in haloes */
  if (params->pann_halo > 0.) {
    u_min = zp1/zp1_halo;
    erfc  = pow(1.+0.278393*u_min+0.230389*u_min*u_min+0.000972*u_min*u_min*u_min+0.078108*u_min*u_min*u_min*u_min,-4); 
    pann_tot += params->pann_halo *erfc;
  }
  
  return square(10537.4*params->odmh2) * zp1*zp1*zp1*1e-9* pann_tot
        +10537.4*params->odmh2*pow((1+z),3)*params->decay;
  /* the prefactor is 3 H100^2/(8 Pi G) c^2 in eV/cm^3, H100 = 100km/s/Mpc */
  /* pann is given in cm^3/s/GeV, multiply by 1e-9 to get cm^3/s/eV */
  
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
movsd 0x8(%rdi), %xmm1
movsd 0x11897(%rip), %xmm4    # 0xee260
addsd %xmm4, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x38(%rdi), %xmm2
addsd %xmm4, %xmm2
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
xorpd %xmm0, %xmm0
jbe 0xdcacd
movsd %xmm1, 0x8(%rsp)
movsd %xmm2, (%rsp)
movsd 0x30(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x20(%rbx), %xmm1
addsd %xmm4, %xmm1
movsd %xmm1, 0x38(%rsp)
addsd 0x28(%rbx), %xmm4
movsd %xmm4, 0x30(%rsp)
movsd 0x18(%rbx), %xmm0
addsd 0x11836(%rip), %xmm0    # 0xee260
divsd %xmm1, %xmm0
callq 0x82c0
callq 0xd3754
movsd 0x38(%rsp), %xmm3
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm2
ucomisd %xmm3, %xmm2
jbe 0xdca5e
movapd 0x20(%rsp), %xmm0
xorpd 0x117d4(%rip), %xmm0    # 0xee230
jmp 0xdca8e
movsd %xmm1, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm2
jbe 0xdca74
movapd %xmm2, %xmm0
divsd %xmm3, %xmm0
callq 0x82c0
callq 0xd3754
subsd 0x18(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x8670
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x12bcd(%rip), %xmm1    # 0xef680
movsd 0x10(%rsp), %xmm0
callq 0x8620
mulsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm2
xorpd %xmm3, %xmm3
movsd %xmm0, (%rsp)
movsd 0x10(%rbx), %xmm0
ucomisd %xmm3, %xmm0
jbe 0xdcb67
movsd 0x10(%rsp), %xmm1
divsd %xmm2, %xmm1
movsd 0x4e9c5(%rip), %xmm0    # 0x12b4b8
mulsd %xmm1, %xmm0
addsd 0x11761(%rip), %xmm0    # 0xee260
movsd 0x4e9b9(%rip), %xmm2    # 0x12b4c0
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd 0x4e9ad(%rip), %xmm3    # 0x12b4c8
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
movsd 0x4e99d(%rip), %xmm0    # 0x12b4d0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movsd 0x14919(%rip), %xmm1    # 0xf1468
callq 0x8620
mulsd 0x10(%rbx), %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd 0x4e969(%rip), %xmm1    # 0x12b4d8
movsd %xmm1, 0x8(%rsp)
movsd (%rbx), %xmm0
mulsd %xmm1, %xmm0
callq 0xd3754
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd 0x12af0(%rip), %xmm1    # 0xef690
mulsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
movsd 0x8(%rsp), %xmm1
mulsd (%rbx), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x12abe(%rip), %xmm1    # 0xef680
callq 0x8620
mulsd 0x8(%rsp), %xmm0
mulsd 0x40(%rbx), %xmm0
addsd (%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
retq