// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/distortions.c
// Function: distortions_compute_heating_rate
int distortions_compute_heating_rate(struct precision* ppr,
                                     struct background* pba,
                                     struct thermodynamics * pth,
                                     struct perturbations * ppt,
                                     struct primordial * ppm,
                                     struct distortions * psd){

  /** Define local variables */
  struct noninjection* pni = &(psd->ni);
  struct injection* pin = &(pth->in);

  int index_z;
  double tau;
  int last_index_back;
  double *pvecback;
  double heat;
  double H, a, rho_g;

  if (psd->include_only_exotic == _FALSE_) {
    /** Update heating table with second order contributions */
    class_call(noninjection_init(ppr,pba,pth,ppt,ppm,pni),
               pni->error_message,
               psd->error_message);
  }

  /** Allocate space for background vector */
  last_index_back = 0;
  class_alloc(pvecback,
              pba->bg_size*sizeof(double),
              psd->error_message);

  /** Allocate space for total heating function */
  class_alloc(psd->dQrho_dz_tot,
              psd->z_size*sizeof(double*),
              psd->error_message);

  /* Loop over z and calculate the heating at each point */
  for (index_z=0; index_z<psd->z_size; ++index_z){

    /** Import quantities from background structure */
    class_call(background_tau_of_z(pba,
                                   psd->z[index_z],
                                   &tau),
               pba->error_message,
               psd->error_message);
    class_call(background_at_tau(pba,
                                 tau,
                                 long_info,
                                 inter_closeby,
                                 &last_index_back,
                                 pvecback),
               pba->error_message,
               psd->error_message);
    H = pvecback[pba->index_bg_H]*_c_/_Mpc_over_m_;               // [1/s]
    a = pvecback[pba->index_bg_a];                                // [-]
    rho_g = pvecback[pba->index_bg_rho_g]*_Jm3_over_Mpc2_;        // [J/m^3]

    heat = 0;

    /** Import heat from non-injection structure */
    if (psd->include_only_exotic == _FALSE_) {
      class_call(noninjection_photon_heating_at_z(pni,
                                                  psd->z[index_z],
                                                  &heat),           // [J/(m^3 s)]
                 pni->error_message,
                 psd->error_message);
    }

    /** Add heat from injection structure */
    if (pth->has_exotic_injection == _TRUE_) {
      class_call(injection_deposition_at_z(pth,
                                           psd->z[index_z]),
                 pin->error_message,
                 psd->error_message);
      heat += pin->pvecdeposition[pin->index_dep_heat];
    }

    /** Calculate total heating rate */
    psd->dQrho_dz_tot[index_z] = heat*a/(H*rho_g);                // [-]
  }

  free(pvecback);

  if (psd->include_only_exotic == _FALSE_) {
    /** Update heating table with second order contributions */
    class_call(noninjection_free(pni),
               pni->error_message,
               psd->error_message);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movq %r9, %rbx
movq %rdx, %r15
movq %rsi, %r14
leaq 0xcf0(%r9), %r12
cmpl $0x0, 0xce4(%r9)
jne 0xc8d56
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %r9
callq 0xd26e8
cmpl $0x1, %eax
jne 0xc8d56
leaq 0xe00(%rbx), %rcx
leaq 0x256d2(%rip), %rsi     # 0xee3f0
leaq 0x5e0f3(%rip), %rdx     # 0x126e18
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x252f2(%rip), %rsi     # 0xee034
leaq 0x5e0fa(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x326, %ecx            # imm = 0x326
jmp 0xc9018
movl $0x0, 0x24(%rsp)
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xc8f96
movq %rax, %r13
movslq 0x330(%rbx), %rbp
movq %rbp, %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0xc00(%rbx)
testq %rax, %rax
je 0xc8fd7
testl %ebp, %ebp
jle 0xc8f28
xorl %ebp, %ebp
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x5c896
cmpl $0x1, %eax
je 0xc903b
movsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
leaq 0x24(%rsp), %rcx
movq %r13, %r8
callq 0x5c63f
cmpl $0x1, %eax
je 0xc9081
movslq 0x384(%r14), %rax
movsd (%r13,%rax,8), %xmm1
mulsd 0x29de4(%rip), %xmm1    # 0xf2bf0
divsd 0x29cd4(%rip), %xmm1    # 0xf2ae8
movslq 0x380(%r14), %rax
movsd (%r13,%rax,8), %xmm2
movslq 0x38c(%r14), %rax
movsd (%r13,%rax,8), %xmm3
mulsd 0x448c8(%rip), %xmm3    # 0x10d700
movq $0x0, (%rsp)
cmpl $0x0, 0xce4(%rbx)
jne 0xc8e8d
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r12, %rdi
movq %rsp, %rsi
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x10(%rsp)
movsd %xmm3, 0x8(%rsp)
callq 0xd35e5
movsd 0x8(%rsp), %xmm3
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm1
cmpl $0x1, %eax
je 0xc9116
cmpw $0x1, 0xb8(%r15)
jne 0xc8ef8
movsd %xmm3, 0x8(%rsp)
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r15, %rdi
callq 0xd2409
cmpl $0x1, %eax
je 0xc90cd
movq 0x610(%r15), %rax
movslq 0x5f8(%r15), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x18(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x8(%rsp), %xmm3
jmp 0xc8efd
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm2
mulsd %xmm3, %xmm1
divsd %xmm1, %xmm2
movq 0xc00(%rbx), %rax
movsd %xmm2, (%rax,%rbp,8)
incq %rbp
movslq 0x330(%rbx), %rax
cmpq %rax, %rbp
jl 0xc8dab
movq %r13, %rdi
callq 0x8410
xorl %ebp, %ebp
cmpl $0x0, 0xce4(%rbx)
jne 0xc9027
movq %r12, %rdi
callq 0xd3589
cmpl $0x1, %eax
jne 0xc9027
leaq 0xe00(%rbx), %rcx
leaq 0x25492(%rip), %rsi     # 0xee3f0
leaq 0x5e001(%rip), %rdx     # 0x126f66
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x250b2(%rip), %rsi     # 0xee034
leaq 0x5deba(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x367, %ecx            # imm = 0x367
jmp 0xc9018
shll $0x3, %ebp
leaq 0x25064(%rip), %rsi     # 0xee004
leaq 0x4c2eb(%rip), %rdx     # 0x115292
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2506e(%rip), %rsi     # 0xee034
leaq 0x5de76(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x32d, %ecx            # imm = 0x32D
jmp 0xc9018
leal (,%rbp,8), %ecx
leaq 0x2501f(%rip), %rsi     # 0xee004
leaq 0x5de78(%rip), %rdx     # 0x126e64
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2502b(%rip), %rsi     # 0xee034
leaq 0x5de33(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x332, %ecx            # imm = 0x332
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x253a7(%rip), %rsi     # 0xee3f0
leaq 0x5de26(%rip), %rdx     # 0x126e76
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24fc4(%rip), %rsi     # 0xee034
leaq 0x5ddcc(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x33c, %ecx            # imm = 0x33C
jmp 0xc90c5
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x25361(%rip), %rsi     # 0xee3f0
leaq 0x5de10(%rip), %rdx     # 0x126ea6
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24f7e(%rip), %rsi     # 0xee034
leaq 0x5dd86(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x344, %ecx            # imm = 0x344
movq %r15, %r8
jmp 0xc901b
addq $0x630, %r15            # imm = 0x630
leaq 0x25315(%rip), %rsi     # 0xee3f0
leaq 0x5de54(%rip), %rdx     # 0x126f36
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24f32(%rip), %rsi     # 0xee034
leaq 0x5dd3a(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x359, %ecx            # imm = 0x359
jmp 0xc9018
leaq 0xe00(%rbx), %rcx
leaq 0x252cc(%rip), %rsi     # 0xee3f0
leaq 0x5ddcd(%rip), %rdx     # 0x126ef8
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24eec(%rip), %rsi     # 0xee034
leaq 0x5dcf4(%rip), %rdx     # 0x126e43
movq %rbx, %rdi
movl $0x351, %ecx            # imm = 0x351
jmp 0xc9018