// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Particle.cpp
// Function: Particle::addSubParticle(subParticle*, unsigned int, bool)
void Particle::addSubParticle(subParticle* subparticle, unsigned int mid, bool overwrite){

	/* razi: moved to constructor
	unsigned int gap;
	gap = mid+1 - subParticles.size();
	if (gap>0){
		for (int i=0; i < gap; i++)
			subParticles.push_back(0);  //fill dummy
	}
	if(overwrite || !(subParticles.at(mid)))
		subParticles.at(mid)=subparticle;//	subParticles.at(mid)=.insert(subparticle);

	std::map<std::string, std::map<int, Data*> > dummyFile;
	gap= mid+1 - dataFiles_.size();
	if (gap>0)
		for (int i=0; i < gap; i++)
			dataFiles_.push_back(dummyFile);

	gap = mid+1-models.size();
	if(gap>0)
		for (int i=0; i<gap; i++)
			models.push_back(0);

	std::map<std::string, double> dummyParam;
	gap= mid+1 - simParams_.size();
	if (gap>0)
		for (int i=0; i < gap; i++)
			simParams_.push_back(dummyParam);


	std::map<int, double> dummy_fit;
	gap= mid+1 - fitCalcs.size();
	if (gap>0)
		for (int i=0; i < gap; i++)
			fitCalcs.push_back(dummy_fit);
	*/
	if((mid<0) || ( (mid>=models.size()) || (mid>=subParticles.size()) || (mid>=dataFiles_.size()) || (mid>=simParams_.size()) || (mid>=fitCalcs.size())) )
		 outputError("Add subParticle failed. Invalid model id:"+toString(mid)+". I am quitting....");
	subParIDs.push_back(subparticle->subParID_);
	if(overwrite || !(subParticles.at(mid)))
		subParticles.at(mid)=subparticle;//	subParticles.at(mid)=.insert(subparticle);
	else
		cout<<"SubParticle is not added. No empty room found!!!";

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movl %ecx, %ebp
movl %edx, %ecx
movq %rsi, %rbx
movq %rdi, %r15
movl %edx, %r14d
movq 0x80(%rdi), %rax
subq 0x78(%rdi), %rax
sarq $0x3, %rax
cmpq %r14, %rax
jbe 0x5993c
movq 0x50(%r15), %rax
subq 0x48(%r15), %rax
sarq $0x3, %rax
cmpq %r14, %rax
jbe 0x5993c
movq 0x98(%r15), %rax
subq 0x90(%r15), %rax
pushq $0x30
popq %rsi
cqto
idivq %rsi
cmpq %r14, %rax
jbe 0x5993c
movq 0x8(%r15), %rax
subq (%r15), %rax
cqto
idivq %rsi
cmpq %r14, %rax
jbe 0x5993c
movq 0x20(%r15), %rax
subq 0x18(%r15), %rax
cqto
idivq %rsi
cmpq %r14, %rax
ja 0x59997
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movl %ecx, %esi
callq 0x9f56b
leaq 0x7df8e(%rip), %rsi     # 0xd78e0
movq %rsp, %rdi
movq %r12, %rdx
callq 0x4933b
leaq 0x7ce89(%rip), %rdx     # 0xd67ed
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x3336c
leaq 0x20(%rsp), %rdi
callq 0x9f54b
leaq 0x20(%rsp), %rdi
callq 0x295a0
movq %rsp, %rdi
callq 0x295a0
leaq 0x40(%rsp), %rdi
callq 0x295a0
leaq 0x60(%r15), %rdi
leaq 0x18(%rbx), %rsi
callq 0x5a59e
testb %bpl, %bpl
jne 0x599d0
leaq 0x48(%r15), %rdi
movq %r14, %rsi
callq 0x5a5bc
cmpq $0x0, (%rax)
je 0x599d0
movq 0x10c5d6(%rip), %rdi    # 0x165f98
leaq 0x7df41(%rip), %rsi     # 0xd790a
callq 0x289f0
jmp 0x599e2
addq $0x48, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5a5bc
movq %rbx, (%rax)
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x295a0
jmp 0x59a01
movq %rax, %rbx
movq %rsp, %rdi
callq 0x295a0
jmp 0x59a0e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0