// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateBestFitModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Swarm::generateBestFitModel(string outputDir) {
	map<string, double> paramSet;

	vector<string> paramVals;
	auto best = allGenFits.begin();
	split(best->second, paramVals);

	auto fp = this->getFreeParams_().begin();
	for (unsigned int i = 1; i < paramVals.size(); i++) {
		paramSet.insert(pair<string, double> (fp->first, stod(paramVals[i])));
		++fp;
	}
	if (options.verbosity>=3) cout<<"Swarm: Generating Best Fit Model in path:"<< outputDir<< " File:"<<options.jobName<<".bngl .\n";

	//razi TODO:   adjust paramSet based on the model
	for (unsigned int mid =0; mid < options.models.size(); mid++){
		options.models[mid]->outputModelWithParams(paramSet, outputDir, (options.jobName + ".bngl"), "", false, false, false, false, false);
	}

	if(options.verbosity>=3){
		cout << "Finished saving " << options.jobName << ".bngl" << endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, 0x38(%rsp)
leaq 0xe0(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rcx, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x20(%rdi), %r14
leaq 0x70(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x6c127(%rip), %rsi     # 0x10143d
leaq 0x6c121(%rip), %rdx     # 0x10143e
leaq 0x60(%rsp), %rdi
callq 0x32210
addq $0x28, %r14
leaq 0x20(%rsp), %rsi
leaq 0x60(%rsp), %rdx
movq %r14, %rdi
callq 0xbf342
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x95354
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rax
subq %r12, %rax
cmpq $0x21, %rax
jb 0x95464
movq 0x8(%rsp), %rax
movq 0x15a8(%rax), %rbx
callq 0x22070
movq %rax, 0x18(%rsp)
movl $0x1, %eax
movl $0x2, %ebp
leaq 0x60(%rsp), %r14
movq 0x18(%rsp), %r15
shlq $0x5, %rax
movq (%r12,%rax), %r12
movl (%r15), %eax
movl %eax, 0x14(%rsp)
movl $0x0, (%r15)
movq %r12, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x22760
cmpq %r12, 0xd0(%rsp)
je 0x95723
movl (%r15), %eax
testl %eax, %eax
movsd %xmm0, 0xc8(%rsp)
je 0x953e3
cmpl $0x22, %eax
jne 0x953ea
jmp 0x9572f
movl 0x14(%rsp), %eax
movl %eax, (%r15)
movq %r13, 0x60(%rsp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x32180
movsd 0xc8(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
callq 0x4d33e
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x9543b
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x22ad0
movq %rax, %rbx
movl %ebp, %eax
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %rcx
subq %r12, %rcx
sarq $0x5, %rcx
incl %ebp
cmpq %rax, %rcx
ja 0x95395
movq 0x8(%rsp), %rax
cmpl $0x2, 0x1614(%rax)
jbe 0x954e8
movq 0xe0b17(%rip), %rdi     # 0x175f90
leaq 0x6c03d(%rip), %rsi     # 0x1014bd
movl $0x29, %edx
callq 0x22ab0
movq 0x38(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xe0af3(%rip), %rdi     # 0x175f90
callq 0x22ab0
movq %rax, %r14
leaq 0x690f8(%rip), %rsi     # 0xfe5a4
movl $0x6, %edx
movq %rax, %rdi
callq 0x22ab0
movq 0x8(%rsp), %rax
movq 0x14c0(%rax), %rsi
movq 0x14c8(%rax), %rdx
movq %r14, %rdi
callq 0x22ab0
leaq 0x6c00c(%rip), %rsi     # 0x1014e7
movl $0x8, %edx
movq %rax, %rdi
callq 0x22ab0
movq 0x8(%rsp), %rcx
movq 0x15c0(%rcx), %rax
cmpq %rax, 0x15c8(%rcx)
je 0x95677
movl $0x1, %r12d
leaq 0x108(%rsp), %r13
leaq 0x40(%rsp), %rbp
leaq 0xa8(%rsp), %r15
xorl %ecx, %ecx
movq %r13, %rdi
movq (%rax,%rcx,8), %rbx
leaq 0xd8(%rsp), %rsi
callq 0x51a66
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x32180
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rsp), %rax
movq 0x14c0(%rax), %rsi
movq 0x14c8(%rax), %rdx
addq %rsi, %rdx
movq %rbp, %r14
movq %rbp, %rdi
callq 0x32180
movq %r14, %rdi
leaq 0x63d90(%rip), %rsi     # 0xf9323
callq 0x233b0
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %r15, %rdi
leaq 0x6170f(%rip), %rdx     # 0xf6cc1
movq %rdx, %rsi
callq 0x32210
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x88(%rsp), %rdx
movq %rbp, %rcx
movq %r15, %r8
xorl %r9d, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
pushq %rax
pushq %rax
callq 0x4eede
addq $0x20, %rsp
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x95605
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x95621
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x95646
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %r13, %rdi
callq 0x4a694
movl %r12d, %ecx
movq 0x8(%rsp), %rdx
movq 0x15c0(%rdx), %rax
movq 0x15c8(%rdx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r12d
cmpq %rcx, %rdx
ja 0x9551e
movq 0x8(%rsp), %rax
cmpl $0x2, 0x1614(%rax)
jbe 0x956fa
movq 0xe0904(%rip), %rdi     # 0x175f90
leaq 0x6be5d(%rip), %rsi     # 0x1014f0
movl $0x10, %edx
callq 0x22ab0
movq 0x8(%rsp), %rax
movq 0x14c0(%rax), %rsi
movq 0x14c8(%rax), %rdx
movq 0xe08d9(%rip), %rdi     # 0x175f90
callq 0x22ab0
movq %rax, %rbx
leaq 0x63c5d(%rip), %rsi     # 0xf9323
movl $0x5, %edx
movq %rax, %rdi
callq 0x22ab0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %rbx, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
leaq 0x20(%rsp), %rdi
callq 0x31a9e
leaq 0xd8(%rsp), %rdi
callq 0x4a694
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d031(%rip), %rdi     # 0xf275b
callq 0x225a0
leaq 0x5d025(%rip), %rdi     # 0xf275b
callq 0x22e40
jmp 0x95743
jmp 0x95766
jmp 0x95766
jmp 0x95766
movq %rax, %r15
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x957f5
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x957f5
movq %rax, %r15
jmp 0x957f5
movq %rax, %r15
jmp 0x957e8
movq %rax, %r15
jmp 0x957c3
jmp 0x9577a
movq %rax, %r15
jmp 0x957a7
movq %rax, %r15
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x957a7
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x957c3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x957e8
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x108(%rsp), %rdi
callq 0x4a694
leaq 0x20(%rsp), %rdi
callq 0x31a9e
leaq 0xd8(%rsp), %rdi
callq 0x4a694
movq %r15, %rdi
callq 0x23240
movq %rax, %r15
movq 0x18(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x957f5
movq 0x18(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
jmp 0x957f5