// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq %rax, -0xd0(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x45f0
movq -0xc8(%rbp), %rdx
leaq 0x2b9b(%rip), %rsi      # 0x37948
leaq -0x50(%rbp), %rdi
callq 0x44d0
jmp 0x34db8
movq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x13990
movq %rax, -0xe0(%rbp)
jmp 0x34dd1
movq -0xe0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x13960
leaq -0x50(%rbp), %rdi
callq 0x4220
leaq -0x51(%rbp), %rdi
callq 0x4410
movq -0xd0(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x45f0
movq -0xe8(%rbp), %rdx
leaq 0x2b12(%rip), %rsi      # 0x37934
leaq -0x98(%rbp), %rdi
callq 0x44d0
jmp 0x34e30
movq -0xf0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x13990
movq %rax, -0xf8(%rbp)
jmp 0x34e4c
movq -0xf8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x13960
leaq -0x98(%rbp), %rdi
callq 0x4220
leaq -0x99(%rbp), %rdi
callq 0x4410
movl $0x0, -0xa0(%rbp)
movq -0xd0(%rbp), %rcx
movl -0xa0(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x3504c
leaq -0x30(%rbp), %rdi
callq 0x5970
movq %rax, %rdi
movl -0xa0(%rbp), %esi
movsd -0x20(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x1aa40
movsd %xmm0, -0x100(%rbp)
jmp 0x34ebf
movsd -0x100(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5970
movq %rax, %rdi
movl -0xa0(%rbp), %esi
movsd -0x20(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x1aa40
movsd %xmm0, -0x108(%rbp)
jmp 0x34efa
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xa8(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
movq -0x18(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0x26b60
movsd -0x118(%rbp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb0(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movq -0x18(%rbp), %rdi
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x26b60
movsd -0x110(%rbp), %xmm0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
mulsd (%rcx), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xb8(%rbp), %xmm0
addsd -0xc0(%rbp), %xmm0
addsd 0x68(%rax), %xmm0
movsd %xmm0, 0x68(%rax)
movsd -0xb8(%rbp), %xmm0
addsd -0xc0(%rbp), %xmm0
addsd 0x60(%rax), %xmm0
movsd %xmm0, 0x60(%rax)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x34e7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x34ff6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4220
leaq -0x51(%rbp), %rdi
callq 0x4410
jmp 0x35070
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x35027
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4220
leaq -0x99(%rbp), %rdi
callq 0x4410
jmp 0x35067
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5990
jmp 0x35067
leaq -0x78(%rbp), %rdi
callq 0x5990
leaq -0x30(%rbp), %rdi
callq 0x5990
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x5990
movq -0x60(%rbp), %rdi
callq 0x45e0
nopl (%rax)