// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::mutateParamGA[abi:cxx11](FreeParam*, double)
string Swarm::mutateParamGA(FreeParam* fp, double paramValue) {
	//Timer tmr;
	//uniform_real_distribution<double> unif(0,1);
	if(options.verbosity>=3){
		cout << "generating random dist" << endl;
	}
	boost::random::uniform_real_distribution<double> unif(0,1);
	if(options.verbosity>=3){
		cout << "done" << endl;
	}
	// Generate a random number and see if it's less than our mutation rate.  If is, we mutate.
	if (unif(generalRand) < fp->getMutationRate()) {
		// Store our mutation factor
		if(options.verbosity>=3){
			cout << "setting maxrange" << endl;
		}
		float maxChange = abs(paramValue) * fp->getMutationFactor();
		if(options.verbosity>=3){
			cout << "done" << endl;
		}
		// Generate a new distribution between 0 and double maxChange
		//using param_t = uniform_real_distribution<>::param_type;
		//param_t p{0.0, maxChange * 2};
		//unif.param(p);

		boost::random::uniform_real_distribution<double> unif(0.0, maxChange * 2);

		// Ger our new random number between 0 and maxChange, subtract maxChange.
		double change = unif(generalRand) - maxChange;

		// Add/subtract the value from the parameter
		paramValue+= change;
		//cout << "factor: " << fp->getMutationFactor() << " max change: " << maxChange << " rand: " << rand << endl << endl;
	}
	//double t = tmr.elapsed();
	//cout << "Mutate took " << t << " seconds" << endl;
	return toString(paramValue);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x68(%rbp)
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpl $0x3, 0x1614(%rax)
jb 0x10f14a
movq 0x1c5e21(%rip), %rdi    # 0x2d4f50
leaq 0xd40b0(%rip), %rsi     # 0x1e31e6
callq 0x2ff50
movq %rax, %rdi
movq 0x1c5e83(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
leaq -0x30(%rbp), %rdi
xorps %xmm0, %xmm0
movsd 0xcb9cf(%rip), %xmm1    # 0x1dab28
callq 0x123940
movq -0x58(%rbp), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x10f18d
movq 0x1c5dde(%rip), %rdi    # 0x2d4f50
leaq 0xcf083(%rip), %rsi     # 0x1de1fc
callq 0x2ff50
movq %rax, %rdi
movq 0x1c5e40(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
movq -0x58(%rbp), %rsi
addq $0x58, %rsi
leaq -0x30(%rbp), %rdi
callq 0x1239b0
movsd %xmm0, -0x70(%rbp)
movq -0x18(%rbp), %rdi
callq 0x123ae0
movsd -0x70(%rbp), %xmm1
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x10f29d
movq -0x58(%rbp), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x10f1ee
movq 0x1c5d7d(%rip), %rdi    # 0x2d4f50
leaq 0xd4023(%rip), %rsi     # 0x1e31fd
callq 0x2ff50
movq %rax, %rdi
movq 0x1c5ddf(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
movsd -0x20(%rbp), %xmm0
callq 0x9c8a0
movsd %xmm0, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x123b00
movq -0x58(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
cvtss2sd %xmm1, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
cmpl $0x3, 0x1614(%rax)
jb 0x10f24e
movq 0x1c5d1d(%rip), %rdi    # 0x2d4f50
leaq 0xcefc2(%rip), %rsi     # 0x1de1fc
callq 0x2ff50
movq %rax, %rdi
movq 0x1c5d7f(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
movss 0xcb8ee(%rip), %xmm0    # 0x1dab44
mulss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
leaq -0x48(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x123940
movq -0x58(%rbp), %rsi
addq $0x58, %rsi
leaq -0x48(%rbp), %rdi
callq 0x1239b0
movss -0x34(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x68(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x17e490
movq -0x60(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)