// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %r15
movq 0x8(%rsi), %rax
xorpd %xmm0, %xmm0
xorpd %xmm4, %xmm4
xorpd %xmm3, %xmm3
cmpq %rax, %r15
je 0x15b1
movq %r15, %rcx
addsd (%rcx), %xmm4
addsd 0x8(%rcx), %xmm3
addq $0x18, %rcx
cmpq %rax, %rcx
jne 0x159f
subq %r15, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq %rcx, %xmm2
punpckldq 0x4a3d(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x4a45(%rip), %xmm2     # 0x6020
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm4
divsd %xmm1, %xmm3
cmpq 0x8(%r14), %r15
movsd %xmm3, 0x28(%rsp)
movsd %xmm4, 0x8(%rsp)
je 0x168b
xorpd %xmm5, %xmm5
movsd 0x4a1f(%rip), %xmm6     # 0x6030
xorpd %xmm7, %xmm7
movsd (%r15), %xmm1
movsd 0x8(%r15), %xmm2
subsd %xmm4, %xmm1
subsd %xmm3, %xmm2
movsd 0x10(%r15), %xmm0
addsd %xmm6, %xmm0
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm5, %xmm0
jb 0x1652
sqrtsd %xmm0, %xmm0
jmp 0x1679
movsd %xmm7, (%rsp)
callq 0x10c0
movsd (%rsp), %xmm7
movsd 0x49c7(%rip), %xmm6     # 0x6030
xorpd %xmm5, %xmm5
movsd 0x8(%rsp), %xmm4
movsd 0x28(%rsp), %xmm3
maxsd %xmm7, %xmm0
addq $0x18, %r15
movapd %xmm0, %xmm7
cmpq 0x8(%r14), %r15
jne 0x1615
subsd %xmm0, %xmm3
addsd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
leaq 0x38(%rsp), %rsi
movupd %xmm1, 0x8(%rsi)
movq $0x0, 0x18(%rsi)
leaq 0x68(%rsp), %r14
leaq 0x98(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movupd %xmm1, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movupd %xmm1, -0x8(%rax)
movl $0xffffffff, -0x38(%rax) # imm = 0xFFFFFFFF
movq $-0x1, %rcx
movq %rcx, -0x40(%rax)
movq %rcx, 0x20(%rsp)
pcmpeqd %xmm1, %xmm1
movdqa %xmm1, 0x10(%rsp)
movsd %xmm2, 0x8(%rsi)
movsd %xmm3, 0x30(%rsp)
movsd %xmm3, 0x10(%rsi)
leaq 0x10(%rbx), %r15
movq %r15, %rdi
callq 0x3558
movsd 0x8(%rsp), %xmm0
addsd (%rsp), %xmm0
leaq 0x38(%rsp), %rsi
movsd %xmm0, 0x8(%rsi)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%rsi)
movq $0x0, 0x18(%rsi)
movq %r15, %rdi
callq 0x3558
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
addsd (%rsp), %xmm0
leaq 0x38(%rsp), %rsi
movsd %xmm1, 0x8(%rsi)
movsd %xmm0, 0x10(%rsi)
movq $0x0, 0x18(%rsi)
movq %r15, %rdi
callq 0x3558
leaq 0x40(%rbx), %r15
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x17ad
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x48(%rbx)
jmp 0x17ba
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x3e50
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x17de
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x48(%rbx)
jmp 0x17eb
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x3e50
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0x180f
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsi)
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x48(%rbx)
jmp 0x181c
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x3e50
movq (%r15), %rax
xorl %ecx, %ecx
movq %rax, %rdx
xorl %esi, %esi
leaq 0x1(%rsi), %rdi
cmpq $0x2, %rsi
movl %edi, %r8d
cmovel %ecx, %r8d
movl %esi, (%rdx)
movl %r8d, 0x4(%rdx)
movl %r8d, 0xc(%rdx)
leaq (%r8,%r8,2), %r8
movl %esi, 0x10(%rax,%r8,8)
movl %esi, 0x58(%rsp,%rsi,4)
addq $0x18, %rdx
movq %rdi, %rsi
cmpq $0x3, %rdi
jne 0x1826
addq $0x28, %rbx
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x3592
movq (%r15), %rax
movl $0x8, %ecx
movl $0x0, (%rax,%rcx)
addq $0x18, %rcx
cmpq $0x50, %rcx
jne 0x1872
movq %r14, %rdi
callq 0x39be
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x39be
movq %rbx, %rdi
callq 0x11b0
nop