// File: /workspace/github_cpp_makefile_star2_O2/sunweilun[P]Delaunay/Mesh.cpp
// Function: Mesh::correctEdges(std::stack<unsigned int, std::deque<unsigned int, std::allocator<unsigned int>>>&, std::unordered_set<unsigned long long, std::hash<unsigned long long>, std::equal_to<unsigned long long>, std::allocator<unsigned long long>>&)
void Mesh::correctEdges(std::stack<unsigned>& suspEdgeIndices, std::unordered_set<llu>& checked)
{
    while(suspEdgeIndices.size())
    {
        unsigned eIndex = suspEdgeIndices.top();
        suspEdgeIndices.pop();
        const HalfEdge &e = halfEdges[eIndex];
        if(checked.find(e.getHashValue()) != checked.end()) // Skip edges that have already been checked.
            continue;
        checked.insert(e.getHashValue());
        if(e.neighborIndex == MAX_UINT) // No neighbor, must be Delaunay.
            continue;
        checked.insert(halfEdges[e.neighborIndex].getHashValue());
        if(isDelaunay(eIndex))
            continue;
        flipEdge(eIndex);
        checked.insert(e.getHashValue());
        checked.insert(halfEdges[e.neighborIndex].getHashValue());
        suspEdgeIndices.push(e.nextIndex);
        suspEdgeIndices.push(e.prevIndex);
        suspEdgeIndices.push(halfEdges[e.neighborIndex].nextIndex);
        suspEdgeIndices.push(halfEdges[e.neighborIndex].prevIndex);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
leaq 0x8(%rsp), %rbx
movq %r14, %rdi
callq 0x45ca
testq %rax, %rax
je 0x205a
movq 0x30(%r14), %rax
cmpq 0x38(%r14), %rax
jne 0x1eff
movq 0x48(%r14), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %r13d
movq %r14, %rdi
callq 0x4612
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rbp
imulq $0x18, %r13, %r12
movl (%rbp,%r12), %eax
movl 0x4(%rbp,%r12), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4668
testq %rax, %rax
jne 0x1ed4
addq %r12, %rbp
movl (%rbp), %eax
movl 0x4(%rbp), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x46e4
movl 0x14(%rbp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1ed4
movq 0x10(%rsp), %r12
movq 0x40(%r12), %rcx
imulq $0x18, %rax, %rax
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %eax
shlq $0x20, %rdx
orq %rdx, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x46e4
movq %r12, %rdi
movl %r13d, %esi
callq 0x1d48
testb %al, %al
jne 0x1ed4
movq 0x10(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
callq 0x206a
movl (%rbp), %eax
movl 0x4(%rbp), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x46e4
movl 0x14(%rbp), %eax
movq 0x40(%r12), %rcx
imulq $0x18, %rax, %rax
movl (%rcx,%rax), %edx
movl 0x4(%rcx,%rax), %eax
shlq $0x20, %rdx
orq %rdx, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x46e4
leaq 0xc(%rbp), %rsi
movq %r14, %rdi
callq 0x49cc
leaq 0x10(%rbp), %rsi
movq %r14, %rdi
callq 0x49cc
movl 0x14(%rbp), %eax
movq 0x40(%r12), %rcx
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $0xc, %rsi
movq %r14, %rdi
callq 0x49cc
movl 0x14(%rbp), %eax
movq 0x40(%r12), %rcx
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x49cc
jmp 0x1ed4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop