// File: /workspace/github_c_makefile_star2_O2/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 0xc9603
movq 0x448(%rbx), %rdi
movl 0x450(%rbx), %esi
leaq 0x478(%rbx), %rdx
leaq 0x570(%rbx), %r15
movq %r15, (%rsp)
leaq 0x830(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x28(%rsp), %r9
callq 0x17d10
cmpl $0x1, %eax
jne 0xc9725
leaq 0x1be24(%rip), %rsi     # 0xe53f0
leaq 0x5647d(%rip), %rdx     # 0x11fa50
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1ba48(%rip), %rsi     # 0xe5034
leaq 0x564c5(%rip), %rdx     # 0x11fab8
movq %r15, %rdi
movl $0x18a, %ecx            # imm = 0x18A
movq %rbx, %r8
jmp 0xc981e
xorpd %xmm4, %xmm4
cmpl $0x1, 0x55c(%rbx)
movsd %xmm0, 0x20(%rsp)
jne 0xc9660
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc9f7f
cmpl $0x1, 0x56c(%rbx)
movsd (%r15), %xmm4
jne 0xc9652
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 0x20(%rsp), %xmm0
cmpl $0x1, 0x560(%rbx)
jne 0xc96bb
movsd %xmm4, 0x18(%rsp)
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xca14d
cmpl $0x1, 0x56c(%rbx)
movsd (%r15), %xmm0
jne 0xc96ab
movq 0x4c8(%rbx), %rax
movslq 0x4dc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x18(%rsp), %xmm4
addsd %xmm0, %xmm4
movsd 0x20(%rsp), %xmm0
cmpl $0x1, 0x564(%rbx)
jne 0xc97be
movsd %xmm4, 0x18(%rsp)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xca198
testl %eax, %eax
je 0xc977d
addq $0x570, %rbx            # imm = 0x570
leaq 0x1bcff(%rip), %rsi     # 0xe53f0
leaq 0x563e0(%rip), %rdx     # 0x11fad8
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1b923(%rip), %rsi     # 0xe5034
leaq 0x563a0(%rip), %rdx     # 0x11fab8
movq %rbx, %rdi
movl $0x1b6, %ecx            # imm = 0x1B6
jmp 0xc981b
movl 0x4ec(%rbx), %eax
movsd 0x10(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
xorpd %xmm4, %xmm4
cmpq %rcx, %rax
je 0xc98ff
movq 0x4c8(%rbx), %rdx
movq (%rdx,%rcx,8), %rdx
movslq 0x478(%rbx), %rsi
movsd 0x8(%rdx,%rsi,8), %xmm2
mulsd %xmm1, %xmm2
movsd (%rdx,%rsi,8), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
addsd %xmm3, %xmm4
incq %rcx
jmp 0xc9742
movsd 0x20(%rsp), %xmm1
cmpl $0x1, 0x56c(%rbx)
movsd 0x10(%rsp), %xmm0
jne 0xc97b0
movq 0x4c8(%rbx), %rax
movslq 0x4e0(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x18(%rsp), %xmm4
addsd %xmm0, %xmm4
movapd %xmm1, %xmm0
cmpl $0x1, 0x568(%rbx)
jne 0xc982d
movsd %xmm4, 0x18(%rsp)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xca397
testl %eax, %eax
je 0xc9835
addq $0x570, %rbx            # imm = 0x570
leaq 0x1bc04(%rip), %rsi     # 0xe53f0
leaq 0x56313(%rip), %rdx     # 0x11fb06
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1b828(%rip), %rsi     # 0xe5034
leaq 0x562a5(%rip), %rdx     # 0x11fab8
movq %rbx, %rdi
movl $0x1c3, %ecx            # imm = 0x1C3
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0xc9906
movl 0x56c(%rbx), %eax
jmp 0xc986e
movl 0x56c(%rbx), %eax
movsd 0x10(%rsp), %xmm0
cmpl $0x1, %eax
jne 0xc9864
movq 0x4c8(%rbx), %rcx
movslq 0x4e4(%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x480(%rbx), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movsd 0x18(%rsp), %xmm4
addsd %xmm0, %xmm4
cmpl $0x1, %eax
jne 0xc98ff
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 0xc98ff
leaq 0x5628a(%rip), %rsi     # 0x11fb32
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x1b7c4(%rip), %rsi     # 0xe5082
leaq 0x5615a(%rip), %rdx     # 0x11fa1f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x570, %rbx            # imm = 0x570
leaq 0x1b74c(%rip), %rsi     # 0xe5034
leaq 0x561c9(%rip), %rdx     # 0x11fab8
movq %rbx, %rdi
movl $0x1d0, %ecx            # imm = 0x1D0
movq %r15, %r8
jmp 0xc981e
movsd %xmm4, (%r14)
xorl %eax, %eax
addq $0x1030, %rsp           # imm = 0x1030
popq %rbx
popq %r14
popq %r15
retq