// File: TBody[P]atomicpp/atomicpp/RateEquations.cpp
// Function: atomicpp::RateEquations::calculateElectronImpactPopulationEquation(double, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>> const&, double)
void RateEquations::calculateElectronImpactPopulationEquation(
	const double Ne,
	const std::vector<double>& Nzk,
	const std::vector<double>& Vzk,
	const double Te
	){
	
	// Initialise vectors as all zeros (this is default, but it doesn't hurt to be explicit)
	// These will be summed with Neumaier summation
	//Rates for population equation
		std::vector<double>    iz_to_above(Z+1, 0.0); //Rate (m^-3 s^-1)
		std::vector<double>  iz_from_below(Z+1, 0.0);
		std::vector<double>   rec_to_below(Z+1, 0.0);
		std::vector<double> rec_from_above(Z+1, 0.0);

	//Rates for momentum equation
		std::vector<double>    iz_p_to_above(Z+1, 0.0); //Momentum (kg m/s s^-1 = N)
		std::vector<double>  iz_p_from_below(Z+1, 0.0);
		std::vector<double>   rec_p_to_below(Z+1, 0.0);
		std::vector<double> rec_p_from_above(Z+1, 0.0);

	std::shared_ptr<RateCoefficient> ionisation_coefficient    = rate_coefficients["ionisation"];
	std::shared_ptr<RateCoefficient> recombination_coefficient = rate_coefficients["recombination"];
	
	//N.b. iterating over all data indices of the rate coefficient, hence the < since these are 0,...,Z-1  or 1,...,Z indexed
	for(int k=0; k < Z; ++k){
		double ionisation_coefficient_evaluated = ionisation_coefficient->call0D(k, Te, Ne);
		double recombination_coefficient_evaluated = recombination_coefficient->call0D(k, Te, Ne);
		
		// Note that recombination coefficients are indexed from 1 to Z, while ionisation is indexed from 0 to Z-1 (consider what 
		// charge the target must have in each case)
		int k_rec = k + 1; //The target charge state for recombination -- makes it a bit easier to understand

		double ionisation_rate_factor = ionisation_coefficient_evaluated * Ne;
		// std::printf("ionisation(%i)    K = %e, Ne = %e, Nzk = %e, R= %e\n",k,ionisation_coefficient_evaluated, Ne, Nzk[k],ionisation_rate_factor);
		double recombination_rate_factor = recombination_coefficient_evaluated * Ne;
		// std::printf("recombination(%i) K = %e, Ne = %e, Nzk = %e, R= %e\n",k+1,recombination_coefficient_evaluated, Ne, Nzk[k+1],recombination_rate_factor);

		// Want both the target and source densities to be above the Nthres density threshold
		// If we allow target to be below the source density, then won't get particle balance if ignoring stage or alternatively
		// 	will artificially pump a low density stage if we consider only source terms
		// 	N.b. Nzk[k+1] = Nzk[k_rec], Nzk[k] = Nzk[k_rec - 1], so can test just one condition and it will work for ionisation and recombination
		if((Nzk[k+1] > Nthres) and (Nzk[k] > Nthres)){
			//Rates 'to' a state are loss terms from that state. They are paired with Rates 'from'
			//which are source terms for other states
			iz_to_above.at(k)               = -ionisation_rate_factor * Nzk.at(k);
			iz_from_below.at(k+1)        = +ionisation_rate_factor * Nzk.at(k);
			rec_to_below.at(k_rec)       = -recombination_rate_factor * Nzk.at(k_rec);
			rec_from_above.at(k_rec-1)   = +recombination_rate_factor * Nzk.at(k_rec);

			iz_p_to_above.at(k)          = -ionisation_rate_factor * mz * amu_to_kg * Vzk.at(k);
			iz_p_from_below.at(k+1)      = +ionisation_rate_factor * mz * amu_to_kg * Vzk.at(k);
			rec_p_to_below.at(k_rec)     = -recombination_rate_factor * mz * amu_to_kg * Vzk.at(k_rec);
			rec_p_from_above.at(k_rec-1) = +recombination_rate_factor * mz * amu_to_kg * Vzk.at(k_rec);
		}
		// Otherwise, the rates stay as default = 0
	}

	for(int k=0; k <= Z; ++k){
		// N.b. bare nucleus will not contribute to electron density nor have an ionisation potential -- treat it separately
		// Rates will be zero for edge cases (from initialisation)
		std::vector<double> rates_for_stage              = {iz_to_above[k],iz_from_below[k],rec_to_below[k],rec_from_above[k]};
		std::pair<double, double> neumaier_pair_rates    = neumaierSum(rates_for_stage);
		dNzk[k]                                          = neumaier_pair_rates.first;
		dNzk_correction[k]                               = neumaier_pair_rates.second; //Store compensation separately for later evaluation

		std::vector<double> momentum_for_stage           = {iz_p_to_above[k],iz_p_from_below[k],rec_p_to_below[k],rec_p_from_above[k]};
		std::pair<double, double> neumaier_pair_momentum = neumaierSum(momentum_for_stage);
		F_zk[k]                                          = neumaier_pair_momentum.first;
		F_zk_correction[k]                               = neumaier_pair_momentum.second; //Store compensation separately for later evaluation
	}

	//For Neumaier summation of the change in Ne from the different rates 
	std::vector<double> dNe_from_stage(Z, 0.0);
	// Ionisation potential (in eV per transition) is not a rate coefficient, but is treated as one since the interpolation methods and
	// data shape are identical. This is used to calculate the effect of iz and rec on the electron energy (in Pcool).
	std::shared_ptr<RateCoefficient> ionisation_potential = rate_coefficients["ionisation_potential"];
	for(int k=0; k < Z; ++k){
		// N.b. bare nucleus will not contribute to electron density nor have an ionisation potential
		// Rates will be zero for edge cases (from initialisation)
		double ionisation_potential_evaluated            = ionisation_potential->call0D(k, Te, Ne);
		Pcool                                            += eV_to_J * ionisation_potential_evaluated * (iz_to_above[k] + rec_from_above[k]); //N.b. iz_to_above is -ve, rec_from_above is +ve
		dNe_from_stage[k]                                = -(iz_to_above[k] + rec_from_above[k]); //N.b. rates already have signs
	}
	// Perturbation on electron density
	std::pair<double, double> neumaier_pair_dNe      = neumaierSum(dNe_from_stage);
	dNe                                              = neumaier_pair_dNe.first + neumaier_pair_dNe.second;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5d0, %rsp            # imm = 0x5D0
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x368(%rbp)
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x360(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x58a0
movq -0x360(%rbp), %rsi
movq -0x358(%rbp), %rcx
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x26390
jmp 0x327df
leaq -0x49(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x378(%rbp)
movq $0x0, -0x80(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x58a0
movq -0x378(%rbp), %rsi
movq -0x370(%rbp), %rcx
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x26390
jmp 0x32835
leaq -0x81(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x388(%rbp)
movq $0x0, -0xa8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0x58a0
movq -0x388(%rbp), %rsi
movq -0x380(%rbp), %rcx
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x26390
jmp 0x32897
leaq -0xa9(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x398(%rbp)
movq $0x0, -0xd0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x58a0
movq -0x398(%rbp), %rsi
movq -0x390(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x26390
jmp 0x328f9
leaq -0xd1(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x3a8(%rbp)
movq $0x0, -0xf8(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x58a0
movq -0x3a8(%rbp), %rsi
movq -0x3a0(%rbp), %rcx
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
callq 0x26390
jmp 0x3295b
leaq -0xf9(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x3b8(%rbp)
movq $0x0, -0x120(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x58a0
movq -0x3b8(%rbp), %rsi
movq -0x3b0(%rbp), %rcx
leaq -0x118(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0x26390
jmp 0x329bd
leaq -0x121(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x3c8(%rbp)
movq $0x0, -0x148(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x58a0
movq -0x3c8(%rbp), %rsi
movq -0x3c0(%rbp), %rcx
leaq -0x140(%rbp), %rdi
leaq -0x148(%rbp), %rdx
callq 0x26390
jmp 0x32a1f
leaq -0x149(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movl 0x34(%rax), %eax
incl %eax
cltq
movq %rax, -0x3d8(%rbp)
movq $0x0, -0x170(%rbp)
leaq -0x171(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x58a0
movq -0x3d8(%rbp), %rsi
movq -0x3d0(%rbp), %rcx
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rdx
callq 0x26390
jmp 0x32a81
leaq -0x171(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movq %rax, -0x3e8(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x45f0
movq -0x3e0(%rbp), %rdx
leaq 0x3574(%rip), %rsi      # 0x36030
leaq -0x1a8(%rbp), %rdi
callq 0x44d0
jmp 0x32aca
movq -0x3e8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x13990
movq %rax, -0x3f0(%rbp)
jmp 0x32ae6
movq -0x3f0(%rbp), %rsi
leaq -0x188(%rbp), %rdi
callq 0x13960
leaq -0x1a8(%rbp), %rdi
callq 0x4220
leaq -0x1a9(%rbp), %rdi
callq 0x4410
movq -0x368(%rbp), %rax
movq %rax, -0x400(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0x45f0
movq -0x3f8(%rbp), %rdx
leaq 0x34fb(%rip), %rsi      # 0x3603b
leaq -0x1e0(%rbp), %rdi
callq 0x44d0
jmp 0x32b4e
movq -0x400(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x13990
movq %rax, -0x408(%rbp)
jmp 0x32b6a
movq -0x408(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x13960
leaq -0x1e0(%rbp), %rdi
callq 0x4220
leaq -0x1e1(%rbp), %rdi
callq 0x4410
movl $0x0, -0x1e8(%rbp)
movq -0x368(%rbp), %rcx
movl -0x1e8(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x33288
leaq -0x188(%rbp), %rdi
callq 0x5970
movq %rax, %rdi
movl -0x1e8(%rbp), %esi
movsd -0x28(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x1aa40
movsd %xmm0, -0x410(%rbp)
jmp 0x32be3
movsd -0x410(%rbp), %xmm0
movsd %xmm0, -0x1f0(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x5970
movq %rax, %rdi
movl -0x1e8(%rbp), %esi
movsd -0x28(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x1aa40
movsd %xmm0, -0x418(%rbp)
jmp 0x32c21
movsd -0x418(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movl -0x1e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
movsd -0x1f0(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x208(%rbp)
movsd -0x1f8(%rbp), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x210(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1e8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x26b60
movq %rax, %rcx
movq -0x368(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x40(%rax), %xmm0
jbe 0x33272
movq -0x18(%rbp), %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x26b60
movq %rax, %rcx
movq -0x368(%rbp), %rax
movsd (%rcx), %xmm0
ucomisd 0x40(%rax), %xmm0
jbe 0x33272
movaps 0x65d8(%rip), %xmm1     # 0x392a0
movsd -0x208(%rbp), %xmm0
pxor %xmm1, %xmm0
movsd %xmm0, -0x428(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x2f490
movq %rax, -0x420(%rbp)
jmp 0x32cf5
movsd -0x428(%rbp), %xmm0
movq -0x420(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x438(%rbp)
movslq -0x1e8(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x430(%rbp)
jmp 0x32d2d
movq -0x430(%rbp), %rax
movsd -0x438(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x208(%rbp), %xmm0
movsd %xmm0, -0x448(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x2f490
movq %rax, -0x440(%rbp)
jmp 0x32d69
movsd -0x448(%rbp), %xmm0
movq -0x440(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x458(%rbp)
movl -0x1e8(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x450(%rbp)
jmp 0x32da5
movq -0x450(%rbp), %rax
movsd -0x458(%rbp), %xmm0
movsd %xmm0, (%rax)
movaps 0x64e1(%rip), %xmm1     # 0x392a0
movsd -0x210(%rbp), %xmm0
pxor %xmm1, %xmm0
movsd %xmm0, -0x468(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x1fc(%rbp), %rsi
callq 0x2f490
movq %rax, -0x460(%rbp)
jmp 0x32dec
movsd -0x468(%rbp), %xmm0
movq -0x460(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x478(%rbp)
movslq -0x1fc(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x470(%rbp)
jmp 0x32e27
movq -0x470(%rbp), %rax
movsd -0x478(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x210(%rbp), %xmm0
movsd %xmm0, -0x488(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x1fc(%rbp), %rsi
callq 0x2f490
movq %rax, -0x480(%rbp)
jmp 0x32e63
movsd -0x488(%rbp), %xmm0
movq -0x480(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x498(%rbp)
movl -0x1fc(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x490(%rbp)
jmp 0x32ea2
movq -0x368(%rbp), %rax
movq -0x490(%rbp), %rcx
movsd -0x498(%rbp), %xmm0
movsd %xmm0, (%rcx)
movsd -0x208(%rbp), %xmm0
movsd 0x38(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x63ab(%rip), %xmm1     # 0x39280
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4a8(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x2f490
movq %rax, -0x4a0(%rbp)
jmp 0x32efa
movsd -0x4a8(%rbp), %xmm0
movq -0x4a0(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4b8(%rbp)
movslq -0x1e8(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x4b0(%rbp)
jmp 0x32f35
movq -0x368(%rbp), %rax
movq -0x4b0(%rbp), %rcx
movsd -0x4b8(%rbp), %xmm0
movsd %xmm0, (%rcx)
movsd -0x208(%rbp), %xmm0
movsd 0x38(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x6320(%rip), %xmm1     # 0x39288
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4c8(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x2f490
movq %rax, -0x4c0(%rbp)
jmp 0x32f8d
movsd -0x4c8(%rbp), %xmm0
movq -0x4c0(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4d8(%rbp)
movl -0x1e8(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x118(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x4d0(%rbp)
jmp 0x32fcc
movq -0x368(%rbp), %rax
movq -0x4d0(%rbp), %rcx
movsd -0x4d8(%rbp), %xmm0
movsd %xmm0, (%rcx)
movsd -0x210(%rbp), %xmm0
movsd 0x38(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x6281(%rip), %xmm1     # 0x39280
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4e8(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x1fc(%rbp), %rsi
callq 0x2f490
movq %rax, -0x4e0(%rbp)
jmp 0x33024
movsd -0x4e8(%rbp), %xmm0
movq -0x4e0(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x4f8(%rbp)
movslq -0x1fc(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x4f0(%rbp)
jmp 0x3305f
movq -0x368(%rbp), %rax
movq -0x4f0(%rbp), %rcx
movsd -0x4f8(%rbp), %xmm0
movsd %xmm0, (%rcx)
movsd -0x210(%rbp), %xmm0
movsd 0x38(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x61f6(%rip), %xmm1     # 0x39288
mulsd %xmm1, %xmm0
movsd %xmm0, -0x508(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x1fc(%rbp), %rsi
callq 0x2f490
movq %rax, -0x500(%rbp)
jmp 0x330b7
movsd -0x508(%rbp), %xmm0
movq -0x500(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x518(%rbp)
movl -0x1fc(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x168(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0x510(%rbp)
jmp 0x330f6
movq -0x510(%rbp), %rax
movsd -0x518(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x33272
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x5930
jmp 0x33a68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x5930
jmp 0x33a5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x5930
jmp 0x33a56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x5930
jmp 0x33a4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf9(%rbp), %rdi
callq 0x5930
jmp 0x33a3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x5930
jmp 0x33a32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x149(%rbp), %rdi
callq 0x5930
jmp 0x33a26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x171(%rbp), %rdi
callq 0x5930
jmp 0x33a1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x33219
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x4220
leaq -0x1a9(%rbp), %rdi
callq 0x4410
jmp 0x33a0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x33250
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x4220
leaq -0x1e1(%rbp), %rdi
callq 0x4410
jmp 0x33a02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x339f6
jmp 0x33274
movl -0x1e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e8(%rbp)
jmp 0x32b9f
movl $0x0, -0x214(%rbp)
movq -0x368(%rbp), %rcx
movl -0x214(%rbp), %eax
cmpl 0x34(%rcx), %eax
jg 0x33641
movslq -0x214(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x260(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x258(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x250(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x248(%rbp)
leaq -0x260(%rbp), %rax
movq %rax, -0x240(%rbp)
movq $0x4, -0x238(%rbp)
leaq -0x261(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x58a0
movq -0x520(%rbp), %rcx
movq -0x240(%rbp), %rsi
movq -0x238(%rbp), %rdx
leaq -0x230(%rbp), %rdi
callq 0x26a40
jmp 0x3336d
leaq -0x261(%rbp), %rdi
callq 0x5930
leaq -0x230(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x35490
movsd %xmm1, -0x530(%rbp)
movsd %xmm0, -0x528(%rbp)
jmp 0x3339a
movq -0x368(%rbp), %rdi
movsd -0x530(%rbp), %xmm0
movsd -0x528(%rbp), %xmm1
movsd %xmm1, -0x278(%rbp)
movsd %xmm0, -0x270(%rbp)
movsd -0x278(%rbp), %xmm0
movsd %xmm0, -0x548(%rbp)
addq $0x70, %rdi
movslq -0x214(%rbp), %rsi
callq 0x5950
movsd -0x548(%rbp), %xmm0
movq -0x368(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x270(%rbp), %xmm0
movsd %xmm0, -0x540(%rbp)
addq $0xa0, %rdi
movslq -0x214(%rbp), %rsi
callq 0x5950
movsd -0x540(%rbp), %xmm0
movsd %xmm0, (%rax)
movslq -0x214(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x2c0(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0x118(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x2b8(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x2b0(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0x168(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x2a8(%rbp)
leaq -0x2c0(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq $0x4, -0x298(%rbp)
leaq -0x2c1(%rbp), %rdi
movq %rdi, -0x538(%rbp)
callq 0x58a0
movq -0x538(%rbp), %rcx
movq -0x2a0(%rbp), %rsi
movq -0x298(%rbp), %rdx
leaq -0x290(%rbp), %rdi
callq 0x26a40
jmp 0x334ee
leaq -0x2c1(%rbp), %rdi
callq 0x5930
leaq -0x290(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x35490
movsd %xmm1, -0x558(%rbp)
movsd %xmm0, -0x550(%rbp)
jmp 0x3351b
movq -0x368(%rbp), %rdi
movsd -0x558(%rbp), %xmm0
movsd -0x550(%rbp), %xmm1
movsd %xmm1, -0x2d8(%rbp)
movsd %xmm0, -0x2d0(%rbp)
movsd -0x2d8(%rbp), %xmm0
movsd %xmm0, -0x568(%rbp)
addq $0x88, %rdi
movslq -0x214(%rbp), %rsi
callq 0x5950
movsd -0x568(%rbp), %xmm0
movq -0x368(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x2d0(%rbp), %xmm0
movsd %xmm0, -0x560(%rbp)
addq $0xb8, %rdi
movslq -0x214(%rbp), %rsi
callq 0x5950
movsd -0x560(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x290(%rbp), %rdi
callq 0x59b0
leaq -0x230(%rbp), %rdi
callq 0x59b0
movl -0x214(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x33292
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x261(%rbp), %rdi
callq 0x5930
jmp 0x339f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x33630
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x2c1(%rbp), %rdi
callq 0x5930
jmp 0x33630
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x59b0
leaq -0x230(%rbp), %rdi
callq 0x59b0
jmp 0x339f6
movq -0x368(%rbp), %rax
movslq 0x34(%rax), %rax
movq %rax, -0x578(%rbp)
movq $0x0, -0x2f8(%rbp)
leaq -0x2f9(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x58a0
movq -0x578(%rbp), %rsi
movq -0x570(%rbp), %rcx
leaq -0x2f0(%rbp), %rdi
leaq -0x2f8(%rbp), %rdx
callq 0x26390
jmp 0x33694
leaq -0x2f9(%rbp), %rdi
callq 0x5930
movq -0x368(%rbp), %rax
movq %rax, -0x588(%rbp)
leaq -0x331(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0x45f0
movq -0x580(%rbp), %rdx
leaq 0x4295(%rip), %rsi      # 0x37964
leaq -0x330(%rbp), %rdi
callq 0x44d0
jmp 0x336dd
movq -0x588(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x13990
movq %rax, -0x590(%rbp)
jmp 0x336f9
movq -0x590(%rbp), %rsi
leaq -0x310(%rbp), %rdi
callq 0x13960
leaq -0x330(%rbp), %rdi
callq 0x4220
leaq -0x331(%rbp), %rdi
callq 0x4410
movl $0x0, -0x338(%rbp)
movq -0x368(%rbp), %rcx
movl -0x338(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x338f7
leaq -0x310(%rbp), %rdi
callq 0x5970
movq %rax, %rdi
movl -0x338(%rbp), %esi
movsd -0x28(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x1aa40
movsd %xmm0, -0x598(%rbp)
jmp 0x33772
movsd -0x598(%rbp), %xmm0
movsd %xmm0, -0x340(%rbp)
movsd 0x5aee(%rip), %xmm0     # 0x39278
mulsd -0x340(%rbp), %xmm0
movsd %xmm0, -0x5b0(%rbp)
movslq -0x338(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x5b8(%rbp)
movslq -0x338(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x5950
movsd -0x5b8(%rbp), %xmm2
movsd -0x5b0(%rbp), %xmm0
movq %rax, %rcx
movq -0x368(%rbp), %rax
addsd (%rcx), %xmm2
movsd 0x60(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rax)
movslq -0x338(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x5950
movsd (%rax), %xmm0
movsd %xmm0, -0x5a8(%rbp)
movslq -0x338(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x5950
movsd -0x5a8(%rbp), %xmm0
addsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x5a0(%rbp)
movslq -0x338(%rbp), %rsi
leaq -0x2f0(%rbp), %rdi
callq 0x5950
movsd -0x5a0(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x338(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x338(%rbp)
jmp 0x3372e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x2f9(%rbp), %rdi
callq 0x5930
jmp 0x339f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x338c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x330(%rbp), %rdi
callq 0x4220
leaq -0x331(%rbp), %rdi
callq 0x4410
jmp 0x339ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x5990
jmp 0x339ea
leaq -0x2f0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x35490
movsd %xmm1, -0x5c8(%rbp)
movsd %xmm0, -0x5c0(%rbp)
jmp 0x33918
movq -0x368(%rbp), %rax
movsd -0x5c8(%rbp), %xmm0
movsd -0x5c0(%rbp), %xmm1
movsd %xmm1, -0x350(%rbp)
movsd %xmm0, -0x348(%rbp)
movsd -0x350(%rbp), %xmm0
addsd -0x348(%rbp), %xmm0
movsd %xmm0, 0xd0(%rax)
leaq -0x310(%rbp), %rdi
callq 0x5990
leaq -0x2f0(%rbp), %rdi
callq 0x59b0
leaq -0x1c0(%rbp), %rdi
callq 0x5990
leaq -0x188(%rbp), %rdi
callq 0x5990
leaq -0x168(%rbp), %rdi
callq 0x59b0
leaq -0x140(%rbp), %rdi
callq 0x59b0
leaq -0x118(%rbp), %rdi
callq 0x59b0
leaq -0xf0(%rbp), %rdi
callq 0x59b0
leaq -0xc8(%rbp), %rdi
callq 0x59b0
leaq -0xa0(%rbp), %rdi
callq 0x59b0
leaq -0x78(%rbp), %rdi
callq 0x59b0
leaq -0x40(%rbp), %rdi
callq 0x59b0
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
leaq -0x2f0(%rbp), %rdi
callq 0x59b0
leaq -0x1c0(%rbp), %rdi
callq 0x5990
leaq -0x188(%rbp), %rdi
callq 0x5990
leaq -0x168(%rbp), %rdi
callq 0x59b0
leaq -0x140(%rbp), %rdi
callq 0x59b0
leaq -0x118(%rbp), %rdi
callq 0x59b0
leaq -0xf0(%rbp), %rdi
callq 0x59b0
leaq -0xc8(%rbp), %rdi
callq 0x59b0
leaq -0xa0(%rbp), %rdi
callq 0x59b0
leaq -0x78(%rbp), %rdi
callq 0x59b0
leaq -0x40(%rbp), %rdi
callq 0x59b0
movq -0x58(%rbp), %rdi
callq 0x45e0
nopw %cs:(%rax,%rax)