// File: /workspace/github_cpp_makefile_star2_O1/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, 0x2c(%rsp)
movq %rdi, %rbx
movl %esi, 0x8(%rsp)
movl %edx, 0x4(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x4, 0x1614(%rdi)
jb 0x8ba5e
movq 0xea571(%rip), %r14     # 0x175f90
leaq 0x76412(%rip), %rsi     # 0x101e38
movl $0x23, %edx
movq %r14, %rdi
callq 0x22ab0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0xea53f(%rip), %rdi     # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movl 0x4(%rsp), %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rsi
je 0x8ba87
movq 0x15c8(%rbx), %rax
subq 0x15c0(%rbx), %rax
sarq $0x3, %rax
cmpq %rsi, %rax
jbe 0x8be1d
movl 0x4(%rsp), %eax
cmpl $-0x1, %eax
je 0x8baa9
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x8bb0f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x8bb1e
movl $0x0, (%rsp)
movq 0x15c8(%rbx), %rax
cmpq 0x15c0(%rbx), %rax
je 0x8bb1e
xorl %eax, %eax
leaq 0x10(%rsp), %r14
movq %rsp, %r15
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x8bae3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x8baee
movq %r14, %rdi
movq %r15, %rdx
callq 0x6b5ce
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
movq 0x15c8(%rbx), %rcx
subq 0x15c0(%rbx), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
ja 0x8baca
jmp 0x8bb1e
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x6b5ce
movl $0x0, (%rsp)
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x8bda5
leaq 0x1460(%rbx), %rcx
movq %rcx, 0x70(%rsp)
leaq 0x1400(%rbx), %r15
xorl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x4(%rsp)
movq 0x15c0(%rbx), %rcx
movq (%rcx,%rax,8), %rax
movq 0x58(%rax), %r12
movq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa879e
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0xa873a
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x66228
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x8bd6c
movl %r12d, %r14d
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
leaq 0xf(%rsp), %rdx
callq 0xa800e
cmpb $0x0, 0x2c(%rsp)
jne 0x8bc0b
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa873a
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jb 0x8bc0b
movl $0x0, (%rsp)
testl %r12d, %r12d
je 0x8bc0b
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa873a
movl (%rsp), %ecx
movq (%rax), %rax
movsd (%rax,%rcx,8), %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, (%rsp)
cmpl %r12d, %eax
jb 0x8bbde
movl 0x4(%rsp), %eax
movq 0x1980(%rbx), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
movq 0x10(%rax), %r14
cmpq %rax, %r14
je 0x8bd55
movl 0x20(%r14), %r12d
movl 0x24(%r14), %r13d
cmpl $0x4, 0x1614(%rbx)
jb 0x8bcdd
movl $0x2a, %edx
movq 0xea33d(%rip), %rdi     # 0x175f90
leaq 0x7624a(%rip), %rsi     # 0x101ea4
callq 0x22ab0
movl 0x4(%rsp), %esi
movq 0xea326(%rip), %rdi     # 0x175f90
callq 0x22650
movq %rax, %rbp
movl $0x19, %edx
movq %rax, %rdi
leaq 0x7624e(%rip), %rsi     # 0x101ecf
callq 0x22ab0
movq %rbp, %rdi
movq %r12, %rsi
callq 0x22650
movq %rax, %rbp
movl $0x9, %edx
movq %rax, %rdi
leaq 0x76246(%rip), %rsi     # 0x101ee9
callq 0x22ab0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x22650
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %rbp, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
cmpb $0x0, 0x2c(%rsp)
jne 0x8bcfb
movq 0x50(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
ucomisd 0x6ae41(%rip), %xmm0    # 0xf6b38
jne 0x8bd11
jp 0x8bd11
movq 0x30(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq 0x50(%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa873a
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0xa8098
movq %r14, %rdi
callq 0x22670
movq %rax, %r14
movl 0x4(%rsp), %eax
movq 0x1980(%rbx), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
jmp 0x8bc29
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8bd6c
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8bd83
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movl (%rsp), %ecx
incl %ecx
movl %ecx, (%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rcx, %rdx
ja 0x8bb4a
cmpl $0x4, 0x1614(%rbx)
jb 0x8bdf4
movq 0xea1db(%rip), %rbx     # 0x175f90
leaq 0x76137(%rip), %rsi     # 0x101ef3
movl $0x24, %edx
movq %rbx, %rdi
callq 0x22ab0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0xea1a9(%rip), %rdi     # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8be0b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %rdi
callq 0xc03b8
leaq 0x7602e(%rip), %rcx     # 0x101e5c
leaq 0x50(%rsp), %rdi
movl $0x38, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x8be65
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
jmp 0x8be72
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x76000(%rip), %rsi     # 0x101e95
callq 0x233b0
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x8bec0
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
jmp 0x8bed0
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
movq 0x8(%rax), %rdx
leaq 0x78(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0x78b66
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x8bf16
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x8bf16
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x8bf32
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x8bf32
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8bf8f
movq 0x60(%rsp), %rsi
incq %rsi
jmp 0x8bf8a
jmp 0x8bf57
jmp 0x8bf57
jmp 0x8bf57
jmp 0x8bf5e
movq %rax, %rbx
jmp 0x8bf78
movq %rax, %rbx
jmp 0x8bf8f
jmp 0x8bf5e
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x8bf78
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8bf8f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8bfa6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240