// File: /workspace/github_cpp_makefile_star2_O2/TBody[P]atomicpp/atomicpp/RateEquations.cpp
// Function: atomicpp::RateEquations::verifyNeumaierSummation(double, double, double)
void RateEquations::verifyNeumaierSummation(const double Te, const double Ne, const double NeumaierTolerance){
	// Verify that the sum over all elements equals zero (or very close to) 
	
	std::vector<double> check_dNzk(2*(Z+1), 0.0);
	std::vector<double> check_F_zk(2*(Z+1), 0.0);
	for(int k=0; k<=Z; ++k){
		check_dNzk[2*k] = dNzk[k];
		check_dNzk[2*k+1] = dNzk_correction[k];
		check_F_zk[2*k] = F_zk[k];
		check_F_zk[2*k+1] = F_zk_correction[k];
	}
	std::pair<double, double> neumaier_pair_total_dNzk = neumaierSum(check_dNzk);
	std::pair<double, double> neumaier_pair_total_F_zk = neumaierSum(check_F_zk); 

	// std::printf("Total sum: %e\n", neumaier_pair_total_dNzk.first + neumaier_pair_total_dNzk.second); 
	if(std::fabs(neumaier_pair_total_dNzk.first + neumaier_pair_total_dNzk.second) > NeumaierTolerance){ 
		std::printf("Warning: total sum of dNzk elements is non-zero (=%e) for Te = %f, Ne = %e- may result in error\n>>>in Prad.cpp/computeDerivs (May be an error with Kahan-Neumaier summation)\n", neumaier_pair_total_dNzk.first + neumaier_pair_total_dNzk.second, Te, Ne);
	}

	// std::printf("Total sum: %e\n", neumaier_pair_total_F_zk.first + neumaier_pair_total_F_zk.second); 
	if(std::fabs(neumaier_pair_total_F_zk.first + neumaier_pair_total_F_zk.second) > NeumaierTolerance){ 
		std::printf("Warning: total sum of F_zk elements is non-zero (=%e) for Te = %f, Ne = %e- may result in error\n>>>in Prad.cpp/computeDerivs (May be an error with Kahan-Neumaier summation)\n", neumaier_pair_total_F_zk.first + neumaier_pair_total_F_zk.second, Te, Ne);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm2, -0x78(%rbp)
movsd %xmm1, -0x70(%rbp)
movsd %xmm0, -0x68(%rbp)
movq %rdi, %r13
movl 0x34(%rdi), %eax
leal 0x2(,%rax,2), %eax
movslq %eax, %rbx
leaq -0xa8(%rbp), %r14
andq $0x0, (%r14)
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x531c
leaq -0xc0(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x17a40
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x5a64
movl 0x34(%r13), %eax
leal 0x2(,%rax,2), %eax
movslq %eax, %r14
andq $0x0, (%rbx)
leaq -0x29(%rbp), %rbx
movq %rbx, %rdi
callq 0x531c
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rdx
movq %r14, %rsi
movq %rbx, %rcx
callq 0x17a40
leaq -0x29(%rbp), %rdi
callq 0x5a64
leaq 0x70(%r13), %rax
movq %rax, -0x60(%rbp)
leaq 0xa0(%r13), %rax
movq %rax, -0x90(%rbp)
leaq 0x88(%r13), %rax
movq %rax, -0x88(%rbp)
leaq 0xb8(%r13), %rax
movq %rax, -0x80(%rbp)
pushq $0x1
popq %rbx
xorl %r14d, %r14d
movslq 0x34(%r13), %rax
cmpq %rax, %r14
jg 0x1fda6
movq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq %r13, %r15
leaq -0x1(%rbx), %r13
leaq -0xc0(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x537c
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x537c
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq -0xa8(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %r13
callq 0x537c
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x537c
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x537c
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
incq %r14
addq $0x2, %rbx
jmp 0x1fccb
leaq -0xc0(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x20572
movsd %xmm0, -0x40(%rbp)
movapd %xmm1, -0x60(%rbp)
leaq -0xa8(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x20572
movapd %xmm0, %xmm2
movapd %xmm1, %xmm3
movapd -0x60(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movapd 0x3d06(%rip), %xmm1     # 0x23af0
andpd %xmm0, %xmm1
ucomisd -0x78(%rbp), %xmm1
jbe 0x1fe21
leaq 0x42a4(%rip), %rdi      # 0x240a0
movsd -0x68(%rbp), %xmm1
movapd %xmm2, -0x40(%rbp)
movsd -0x70(%rbp), %xmm2
movb $0x3, %al
movsd %xmm3, -0x60(%rbp)
callq 0x4080
movsd -0x60(%rbp), %xmm3
movapd -0x40(%rbp), %xmm2
addsd %xmm3, %xmm2
movapd 0x3cc3(%rip), %xmm0     # 0x23af0
andpd %xmm2, %xmm0
ucomisd -0x78(%rbp), %xmm0
jbe 0x1fe54
leaq 0x430f(%rip), %rdi      # 0x2414e
movapd %xmm2, %xmm0
movsd -0x68(%rbp), %xmm1
movsd -0x70(%rbp), %xmm2
movb $0x3, %al
callq 0x4080
leaq -0xa8(%rbp), %rdi
callq 0x53a6
leaq -0xc0(%rbp), %rdi
callq 0x53a6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x29(%rbp), %rdi
callq 0x5a64
leaq -0xc0(%rbp), %rdi
callq 0x53a6
jmp 0x1fea4
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x5a64
movq %rbx, %rdi
callq 0x45a0