// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/heating/injection.c
// Function: injection_calculate_at_z
int injection_calculate_at_z(struct background* pba,
                             struct thermodynamics* pth,
                             double x,
                             double z,
                             double Tmat,
                             double* pvecback){

  /** - Define local variables */
  struct injection * pin = &(pth->in);
  int index_dep;
  double h,a,b;
  double dEdt_inj;

  /** - Store input parameters in struct */
  pin->T_b = Tmat;                                                                                  // [K]
  pin->x_e = x;                                                                                     // [-]
  pin->nH = pin->N_e0*pow(1.+z,3);                                                                  // [1/m^3]
  pin->heat_capacity = (3./2.)*_k_B_*pin->nH*(1.+pin->fHe+pin->x_e);                                // [J/(K m^3)]
  dEdt_inj = 0.;

  /** - Import varying quantities from background structure, convert to SI units */
  pin->H = pvecback[pba->index_bg_H]*_c_/_Mpc_over_m_;                                              // [1/s]
  pin->a = pvecback[pba->index_bg_a];                                                               // [-]
  pin->t = pvecback[pba->index_bg_time]/_s_over_Mpc_;                                               // [s]
  pin->rho_cdm = pvecback[pba->index_bg_rho_cdm]*_Jm3_over_Mpc2_;                                   // [J/m^3]
  pin->rho_g = pvecback[pba->index_bg_rho_g]*_Jm3_over_Mpc2_;                                       // [J/m^3]
  pin->rho_b = pvecback[pba->index_bg_rho_b]*_Jm3_over_Mpc2_;                                       // [J/m^3]

  /** - Hunt within the redshift table for the given index of deposition */
  class_call(array_spline_hunt(pin->z_table,
                               pin->z_size,
                               z,
                               &(pin->index_z_store),
                               &h,&a,&b,
                               pin->error_message),
             pin->error_message,
             pin->error_message);

  /** - Test if and where the new values should be stored in the injection table */
  /* If this value is important, store it */
  if(pin->to_store == _TRUE_){
    /* Calculate where to store the value */
    if(fabs(b-1) < pin->tol_z_table){
      pin->index_z_store = pin->index_z_store+1;
    }
    else if(fabs(b) < pin->tol_z_table){
      pin->index_z_store = pin->index_z_store;
    }
    /* Could not find a matching index in the z table for this z */
    else{
      class_stop(pin->error_message,
                 "Should store z = %.10e, but it was not in the z table (next lower = %.10e , next higher = %.10e )",
                 pin->z_table[pin->index_z_store], pin->z_table[pin->index_z_store+1]);
    }
  }

  /** - Get the injected energy that needs to be deposited (i.e. excluding adiabatic terms) */
  class_call(injection_energy_injection_at_z(pin,
                                             z,
                                             &dEdt_inj),
             pin->error_message,
             pin->error_message);

  /** - Get the deposition and the efficiency functions */
  class_call(injection_deposition_function_at_z(pin,
                                                x,
                                                z),
             pin->error_message,
             pin->error_message);

  /** - Put result into deposition vector */
  for(index_dep = 0; index_dep < pin->dep_size; ++index_dep){
    pin->pvecdeposition[index_dep] = pin->chi[index_dep]*dEdt_inj;
  }

  /** - Store z values in table */
  if(pin->to_store == _TRUE_){
    for(index_dep = 0; index_dep < pin->dep_size; ++index_dep){
      pin->deposition_table[index_dep][pin->index_z_store] = pin->pvecdeposition[index_dep];
    }

    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 module agree in their z sampling.");
    pin->filled_until_index_z = pin->index_z_store;
    pin->filled_until_z = pin->z_table[pin->index_z_store];
  }

  pin->to_store = _FALSE_;

  return _SUCCESS_;
}

// Assembly:
subq $0x3878, %rsp           # imm = 0x3878
movq %rdi, 0x3868(%rsp)
movq %rsi, 0x3860(%rsp)
movsd %xmm0, 0x3858(%rsp)
movsd %xmm1, 0x3850(%rsp)
movsd %xmm2, 0x3848(%rsp)
movq %rdx, 0x3840(%rsp)
movq 0x3860(%rsp), %rax
addq $0xc0, %rax
movq %rax, 0x3838(%rsp)
movsd 0x3848(%rsp), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x430(%rax)
movsd 0x3858(%rsp), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x438(%rax)
movq 0x3838(%rsp), %rax
movsd 0x420(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x32748(%rip), %xmm0    # 0x1d2248
addsd 0x3850(%rsp), %xmm0
movsd 0x33b87(%rip), %xmm1    # 0x1d3698
callq 0x8610
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x440(%rax)
movq 0x3838(%rsp), %rax
movsd 0x51a25(%rip), %xmm0    # 0x1f1568
mulsd 0x440(%rax), %xmm0
movq 0x3838(%rsp), %rax
movsd 0x326ed(%rip), %xmm1    # 0x1d2248
addsd 0x418(%rax), %xmm1
movq 0x3838(%rsp), %rax
addsd 0x438(%rax), %xmm1
mulsd %xmm1, %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x428(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3810(%rsp)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x384(%rcx), %rcx
movsd 0x36a7e(%rip), %xmm0    # 0x1d6630
mulsd (%rax,%rcx,8), %xmm0
movsd 0x36aa1(%rip), %xmm1    # 0x1d6660
divsd %xmm1, %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x3e8(%rax)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x380(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x3f0(%rax)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x41c(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x6cf95(%rip), %xmm1    # 0x20cbb8
divsd %xmm1, %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x3f8(%rax)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x394(%rcx), %rcx
movsd 0x5190a(%rip), %xmm0    # 0x1f1560
mulsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x410(%rax)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x38c(%rcx), %rcx
movsd 0x518d6(%rip), %xmm0    # 0x1f1560
mulsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x400(%rax)
movq 0x3840(%rsp), %rax
movq 0x3868(%rsp), %rcx
movslq 0x390(%rcx), %rcx
movsd 0x518a2(%rip), %xmm0    # 0x1f1560
mulsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x408(%rax)
movq 0x3838(%rsp), %rax
movq 0x448(%rax), %rdi
movq 0x3838(%rsp), %rax
movl 0x450(%rax), %esi
movsd 0x3850(%rsp), %xmm0
movq 0x3838(%rsp), %rdx
addq $0x480, %rdx            # imm = 0x480
movq 0x3838(%rsp), %rax
addq $0x570, %rax            # imm = 0x570
leaq 0x3828(%rsp), %rcx
leaq 0x3820(%rsp), %r8
leaq 0x3818(%rsp), %r9
movq %rax, (%rsp)
callq 0x27de0
cmpl $0x1, %eax
jne 0x19fda9
leaq 0x3010(%rsp), %rdi
movq 0x3838(%rsp), %rcx
addq $0x570, %rcx            # imm = 0x570
leaq 0x3267e(%rip), %rsi     # 0x1d23d8
leaq 0x6d18f(%rip), %rdx     # 0x20cef0
movb $0x0, %al
callq 0x5b9c0
movq 0x3838(%rsp), %rdi
addq $0x570, %rdi            # imm = 0x570
leaq 0x3010(%rsp), %r8
leaq 0x322ae(%rip), %rsi     # 0x1d2034
leaq 0x6d1c8(%rip), %rdx     # 0x20cf55
movl $0x132, %ecx            # imm = 0x132
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3874(%rsp)
jmp 0x1a0255
movq 0x3838(%rsp), %rax
cmpl $0x1, 0x56c(%rax)
jne 0x19ff27
movsd 0x3818(%rsp), %xmm1
movsd 0x32479(%rip), %xmm0    # 0x1d2248
subsd %xmm0, %xmm1
movaps 0x32456(%rip), %xmm0    # 0x1d2230
pand %xmm0, %xmm1
movq 0x3838(%rsp), %rax
movsd 0x458(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x19fe18
movq 0x3838(%rsp), %rax
movl 0x480(%rax), %ecx
addl $0x1, %ecx
movq 0x3838(%rsp), %rax
movl %ecx, 0x480(%rax)
jmp 0x19ff25
movsd 0x3818(%rsp), %xmm1
movaps 0x32408(%rip), %xmm0    # 0x1d2230
pand %xmm0, %xmm1
movq 0x3838(%rsp), %rax
movsd 0x458(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x19fe63
movq 0x3838(%rsp), %rax
movl 0x480(%rax), %ecx
movq 0x3838(%rsp), %rax
movl %ecx, 0x480(%rax)
jmp 0x19ff23
leaq 0x2810(%rsp), %rdi
movq 0x3838(%rsp), %rax
movq 0x448(%rax), %rax
movq 0x3838(%rsp), %rcx
movslq 0x480(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movq 0x448(%rax), %rax
movq 0x3838(%rsp), %rcx
movl 0x480(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x6d0b1(%rip), %rsi     # 0x20cf6e
movb $0x2, %al
callq 0x5b9c0
leaq 0x2010(%rsp), %rdi
leaq 0x2810(%rsp), %rdx
leaq 0x32692(%rip), %rsi     # 0x1d256d
movb $0x0, %al
callq 0x5b9c0
movq 0x3838(%rsp), %rdi
addq $0x570, %rdi            # imm = 0x570
leaq 0x2010(%rsp), %r8
leaq 0x32134(%rip), %rsi     # 0x1d2034
leaq 0x6d04e(%rip), %rdx     # 0x20cf55
movl $0x142, %ecx            # imm = 0x142
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3874(%rsp)
jmp 0x1a0255
jmp 0x19ff25
jmp 0x19ff27
movq 0x3838(%rsp), %rdi
movsd 0x3850(%rsp), %xmm0
leaq 0x3810(%rsp), %rsi
callq 0x1a0270
cmpl $0x1, %eax
jne 0x19ffb7
leaq 0x1810(%rsp), %rdi
movq 0x3838(%rsp), %rcx
addq $0x570, %rcx            # imm = 0x570
leaq 0x32470(%rip), %rsi     # 0x1d23d8
leaq 0x6d061(%rip), %rdx     # 0x20cfd0
movb $0x0, %al
callq 0x5b9c0
movq 0x3838(%rsp), %rdi
addq $0x570, %rdi            # imm = 0x570
leaq 0x1810(%rsp), %r8
leaq 0x320a0(%rip), %rsi     # 0x1d2034
leaq 0x6cfba(%rip), %rdx     # 0x20cf55
movl $0x14b, %ecx            # imm = 0x14B
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3874(%rsp)
jmp 0x1a0255
movq 0x3838(%rsp), %rdi
movsd 0x3858(%rsp), %xmm0
movsd 0x3850(%rsp), %xmm1
callq 0x1a09e0
cmpl $0x1, %eax
jne 0x1a0048
leaq 0x1010(%rsp), %rdi
movq 0x3838(%rsp), %rcx
addq $0x570, %rcx            # imm = 0x570
leaq 0x323df(%rip), %rsi     # 0x1d23d8
leaq 0x6d003(%rip), %rdx     # 0x20d003
movb $0x0, %al
callq 0x5b9c0
movq 0x3838(%rsp), %rdi
addq $0x570, %rdi            # imm = 0x570
leaq 0x1010(%rsp), %r8
leaq 0x3200f(%rip), %rsi     # 0x1d2034
leaq 0x6cf29(%rip), %rdx     # 0x20cf55
movl $0x152, %ecx            # imm = 0x152
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3874(%rsp)
jmp 0x1a0255
movl $0x0, 0x3834(%rsp)
movl 0x3834(%rsp), %eax
movq 0x3838(%rsp), %rcx
cmpl 0x54c(%rcx), %eax
jge 0x1a00be
movq 0x3838(%rsp), %rax
movq 0x530(%rax), %rax
movslq 0x3834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd 0x3810(%rsp), %xmm0
movq 0x3838(%rsp), %rax
movq 0x550(%rax), %rax
movslq 0x3834(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x3834(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3834(%rsp)
jmp 0x1a0053
movq 0x3838(%rsp), %rax
cmpl $0x1, 0x56c(%rax)
jne 0x1a0238
movl $0x0, 0x3834(%rsp)
movl 0x3834(%rsp), %eax
movq 0x3838(%rsp), %rcx
cmpl 0x54c(%rcx), %eax
jge 0x1a0153
movq 0x3838(%rsp), %rax
movq 0x550(%rax), %rax
movslq 0x3834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movq 0x528(%rax), %rax
movslq 0x3834(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x3838(%rsp), %rcx
movslq 0x480(%rcx), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x3834(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3834(%rsp)
jmp 0x1a00de
movq 0x3838(%rsp), %rax
movl 0x480(%rax), %eax
movq 0x3838(%rsp), %rcx
movl 0x460(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1a01e9
leaq 0x810(%rsp), %rdi
leaq 0x6ceac(%rip), %rsi     # 0x20d031
movb $0x0, %al
callq 0x5b9c0
leaq 0x10(%rsp), %rdi
leaq 0x810(%rsp), %rcx
leaq 0x31ee2(%rip), %rsi     # 0x1d2082
leaq 0x6cefb(%rip), %rdx     # 0x20d0a2
movb $0x0, %al
callq 0x5b9c0
movq 0x3838(%rsp), %rdi
addq $0x570, %rdi            # imm = 0x570
leaq 0x10(%rsp), %r8
leaq 0x31e6b(%rip), %rsi     # 0x1d2034
leaq 0x6cd85(%rip), %rdx     # 0x20cf55
movl $0x161, %ecx            # imm = 0x161
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3874(%rsp)
jmp 0x1a0255
movq 0x3838(%rsp), %rax
movl 0x480(%rax), %ecx
movq 0x3838(%rsp), %rax
movl %ecx, 0x460(%rax)
movq 0x3838(%rsp), %rax
movq 0x448(%rax), %rax
movq 0x3838(%rsp), %rcx
movslq 0x480(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3838(%rsp), %rax
movsd %xmm0, 0x468(%rax)
movq 0x3838(%rsp), %rax
movl $0x0, 0x56c(%rax)
movl $0x0, 0x3874(%rsp)
movl 0x3874(%rsp), %eax
addq $0x3878, %rsp           # imm = 0x3878
retq
nopw %cs:(%rax,%rax)