// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3TriangleArray.cpp
// Function: gaps::R3TriangleArray::operator=(gaps::R3TriangleArray const&)
R3TriangleArray& R3TriangleArray::
operator=(const R3TriangleArray& array)
{
    // Delete previous triangles and vertices
    for (int i = 0; i < triangles.NEntries(); i++) delete triangles[i];
    for (int i = 0; i < vertices.NEntries(); i++) delete vertices[i];
    triangles.Empty();
    vertices.Empty();

    // Copy vertices
    for (int i = 0; i < array.vertices.NEntries(); i++) {
      R3TriangleVertex *oldv = array.vertices.Kth(i);
      R3TriangleVertex *newv = new R3TriangleVertex(*oldv);
      vertices.Insert(newv);
      newv->SetSharedFlag();
      oldv->SetMark(i);
    }

    // Copy triangles
    for (int i = 0; i < array.triangles.NEntries(); i++) {
      R3Triangle *oldt = array.triangles.Kth(i);
      R3TriangleVertex *v0 = vertices.Kth(oldt->V0()->Mark());
      R3TriangleVertex *v1 = vertices.Kth(oldt->V1()->Mark());
      R3TriangleVertex *v2 = vertices.Kth(oldt->V2()->Mark());
      R3Triangle *newt = new R3Triangle(v0, v1, v2);
      triangles.Insert(newt);
    }

    // Copy bbox
    bbox = array.bbox;

    // Update everything
    Update();

    // Return this
    return *this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x18(%rdi), %r12
xorl %ebx, %ebx
movslq 0x24(%r15), %rax
cmpq %rax, %rbx
jge 0x4b22f
movq (%r12), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x4b22a
movq (%rdi), %rax
callq *0x8(%rax)
incq %rbx
jmp 0x4b20e
leaq 0x8(%r15), %rax
movq %rax, (%rsp)
xorl %ebx, %ebx
pushq $0x68
popq %r13
movslq 0x14(%r15), %rax
cmpq %rax, %rbx
jge 0x4b25e
movq (%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %rdi
movq %r13, %rsi
callq 0xe460
incq %rbx
jmp 0x4b23d
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x66528
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x66528
movslq 0x14(%r14), %rax
cmpq %rax, %rbx
jge 0x4b2b5
movq 0x8(%r14), %rax
movq (%rax,%rbx,8), %rbp
pushq $0x68
popq %rdi
callq 0xe450
movq %rax, %r13
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4c472
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x22bfc
orb $0x1, 0x5a(%r13)
movl %ebx, 0x60(%rbp)
incq %rbx
jmp 0x4b275
movq %r12, 0x10(%rsp)
movq %r15, 0x8(%rsp)
xorl %r12d, %r12d
movslq 0x24(%r14), %rax
cmpq %rax, %r12
jge 0x4b32e
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rdx
movslq 0x60(%rcx), %rcx
movq (%rsp), %rsi
movq (%rsi), %rsi
movq (%rsi,%rcx,8), %rbp
movslq 0x60(%rdx), %rcx
movq (%rsi,%rcx,8), %r15
movq 0x18(%rax), %rax
movslq 0x60(%rax), %rax
movq (%rsi,%rax,8), %rbx
movl $0x88, %edi
callq 0xe450
movq %rax, %r13
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x4c910
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x22bfc
incq %r12
jmp 0x4b2c2
addq $0x28, %r14
movq 0x8(%rsp), %rbx
leaq 0x28(%rbx), %rdi
movq %r14, %rsi
callq 0x2141e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x248(%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x88, %esi
jmp 0x4b371
movq %rax, %rbx
pushq $0x68
popq %rsi
movq %r13, %rdi
callq 0xe460
movq %rbx, %rdi
callq 0xe810
nop