// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3TriangleArray.cpp
// Function: gaps::R3TriangleArray::R3TriangleArray(gaps::R3TriangleArray const&)
R3TriangleArray::
R3TriangleArray(const R3TriangleArray& array)
  : vertices(),
    triangles(),
    bbox(array.bbox),
    flags(array.flags),
    vbo_id(0),
    vbo_size(0)
{
    // 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);
    }

    // Update everything
    Update();
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq 0x110(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x9cbd0
movq 0xa8(%rsp), %rdi
leaq 0xd6b6d(%rip), %rax     # 0x16d218
movq %rax, (%rdi)
addq $0x8, %rdi
movq %rdi, 0xb0(%rsp)
callq 0x9a220
jmp 0x966c1
movq 0xa8(%rsp), %rdi
addq $0x18, %rdi
movq %rdi, 0xa0(%rsp)
callq 0x9a230
jmp 0x966dc
movq 0xa8(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0x98(%rsp)
movq 0x108(%rsp), %rsi
addq $0x28, %rsi
callq 0x428c0
jmp 0x96703
movq 0xa8(%rsp), %rax
movq 0x108(%rsp), %rcx
movq 0x60(%rcx), %rcx
movq %rcx, 0x60(%rax)
movl $0x0, 0x68(%rax)
movl $0x0, 0x6c(%rax)
movl $0x0, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
movl %eax, 0x90(%rsp)
movq 0x108(%rsp), %rdi
addq $0x8, %rdi
callq 0x13600
movl %eax, 0x94(%rsp)
jmp 0x9675c
movl 0x90(%rsp), %eax
movl 0x94(%rsp), %ecx
cmpl %ecx, %eax
jge 0x968c6
movq 0x108(%rsp), %rdi
addq $0x8, %rdi
movl 0xf8(%rsp), %esi
callq 0x9a260
movq %rax, 0x88(%rsp)
jmp 0x96794
movq 0x88(%rsp), %rax
movq %rax, 0xf0(%rsp)
movl $0x68, %edi
callq 0xf4c0
movq %rax, 0x80(%rsp)
jmp 0x967b8
movq 0x80(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x9a850
jmp 0x967cf
movq 0xa8(%rsp), %rdi
movq 0x80(%rsp), %rax
movq %rax, 0xe8(%rsp)
addq $0x8, %rdi
movq 0xe8(%rsp), %rsi
callq 0x9a280
jmp 0x967fa
movq 0xe8(%rsp), %rdi
callq 0x9a2b0
jmp 0x96809
movq 0xf0(%rsp), %rdi
movl 0xf8(%rsp), %esi
callq 0x9a2f0
jmp 0x9681f
jmp 0x96821
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x96734
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x96b13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x96b06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x96af9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x96aec
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
movl $0x68, %esi
callq 0xf4d0
jmp 0x96aec
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
movl %eax, 0x78(%rsp)
movq 0x108(%rsp), %rdi
addq $0x18, %rdi
callq 0x13600
movl %eax, 0x7c(%rsp)
jmp 0x968f3
movl 0x78(%rsp), %eax
movl 0x7c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x96ace
movq 0x108(%rsp), %rdi
addq $0x18, %rdi
movl 0xe4(%rsp), %esi
callq 0x9a310
movq %rax, 0x70(%rsp)
jmp 0x96922
movq 0xa8(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
addq $0x8, %rax
movq %rax, 0x60(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x86a00
movq %rax, 0x68(%rsp)
jmp 0x96954
movq 0x68(%rsp), %rdi
callq 0x9a330
movl %eax, 0x5c(%rsp)
jmp 0x96964
movl 0x5c(%rsp), %esi
movq 0x60(%rsp), %rdi
callq 0x9a260
movq %rax, 0x50(%rsp)
jmp 0x96979
movq 0xa8(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
addq $0x8, %rax
movq %rax, 0x40(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x86a10
movq %rax, 0x48(%rsp)
jmp 0x969ab
movq 0x48(%rsp), %rdi
callq 0x9a330
movl %eax, 0x3c(%rsp)
jmp 0x969bb
movl 0x3c(%rsp), %esi
movq 0x40(%rsp), %rdi
callq 0x9a260
movq %rax, 0x30(%rsp)
jmp 0x969d0
movq 0xa8(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x86a20
movq %rax, 0x28(%rsp)
jmp 0x96a02
movq 0x28(%rsp), %rdi
callq 0x9a330
movl %eax, 0x1c(%rsp)
jmp 0x96a12
movl 0x1c(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x9a260
movq %rax, 0x10(%rsp)
jmp 0x96a27
movq 0x10(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl $0x88, %edi
callq 0xf4c0
movq %rax, 0x8(%rsp)
jmp 0x96a45
movq 0x8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x9b320
jmp 0x96a69
movq 0xa8(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0xb8(%rsp)
addq $0x18, %rdi
movq 0xb8(%rsp), %rsi
callq 0x9a340
jmp 0x96a91
jmp 0x96a93
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x968d1
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
movl $0x88, %esi
callq 0xf4d0
jmp 0x96aec
movq 0xa8(%rsp), %rdi
movq (%rdi), %rax
movq 0x248(%rax), %rax
callq *%rax
jmp 0x96ae4
addq $0x118, %rsp            # imm = 0x118
retq
movq 0x98(%rsp), %rdi
callq 0x36a80
movq 0xa0(%rsp), %rdi
callq 0x9a240
movq 0xb0(%rsp), %rdi
callq 0x9a250
movq 0xa8(%rsp), %rdi
callq 0x9cc00
movq 0x100(%rsp), %rdi
callq 0xf890
nopl (%rax)