// File: /workspace/github_cpp_makefile_star2_O2/sunweilun[P]Delaunay/Mesh.cpp
// Function: Mesh::insertVertex(unsigned int)
void Mesh::insertVertex(unsigned vIndex)
{
    std::unordered_set<llu> checked; // set of checked edges (Hash Values)
    std::stack<unsigned> suspEdgeIndices; // stack of suspicious edges
    HalfEdge e;

    unsigned oldEdgeIndices[3];

    unsigned eIndexList[3][2];

    unsigned oldTriIndex = locateTriangle(vIndex);

    for(int i=0; i<3; i++)
    {
        unsigned eIndex = triangles[oldTriIndex].eIndices[i];
        HalfEdge &oldEdge = halfEdges[eIndex];
        suspEdgeIndices.push(eIndex); // Edges of the old triangle are suspicious.

        oldEdgeIndices[i] = eIndex;

        // new edge
        e.vIndices[0] = oldEdge.vIndices[1];
        e.vIndices[1] = vIndex;
        halfEdges.push_back(e);
        eIndexList[i][0] = unsigned(halfEdges.size())-1;

        // new edge
        e.vIndices[1] = oldEdge.vIndices[1];
        e.vIndices[0] = vIndex;
        halfEdges.push_back(e);
        eIndexList[i][1] = unsigned(halfEdges.size())-1;
    }

    for(int i=0; i<3; i++)
    {
        unsigned eIndex = oldEdgeIndices[i];
        int prev_i = (i+2)%3;

        unsigned tIndex = unsigned(triangles.size());
        if(i > 0)
            triangles.push_back(Triangle());
        else
            tIndex = oldTriIndex;

        fillTriangle(tIndex, eIndex, eIndexList[i][0], eIndexList[prev_i][1]);
        pairEdges(eIndexList[i][0], eIndexList[i][1]);
        checked.insert(halfEdges[eIndexList[i][0]].getHashValue());
        checked.insert(halfEdges[eIndexList[i][1]].getHashValue());
    }

    correctEdges(suspEdgeIndices, checked);

    if(method == CONFLICT_GRAPH) // redistribute
    {
        updateConfGraph(vIndex, oldTriIndex);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %esi, %ebx
movq %rdi, %r14
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
pxor %xmm0, %xmm0
movdqu %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movdqu %xmm0, -0x8(%rax)
leaq 0xe8(%rsp), %rdi
callq 0x2f14
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
orq $-0x1, 0x20(%rsp)
movq %r14, %rdi
movl %ebx, 0x4(%rsp)
movl %ebx, %esi
callq 0x1c9a
movl %eax, (%rsp)
leaq 0x28(%r14), %rax
movq %rax, 0x8(%rsp)
movl (%rsp), %eax
leaq 0x40(%r14), %r12
imulq $0x48, %rax, %rax
movq %rax, 0x38(%rsp)
xorl %r15d, %r15d
leaq 0x10(%rsp), %r13
cmpq $0x3, %r15
je 0x23c3
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq 0x38(%rsp), %rax
movl (%rax,%r15,4), %ebp
movl %ebp, 0x58(%rsp)
movq (%r12), %rbx
leaq 0xe8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x49cc
movl 0x58(%rsp), %eax
movl %eax, 0xa4(%rsp,%r15,4)
imulq $0x18, %rbp, %rbp
movl 0x4(%rbx,%rbp), %eax
movl %eax, 0x10(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x14(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2ac4
leaq (%rbx,%rbp), %rcx
addq $0x4, %rcx
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
decl %eax
movl %eax, 0x40(%rsp,%r15,8)
movl (%rcx), %eax
movl %eax, 0x14(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2ac4
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
decl %eax
movl %eax, 0x44(%rsp,%r15,8)
incq %r15
jmp 0x230c
xorl %ebx, %ebx
movq %r14, 0x30(%rsp)
cmpq $0x3, %rbx
je 0x24f3
movq 0x30(%r14), %rax
subq 0x28(%r14), %rax
movl 0xa4(%rsp,%rbx,4), %r9d
cqto
pushq $0x48
popq %rcx
idivq %rcx
pushq $0x2
popq %r13
movl (%rsp), %esi
testq %rbx, %rbx
je 0x246d
movq %rax, %r14
movl %r9d, %ebp
movq %r12, %r15
leaq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq $0x1, 0x70(%rsp)
leaq 0x68(%rsp), %r12
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%r12)
movl $0x3f800000, 0x88(%rsp) # imm = 0x3F800000
movdqu %xmm0, 0x28(%r12)
orl $-0x1, 0x60(%rsp)
orq $-0x1, 0x58(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x515e
leal -0x1(%rbx), %r13d
movq %r12, %rdi
callq 0x3018
movl %r14d, %esi
movq %r15, %r12
movl %ebp, %r9d
movq 0x30(%rsp), %r14
movl 0x40(%rsp,%rbx,8), %ebp
movl 0x44(%rsp,%r13,8), %r8d
movq %r14, %rdi
movl %r9d, %edx
movl %ebp, %ecx
callq 0x1cec
movl 0x44(%rsp,%rbx,8), %eax
movq 0x40(%r14), %rcx
imulq $0x18, %rbp, %rdx
movl %eax, 0x14(%rcx,%rdx)
imulq $0x18, %rax, %r15
movl %ebp, 0x14(%rcx,%r15)
movl (%rcx,%rdx), %eax
movl 0x4(%rcx,%rdx), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x58(%rsp)
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
leaq 0x58(%rsp), %rbp
movq %rbp, %rsi
callq 0x46e4
movq (%r12), %rax
movl (%rax,%r15), %ecx
movl 0x4(%rax,%r15), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x58(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x46e4
incq %rbx
jmp 0x23ca
leaq 0xe8(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq %r14, %rdi
callq 0x1eb6
cmpl $0x1, 0x8(%r14)
jne 0x2521
movq %r14, %rdi
movl 0x4(%rsp), %esi
movl (%rsp), %edx
callq 0x2102
leaq 0xe8(%rsp), %rdi
callq 0x30cc
leaq 0xb0(%rsp), %rdi
callq 0x3124
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2575
jmp 0x2565
movq %rax, %rbx
movq %r12, %rdi
callq 0x3018
jmp 0x2568
jmp 0x2565
jmp 0x2565
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x30cc
leaq 0xb0(%rsp), %rdi
callq 0x3124
movq %rbx, %rdi
callq 0x11a0