// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x10(%rsp), %r13
movq 0x48(%r14), %rax
movq %rax, %rsi
subq 0x28(%r14), %rsi
shrq $0x3, %rsi
cmpq $0x1, %rax
adcq $-0x1, %rsi
shlq $0x7, %rsi
movq 0x20(%r14), %rdi
movq 0x30(%r14), %rcx
movq 0x38(%r14), %rdx
movq %rcx, %r8
subq %rdx, %r8
sarq $0x2, %r8
addq %rsi, %r8
subq 0x10(%r14), %rdi
sarq $0x2, %rdi
addq %r8, %rdi
je 0x28d5
cmpq %rdx, %rcx
jne 0x2680
movq -0x8(%rax), %rcx
movl $0x200, %eax            # imm = 0x200
addq %rax, %rcx
movl -0x4(%rcx), %ebp
movq %r14, %rdi
callq 0x4d54
movq 0x40(%r15), %r8
leaq (,%rbp,2), %r9
addq %rbp, %r9
movl (%r8,%r9,8), %eax
movl 0x4(%r8,%r9,8), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq (%rbx), %rdi
movq 0x8(%rbx), %r10
movq %rcx, %rax
xorl %edx, %edx
divq %r10
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x2703
movq (%rdx), %r11
movq %rdx, %rax
cmpq 0x8(%r11), %rcx
je 0x2703
movq %r11, %r12
movq (%r11), %r11
testq %r11, %r11
je 0x2701
movq 0x8(%r11), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r10
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x2703
movq %r12, %rax
cmpq %rdi, %rcx
jne 0x26d6
jmp 0x2703
xorl %eax, %eax
testq %rax, %rax
je 0x2712
cmpq $0x0, (%rax)
jne 0x262a
leaq (%r8,%r9,8), %r12
movl (%r12), %eax
movl 0x4(%r12), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x4de8
cmpl $-0x1, 0x14(%r12)
je 0x262a
movl 0x14(%r12), %eax
movq 0x40(%r15), %rcx
leaq (%rax,%rax,2), %rax
movl (%rcx,%rax,8), %edx
movl 0x4(%rcx,%rax,8), %eax
shlq $0x20, %rdx
orq %rdx, %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x4de8
movq %r15, %rdi
movl %ebp, %esi
callq 0x226e
testb %al, %al
jne 0x262a
movq %r15, %rdi
movl %ebp, %esi
callq 0x28e4
movl (%r12), %eax
movl 0x4(%r12), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %r13, %rdx
callq 0x4de8
movl 0x14(%r12), %eax
movq 0x40(%r15), %rcx
leaq (%rax,%rax,2), %rax
movl (%rcx,%rax,8), %edx
movl 0x4(%rcx,%rax,8), %eax
shlq $0x20, %rdx
orq %rdx, %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x4de8
leaq 0xc(%r12), %rsi
movq 0x30(%r14), %rax
movq 0x40(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x2821
movl (%rsi), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x2829
movq %r14, %rdi
callq 0x5066
leaq 0x10(%r12), %rsi
movq 0x30(%r14), %rax
movq 0x40(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x284d
movl (%rsi), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x2855
movq %r14, %rdi
callq 0x5066
movl 0x14(%r12), %eax
movq 0x40(%r15), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rsi
addq $0xc, %rsi
movq 0x30(%r14), %rax
movq 0x40(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x2889
movl (%rsi), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x2891
movq %r14, %rdi
callq 0x5066
movl 0x14(%r12), %eax
movq 0x40(%r15), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rsi
addq $0x10, %rsi
movq 0x30(%r14), %rax
movq 0x40(%r14), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x28c8
movl (%rsi), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, 0x30(%r14)
jmp 0x262a
movq %r14, %rdi
callq 0x5066
jmp 0x262a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq