// File: 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:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0xa4(%rsp)
movq 0x48(%rsp), %rdi
movl 0xa4(%rsp), %eax
movl %eax, 0x44(%rsp)
addq $0x18, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x97525
movq 0x48(%rsp), %rdi
addq $0x18, %rdi
movl 0xa4(%rsp), %esi
callq 0x9a3d0
movq (%rax), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x97510
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x97512
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x974bf
movl $0x0, 0xa0(%rsp)
movq 0x48(%rsp), %rdi
movl 0xa0(%rsp), %eax
movl %eax, 0x34(%rsp)
addq $0x8, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jge 0x9759a
movq 0x48(%rsp), %rdi
addq $0x8, %rdi
movl 0xa0(%rsp), %esi
callq 0x9a3f0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x97585
movq 0x28(%rsp), %rdi
movl $0x68, %esi
callq 0xf4d0
jmp 0x97587
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x97530
movq 0x48(%rsp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0xd1d30
movq 0x48(%rsp), %rdi
addq $0x8, %rdi
xorl %esi, %esi
callq 0xd1d30
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x976b2
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
movl 0x9c(%rsp), %esi
callq 0x9a260
movq %rax, 0x90(%rsp)
movl $0x68, %edi
callq 0xf4c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rsi
callq 0x9a850
jmp 0x97633
movq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0x88(%rsp)
addq $0x8, %rdi
movq 0x88(%rsp), %rsi
callq 0x9a280
movq 0x88(%rsp), %rdi
callq 0x9a2b0
movq 0x90(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x9a2f0
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x975c5
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
movl $0x68, %esi
callq 0xf4d0
jmp 0x97820
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x18, %rdi
callq 0x13600
movl %eax, %ecx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jge 0x977eb
movq 0xa8(%rsp), %rdi
addq $0x18, %rdi
movl 0x78(%rsp), %esi
callq 0x9a310
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x70(%rsp)
addq $0x8, %rax
movq %rax, (%rsp)
movq 0x70(%rsp), %rdi
callq 0x86a00
movq %rax, %rdi
callq 0x9a330
movq (%rsp), %rdi
movl %eax, %esi
callq 0x9a260
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
callq 0x86a10
movq %rax, %rdi
callq 0x9a330
movq (%rsp), %rdi
movl %eax, %esi
callq 0x9a260
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rdi
callq 0x86a20
movq %rax, %rdi
callq 0x9a330
movq (%rsp), %rdi
movl %eax, %esi
callq 0x9a260
movq %rax, 0x58(%rsp)
movl $0x88, %edi
callq 0xf4c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x58(%rsp), %rcx
callq 0x9b320
jmp 0x9779c
movq 0x48(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
addq $0x18, %rdi
movq 0x50(%rsp), %rsi
callq 0x9a340
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x976ba
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
movl $0x88, %esi
callq 0xf4d0
jmp 0x97820
movq 0x48(%rsp), %rdi
movq 0xa8(%rsp), %rsi
addq $0x28, %rsi
addq $0x28, %rdi
callq 0x37500
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
callq *0x248(%rax)
movq 0x48(%rsp), %rax
addq $0xb8, %rsp
retq
movq 0x80(%rsp), %rdi
callq 0xf890
nopl (%rax)