// File: /workspace/github_cpp_makefile_star2_O2/TBody[P]atomicpp/atomicpp/RateEquations.cpp
// Function: atomicpp::RateEquations::calculateElectronImpactPowerEquation(double, std::vector<double, std::allocator<double>> const&, double)
void RateEquations::calculateElectronImpactPowerEquation(
	const double Ne,
	const std::vector<double>& Nzk,
	const double Te
	){
	//Calculate the power - doesn't need as high precision since everything is positive
	std::shared_ptr<RateCoefficient> line_power_coefficient = rate_coefficients["line_power"];
	std::shared_ptr<RateCoefficient> continuum_power_coefficient = rate_coefficients["continuum_power"];
	for(int k=0; k < Z; ++k){//N.b. iterating over all data indicies of the rate coefficient, hence the <
		double line_power_coefficient_evaluated = line_power_coefficient->call0D(k, Te, Ne);
		double continuum_power_coefficient_evaluated = continuum_power_coefficient->call0D(k, Te, Ne);
		
		// Note that continuum_power coefficients are indexed from 1 to Z, while line_power is indexed from 0 to Z-1 (consider what 
		// charge the target must have in each case)

		double line_power_rate = line_power_coefficient_evaluated * Ne * Nzk[k];
		double continuum_power_rate = continuum_power_coefficient_evaluated * Ne * Nzk[k+1];

		Prad  += line_power_rate + continuum_power_rate;
		Pcool += line_power_rate + continuum_power_rate;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movsd %xmm1, -0x50(%rbp)
movq %rsi, %rbx
movsd %xmm0, -0x40(%rbp)
movq %rdi, %r14
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0x4540
leaq 0x2706(%rip), %rsi      # 0x227c8
leaq -0x80(%rbp), %rdi
movq %r15, %rdx
callq 0x4160
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0xcf52
leaq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0xcf48
leaq -0x80(%rbp), %rdi
callq 0x41a0
leaq -0x60(%rbp), %rdi
callq 0x58aa
leaq -0x29(%rbp), %r15
movq %r15, %rdi
callq 0x4540
leaq 0x26a6(%rip), %rsi      # 0x227b4
leaq -0x80(%rbp), %rdi
movq %r15, %rdx
callq 0x4160
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0xcf52
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xcf48
leaq -0x80(%rbp), %rdi
callq 0x41a0
leaq -0x29(%rbp), %rdi
callq 0x58aa
xorl %r12d, %r12d
leaq -0x90(%rbp), %r13
movslq 0x34(%r14), %rax
cmpq %rax, %r12
jge 0x20216
movq %r13, %rdi
callq 0x538e
movq %rax, %rdi
movl %r12d, %esi
movsd -0x50(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x10f96
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
callq 0x538e
movq %rax, %rdi
movl %r12d, %esi
movsd -0x50(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x10f96
movsd %xmm0, -0x48(%rbp)
movsd -0x38(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x17efc
movsd -0x38(%rbp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x48(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
incq %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x17efc
movsd -0x48(%rbp), %xmm1
mulsd (%rax), %xmm1
addsd -0x38(%rbp), %xmm1
movsd 0x68(%r14), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%r14)
addsd 0x60(%r14), %xmm1
movsd %xmm1, 0x60(%r14)
jmp 0x20151
leaq -0x60(%rbp), %rdi
callq 0x5398
leaq -0x90(%rbp), %rdi
callq 0x5398
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x41a0
jmp 0x2024b
movq %rax, %rbx
leaq -0x29(%rbp), %rdi
callq 0x58aa
jmp 0x20280
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x41a0
jmp 0x20267
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x58aa
jmp 0x2028c
jmp 0x20274
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x5398
leaq -0x90(%rbp), %rdi
callq 0x5398
movq %rbx, %rdi
callq 0x45a0