// File: /workspace/github_c_makefile_star2_O1/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 0xd4605
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 0x19cfd
cmpl $0x1, %eax
jne 0xd474f
leaq 0x1ce22(%rip), %rsi     # 0xf13f0
leaq 0x5759b(%rip), %rdx     # 0x12bb70
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1ca46(%rip), %rsi     # 0xf1034
leaq 0x575e3(%rip), %rdx     # 0x12bbd8
movq %r15, %rdi
movl $0x18a, %ecx            # imm = 0x18A
movq %rbx, %r8
jmp 0xd4852
xorpd %xmm4, %xmm4
cmpl $0x1, 0x55c(%rbx)
movsd %xmm0, 0x18(%rsp)
jne 0xd4662
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd4fe8
cmpl $0x1, 0x56c(%rbx)
jne 0xd4652
movsd 0x8(%rsp), %xmm0
movq 0x4c8(%rbx), %rax
movslq 0x4d8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
xorpd %xmm4, %xmm4
addsd 0x8(%rsp), %xmm4
movsd 0x18(%rsp), %xmm0
cmpl $0x1, 0x560(%rbx)
jne 0xd46e5
movsd %xmm4, 0x10(%rsp)
movsd 0x410(%rbx), %xmm1
mulsd 0x50(%rbx), %xmm1
movsd 0x58(%rbx), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
xorpd 0x1cb9b(%rip), %xmm0    # 0xf1230
mulsd 0x3f8(%rbx), %xmm0
callq 0x8670
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpl $0x1, 0x56c(%rbx)
jne 0xd46d5
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 0xd47ee
movsd %xmm4, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd5201
testl %eax, %eax
je 0xd47ab
addq $0x570, %rbx            # imm = 0x570
leaq 0x1ccd5(%rip), %rsi     # 0xf13f0
leaq 0x574d6(%rip), %rdx     # 0x12bbf8
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1c8f9(%rip), %rsi     # 0xf1034
leaq 0x57496(%rip), %rdx     # 0x12bbd8
movq %rbx, %rdi
movl $0x1b6, %ecx            # imm = 0x1B6
jmp 0xd484f
movslq 0x4ec(%rbx), %rax
testq %rax, %rax
jle 0xd4863
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 0xd477f
jmp 0xd493a
movsd 0x18(%rsp), %xmm1
cmpl $0x1, 0x56c(%rbx)
jne 0xd47de
movsd 0x8(%rsp), %xmm0
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 0x8(%rsp), %xmm4
movapd %xmm1, %xmm0
cmpl $0x1, 0x568(%rbx)
jne 0xd48a5
movsd %xmm4, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xd540d
testl %eax, %eax
je 0xd486c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1cbd0(%rip), %rsi     # 0xf13f0
leaq 0x573ff(%rip), %rdx     # 0x12bc26
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1c7f4(%rip), %rsi     # 0xf1034
leaq 0x57391(%rip), %rdx     # 0x12bbd8
movq %rbx, %rdi
movl $0x1c3, %ecx            # imm = 0x1C3
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0xd4941
xorpd %xmm4, %xmm4
jmp 0xd493a
cmpl $0x1, 0x56c(%rbx)
jne 0xd4899
movsd 0x8(%rsp), %xmm0
movq 0x4c8(%rbx), %rax
movslq 0x4e4(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x480(%rbx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x10(%rsp), %xmm4
addsd 0x8(%rsp), %xmm4
cmpl $0x1, 0x56c(%rbx)
jne 0xd493a
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 0xd493a
leaq 0x5736f(%rip), %rsi     # 0x12bc52
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x1c789(%rip), %rsi     # 0xf1082
leaq 0x5723f(%rip), %rdx     # 0x12bb3f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1c711(%rip), %rsi     # 0xf1034
leaq 0x572ae(%rip), %rdx     # 0x12bbd8
movq %rbx, %rdi
movl $0x1d0, %ecx            # imm = 0x1D0
movq %r15, %r8
jmp 0xd4852
movsd %xmm4, (%r14)
xorl %eax, %eax
addq $0x1030, %rsp           # imm = 0x1030
popq %rbx
popq %r14
popq %r15
retq