// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movapd %xmm0, 0x10(%rsp)
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
cmpl $0x2, 0x1614(%rsi)
jbe 0x7eb66
movq 0xe7482(%rip), %rdi     # 0x165f98
leaq 0x5fcba(%rip), %rsi     # 0xde7d7
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movl 0x1614(%r12), %eax
xorpd %xmm0, %xmm0
movhpd 0x576da(%rip), %xmm0    # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x20(%rsp)
cmpl $0x3, %eax
jb 0x7eb78
movq 0xe7448(%rip), %rdi     # 0x165f98
leaq 0x5ac15(%rip), %rsi     # 0xd976c
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
jmp 0x7eb78
xorpd %xmm0, %xmm0
movhpd 0x576a6(%rip), %xmm0    # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x20(%rsp)
leaq 0x58(%r12), %r15
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x866dc
cvtss2sd 0x40(%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x7ebca
cmpl $0x3, 0x1614(%r12)
jb 0x7ebd5
movq 0xe73f0(%rip), %rdi     # 0x165f98
leaq 0x5fc3f(%rip), %rsi     # 0xde7ee
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
cmpl $0x3, 0x1614(%r12)
setae %al
jmp 0x7ebd7
movapd 0x10(%rsp), %xmm0
jmp 0x7ec59
xorl %eax, %eax
movapd 0x56fc1(%rip), %xmm0    # 0xd5ba0
andpd 0x10(%rsp), %xmm0
cvtss2sd 0x44(%r14), %xmm1
mulsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
testb %al, %al
je 0x7ec18
movq 0xe7394(%rip), %rdi     # 0x165f98
leaq 0x5ab61(%rip), %rsi     # 0xd976c
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movss 0xc(%rsp), %xmm0
addss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm1
leaq 0x38(%rsp), %r14
xorps %xmm0, %xmm0
movq %r14, %rdi
callq 0x866ac
movq %r14, %rdi
movq %r15, %rsi
callq 0x866dc
cvtss2sd 0xc(%rsp), %xmm1
subsd %xmm1, %xmm0
movapd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x9f57b
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq