// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %rdi, (%rsp)
leaq 0x130(%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 0xb0(%rsp), %rdi
movdqa %xmm0, 0x40(%rdi)
movdqa %xmm0, 0x30(%rdi)
movdqa %xmm0, 0x20(%rdi)
movdqa %xmm0, 0x10(%rdi)
movdqa %xmm0, (%rdi)
xorl %esi, %esi
callq 0x563c
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
movq $-0x1, 0x20(%rsp)
movq (%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x2c55
movl 0x8(%rsp), %eax
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
shlq $0x5, %rax
movl (%rcx,%rax), %eax
jmp 0x2c64
movq (%rsp), %rdi
xorl %esi, %esi
movl 0x8(%rsp), %edx
callq 0x2014
movl %eax, 0xc(%rsp)
movl %eax, %eax
movq (%rsp), %rcx
leaq 0x40(%rcx), %r15
shlq $0x3, %rax
leaq (%rax,%rax,8), %rbx
xorl %r12d, %r12d
leaq 0xb0(%rsp), %r14
movq (%rsp), %rcx
movq 0x28(%rcx), %rax
addq %rbx, %rax
movl (%rax,%r12,4), %ebp
movl %ebp, 0x58(%rsp)
movq 0x40(%rcx), %r13
movq 0xe0(%rsp), %rax
movq 0xf0(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x2cc5
movl %ebp, (%rax)
addq $0x4, %rax
movq %rax, 0xe0(%rsp)
jmp 0x2cd2
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x5066
movl 0x58(%rsp), %eax
movl %eax, 0xa4(%rsp,%r12,4)
leaq (%rbp,%rbp,2), %rbp
movl 0x4(%r13,%rbp,8), %eax
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x14(%rsp)
movq (%rsp), %rax
movq 0x48(%rax), %rsi
cmpq 0x50(%rax), %rsi
je 0x2d20
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movdqa 0x10(%rsp), %xmm0
movdqu %xmm0, (%rsi)
movq (%rsp), %rax
addq $0x18, 0x48(%rax)
jmp 0x2d2d
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x3e50
leaq 0x4(,%rbp,8), %rax
addq %r13, %rax
movq (%rsp), %rdx
movq 0x48(%rdx), %rsi
movq %rsi, %rcx
subq 0x40(%rdx), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
decl %ecx
movl %ecx, 0x40(%rsp,%r12,8)
movl (%rax), %eax
movl %eax, 0x14(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
cmpq 0x50(%rdx), %rsi
je 0x2d8a
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movdqa 0x10(%rsp), %xmm0
movdqu %xmm0, (%rsi)
movq (%rsp), %rax
addq $0x18, 0x48(%rax)
jmp 0x2d97
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x3e50
movq (%rsp), %rcx
movq 0x48(%rcx), %rax
subq 0x40(%rcx), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
decl %eax
movl %eax, 0x44(%rsp,%r12,8)
incq %r12
cmpq $0x3, %r12
jne 0x2c85
movq (%rsp), %rax
addq $0x28, %rax
movq %rax, 0x30(%rsp)
movl $0x2, %r13d
xorl %r12d, %r12d
leaq 0x58(%rsp), %r9
movq %r13, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
movq %rdx, %rbx
movl 0xa4(%rsp,%r12), %r15d
movl 0xc(%rsp), %ebp
testq %r12, %r12
je 0x2e85
movq %r13, 0x38(%rsp)
movq (%rsp), %rax
movq 0x30(%rax), %rbp
subq 0x28(%rax), %rbp
leaq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq $0x1, 0x70(%rsp)
leaq 0x68(%rsp), %r14
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%r14)
movl $0x3f800000, 0x88(%rsp) # imm = 0x3F800000
movdqu %xmm0, 0x28(%r14)
movl $0xffffffff, 0x60(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x58(%rsp)
movq 0x30(%rsp), %rdi
movq %r9, %rsi
callq 0x5796
shrq $0x3, %rbp
imull $0x38e38e39, %ebp, %ebp # imm = 0x38E38E39
movq %r14, %rdi
callq 0x39be
movq 0x38(%rsp), %r13
leaq 0x58(%rsp), %r9
shlq $0x2, %rbx
andq $-0x8, %rbx
leaq (%rbx,%rbx,2), %rax
leaq 0x54(%rsp), %rcx
subq %rax, %rcx
movl 0x40(%rsp,%r12,2), %eax
movl (%rcx,%r12,2), %ecx
movl %ebp, %edx
movq (%rsp), %rdi
movq 0x28(%rdi), %rsi
leaq (%rdx,%rdx,8), %rdx
movl %r15d, (%rsi,%rdx,8)
movl %eax, 0x4(%rsi,%rdx,8)
movl %ecx, 0x8(%rsi,%rdx,8)
movq 0x40(%rdi), %rdx
leaq (%r15,%r15,2), %rsi
movl %eax, 0xc(%rdx,%rsi,8)
leaq (%rax,%rax,2), %rdi
movl %r15d, 0x10(%rdx,%rdi,8)
movl %ecx, 0xc(%rdx,%rdi,8)
leaq (%rcx,%rcx,2), %r8
movl %eax, 0x10(%rdx,%r8,8)
movl %r15d, 0xc(%rdx,%r8,8)
movl %ecx, 0x10(%rdx,%rsi,8)
movl %ebp, 0x8(%rdx,%rsi,8)
movl %ebp, 0x8(%rdx,%rdi,8)
movl %ebp, 0x8(%rdx,%r8,8)
movl 0x44(%rsp,%r12,2), %ecx
movl %ecx, 0x14(%rdx,%rdi,8)
leaq (%rcx,%rcx,2), %rbx
movl %eax, 0x14(%rdx,%rbx,8)
movl (%rdx,%rdi,8), %eax
movl 0x4(%rdx,%rdi,8), %ecx
shlq $0x20, %rax
orq %rax, %rcx
movq %rcx, 0x28(%rsp)
leaq 0x100(%rsp), %r15
movq %r15, 0x58(%rsp)
movq %r15, %rdi
leaq 0x28(%rsp), %rbp
movq %rbp, %rsi
movq %r9, %rdx
movq %r9, %r14
callq 0x4de8
movq (%rsp), %rax
movq 0x40(%rax), %rax
movl (%rax,%rbx,8), %ecx
movl 0x4(%rax,%rbx,8), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x28(%rsp)
movq %r15, 0x58(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x4de8
incq %r13
addq $0x4, %r12
cmpq $0xc, %r12
leaq 0x58(%rsp), %r9
jne 0x2ddc
leaq 0xb0(%rsp), %rsi
leaq 0x100(%rsp), %rdx
movq (%rsp), %rdi
callq 0x260e
movq (%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x2fb3
movq (%rsp), %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0x29e0
leaq 0xb0(%rsp), %rdi
callq 0x3a38
leaq 0x100(%rsp), %rdi
callq 0x3a88
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3007
jmp 0x2ff7
movq %rax, %rbx
movq %r14, %rdi
callq 0x39be
jmp 0x2ffa
jmp 0x2ff7
jmp 0x2ff7
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x3a38
leaq 0x100(%rsp), %rdi
callq 0x3a88
movq %rbx, %rdi
callq 0x11b0