// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/voro++/src/cell.cc
// Function: bool voro::voronoicell_base::collapse_order2<voro::voronoicell_neighbor>(voro::voronoicell_neighbor&)
inline bool voronoicell_base::collapse_order2(vc_class &vc) {
	if(!collapse_order1(vc)) return false;
	int a,b,i,j,k,l;
	while(mec[2]>0) {

		// Pick a order 2 vertex and read in its edges
		i=--mec[2];
		j=mep[2][5*i];k=mep[2][5*i+1];
		if(j==k) {
#if VOROPP_VERBOSE >=1
			fputs("Order two vertex joins itself",stderr);
#endif
			return false;
		}

		// Scan the edges of j to see if joins k
		for(l=0;l<nu[j];l++) {
			if(ed[j][l]==k) break;
		}

		// If j doesn't already join k, join them together.
		// Otherwise delete the connection to the current
		// vertex from j and k.
		a=mep[2][5*i+2];b=mep[2][5*i+3];i=mep[2][5*i+4];
		if(l==nu[j]) {
			ed[j][a]=k;
			ed[k][b]=j;
			ed[j][nu[j]+a]=b;
			ed[k][nu[k]+b]=a;
		} else {
			if(!delete_connection(vc,j,a,false)) return false;
			if(!delete_connection(vc,k,b,true)) return false;
		}

		// Compact the memory
		--p;
		if(up==i) up=0;
		if(p!=i) {
			if(up==p) up=i;
			pts[i<<2]=pts[p<<2];
			pts[(i<<2)+1]=pts[(p<<2)+1];
			pts[(i<<2)+2]=pts[(p<<2)+2];
			for(k=0;k<nu[p];k++) ed[ed[p][k]][ed[p][nu[p]+k]]=i;
			vc.n_copy_pointer(i,p);
			ed[i]=ed[p];
			nu[i]=nu[p];
			ed[i][nu[i]<<1]=i;
		}

		// Collapse any order 1 vertices if they were created
		if(!collapse_order1(vc)) return false;
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r15
callq 0xf7d4
movq $0x0, (%rsp)
testb %al, %al
je 0xd347
movq 0x68(%r15), %rcx
movl 0x8(%rcx), %eax
testl %eax, %eax
setle %sil
jle 0xd341
decl %eax
movl %eax, 0x8(%rcx)
movq 0x70(%r15), %rcx
movq 0x10(%rcx), %r8
leal (%rax,%rax,4), %r9d
movl (%r8,%r9,4), %edx
movl 0x4(%r8,%r9,4), %r12d
cmpl %r12d, %edx
je 0xd35a
movq %rsi, (%rsp)
movslq %edx, %rdi
movslq %r12d, %rax
movq 0x28(%r15), %r10
movq 0x30(%r15), %rsi
movl (%rsi,%rdi,4), %r11d
testl %r11d, %r11d
movl $0x0, %r14d
cmovgl %r11d, %r14d
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0xd1c1
movq (%r10,%rdi,8), %r13
cmpl %r12d, (%r13,%rcx,4)
je 0xd1be
incq %rcx
jmp 0xd1a9
movl %ecx, %r14d
movl 0x8(%r8,%r9,4), %ecx
movl 0xc(%r8,%r9,4), %r13d
movl 0x10(%r8,%r9,4), %ebp
cmpl %r11d, %r14d
jne 0xd203
movslq %ecx, %r8
movslq %r13d, %r9
movq (%r10,%rdi,8), %r11
movl %r12d, (%r11,%r8,4)
movq (%r10,%rax,8), %r10
movl %edx, (%r10,%r9,4)
movslq (%rsi,%rdi,4), %rdx
addq %r8, %rdx
movl %r13d, (%r11,%rdx,4)
movslq (%rsi,%rax,4), %rax
addq %r9, %rax
movl %ecx, (%r10,%rax,4)
jmp 0xd236
movq %r15, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0xf966
testb %al, %al
je 0xd347
movq %r15, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r13d, %ecx
pushq $0x1
popq %r8
callq 0xf966
testb %al, %al
je 0xd347
movl 0x1c(%r15), %ecx
movl 0x20(%r15), %eax
decl %ecx
movl %ecx, 0x1c(%r15)
cmpl %ebp, %eax
jne 0xd24f
andl $0x0, 0x20(%r15)
xorl %eax, %eax
cmpl %ebp, %ecx
je 0xd331
cmpl %ecx, %eax
jne 0xd25f
movl %ebp, 0x20(%r15)
movslq %ebp, %rax
movq 0x40(%r15), %rdx
leal (,%rcx,4), %esi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm0
leal (,%rbp,4), %esi
movslq %esi, %rsi
movsd %xmm0, (%rdx,%rsi,8)
leal 0x1(,%rcx,4), %esi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm0
leal 0x1(,%rbp,4), %esi
movslq %esi, %rsi
movsd %xmm0, (%rdx,%rsi,8)
leal 0x2(,%rcx,4), %esi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm0
leal 0x2(,%rbp,4), %esi
movslq %esi, %rsi
movsd %xmm0, (%rdx,%rsi,8)
movq 0x28(%r15), %rdx
movq 0x30(%r15), %rsi
xorl %edi, %edi
movslq %ecx, %rcx
movslq (%rsi,%rcx,4), %r8
cmpq %r8, %rdi
jge 0xd2fc
movl %r8d, %r8d
movq (%rdx,%rcx,8), %rcx
movslq (%rcx,%rdi,4), %r9
movq (%rdx,%r9,8), %r9
addl %edi, %r8d
movslq %r8d, %r8
movslq (%rcx,%r8,4), %rcx
movl %ebp, (%r9,%rcx,4)
incq %rdi
movl 0x1c(%r15), %ecx
jmp 0xd2ca
movq 0xf0(%rbx), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x28(%r15), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x30(%r15), %rdx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
movq 0x28(%r15), %rdx
movq (%rdx,%rax,8), %rax
addl %ecx, %ecx
movslq %ecx, %rcx
movl %ebp, (%rax,%rcx,4)
movq %r15, %rdi
movq %rbx, %rsi
callq 0xf7d4
jmp 0xd146
movb $0x1, %al
movq %rax, (%rsp)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x31c7f(%rip), %rax     # 0x3efe0
movq (%rax), %rsi
leaq 0x23b99(%rip), %rdi     # 0x30f04
callq 0x2130
movq $0x0, (%rsp)
jmp 0xd347