// File: /workspace/github_c_makefile_star2_O2/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 $0x848, %rsp            # imm = 0x848
movq %r9, %rbx
movq %rdx, %r15
movq %rsi, %r14
leaq 0xcf0(%r9), %r12
cmpl $0x0, 0xce4(%r9)
jne 0xc17ea
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %r9
callq 0xcae64
cmpl $0x1, %eax
jne 0xc17ea
leaq 0xe00(%rbx), %rcx
leaq 0x23c3e(%rip), %rsi     # 0xe53f0
leaq 0x5c50f(%rip), %rdx     # 0x11dcc8
leaq 0x40(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2385e(%rip), %rsi     # 0xe5034
leaq 0x5c516(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x326, %ecx            # imm = 0x326
jmp 0xc1a42
movq %r12, 0x30(%rsp)
andl $0x0, 0x2c(%rsp)
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8490
testq %rax, %rax
je 0xc19bf
movq %rax, %r13
movslq 0x330(%rbx), %r12
movq %r12, %rdi
shlq $0x3, %rdi
callq 0x8490
movq %rax, 0xc00(%rbx)
testq %rax, %rax
je 0xc1a00
xorl %ebp, %ebp
movslq %r12d, %rax
cmpq %rax, %rbp
jge 0xc1a63
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x58adb
cmpl $0x1, %eax
je 0xc1acb
movsd 0x38(%rsp), %xmm0
movq %r14, %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
leaq 0x2c(%rsp), %rcx
movq %r13, %r8
callq 0x5887d
cmpl $0x1, %eax
je 0xc1b11
movslq 0x384(%r14), %rax
movsd (%r13,%rax,8), %xmm1
mulsd 0x2820e(%rip), %xmm1    # 0xe9ab0
divsd 0x280fe(%rip), %xmm1    # 0xe99a8
movslq 0x380(%r14), %rax
movsd (%r13,%rax,8), %xmm2
movslq 0x38c(%r14), %rax
andq $0x0, 0x8(%rsp)
movsd (%r13,%rax,8), %xmm3
mulsd 0x42cec(%rip), %xmm3    # 0x1045c0
cmpl $0x0, 0xce4(%rbx)
jne 0xc1925
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movsd %xmm1, 0x20(%rsp)
movsd %xmm2, 0x18(%rsp)
movsd %xmm3, 0x10(%rsp)
callq 0xcbce2
movsd 0x10(%rsp), %xmm3
movsd 0x18(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
cmpl $0x1, %eax
je 0xc1ba6
cmpw $0x1, 0xb8(%r15)
jne 0xc1992
movsd %xmm3, 0x10(%rsp)
movsd %xmm2, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r15, %rdi
callq 0xcab99
cmpl $0x1, %eax
je 0xc1b5d
movq 0x610(%r15), %rax
movslq 0x5f8(%r15), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
jmp 0xc1998
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm2
mulsd %xmm3, %xmm1
divsd %xmm1, %xmm2
movq 0xc00(%rbx), %rax
movsd %xmm2, (%rax,%rbp,8)
incq %rbp
movl 0x330(%rbx), %r12d
jmp 0xc1839
shll $0x3, %ebp
leaq 0x2363b(%rip), %rsi     # 0xe5004
leaq 0x4a762(%rip), %rdx     # 0x10c132
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x23645(%rip), %rsi     # 0xe5034
leaq 0x5c2fd(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x32d, %ecx            # imm = 0x32D
jmp 0xc1a42
leal (,%r12,8), %ecx
leaq 0x235f5(%rip), %rsi     # 0xe5004
leaq 0x5c2fe(%rip), %rdx     # 0x11dd14
leaq 0x40(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x23601(%rip), %rsi     # 0xe5034
leaq 0x5c2b9(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x332, %ecx            # imm = 0x332
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x8430
xorl %ebp, %ebp
cmpl $0x0, 0xce4(%rbx)
jne 0xc1a4f
movq 0x30(%rsp), %rdi
callq 0xcbc86
cmpl $0x1, %eax
jne 0xc1a4f
leaq 0xe00(%rbx), %rcx
leaq 0x2395d(%rip), %rsi     # 0xe53f0
leaq 0x5c37c(%rip), %rdx     # 0x11de16
leaq 0x40(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2357d(%rip), %rsi     # 0xe5034
leaq 0x5c235(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x367, %ecx            # imm = 0x367
jmp 0xc1a42
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x23917(%rip), %rsi     # 0xe53f0
leaq 0x5c246(%rip), %rdx     # 0x11dd26
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x23534(%rip), %rsi     # 0xe5034
leaq 0x5c1ec(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x33c, %ecx            # imm = 0x33C
jmp 0xc1b55
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x238d1(%rip), %rsi     # 0xe53f0
leaq 0x5c230(%rip), %rdx     # 0x11dd56
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x234ee(%rip), %rsi     # 0xe5034
leaq 0x5c1a6(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x344, %ecx            # imm = 0x344
movq %r15, %r8
jmp 0xc1a45
addq $0x630, %r15            # imm = 0x630
leaq 0x23885(%rip), %rsi     # 0xe53f0
leaq 0x5c274(%rip), %rdx     # 0x11dde6
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x234a2(%rip), %rsi     # 0xe5034
leaq 0x5c15a(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x359, %ecx            # imm = 0x359
jmp 0xc1a42
leaq 0xe00(%rbx), %rcx
leaq 0x2383c(%rip), %rsi     # 0xe53f0
leaq 0x5c1ed(%rip), %rdx     # 0x11dda8
leaq 0x40(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2345c(%rip), %rsi     # 0xe5034
leaq 0x5c114(%rip), %rdx     # 0x11dcf3
movq %rbx, %rdi
movl $0x351, %ecx            # imm = 0x351
jmp 0xc1a42