// File: /workspace/github_c_makefile_star2_O1/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 0xcc5fc
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %r9
callq 0xd5ef4
cmpl $0x1, %eax
jne 0xcc5fc
leaq 0xe00(%rbx), %rcx
leaq 0x24e2c(%rip), %rsi     # 0xf13f0
leaq 0x5d825(%rip), %rdx     # 0x129df0
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24a4c(%rip), %rsi     # 0xf1034
leaq 0x5d82c(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x326, %ecx            # imm = 0x326
jmp 0xcc8bc
movl $0x0, 0x24(%rsp)
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xcc83c
movq %rax, %r13
movslq 0x330(%rbx), %rbp
leaq (,%rbp,8), %rdi
callq 0x8460
movq %rax, 0xc00(%rbx)
testq %rax, %rax
je 0xcc87d
cmpl $0x0, 0x330(%rbx)
jle 0xcc7ce
xorl %ebp, %ebp
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x5efb7
cmpl $0x1, %eax
je 0xcc8df
movsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
leaq 0x24(%rsp), %rcx
movq %r13, %r8
callq 0x5ed53
cmpl $0x1, %eax
je 0xcc925
movslq 0x384(%r14), %rax
movsd (%r13,%rax,8), %xmm0
mulsd 0x29508(%rip), %xmm0    # 0xf5bc0
divsd 0x293f8(%rip), %xmm0    # 0xf5ab8
movslq 0x380(%r14), %rax
movsd (%r13,%rax,8), %xmm1
movslq 0x38c(%r14), %rax
movsd (%r13,%rax,8), %xmm2
mulsd 0x43ffc(%rip), %xmm2    # 0x1106e0
movq $0x0, (%rsp)
cmpl $0x0, 0xce4(%rbx)
jne 0xcc739
movq 0x340(%rbx), %rax
movsd %xmm0, 0x18(%rsp)
movsd (%rax,%rbp,8), %xmm0
movq %r12, %rdi
movq %rsp, %rsi
movsd %xmm1, 0x10(%rsp)
movsd %xmm2, 0x8(%rsp)
callq 0xd6de0
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
cmpl $0x1, %eax
je 0xcc9ba
cmpw $0x1, 0xb8(%r15)
jne 0xcc7a2
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
movq 0x340(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r15, %rdi
callq 0xd5c17
cmpl $0x1, %eax
je 0xcc971
movq 0x610(%r15), %rax
movslq 0x5f8(%r15), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x8(%rsp), %xmm2
mulsd (%rsp), %xmm1
mulsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movq 0xc00(%rbx), %rax
movsd %xmm1, (%rax,%rbp,8)
incq %rbp
movslq 0x330(%rbx), %rax
cmpq %rax, %rbp
jl 0xcc657
movq %r13, %rdi
callq 0x8410
xorl %ebp, %ebp
cmpl $0x0, 0xce4(%rbx)
jne 0xcc8cb
movq %r12, %rdi
callq 0xd6d84
cmpl $0x1, %eax
jne 0xcc8cb
leaq 0xe00(%rbx), %rcx
leaq 0x24bec(%rip), %rsi     # 0xf13f0
leaq 0x5d733(%rip), %rdx     # 0x129f3e
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2480c(%rip), %rsi     # 0xf1034
leaq 0x5d5ec(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x367, %ecx            # imm = 0x367
jmp 0xcc8bc
shll $0x3, %ebp
leaq 0x247be(%rip), %rsi     # 0xf1004
leaq 0x4ba05(%rip), %rdx     # 0x118252
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x247c8(%rip), %rsi     # 0xf1034
leaq 0x5d5a8(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x32d, %ecx            # imm = 0x32D
jmp 0xcc8bc
shll $0x3, %ebp
leaq 0x2477d(%rip), %rsi     # 0xf1004
leaq 0x5d5ae(%rip), %rdx     # 0x129e3c
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24787(%rip), %rsi     # 0xf1034
leaq 0x5d567(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x332, %ecx            # imm = 0x332
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
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 0x24b03(%rip), %rsi     # 0xf13f0
leaq 0x5d55a(%rip), %rdx     # 0x129e4e
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24720(%rip), %rsi     # 0xf1034
leaq 0x5d500(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x33c, %ecx            # imm = 0x33C
jmp 0xcc969
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x24abd(%rip), %rsi     # 0xf13f0
leaq 0x5d544(%rip), %rdx     # 0x129e7e
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x246da(%rip), %rsi     # 0xf1034
leaq 0x5d4ba(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x344, %ecx            # imm = 0x344
movq %r15, %r8
jmp 0xcc8bf
addq $0x630, %r15            # imm = 0x630
leaq 0x24a71(%rip), %rsi     # 0xf13f0
leaq 0x5d588(%rip), %rdx     # 0x129f0e
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2468e(%rip), %rsi     # 0xf1034
leaq 0x5d46e(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x359, %ecx            # imm = 0x359
jmp 0xcc8bc
leaq 0xe00(%rbx), %rcx
leaq 0x24a28(%rip), %rsi     # 0xf13f0
leaq 0x5d501(%rip), %rdx     # 0x129ed0
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x24648(%rip), %rsi     # 0xf1034
leaq 0x5d428(%rip), %rdx     # 0x129e1b
movq %rbx, %rdi
movl $0x351, %ecx            # imm = 0x351
jmp 0xcc8bc