// File: /workspace/github_cpp_makefile_star2_O1/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, -0x58(%rbp)
movsd %xmm3, -0x48(%rbp)
movsd %xmm2, -0x50(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm0, -0x40(%rbp)
movq %rsi, %rbx
movq %rdi, -0x60(%rbp)
movq %rsi, %rdi
callq 0x1f070
movq %rbx, %rdi
movsd -0x30(%rbp), %xmm0
movq %r15, %rsi
movq %r12, %rdx
movsd -0x40(%rbp), %xmm1
callq 0x1f124
movq %rbx, -0x38(%rbp)
cmpb $0x1, 0x30(%rbx)
jne 0x1ef2b
movsd 0x615b(%rip), %xmm3     # 0x25068
movq -0x38(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movq %r15, %rsi
movq %r12, %rdx
movsd -0x40(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x1fcf2
movsd 0x30d5(%rip), %xmm2     # 0x22008
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x20518
movq %rbx, %rdi
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
movq %r15, %rsi
movq %r12, %rdx
callq 0x207fa
movq %rbx, %rdi
movsd -0x48(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movq %r15, %rsi
movq %r12, %rdx
callq 0x2091a
movq %rbx, %rdi
movsd -0x30(%rbp), %xmm0
movq %r15, %rsi
movsd -0x40(%rbp), %xmm1
callq 0x209fa
cmpb $0x1, 0x30(%rbx)
jne 0x1efb4
movq -0x38(%rbp), %rdi
movsd -0x48(%rbp), %xmm0
movq %r15, %rsi
movsd -0x40(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x20c08
movq -0x38(%rbp), %rax
cmpl $0x0, 0x34(%rax)
js 0x1f04e
movq -0x38(%rbp), %rax
leaq 0xa0(%rax), %r15
leaq 0x70(%rax), %r12
leaq 0xb8(%rax), %r13
leaq 0x88(%rax), %rbx
movq $-0x1, %r14
incq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq %r13, %rdi
movq %r14, %rsi
callq 0x539c
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x539c
movsd -0x30(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x38(%rbp), %rax
movslq 0x34(%rax), %rax
cmpq %rax, %r14
jl 0x1efe6
movq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x20d2c
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq