// File: /workspace/github_c_makefile_star2_O1/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 0x11337(%rip), %xmm4    # 0xf1260
addsd %xmm4, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x38(%rdi), %xmm2
addsd %xmm4, %xmm2
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
xorpd %xmm0, %xmm0
jbe 0xe002d
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 0x112d6(%rip), %xmm0    # 0xf1260
divsd %xmm1, %xmm0
callq 0x82c0
callq 0xd6f4c
movsd 0x38(%rsp), %xmm3
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm2
ucomisd %xmm3, %xmm2
jbe 0xdffbe
movapd 0x20(%rsp), %xmm0
xorpd 0x11274(%rip), %xmm0    # 0xf1230
jmp 0xdffee
movsd %xmm1, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm2
jbe 0xdffd4
movapd %xmm2, %xmm0
divsd %xmm3, %xmm0
callq 0x82c0
callq 0xd6f4c
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 0x1266d(%rip), %xmm1    # 0xf2680
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 0xe00c7
movsd 0x10(%rsp), %xmm1
divsd %xmm2, %xmm1
movsd 0x4e435(%rip), %xmm0    # 0x12e488
mulsd %xmm1, %xmm0
addsd 0x11201(%rip), %xmm0    # 0xf1260
movsd 0x4e429(%rip), %xmm2    # 0x12e490
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd 0x4e41d(%rip), %xmm3    # 0x12e498
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
movsd 0x4e40d(%rip), %xmm0    # 0x12e4a0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm3, %xmm0
movsd 0x143a9(%rip), %xmm1    # 0xf4458
callq 0x8620
mulsd 0x10(%rbx), %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd 0x4e3d9(%rip), %xmm1    # 0x12e4a8
movsd %xmm1, 0x8(%rsp)
movsd (%rbx), %xmm0
mulsd %xmm1, %xmm0
callq 0xd6f4c
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd 0x12590(%rip), %xmm1    # 0xf2690
mulsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
movsd 0x8(%rsp), %xmm1
mulsd (%rbx), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x1255e(%rip), %xmm1    # 0xf2680
callq 0x8620
mulsd 0x8(%rsp), %xmm0
mulsd 0x40(%rbx), %xmm0
addsd (%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
retq