// File: /workspace/github_cpp_makefile_star2_O3/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 $0x168, %rsp            # imm = 0x168
movl %esi, %r12d
movq %rdi, 0x8(%rsp)
leaq 0x160(%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 0xe0(%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 0x54ae
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x20(%rsp)
movq $-0x1, 0x30(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x2a7e
movl %r12d, %eax
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
shlq $0x5, %rax
movl (%rcx,%rax), %eax
jmp 0x2a8d
movq 0x8(%rsp), %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x1ec8
movq 0x8(%rsp), %rdx
leaq 0x28(%rdx), %rcx
movq %rcx, 0x40(%rsp)
movl %eax, 0x1c(%rsp)
movl %eax, %eax
leaq 0x40(%rdx), %rcx
movq %rcx, 0x10(%rsp)
movq 0x40(%rdx), %rbp
movq %rax, 0x58(%rsp)
leaq (,%rax,8), %rax
leaq (%rax,%rax,8), %rbx
xorl %r13d, %r13d
movq 0x40(%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
movl (%rax,%r13,4), %r15d
movl %r15d, 0x68(%rsp)
movq 0x110(%rsp), %rax
movq 0x120(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x2b00
movl %r15d, (%rax)
addq $0x4, %rax
movq %rax, 0x110(%rsp)
jmp 0x2b12
leaq 0xe0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x4f06
movl 0x68(%rsp), %eax
movl %eax, 0xd4(%rsp,%r13,4)
leaq (%r15,%r15,2), %r15
movl 0x4(%rbp,%r15,8), %eax
movl %eax, 0x20(%rsp)
movl %r12d, 0x24(%rsp)
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rsi
cmpq 0x50(%rax), %rsi
je 0x2b65
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movdqa 0x20(%rsp), %xmm0
movdqu %xmm0, (%rsi)
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rsi
addq $0x18, %rsi
movq %rsi, 0x48(%rax)
jmp 0x2b7d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3cc4
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rsi
leaq 0x4(,%r15,8), %rax
addq %rbp, %rax
movq %rsi, %rcx
movq 0x8(%rsp), %rdx
subq 0x40(%rdx), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
decl %ecx
movl %ecx, 0xb0(%rsp,%r13,8)
movl (%rax), %eax
movl %eax, 0x24(%rsp)
movl %r12d, 0x20(%rsp)
cmpq 0x50(%rdx), %rsi
je 0x2bdf
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsi)
movdqa 0x20(%rsp), %xmm0
movdqu %xmm0, (%rsi)
movq 0x8(%rsp), %rcx
movq 0x48(%rcx), %rax
addq $0x18, %rax
movq %rax, 0x48(%rcx)
jmp 0x2bf7
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3cc4
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rbp
subq %rbp, %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
decl %eax
movl %eax, 0xb4(%rsp,%r13,8)
incq %r13
cmpq $0x3, %r13
jne 0x2ac2
leaq 0x78(%rsp), %rax
xorl %ebx, %ebx
leaq 0x68(%rsp), %rdx
movl %r12d, 0x4c(%rsp)
movq 0x40(%rsp), %r14
movl 0xd4(%rsp,%rbx,4), %r15d
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rbp
testq %rbx, %rbx
je 0x2ce9
movq 0x8(%rsp), %rcx
movq 0x30(%rcx), %r13
leaq 0xa8(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movq $0x1, 0x80(%rsp)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax)
movl $0x3f800000, 0x98(%rsp) # imm = 0x3F800000
movdqu %xmm0, 0x28(%rax)
movl $0xffffffff, 0x70(%rsp) # imm = 0xFFFFFFFF
movq $-0x1, 0x68(%rsp)
movq %r14, %rdi
movq %rdx, %rsi
movq %rax, %r12
callq 0x5608
leal -0x1(%rbx), %eax
movq %rax, 0x60(%rsp)
subq %rbp, %r13
sarq $0x3, %r13
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %r13
movq %r12, %rdi
callq 0x382a
movq 0x60(%rsp), %rsi
movq (%r14), %rbp
movl %r13d, %eax
movq 0x10(%rsp), %r14
leaq 0x68(%rsp), %rdx
jmp 0x2cff
movl $0x2, %esi
movq 0x58(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %r13d
movq 0x10(%rsp), %r14
movl 0xb0(%rsp,%rbx,8), %ecx
movl 0xb4(%rsp,%rsi,8), %r9d
leaq (%rax,%rax,8), %rax
movl %r15d, (%rbp,%rax,8)
movl %ecx, 0x4(%rbp,%rax,8)
movl %r9d, 0x8(%rbp,%rax,8)
movq (%r14), %rax
leaq (%r15,%r15,2), %rsi
movl %ecx, 0xc(%rax,%rsi,8)
leaq (%rcx,%rcx,2), %rdi
movl %r15d, 0x10(%rax,%rdi,8)
movl %r9d, 0xc(%rax,%rdi,8)
leaq (%r9,%r9,2), %r8
movl %ecx, 0x10(%rax,%r8,8)
movl %r15d, 0xc(%rax,%r8,8)
movl %r9d, 0x10(%rax,%rsi,8)
movl %r13d, 0x8(%rax,%rsi,8)
movl %r13d, 0x8(%rax,%rdi,8)
movl %r13d, 0x8(%rax,%r8,8)
movl 0xb4(%rsp,%rbx,8), %esi
movl %esi, 0x14(%rax,%rdi,8)
leaq (%rsi,%rsi,2), %r15
movl %ecx, 0x14(%rax,%r15,8)
movl (%rax,%rdi,8), %ecx
movl 0x4(%rax,%rdi,8), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x50(%rsp)
leaq 0x130(%rsp), %r13
movq %r13, 0x68(%rsp)
movq %r13, %rdi
leaq 0x50(%rsp), %rbp
movq %rbp, %rsi
movq %rdx, %r12
callq 0x4c78
movq (%r14), %rax
movl (%rax,%r15,8), %ecx
movl 0x4(%rax,%r15,8), %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x50(%rsp)
movq %r13, 0x68(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x4c78
movl 0x4c(%rsp), %ebp
incq %rbx
cmpq $0x3, %rbx
movq 0x40(%rsp), %r14
leaq 0x78(%rsp), %rax
leaq 0x68(%rsp), %rdx
jne 0x2c39
leaq 0xe0(%rsp), %rsi
leaq 0x130(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x2476
movq 0x8(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x2e22
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl 0x1c(%rsp), %edx
callq 0x2814
leaq 0xe0(%rsp), %rdi
callq 0x38a4
leaq 0x130(%rsp), %rdi
callq 0x38fc
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2e76
jmp 0x2e66
movq %rax, %rbx
movq %r12, %rdi
callq 0x382a
jmp 0x2e69
jmp 0x2e66
jmp 0x2e66
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x38a4
leaq 0x130(%rsp), %rdi
callq 0x38fc
movq %rbx, %rdi
callq 0x11a0
nop