// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::update_cur_particle_params(unsigned int, unsigned int, bool)
void Swarm::update_cur_particle_params(unsigned int pID, unsigned int mid, bool overwrite){ //razi: this need to be tested


	std::vector<unsigned int> mids;
	unsigned int i, mapfrom, mapto, nF;

	if(options.verbosity >=4){cout<<"update_cur_particle_params started."<<endl;} //mypause();

	if ((mid < (unsigned) -1) && (mid >= options.models.size()))
		outputError("updating current particle parameters, wrong model number" + toString(mid)+". Quitting....");

	if (mid == (unsigned) -1){
		for (i=0; i< options.models.size(); i++)
			mids.push_back(i);  //razi: do for all models if mid=-1
	}else
		mids.push_back(mid);

	for (i = 0; i <mids.size(); i++){
		mid=mids[i]; nF=options.models[mid]->getNumFreeParams();
		vector <double> InVec = subparticleCurrParamSets_[pID][mid];
		if (!InVec.empty()){
			vector <double> OutVec(nF);
			if ((!overwrite) && (particleCurrParamSets_[pID].size()>= nF)){
				for (i=0; i<nF; i++)
					OutVec[i] = particleCurrParamSets_[pID][i];
			}
			for (auto fp = freeParamMapping[mid].begin(); fp != freeParamMapping[mid].end(); fp++){
				mapfrom = fp->first;
				mapto = fp->second;
				if(options.verbosity >=4) cout<<"copying value for free parames from model:"<<mid<< " to the full list index1:"<< mapfrom <<"  index2:"<<mapto<<endl;
				if (overwrite || (OutVec[mapto]==0))
					OutVec[mapto] = InVec[mapfrom];
				particleCurrParamSets_[pID] = OutVec;
			}

		}
	}
	if(options.verbosity >=4){cout<<"update_cur_particle_params finished."<<endl;} //mypause();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
movl %esi, 0x8(%rsp)
movl %edx, (%rsp)
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
cmpl $0x4, 0x1614(%rdi)
jb 0x75b4a
movq 0xf0465(%rip), %rdi     # 0x165f98
leaq 0x6a4ce(%rip), %rsi     # 0xe0008
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movl (%rsp), %edx
cmpl $-0x1, %edx
je 0x75dc4
movl %edx, %eax
movq 0x15c8(%rbx), %rcx
subq 0x15c0(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
jbe 0x75e04
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x5a59e
leaq 0x1460(%rbx), %rax
movq %rax, 0x70(%rsp)
leaq 0x1400(%rbx), %r15
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movl %eax, %eax
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x75d84
movl (%rcx,%rax,4), %eax
movl %eax, (%rsp)
movq 0x15c0(%rbx), %rcx
movq (%rcx,%rax,8), %rax
movq 0x58(%rax), %r12
movq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x86550
movq %rax, %rdi
movq %rsp, %rsi
callq 0x86502
leaq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x59fa2
movq 0x50(%rsp), %rax
cmpq 0x58(%rsp), %rax
je 0x75d38
movl %r12d, %r14d
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
leaq 0xf(%rsp), %rdx
callq 0x85f4a
testb %bpl, %bpl
jne 0x75c39
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x86502
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jae 0x75d4d
movl (%rsp), %eax
movq 0x1980(%rbx), %rcx
imulq $0x30, %rax, %rdx
movq 0x18(%rcx,%rdx), %r14
movl %eax, %eax
imulq $0x30, %rax, %rax
addq %rcx, %rax
addq $0x8, %rax
cmpq %rax, %r14
je 0x75d2e
movl 0x20(%r14), %r13d
movl 0x24(%r14), %r12d
cmpl $0x4, 0x1614(%rbx)
jb 0x75ccd
movq 0xf031e(%rip), %rdi     # 0x165f98
leaq 0x6a3f3(%rip), %rsi     # 0xe0074
callq 0x289f0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
leaq 0x6a404(%rip), %rsi     # 0xe009f
callq 0x289f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x286e0
movq %rax, %rdi
leaq 0x6a404(%rip), %rsi     # 0xe00b9
callq 0x289f0
movq %rax, %rdi
movq %r12, %rsi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0x30(%rsp), %rax
testb %bpl, %bpl
jne 0x75ce9
movsd (%rax,%r12,8), %xmm0
ucomisd 0x5ed9b(%rip), %xmm0    # 0xd4a80
jne 0x75cfa
jp 0x75cfa
movq 0x50(%rsp), %rcx
movsd (%rcx,%r13,8), %xmm0
movsd %xmm0, (%rax,%r12,8)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x86502
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x85f9c
movq %r14, %rdi
callq 0x28700
movq %rax, %r14
movl (%rsp), %eax
movq 0x1980(%rbx), %rcx
jmp 0x75c4c
leaq 0x30(%rsp), %rdi
callq 0x5c44e
leaq 0x50(%rsp), %rdi
callq 0x5c44e
movl 0x4(%rsp), %eax
incl %eax
jmp 0x75b92
xorl %eax, %eax
movl %eax, 0x4(%rsp)
cmpl %r12d, %eax
jae 0x75c39
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x86502
movl 0x4(%rsp), %ecx
movq (%rax), %rax
movsd (%rax,%rcx,8), %xmm0
movq 0x30(%rsp), %rax
movsd %xmm0, (%rax,%rcx,8)
leal 0x1(%rcx), %eax
jmp 0x75d4f
cmpl $0x4, 0x1614(%rbx)
jb 0x75da8
movq 0xf0204(%rip), %rdi     # 0x165f98
leaq 0x6a328(%rip), %rsi     # 0xe00c3
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x10(%rsp), %rdi
callq 0x5b268
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
leaq 0x10(%rsp), %r14
leaq 0x4(%rsp), %r15
movl %eax, 0x4(%rsp)
movl %eax, %eax
movq 0x15c8(%rbx), %rcx
subq 0x15c0(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
jbe 0x75b7d
movq %r14, %rdi
movq %r15, %rsi
callq 0x5a59e
movl 0x4(%rsp), %eax
incl %eax
jmp 0x75dd0
leaq 0x30(%rsp), %rdi
movl %edx, %esi
callq 0x9f56b
leaq 0x6a215(%rip), %rsi     # 0xe002c
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x4933b
leaq 0x6a238(%rip), %rdx     # 0xe0065
leaq 0x78(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3336c
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aed2
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x295a0
jmp 0x75e5b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x295a0
jmp 0x75e6a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x295a0
jmp 0x75ea1
jmp 0x75e83
jmp 0x75e83
jmp 0x75e8a
jmp 0x75e83
movq %rax, %rbx
jmp 0x75e97
movq %rax, %rbx
jmp 0x75ea1
jmp 0x75e8a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5c44e
leaq 0x50(%rsp), %rdi
callq 0x5c44e
leaq 0x10(%rsp), %rdi
callq 0x5b268
movq %rbx, %rdi
callq 0x292f0
nop