// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
callq 0x26a68
testb %al, %al
je 0x25538
movq 0x40(%r14), %rcx
movslq 0x8(%rcx), %rax
testq %rax, %rax
setle %r15b
jle 0x2553b
decq %rax
movl %eax, 0x8(%rcx)
movq 0x48(%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
xorl %r15d, %r15d
cmpl %ebp, %edx
je 0x2553b
movslq %edx, %rsi
movq 0x28(%r14), %rax
movl (%rax,%rsi,4), %r9d
testl %r9d, %r9d
jle 0x253d9
movq 0x20(%r14), %rcx
movq (%rcx,%rsi,8), %rcx
xorl %r15d, %r15d
cmpl %ebp, (%rcx,%r15,4)
je 0x253d9
incq %r15
cmpq %r15, %r9
jne 0x253c8
movl %r9d, %r15d
movl 0x8(%rdi,%r8,4), %ecx
movl 0xc(%rdi,%r8,4), %r12d
movl 0x10(%rdi,%r8,4), %r13d
cmpl %r9d, %r15d
jne 0x25422
movslq %ebp, %rdi
movslq %ecx, %r8
movslq %r12d, %r9
movq 0x20(%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 0x25459
xorl %r15d, %r15d
movq %r14, %rdi
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x26bc4
testb %al, %al
je 0x2553b
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r12d, %ecx
movl $0x1, %r8d
callq 0x26bc4
testb %al, %al
je 0x25538
movslq 0x18(%r14), %rcx
decq %rcx
movl %ecx, 0x18(%r14)
cmpl %r13d, 0x1c(%r14)
jne 0x25472
movl $0x0, 0x1c(%r14)
cmpl %r13d, %ecx
je 0x2552d
cmpl %ecx, 0x1c(%r14)
jne 0x25485
movl %r13d, 0x1c(%r14)
movslq %r13d, %rax
movq 0x30(%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movsd (%rdx,%rcx,8), %xmm0
leaq (%rax,%rax,2), %rsi
movsd %xmm0, (%rdx,%rsi,8)
movsd 0x8(%rdx,%rcx,8), %xmm0
movsd %xmm0, 0x8(%rdx,%rsi,8)
movsd 0x10(%rdx,%rcx,8), %xmm0
movsd %xmm0, 0x10(%rdx,%rsi,8)
movq 0x28(%r14), %rdx
movslq 0x18(%r14), %rcx
movl (%rdx,%rcx,4), %r8d
testl %r8d, %r8d
jle 0x254f7
movq 0x20(%r14), %rsi
xorl %edi, %edi
movq (%rsi,%rcx,8), %rcx
movslq (%rcx,%rdi,4), %r9
movq (%rsi,%r9,8), %r9
movslq %r8d, %r8
addq %rdi, %r8
movslq (%rcx,%r8,4), %rcx
movl %r13d, (%r9,%rcx,4)
incq %rdi
movslq 0x18(%r14), %rcx
movslq (%rdx,%rcx,4), %r8
cmpq %r8, %rdi
jl 0x254cd
movq 0xa8(%rbx), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x20(%r14), %rdx
movq (%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rax,8)
movq 0x28(%r14), %rdx
movl (%rdx,%rcx,4), %ecx
movl %ecx, (%rdx,%rax,4)
movq 0x20(%r14), %rdx
movq (%rdx,%rax,8), %rax
addl %ecx, %ecx
movslq %ecx, %rcx
movl %r13d, (%rax,%rcx,4)
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x25363
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop