// File: /workspace/github_cpp_makefile_star2_O1/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, -0x60(%rbp)
movq %rsi, %rbx
movsd %xmm0, -0x40(%rbp)
movq %rdi, %r14
leaq -0x58(%rbp), %r15
movq %r15, %rdi
callq 0x4540
leaq 0x2d9a(%rip), %rsi      # 0x237c8
leaq -0x80(%rbp), %rdi
movq %r15, %rdx
callq 0x4160
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0xd1fc
leaq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0xd1f2
leaq -0x80(%rbp), %rdi
callq 0x41a0
leaq -0x58(%rbp), %rdi
callq 0x58c6
leaq -0x29(%rbp), %r15
movq %r15, %rdi
callq 0x4540
leaq 0x2d3a(%rip), %rsi      # 0x237b4
leaq -0x80(%rbp), %rdi
movq %r15, %rdx
callq 0x4160
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0xd1fc
leaq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0xd1f2
leaq -0x80(%rbp), %rdi
callq 0x41a0
leaq -0x29(%rbp), %rdi
callq 0x58c6
cmpl $0x0, 0x34(%r14)
jle 0x20b89
xorl %r15d, %r15d
leaq -0x90(%rbp), %r12
leaq -0x58(%rbp), %r13
movq %r12, %rdi
callq 0x53ae
movq %rax, %rdi
movl %r15d, %esi
movsd -0x60(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x1136e
movsd %xmm0, -0x38(%rbp)
movq %r13, %rdi
callq 0x53ae
movq %rax, %rdi
movl %r15d, %esi
movsd -0x60(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
callq 0x1136e
movsd %xmm0, -0x48(%rbp)
movsd -0x38(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18510
movsd -0x38(%rbp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x48(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18510
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)
movslq 0x34(%r14), %rax
cmpq %rax, %r15
jl 0x20ac9
leaq -0x58(%rbp), %rdi
callq 0x53b8
leaq -0x90(%rbp), %rdi
callq 0x53b8
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 0x20bbe
movq %rax, %rbx
leaq -0x29(%rbp), %rdi
callq 0x58c6
jmp 0x20bf3
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x41a0
jmp 0x20bda
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x58c6
jmp 0x20bff
jmp 0x20be7
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x53b8
leaq -0x90(%rbp), %rdi
callq 0x53b8
movq %rbx, %rdi
callq 0x45a0
nop