// File: /workspace/github_cpp_makefile_star2_O2/icemiliang[P]vot/src/vot/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[3*i]=pts[3*p];
            pts[3*i+1]=pts[3*p+1];
            pts[3*i+2]=pts[3*p+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 0x2004a
movq $0x0, (%rsp)
testb %al, %al
je 0x1e8f4
movq 0x40(%r15), %rcx
movl 0x8(%rcx), %eax
testl %eax, %eax
setle %sil
jle 0x1e8e4
decl %eax
movl %eax, 0x8(%rcx)
movq 0x48(%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 0x1e8ec
movq %rsi, (%rsp)
movslq %edx, %rdi
movslq %r12d, %rax
movq 0x20(%r15), %r10
movq 0x28(%r15), %rsi
movl (%rsi,%rdi,4), %r11d
testl %r11d, %r11d
movl $0x0, %r14d
cmovgl %r11d, %r14d
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x1e793
movq (%r10,%rdi,8), %r13
cmpl %r12d, (%r13,%rcx,4)
je 0x1e790
incq %rcx
jmp 0x1e77b
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 0x1e7d5
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 0x1e808
movq %r15, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x20182
testb %al, %al
je 0x1e8f4
movq %r15, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %r13d, %ecx
pushq $0x1
popq %r8
callq 0x20182
testb %al, %al
je 0x1e8f4
movslq 0x18(%r15), %rcx
decq %rcx
movl %ecx, 0x18(%r15)
movl 0x1c(%r15), %eax
cmpl %ebp, %eax
jne 0x1e822
andl $0x0, 0x1c(%r15)
xorl %eax, %eax
cmpl %ebp, %ecx
je 0x1e8d4
cmpl %ecx, %eax
jne 0x1e832
movl %ebp, 0x1c(%r15)
movslq %ebp, %rax
movq 0x30(%r15), %rdx
imulq $0x18, %rcx, %rsi
movsd (%rdx,%rsi), %xmm0
imulq $0x18, %rax, %rdi
movsd %xmm0, (%rdx,%rdi)
movsd 0x8(%rdx,%rsi), %xmm0
movsd %xmm0, 0x8(%rdx,%rdi)
movsd 0x10(%rdx,%rsi), %xmm0
movsd %xmm0, 0x10(%rdx,%rdi)
movq 0x20(%r15), %rdx
movq 0x28(%r15), %rsi
xorl %edi, %edi
movslq %ecx, %rcx
movslq (%rsi,%rcx,4), %r8
cmpq %r8, %rdi
jge 0x1e89f
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 0x18(%r15), %ecx
jmp 0x1e86d
movq 0xa8(%rbx), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x20(%r15), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x28(%r15), %rdx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
movq 0x20(%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 0x2004a
jmp 0x1e718
movb $0x1, %al
movq %rax, (%rsp)
jmp 0x1e8f4
movq $0x0, (%rsp)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop