// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb2010
movq -0x108(%rbp), %rax
cmpl $0x4, 0x1614(%rax)
jb 0xfef24
movq 0x1d6069(%rip), %rdi    # 0x2d4f50
leaq 0xe5bed(%rip), %rsi     # 0x1e4adb
callq 0x2ff50
movq %rax, -0x110(%rbp)
jmp 0xfeefc
movq -0x110(%rbp), %rdi
movq 0x1d60be(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0xfef11
jmp 0xfef24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xff53c
cmpl $-0x1, -0x10(%rbp)
jae 0xff02e
movq -0x108(%rbp), %rdi
movl -0x10(%rbp), %eax
movq %rax, -0x118(%rbp)
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x100, %rdi            # imm = 0x100
callq 0x45170
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jb 0xff02e
movl -0x10(%rbp), %esi
leaq -0xb0(%rbp), %rdi
callq 0x17e460
jmp 0xfef76
leaq 0xe5b82(%rip), %rsi     # 0x1e4aff
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x8e0f0
jmp 0xfef92
leaq 0xe5b9f(%rip), %rdx     # 0x1e4b38
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x441f0
jmp 0xfefab
movq -0x108(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xeada0
jmp 0xfefbd
leaq -0x70(%rbp), %rdi
callq 0x311e8
leaq -0x90(%rbp), %rdi
callq 0x311e8
leaq -0xb0(%rbp), %rdi
callq 0x311e8
jmp 0xff02e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xff01d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xff011
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x311e8
leaq -0x90(%rbp), %rdi
callq 0x311e8
leaq -0xb0(%rbp), %rdi
callq 0x311e8
jmp 0xff53c
cmpl $-0x1, -0x10(%rbp)
jne 0xff08c
movl $0x0, -0x34(%rbp)
movq -0x108(%rbp), %rdi
movl -0x34(%rbp), %eax
movq %rax, -0x120(%rbp)
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x100, %rdi            # imm = 0x100
callq 0x45170
movq %rax, %rcx
movq -0x120(%rbp), %rax
cmpq %rcx, %rax
jae 0xff08a
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0xb4640
jmp 0xff07d
jmp 0xff07f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xff03b
jmp 0xff09d
leaq -0x30(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0xb4640
jmp 0xff09b
jmp 0xff09d
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq %rax, -0x128(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb46f0
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
jae 0xff4e7
movl -0x34(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0xccc10
movq -0x108(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x10(%rbp)
addq $0x15c0, %rdi           # imm = 0x15C0
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x45b40
movq (%rax), %rdi
callq 0x45b60
movl %eax, -0x12c(%rbp)
jmp 0xff105
movq -0x108(%rbp), %rdi
movl -0x12c(%rbp), %eax
movl %eax, -0x40(%rbp)
addq $0x1460, %rdi           # imm = 0x1460
leaq -0xc(%rbp), %rsi
callq 0x122e80
movq %rax, -0x138(%rbp)
jmp 0xff12e
movq -0x138(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x122da0
movq %rax, -0x140(%rbp)
jmp 0xff147
movq -0x140(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0xb2bc0
jmp 0xff15c
leaq -0xc8(%rbp), %rdi
callq 0x126110
testb $0x1, %al
jne 0xff4bf
movl -0x40(%rbp), %eax
movq %rax, -0x150(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0xb5b80
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
leaq -0xe0(%rbp), %rdi
callq 0x121bc0
jmp 0xff1a9
leaq -0xe1(%rbp), %rdi
callq 0xbefe0
testb $0x1, -0x11(%rbp)
jne 0xff2ab
movq -0x108(%rbp), %rdi
addq $0x1400, %rdi           # imm = 0x1400
leaq -0xc(%rbp), %rsi
callq 0x122da0
movq %rax, -0x158(%rbp)
jmp 0xff1df
movq -0x158(%rbp), %rdi
callq 0xb25c0
movl -0x40(%rbp), %ecx
cmpq %rcx, %rax
jb 0xff2ab
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0xff2a9
movq -0x108(%rbp), %rdi
addq $0x1400, %rdi           # imm = 0x1400
leaq -0xc(%rbp), %rsi
callq 0x122da0
movq %rax, -0x160(%rbp)
jmp 0xff22a
movq -0x160(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd (%rax), %xmm0
movsd %xmm0, -0x168(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %esi
leaq -0xe0(%rbp), %rdi
callq 0xb2610
movsd -0x168(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xff1fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0xbefe0
jmp 0xff4d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xb2660
jmp 0xff4d9
jmp 0xff2ab
movq -0x108(%rbp), %rdi
addq $0x1980, %rdi           # imm = 0x1980
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x126150
movq %rax, %rdi
callq 0x126170
movq %rax, -0xf0(%rbp)
movq -0x108(%rbp), %rdi
addq $0x1980, %rdi           # imm = 0x1980
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x126150
movq %rax, %rdi
callq 0x1261d0
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x1261a0
testb $0x1, %al
jne 0xff315
jmp 0xff4b3
leaq -0xf0(%rbp), %rdi
callq 0x126200
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x126200
movq %rax, %rcx
movq -0x108(%rbp), %rax
movl 0x4(%rcx), %ecx
movl %ecx, -0x3c(%rbp)
cmpl $0x4, 0x1614(%rax)
jb 0xff402
movq 0x1d5bfa(%rip), %rdi    # 0x2d4f50
leaq 0xe57ea(%rip), %rsi     # 0x1e4b47
callq 0x2ff50
movq %rax, -0x170(%rbp)
jmp 0xff36b
movq -0x170(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x30640
movq %rax, -0x178(%rbp)
jmp 0xff383
movq -0x178(%rbp), %rdi
leaq 0xe57e1(%rip), %rsi     # 0x1e4b72
callq 0x2ff50
movq %rax, -0x180(%rbp)
jmp 0xff39f
movq -0x180(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x30640
movq %rax, -0x188(%rbp)
jmp 0xff3b7
movq -0x188(%rbp), %rdi
leaq 0xe57c7(%rip), %rsi     # 0x1e4b8c
callq 0x2ff50
movq %rax, -0x190(%rbp)
jmp 0xff3d3
movq -0x190(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x30640
movq %rax, -0x198(%rbp)
jmp 0xff3eb
movq -0x198(%rbp), %rdi
movq 0x1d5bcf(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0xff400
jmp 0xff402
testb $0x1, -0x11(%rbp)
jne 0xff428
movl -0x3c(%rbp), %eax
movl %eax, %esi
leaq -0xe0(%rbp), %rdi
callq 0xb2610
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xff462
jp 0xff462
movl -0x38(%rbp), %eax
movl %eax, %esi
leaq -0xc8(%rbp), %rdi
callq 0xb2610
movsd (%rax), %xmm0
movsd %xmm0, -0x1a0(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, %esi
leaq -0xe0(%rbp), %rdi
callq 0xb2610
movsd -0x1a0(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x108(%rbp), %rdi
addq $0x1400, %rdi           # imm = 0x1400
leaq -0xc(%rbp), %rsi
callq 0x122da0
movq %rax, -0x1a8(%rbp)
jmp 0xff482
movq -0x1a8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x121d70
jmp 0xff497
jmp 0xff499
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0x126220
movq %rax, -0x100(%rbp)
jmp 0xff2d2
leaq -0xe0(%rbp), %rdi
callq 0xb2660
leaq -0xc8(%rbp), %rdi
callq 0xb2660
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xff0a4
leaq -0xc8(%rbp), %rdi
callq 0xb2660
jmp 0xff53c
movq -0x108(%rbp), %rax
cmpl $0x4, 0x1614(%rax)
jb 0xff52a
movq 0x1d5a52(%rip), %rdi    # 0x2d4f50
leaq 0xe5691(%rip), %rsi     # 0x1e4b96
callq 0x2ff50
movq %rax, -0x1b0(%rbp)
jmp 0xff513
movq -0x1b0(%rbp), %rdi
movq 0x1d5aa7(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0xff528
jmp 0xff52a
leaq -0x30(%rbp), %rdi
callq 0xb2400
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0xb2400
movq -0x48(%rbp), %rdi
callq 0x30170
nop