// File: Luthaf[P]zeopp/voro++/src/cell.cc
// Function: bool voro::voronoicell_base::collapse_order2<voro::voronoicell>(voro::voronoicell&)
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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq -0x18(%rbp), %rsi
callq 0x1a400
testb $0x1, %al
jne 0x119ee
movb $0x0, -0x1(%rbp)
jmp 0x11d85
jmp 0x119f0
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rax
cmpl $0x0, 0x8(%rax)
jle 0x11d81
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rdx
movl 0x8(%rdx), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rdx)
movl %ecx, -0x24(%rbp)
movq 0x70(%rax), %rcx
movq 0x10(%rcx), %rcx
imull $0x5, -0x24(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x28(%rbp)
movq 0x70(%rax), %rax
movq 0x10(%rax), %rax
imull $0x5, -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x11a6a
movq 0x5458e(%rip), %rax     # 0x65fe0
movq (%rax), %rsi
leaq 0x461b4(%rip), %rdi     # 0x57c10
callq 0x2140
movb $0x0, -0x1(%rbp)
jmp 0x11d85
movl $0x0, -0x30(%rbp)
movq -0x38(%rbp), %rcx
movl -0x30(%rbp), %eax
movq 0x30(%rcx), %rcx
movslq -0x28(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x11ab0
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x2c(%rbp), %eax
jne 0x11aa3
jmp 0x11ab0
jmp 0x11aa5
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x11a71
movq -0x38(%rbp), %rcx
movq 0x70(%rcx), %rax
movq 0x10(%rax), %rax
imull $0x5, -0x24(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0x1c(%rbp)
movq 0x70(%rcx), %rax
movq 0x10(%rax), %rax
imull $0x5, -0x24(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0x20(%rbp)
movq 0x70(%rcx), %rax
movq 0x10(%rax), %rax
imull $0x5, -0x24(%rbp), %edx
addl $0x4, %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0x24(%rbp)
movl -0x30(%rbp), %eax
movq 0x30(%rcx), %rcx
movslq -0x28(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x11b84
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %esi
movq 0x28(%rcx), %rax
movslq -0x28(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x1c(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movl -0x28(%rbp), %esi
movq 0x28(%rcx), %rax
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x20(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movl -0x20(%rbp), %esi
movq 0x28(%rcx), %rax
movslq -0x28(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x30(%rcx), %rdx
movslq -0x28(%rbp), %rdi
movl (%rdx,%rdi,4), %edx
addl -0x1c(%rbp), %edx
movslq %edx, %rdx
movl %esi, (%rax,%rdx,4)
movl -0x1c(%rbp), %edx
movq 0x28(%rcx), %rax
movslq -0x2c(%rbp), %rsi
movq (%rax,%rsi,8), %rax
movq 0x30(%rcx), %rcx
movslq -0x2c(%rbp), %rsi
movl (%rcx,%rsi,4), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x11bcf
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x28(%rbp), %edx
movl -0x1c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x1a670
testb $0x1, %al
jne 0x11ba7
movb $0x0, -0x1(%rbp)
jmp 0x11d85
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0x1, %r8d
callq 0x1a670
testb $0x1, %al
jne 0x11bcd
movb $0x0, -0x1(%rbp)
jmp 0x11d85
jmp 0x11bcf
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x1c(%rax)
movl 0x20(%rax), %eax
cmpl -0x24(%rbp), %eax
jne 0x11bef
movq -0x38(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x24(%rbp), %eax
je 0x11d65
movq -0x38(%rbp), %rcx
movl 0x20(%rcx), %eax
cmpl 0x1c(%rcx), %eax
jne 0x11c15
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, 0x20(%rax)
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rcx
movl 0x1c(%rax), %edx
shll $0x2, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rax), %rcx
movl -0x24(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x40(%rax), %rcx
movl 0x1c(%rax), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rax), %rcx
movl -0x24(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x40(%rax), %rcx
movl 0x1c(%rax), %edx
shll $0x2, %edx
addl $0x2, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x40(%rax), %rax
movl -0x24(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rdx
movl -0x2c(%rbp), %eax
movq 0x30(%rdx), %rcx
movslq 0x1c(%rdx), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x11cfe
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %edx
movq 0x28(%rdi), %rax
movq 0x28(%rdi), %rcx
movslq 0x1c(%rdi), %rsi
movq (%rcx,%rsi,8), %rcx
movslq -0x2c(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movq (%rax,%rcx,8), %rax
movq 0x28(%rdi), %rcx
movslq 0x1c(%rdi), %rsi
movq (%rcx,%rsi,8), %rcx
movq 0x30(%rdi), %rsi
movslq 0x1c(%rdi), %rdi
movl (%rsi,%rdi,4), %esi
addl -0x2c(%rbp), %esi
movslq %esi, %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11c98
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %esi
movl 0x1c(%rax), %edx
callq 0x119b0
movq -0x38(%rbp), %rcx
movq 0x28(%rcx), %rax
movslq 0x1c(%rcx), %rdx
movq (%rax,%rdx,8), %rsi
movq 0x28(%rcx), %rax
movslq -0x24(%rbp), %rdx
movq %rsi, (%rax,%rdx,8)
movq 0x30(%rcx), %rax
movslq 0x1c(%rcx), %rdx
movl (%rax,%rdx,4), %esi
movq 0x30(%rcx), %rax
movslq -0x24(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movl -0x24(%rbp), %edx
movq 0x28(%rcx), %rax
movslq -0x24(%rbp), %rsi
movq (%rax,%rsi,8), %rax
movq 0x30(%rcx), %rcx
movslq -0x24(%rbp), %rsi
movl (%rcx,%rsi,4), %ecx
shll %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1a400
testb $0x1, %al
jne 0x11d7c
movb $0x0, -0x1(%rbp)
jmp 0x11d85
jmp 0x119f0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq