// File: icemiliang[P]vot/src/vot/container_prd.cc
// Function: voro::container_periodic_base::add_particle_memory(int)
void container_periodic_base::add_particle_memory(int i) {

	// Handle the case when no memory has been allocated for this block
	if(mem[i]==0) {
		mem[i]=init_mem;
		id[i]=new int[init_mem];
		p[i]=new double[ps*init_mem];
		return;
	}

	// Otherwise, double the memory allocation for this block. Carry out a
	// check on the memory allocation size, and print a status message if
	// requested.
	int l,nmem(mem[i]<<1);
	if(nmem>max_particle_memory)
		voro_fatal_error("Absolute maximum memory allocation exceeded",VOROPP_MEMORY_ERROR);
#if VOROPP_VERBOSE >=3
	fprintf(stderr,"Particle memory in region %d scaled up to %d\n",i,nmem);
#endif

	// Allocate new memory and copy in the contents of the old arrays
	int *idp=new int[nmem];
	for(l=0;l<co[i];l++) idp[l]=id[i][l];
	double *pp=new double[ps*nmem];
	for(l=0;l<ps*co[i];l++) pp[l]=p[i][l];

	// Update pointers and delete old arrays
	mem[i]=nmem;
	delete [] id[i];id[i]=idp;
	delete [] p[i];p[i]=pp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0x168(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x8694d
movq -0x30(%rbp), %rax
movl 0x178(%rax), %esi
movq 0x168(%rax), %rcx
movslq -0xc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq 0x178(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0xa030
movq -0x30(%rbp), %rcx
movq %rax, %rsi
movq 0x150(%rcx), %rax
movslq -0xc(%rbp), %rdx
movq %rsi, (%rax,%rdx,8)
movl 0x17c(%rcx), %eax
imull 0x178(%rcx), %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0xa030
movq %rax, %rdx
movq -0x30(%rbp), %rax
movq 0x158(%rax), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x86b0c
movq -0x30(%rbp), %rax
movq 0x168(%rax), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
shll %eax
movl %eax, -0x14(%rbp)
cmpl $0x1000000, -0x14(%rbp) # imm = 0x1000000
jle 0x8697e
leaq 0xdd92(%rip), %rdi      # 0x94706
movl $0x2, %esi
callq 0x4c000
movslq -0x14(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0xa030
movq %rax, -0x20(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x30(%rbp), %rcx
movl -0x10(%rbp), %eax
movq 0x160(%rcx), %rcx
movslq -0xc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x869f5
movq -0x30(%rbp), %rax
movq 0x150(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x869ae
movq -0x30(%rbp), %rax
movl 0x17c(%rax), %eax
imull -0x14(%rbp), %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0xa030
movq %rax, -0x28(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x30(%rbp), %rdx
movl -0x10(%rbp), %eax
movl 0x17c(%rdx), %ecx
movq 0x160(%rdx), %rdx
movslq -0xc(%rbp), %rsi
imull (%rdx,%rsi,4), %ecx
cmpl %ecx, %eax
jge 0x86a85
movq -0x30(%rbp), %rax
movq 0x158(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x86a31
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %esi
movq 0x168(%rax), %rcx
movslq -0xc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x150(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x86abc
movq -0x38(%rbp), %rdi
callq 0xa660
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rsi
movq 0x150(%rax), %rcx
movslq -0xc(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x158(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x86af5
movq -0x40(%rbp), %rdi
callq 0xa660
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rdx
movq 0x158(%rax), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)