// File: /workspace/github_cpp_makefile_star2_O1/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 0x6584d
movq 0x50(%r15), %rax
subq 0x48(%r15), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x6584d
movq 0x98(%r15), %rcx
subq 0x90(%r15), %rcx
sarq $0x4, %rcx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
cmpq %rbx, %rcx
jbe 0x6584d
movq 0x8(%r15), %rcx
subq (%r15), %rcx
sarq $0x4, %rcx
imulq %rax, %rcx
cmpq %rbx, %rcx
jbe 0x6584d
movq 0x20(%r15), %rcx
subq 0x18(%r15), %rcx
sarq $0x4, %rcx
imulq %rax, %rcx
cmpq %rbx, %rcx
ja 0x65966
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movl %edx, %esi
callq 0xc03b8
leaq 0x9417d(%rip), %rcx     # 0xf99e0
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 0x6589d
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x658a5
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 0x93025(%rip), %rsi     # 0xf88ed
callq 0x233b0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x658f4
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x658fc
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 0xc0396
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x65934
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6594b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65966
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x18(%r14), %rdx
movq 0x68(%r15), %rsi
cmpq 0x70(%r15), %rsi
je 0x65982
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x68(%r15)
jmp 0x6598b
leaq 0x60(%r15), %rdi
callq 0x6b5ce
testb %bpl, %bpl
jne 0x659c5
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x659ec
cmpq $0x0, (%rax,%rbx,8)
je 0x659c5
movq 0x1105de(%rip), %rdi    # 0x175f90
leaq 0x94051(%rip), %rsi     # 0xf9a0a
movl $0x30, %edx
callq 0x22ab0
jmp 0x659dd
movq 0x48(%r15), %rax
movq 0x50(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jbe 0x659ec
movq %r14, (%rax,%rbx,8)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8dcd2(%rip), %rdi     # 0xf36c5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22f40
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x65a1c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x65a1c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x65a38
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x65a38
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65a53
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240
nop