// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/heating/injection.c
// Function: injection_energy_injection_at_z
int injection_energy_injection_at_z(struct injection* pin,
                                    double z,
                                    double* dEdt_inj){

  /** - Define local variable */
  double dEdt, rate;
  double h,a,b;
  int index_inj;

  /* Initialize local variables */
  dEdt = 0.;

  /** - Test if the values are already within the table */
  if(z > pin->filled_until_z){
    /* If the value is already within the table, just interpolate */
    class_call(array_spline_hunt(pin->z_table,
                                 pin->z_size,
                                 z,
                                 &(pin->last_index_z_inj),
                                 &h,&a,&b,
                                 pin->error_message),
             pin->error_message,
             pin->error_message);
    /* (Linearly) interpolate within the table */
    for(index_inj=0; index_inj<pin->inj_size; ++index_inj){
      dEdt += pin->injection_table[index_inj][pin->last_index_z_inj]*a+pin->injection_table[index_inj][pin->last_index_z_inj+1]*b;
    }

    *dEdt_inj = dEdt;

  }

  else {
    /** - Exotic energy injection mechanisms */
    /* DM annihilation */
    if(pin->has_DM_ann == _TRUE_){
      class_call(injection_rate_DM_annihilation(pin,
                                                z,
                                                &rate),
                 pin->error_message,
                 pin->error_message);
      if(pin->to_store == _TRUE_){
        pin->injection_table[pin->index_inj_DM_ann][pin->index_z_store] = rate;
      }
      dEdt += rate;
    }

    /* DM decay */
    if(pin->has_DM_dec == _TRUE_){
      class_call(injection_rate_DM_decay(pin,
                                         z,
                                         &rate),
                 pin->error_message,
                 pin->error_message);
      if(pin->to_store == _TRUE_){
        pin->injection_table[pin->index_inj_DM_dec][pin->index_z_store] = rate;
      }
      dEdt += rate;
    }

    /* PBH evaporation */
    if(pin->has_PBH_eva == _TRUE_){
      class_call(injection_rate_PBH_evaporation(pin,
                                                z,
                                                &rate),
                 pin->error_message,
                 pin->error_message);
      if(pin->to_store == _TRUE_){
        pin->injection_table[pin->index_inj_PBH_eva][pin->index_z_store] = rate;
      }
      dEdt += rate;
    }

    /* PBH matter acctretion */
    if(pin->has_PBH_acc == _TRUE_){
      class_call(injection_rate_PBH_accretion(pin,
                                              z,
                                              &rate),
                 pin->error_message,
                 pin->error_message);
      if(pin->to_store == _TRUE_){
        pin->injection_table[pin->index_inj_PBH_acc][pin->index_z_store] = rate;
      }
      dEdt += rate;
    }

    /** Total energy injection */
    if(pin->to_store == _TRUE_){
      pin->injection_table[pin->index_inj_tot][pin->index_z_store] = dEdt;

      class_test(pin->index_z_store < pin->filled_until_index_z-1,
                 pin->error_message,
                 "Skipping too far ahead in z_table. Check that the injection and thermodynamics modules agree in their z sampling.");
    }

    *dEdt_inj = dEdt;

  }

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1030, %rsp           # imm = 0x1030
movq %rsi, %r14
movq %rdi, %rbx
ucomisd 0x468(%rdi), %xmm0
jbe 0xd0df9
movq 0x448(%rbx), %rdi
movl 0x450(%rbx), %esi
leaq 0x478(%rbx), %rdx
leaq 0x570(%rbx), %r15
movq %r15, (%rsp)
leaq 0x830(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0x28(%rsp), %r9
callq 0x19e56
cmpl $0x1, %eax
jne 0xd0f43
leaq 0x1d62e(%rip), %rsi     # 0xee3f0
leaq 0x57dd7(%rip), %rdx     # 0x128ba0
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x1d252(%rip), %rsi     # 0xee034
leaq 0x57e1f(%rip), %rdx     # 0x128c08
movq %r15, %rdi
movl $0x18a, %ecx            # imm = 0x18A
movq %rbx, %r8
jmp 0xd1040
xorpd %xmm4, %xmm4
cmpl $0x1, 0x55c(%rbx)
movsd %xmm0, 0x18(%rsp)
jne 0xd0e56
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd17da
cmpl $0x1, 0x56c(%rbx)
movsd (%r15), %xmm4
jne 0xd0e48
movq 0x4c8(%rbx), %rax
movslq 0x4d8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm4, (%rax,%rcx,8)
xorpd %xmm0, %xmm0
addsd %xmm0, %xmm4
movsd 0x18(%rsp), %xmm0
cmpl $0x1, 0x560(%rbx)
jne 0xd0ed9
movsd %xmm4, 0x10(%rsp)
movsd 0x410(%rbx), %xmm1
mulsd 0x50(%rbx), %xmm1
movsd 0x58(%rbx), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
xorpd 0x1d3a7(%rip), %xmm0    # 0xee230
mulsd 0x3f8(%rbx), %xmm0
callq 0x8670
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpl $0x1, 0x56c(%rbx)
jne 0xd0ec9
movq 0x4c8(%rbx), %rax
movslq 0x4dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x10(%rsp), %xmm4
addsd %xmm0, %xmm4
movsd 0x18(%rsp), %xmm0
cmpl $0x1, 0x564(%rbx)
jne 0xd0fe0
movsd %xmm4, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd19f3
testl %eax, %eax
je 0xd0f9f
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d4e1(%rip), %rsi     # 0xee3f0
leaq 0x57d12(%rip), %rdx     # 0x128c28
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x1d105(%rip), %rsi     # 0xee034
leaq 0x57cd2(%rip), %rdx     # 0x128c08
movq %rbx, %rdi
movl $0x1b6, %ecx            # imm = 0x1B6
jmp 0xd103d
movslq 0x4ec(%rbx), %rax
testq %rax, %rax
jle 0xd1059
movq 0x4c8(%rbx), %rcx
movslq 0x478(%rbx), %rdx
movsd 0x8(%rsp), %xmm0
xorpd %xmm4, %xmm4
movsd 0x28(%rsp), %xmm1
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movsd 0x8(%rdi,%rdx,8), %xmm2
mulsd %xmm1, %xmm2
movsd (%rdi,%rdx,8), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
addsd %xmm3, %xmm4
incq %rsi
cmpq %rsi, %rax
jne 0xd0f73
jmp 0xd112c
movsd 0x18(%rsp), %xmm1
cmpl $0x1, 0x56c(%rbx)
movsd 0x8(%rsp), %xmm0
jne 0xd0fd2
movq 0x4c8(%rbx), %rax
movslq 0x4e0(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x10(%rsp), %xmm4
addsd %xmm0, %xmm4
movapd %xmm1, %xmm0
cmpl $0x1, 0x568(%rbx)
jne 0xd1051
movsd %xmm4, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd1bff
testl %eax, %eax
je 0xd1062
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d3e2(%rip), %rsi     # 0xee3f0
leaq 0x57c41(%rip), %rdx     # 0x128c56
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x1d006(%rip), %rsi     # 0xee034
leaq 0x57bd3(%rip), %rdx     # 0x128c08
movq %rbx, %rdi
movl $0x1c3, %ecx            # imm = 0x1C3
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
jmp 0xd1133
movl 0x56c(%rbx), %eax
jmp 0xd109b
xorpd %xmm4, %xmm4
jmp 0xd112c
movl 0x56c(%rbx), %eax
movsd 0x8(%rsp), %xmm0
cmpl $0x1, %eax
jne 0xd1091
movq 0x4c8(%rbx), %rcx
movslq 0x4e4(%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x480(%rbx), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd 0x10(%rsp), %xmm4
addsd %xmm0, %xmm4
cmpl $0x1, %eax
jne 0xd112c
movq 0x4c8(%rbx), %rax
movslq 0x4e8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm4, (%rax,%rcx,8)
movl 0x460(%rbx), %eax
decl %eax
cmpl %eax, %ecx
jge 0xd112c
leaq 0x57bad(%rip), %rsi     # 0x128c82
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x1cf97(%rip), %rsi     # 0xee082
leaq 0x57a7d(%rip), %rdx     # 0x128b6f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x570, %rbx            # imm = 0x570
leaq 0x1cf1f(%rip), %rsi     # 0xee034
leaq 0x57aec(%rip), %rdx     # 0x128c08
movq %rbx, %rdi
movl $0x1d0, %ecx            # imm = 0x1D0
movq %r15, %r8
jmp 0xd1040
movsd %xmm4, (%r14)
xorl %eax, %eax
addq $0x1030, %rsp           # imm = 0x1030
popq %rbx
popq %r14
popq %r15
retq