// File: sunweilun[P]Delaunay/Mesh.cpp
// Function: Mesh::buildGhostTriangle(std::vector<glm::detail::tvec3<double, (glm::precision)0>, std::allocator<glm::detail::tvec3<double, (glm::precision)0>>> const&)
void Mesh::buildGhostTriangle(const std::vector<vec3>& vList)
{
    vec3 vPos[3];
    vec3 centroid(0, 0, 0);
    real radius = 0;
    for(auto it = vList.begin(); it != vList.end(); it++)
    {
        centroid += *it;
    }
    centroid /= real(vList.size());
    centroid.z = 1;

    for(auto it = vList.begin(); it != vList.end(); it++)
    {
        real dist = glm::length(*it - centroid);
        if(dist > radius)
            radius = dist;
    }

    centroid.z = 0;

    vPos[0] = centroid + vec3(-radius*2, -radius, 0);
    vPos[1] = centroid + vec3(radius*2, -radius, 0);
    vPos[2] = centroid + vec3(0, radius*2, 0);

    Vertex v;
    Triangle t;
    HalfEdge e;

    v.pos = vPos[0];
    vertices.push_back(v);

    v.pos = vPos[1];
    vertices.push_back(v);

    v.pos = vPos[2];
    vertices.push_back(v);

    halfEdges.push_back(e);
    halfEdges.push_back(e);
    halfEdges.push_back(e);

    for(int i=0; i<3; i++)
    {
        int j = (i+1)%3;
        halfEdges[i].vIndices[0] = i;
        halfEdges[i].vIndices[1] = j;
        halfEdges[i].nextIndex = j;
        halfEdges[j].prevIndex = i;
        t.eIndices[i] = i;
    }
    triangles.push_back(t);
    for(int i=0; i<3; i++)
    {
        halfEdges[i].tIndex = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, %rcx
addq $0x48, %rcx
movq %rcx, -0x260(%rbp)
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x43a0
movq -0x270(%rbp), %rax
movq -0x260(%rbp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, -0x258(%rbp)
jne 0x15a7
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
leaq -0x80(%rbp), %rdx
leaq -0x84(%rbp), %rcx
callq 0x43d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4410
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4480
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4440
testb $0x1, %al
jne 0x164c
jmp 0x167b
leaq -0x98(%rbp), %rdi
callq 0x44b0
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x44d0
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x4520
movq %rax, -0xa8(%rbp)
jmp 0x1623
movq -0x10(%rbp), %rdi
callq 0x4560
movq %rax, %xmm0
movaps 0x11990(%rip), %xmm1    # 0x13020
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x11994(%rip), %xmm1    # 0x13030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq -0x78(%rbp), %rdi
callq 0x4590
movsd 0x1194c(%rip), %xmm0    # 0x13008
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4410
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4480
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4440
testb $0x1, %al
jne 0x16fa
jmp 0x176b
leaq -0xb0(%rbp), %rdi
callq 0x44b0
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4650
leaq -0xd8(%rbp), %rdi
callq 0x45e0
movsd %xmm0, -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
ucomisd -0x90(%rbp), %xmm0
jbe 0x174f
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x1751
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x4520
movq %rax, -0xe0(%rbp)
jmp 0x16d1
movq $0x0, -0x68(%rbp)
movsd -0x90(%rbp), %xmm2
movaps %xmm2, %xmm0
movapd 0x118ba(%rip), %xmm1    # 0x13040
movaps %xmm1, -0x2b0(%rbp)
pxor %xmm1, %xmm0
subsd %xmm2, %xmm0
movsd %xmm0, -0x118(%rbp)
movsd -0x90(%rbp), %xmm0
pxor %xmm1, %xmm0
movlpd %xmm0, -0x120(%rbp)
movl $0x0, -0x124(%rbp)
leaq -0x110(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
leaq -0x118(%rbp), %rsi
leaq -0x120(%rbp), %rdx
leaq -0x124(%rbp), %rcx
callq 0x4750
movq -0x2c0(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
leaq -0x78(%rbp), %rsi
movq %rsi, -0x288(%rbp)
callq 0x46d0
movq -0x2b8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4790
movaps -0x2b0(%rbp), %xmm1
movsd -0x90(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x160(%rbp)
movsd -0x90(%rbp), %xmm0
pxor %xmm1, %xmm0
movlpd %xmm0, -0x168(%rbp)
movl $0x0, -0x16c(%rbp)
leaq -0x158(%rbp), %rdi
movq %rdi, -0x298(%rbp)
leaq -0x160(%rbp), %rsi
leaq -0x168(%rbp), %rdx
leaq -0x16c(%rbp), %rcx
callq 0x4750
movq -0x298(%rbp), %rdx
movq -0x288(%rbp), %rsi
leaq -0x140(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x46d0
movq -0x290(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x4790
movl $0x0, -0x1a4(%rbp)
movsd -0x90(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x1b0(%rbp)
movl $0x0, -0x1b4(%rbp)
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x280(%rbp)
leaq -0x1a4(%rbp), %rsi
leaq -0x1b0(%rbp), %rdx
leaq -0x1b4(%rbp), %rcx
callq 0x47d0
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rdx
leaq -0x188(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x46d0
movq -0x278(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x4790
leaq -0x1d8(%rbp), %rdi
callq 0x4810
leaq -0x220(%rbp), %rdi
callq 0x4830
leaq -0x238(%rbp), %rdi
callq 0x4870
jmp 0x1951
leaq -0x1d0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4790
jmp 0x1963
movq -0x268(%rbp), %rdi
addq $0x10, %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x48b0
jmp 0x197c
leaq -0x48(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x4790
jmp 0x198e
movq -0x268(%rbp), %rdi
addq $0x10, %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x48b0
jmp 0x19a7
leaq -0x30(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x4790
jmp 0x19b9
movq -0x268(%rbp), %rdi
addq $0x10, %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x48b0
jmp 0x19d2
movq -0x268(%rbp), %rdi
addq $0x40, %rdi
leaq -0x238(%rbp), %rsi
callq 0x4920
jmp 0x19eb
movq -0x268(%rbp), %rdi
addq $0x40, %rdi
leaq -0x238(%rbp), %rsi
callq 0x4920
jmp 0x1a04
movq -0x268(%rbp), %rdi
addq $0x40, %rdi
leaq -0x238(%rbp), %rsi
callq 0x4920
jmp 0x1a1d
movl $0x0, -0x248(%rbp)
cmpl $0x3, -0x248(%rbp)
jge 0x1b42
movq -0x268(%rbp), %rdi
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %edx, -0x24c(%rbp)
movl -0x248(%rbp), %eax
movl %eax, -0x2d0(%rbp)
addq $0x40, %rdi
movslq -0x248(%rbp), %rsi
callq 0x4990
movl -0x2d0(%rbp), %ecx
movq -0x268(%rbp), %rdi
movl %ecx, (%rax)
movl -0x24c(%rbp), %eax
movl %eax, -0x2cc(%rbp)
addq $0x40, %rdi
movslq -0x248(%rbp), %rsi
callq 0x4990
movl -0x2cc(%rbp), %ecx
movq -0x268(%rbp), %rdi
movl %ecx, 0x4(%rax)
movl -0x24c(%rbp), %eax
movl %eax, -0x2c8(%rbp)
addq $0x40, %rdi
movslq -0x248(%rbp), %rsi
callq 0x4990
movl -0x2c8(%rbp), %ecx
movq -0x268(%rbp), %rdi
movl %ecx, 0xc(%rax)
movl -0x248(%rbp), %eax
movl %eax, -0x2c4(%rbp)
addq $0x40, %rdi
movslq -0x24c(%rbp), %rsi
callq 0x4990
movl -0x2c4(%rbp), %ecx
movl %ecx, 0x10(%rax)
movl -0x248(%rbp), %ecx
movslq -0x248(%rbp), %rax
movl %ecx, -0x220(%rbp,%rax,4)
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x248(%rbp)
jmp 0x1a27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x4a20
jmp 0x1bb2
movq -0x268(%rbp), %rdi
addq $0x28, %rdi
leaq -0x220(%rbp), %rsi
callq 0x49b0
jmp 0x1b5b
movl $0x0, -0x250(%rbp)
cmpl $0x3, -0x250(%rbp)
jge 0x1b9d
movq -0x268(%rbp), %rdi
addq $0x40, %rdi
movslq -0x250(%rbp), %rsi
callq 0x4990
movl $0x0, 0x8(%rax)
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0x1b65
leaq -0x220(%rbp), %rdi
callq 0x4a20
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x11c0
nop