// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movl %edx, %ebx
movq 0x80(%rdi), %rax
subq 0x78(%rdi), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x65373
movq 0x50(%r15), %rax
subq 0x48(%r15), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x65373
movq 0x98(%r15), %rcx
subq 0x90(%r15), %rcx
sarq $0x4, %rcx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
cmpq %rbx, %rcx
jbe 0x65373
movq 0x8(%r15), %rcx
subq (%r15), %rcx
sarq $0x4, %rcx
imulq %rax, %rcx
cmpq %rbx, %rcx
jbe 0x65373
movq 0x20(%r15), %rcx
subq 0x18(%r15), %rcx
sarq $0x4, %rcx
imulq %rax, %rcx
cmpq %rbx, %rcx
ja 0x6548c
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movl %edx, %esi
callq 0xbfa49
leaq 0x94637(%rip), %rcx     # 0xf99c0
movl $0x29, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x653c3
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x653cb
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x934df(%rip), %rsi     # 0xf88cd
callq 0x233b0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6541a
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x65422
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0xbfa27
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x6545a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x65471
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6548c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x18(%r14), %rdx
movq 0x68(%r15), %rsi
cmpq 0x70(%r15), %rsi
je 0x654a8
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x68(%r15)
jmp 0x654b1
leaq 0x60(%r15), %rdi
callq 0x6b0da
testb %bpl, %bpl
je 0x654c7
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
jmp 0x654fc
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x65514
cmpq $0x0, (%rax,%rbx,8)
je 0x654fc
movq 0x110abf(%rip), %rdi    # 0x175fa8
leaq 0x944fa(%rip), %rsi     # 0xf99ea
movl $0x30, %edx
callq 0x22ab0
jmp 0x65505
cmpq %rbx, %rdx
jbe 0x65514
movq %r14, (%rax,%rbx,8)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8e15e(%rip), %rdi     # 0xf3679
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x65544
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x65544
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x65560
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x65560
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6557b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240
nop