// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
callq 0x12c46
testb %al, %al
je 0x10e0f
movq 0x68(%r14), %rcx
movslq 0x8(%rcx), %rax
testq %rax, %rax
setle %r15b
jle 0x10e12
decq %rax
movl %eax, 0x8(%rcx)
movq 0x70(%r14), %rcx
movq 0x10(%rcx), %rdi
leaq (%rax,%rax,4), %r8
movl %r8d, %eax
movl (%rdi,%rax,4), %edx
movl 0x4(%rdi,%r8,4), %ebp
cmpl %ebp, %edx
je 0x10e0a
movslq %edx, %rsi
movq 0x30(%r14), %rax
movl (%rax,%rsi,4), %r9d
testl %r9d, %r9d
jle 0x10c78
movq 0x28(%r14), %rcx
movq (%rcx,%rsi,8), %rcx
xorl %r10d, %r10d
cmpl %ebp, (%rcx,%r10,4)
je 0x10c7b
incq %r10
cmpq %r10, %r9
jne 0x10c65
movl %r9d, %r10d
jmp 0x10c7b
xorl %r10d, %r10d
movl 0x8(%rdi,%r8,4), %ecx
movl 0xc(%rdi,%r8,4), %r12d
movl 0x10(%rdi,%r8,4), %r13d
cmpl %r9d, %r10d
jne 0x10cc4
movslq %ebp, %rdi
movslq %ecx, %r8
movslq %r12d, %r9
movq 0x28(%r14), %r10
movq (%r10,%rsi,8), %r11
movl %ebp, (%r11,%r8,4)
movq (%r10,%rdi,8), %r10
movl %edx, (%r10,%r9,4)
movslq (%rax,%rsi,4), %rdx
addq %r8, %rdx
movl %r12d, (%r11,%rdx,4)
movslq (%rax,%rdi,4), %rax
addq %r9, %rax
movl %ecx, (%r10,%rax,4)
jmp 0x10cfb
xorl %r15d, %r15d
movq %r14, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x12df2
testb %al, %al
je 0x10e12
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r12d, %ecx
movl $0x1, %r8d
callq 0x12df2
testb %al, %al
je 0x10e0f
movl 0x1c(%r14), %eax
movl 0x20(%r14), %ecx
decl %eax
movl %eax, 0x1c(%r14)
cmpl %r13d, %ecx
jne 0x10d16
movl $0x0, 0x20(%r14)
cmpl %r13d, %eax
je 0x10dff
cmpl %eax, 0x20(%r14)
jne 0x10d29
movl %r13d, 0x20(%r14)
movq 0x40(%r14), %rcx
leal (,%rax,4), %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
leal (,%r13,4), %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
leal 0x1(,%rax,4), %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
leal 0x1(,%r13,4), %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
leal 0x2(,%rax,4), %eax
cltq
movsd (%rcx,%rax,8), %xmm0
leal 0x2(,%r13,4), %eax
cltq
movsd %xmm0, (%rcx,%rax,8)
movq 0x30(%r14), %rcx
movslq 0x1c(%r14), %rax
movl (%rcx,%rax,4), %edi
testl %edi, %edi
jle 0x10dc7
movq 0x28(%r14), %rdx
xorl %esi, %esi
movq (%rdx,%rax,8), %rax
movslq (%rax,%rsi,4), %r8
movq (%rdx,%r8,8), %r8
movslq %edi, %rdi
addq %rsi, %rdi
movslq (%rax,%rdi,4), %rax
movl %r13d, (%r8,%rax,4)
incq %rsi
movslq 0x1c(%r14), %rax
movslq (%rcx,%rax,4), %rdi
cmpq %rdi, %rsi
jl 0x10d9d
movslq %r13d, %rcx
movq 0xf0(%rbx), %rdx
movq (%rdx,%rax,8), %rsi
movq %rsi, (%rdx,%rcx,8)
movq 0x28(%r14), %rdx
movq (%rdx,%rax,8), %rsi
movq %rsi, (%rdx,%rcx,8)
movq 0x30(%r14), %rdx
movl (%rdx,%rax,4), %eax
movl %eax, (%rdx,%rcx,4)
movq 0x28(%r14), %rdx
movq (%rdx,%rcx,8), %rcx
addl %eax, %eax
cltq
movl %r13d, (%rcx,%rax,4)
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x10c03
callq 0x2588
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq