// File: /workspace/github_cpp_makefile_star2_O2/TBody[P]atomicpp/atomicpp/RateEquations.cpp
// Function: atomicpp::RateEquations::computeDerivs(double, double, double, double, double, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&)
DerivStruct RateEquations::computeDerivs(
	const double Te,
	const double Ne,
	const double Vi,
	const double Nn,
	const double Vn,
	const std::vector<double>& Nzk,
	const std::vector<double>& Vzk){

	resetDerivatives(); //Reset all the derivatives to zero, since the object has a memory of the previous step

	calculateElectronImpactPopulationEquation(Ne, Nzk, Vzk, Te);

	if (use_charge_exchange){
		calculateChargeExchangePopulationEquation(Nn, Nzk, Vzk, Te, Ne);
	}

	verifyNeumaierSummation(Te, Ne);

	calculateIonIonDrag(Ne, Te, Vi, Nzk, Vzk);

	calculateIonNeutralDrag(Nn, Vn, Nzk, Vzk);

	calculateElectronImpactPowerEquation(Ne, Nzk, Te);
	
	if (use_charge_exchange){
		calculateChargeExchangePowerEquation(Nn, Nzk, Te, Ne);
	}

	// Apply neumairSum corrections
	for(int k=0; k<=Z; ++k){
		dNzk[k] += dNzk_correction[k];
		F_zk[k] += F_zk_correction[k];
	}
	
	DerivStruct derivative_struct = makeDerivativeStruct();
	return derivative_struct;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r12
movq %rdx, %r15
movsd %xmm4, -0x50(%rbp)
movsd %xmm3, -0x40(%rbp)
movsd %xmm2, -0x48(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm0, -0x38(%rbp)
movq %rsi, %r14
movq %rdi, -0x58(%rbp)
movq %rsi, %rdi
callq 0x1e770
movq %r14, %rdi
movsd -0x30(%rbp), %xmm0
movq %r15, %rsi
movq %r12, %rdx
movsd -0x38(%rbp), %xmm1
callq 0x1e810
cmpb $0x1, 0x30(%r14)
jne 0x1e63f
movsd 0x5a46(%rip), %xmm3     # 0x24068
movq %r14, %rdi
movsd -0x40(%rbp), %xmm0
movq %r15, %rsi
movq %r12, %rdx
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x1f3e4
movsd 0x29c1(%rip), %xmm2     # 0x21008
movq %r14, %rdi
movsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x1fbee
movq %r14, %rdi
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
movq %r15, %rsi
movq %r12, %rdx
callq 0x1feac
movq %r14, %rdi
movsd -0x40(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
movq %r15, %rsi
movq %r12, %rdx
callq 0x1ffb6
movq %r14, %rdi
movsd -0x30(%rbp), %xmm0
movq %r15, %rsi
movsd -0x38(%rbp), %xmm1
callq 0x2008e
cmpb $0x1, 0x30(%r14)
jne 0x1e6c4
movq %r14, %rdi
movsd -0x40(%rbp), %xmm0
movq %r15, %rsi
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x20294
leaq 0xa0(%r14), %rax
movq %rax, -0x38(%rbp)
leaq 0x70(%r14), %r12
leaq 0xb8(%r14), %r13
movq %r14, %rbx
leaq 0x88(%r14), %r15
xorl %r14d, %r14d
movslq 0x34(%rbx), %rax
cmpq %rax, %r14
jg 0x1e74e
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq %r13, %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x537c
movsd -0x30(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
incq %r14
jmp 0x1e6e7
movq -0x58(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x203b2
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop