// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
andb $0x1, %al
movb %al, -0x15(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpl $0x0, -0x14(%rbp)
jb 0xb1786
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0x98(%rbp)
addq $0x78, %rdi
callq 0x45170
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1786
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0xa0(%rbp)
addq $0x48, %rdi
callq 0xb45f0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1786
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0xa8(%rbp)
addq $0x90, %rdi
callq 0xb3e60
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1786
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0xb0(%rbp)
callq 0xb32b0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1786
movq -0x90(%rbp), %rdi
movl -0x14(%rbp), %eax
movq %rax, -0xb8(%rbp)
addq $0x18, %rdi
callq 0xb4610
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq %rcx, %rax
jb 0xb1841
movl -0x14(%rbp), %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x17e460
movq -0xc0(%rbp), %rdx
leaq 0x12aa98(%rip), %rsi    # 0x1dc23f
leaq -0x58(%rbp), %rdi
callq 0x8e0f0
jmp 0xb17b2
leaq 0x129953(%rip), %rdx    # 0x1db10c
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x441f0
jmp 0xb17c8
leaq -0x38(%rbp), %rdi
callq 0x17e420
jmp 0xb17d3
leaq -0x38(%rbp), %rdi
callq 0x311e8
leaq -0x58(%rbp), %rdi
callq 0x311e8
leaq -0x78(%rbp), %rdi
callq 0x311e8
jmp 0xb1841
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xb1833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0xb182a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x311e8
leaq -0x58(%rbp), %rdi
callq 0x311e8
leaq -0x78(%rbp), %rdi
callq 0x311e8
jmp 0xb18c2
movq -0x90(%rbp), %rdi
addq $0x60, %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
callq 0xb4640
testb $0x1, -0x15(%rbp)
jne 0xb187a
movq -0x90(%rbp), %rdi
addq $0x48, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0xb46b0
cmpq $0x0, (%rax)
jne 0xb18a6
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
addq $0x48, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0xb46b0
movq -0xc8(%rbp), %rcx
movq %rcx, (%rax)
jmp 0xb18b9
movq 0x2236a3(%rip), %rdi    # 0x2d4f50
leaq 0x12a9b5(%rip), %rsi    # 0x1dc269
callq 0x2ff50
addq $0xd0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x30170
nopl (%rax,%rax)