// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::operator=(gaps::R3Mesh const&)
R3Mesh& R3Mesh::
operator=(const R3Mesh& mesh)
{
  // Delete everything
  Empty();
  
  // Copy bbox
  bbox = mesh.bbox;

  // Copy vertices 
  vertex_block = new R3MeshVertex [ mesh.NVertices() ];
  for (int i = 0; i < mesh.NVertices(); i++) {
    R3MeshVertex *vertex = mesh.Vertex(i);
    const R3Point& position = mesh.VertexPosition(vertex);
    const R3Vector& normal = mesh.VertexNormal(vertex);
    const RNRgb& color = mesh.VertexColor(vertex);
    const R2Point& texcoords = mesh.VertexTextureCoords(vertex);
    R3MeshVertex *copy_vertex = this->CreateVertex(position, normal, color, texcoords, &vertex_block[i] );
    if (this->VertexID(copy_vertex) != i) RNAbort("Mismatching vertex id"); 
  }

  // Copy edges
  edge_block = new R3MeshEdge [ mesh.NEdges() ];
  for (int i = 0; i < mesh.NEdges(); i++) {
    R3MeshEdge *edge = mesh.Edge(i);
    R3MeshVertex *v0 = mesh.VertexOnEdge(edge, 0);
    R3MeshVertex *v1 = mesh.VertexOnEdge(edge, 1);
    int i0 = mesh.VertexID(v0);
    int i1 = mesh.VertexID(v1);
    R3MeshVertex *copy_v0 = this->Vertex(i0);
    R3MeshVertex *copy_v1 = this->Vertex(i1);
    R3MeshEdge *copy_edge = this->CreateEdge(copy_v0, copy_v1, &edge_block[i] );
    if (this->EdgeID(copy_edge) != i) RNAbort("Mismatching edge id"); 
  }

  // Copy faces
  face_block = new R3MeshFace [ mesh.NFaces() ];
  for (int i = 0; i < mesh.NFaces(); i++) {
    R3MeshFace *face = mesh.Face(i);
    R3MeshVertex *v0 = mesh.VertexOnFace(face, 0);
    R3MeshVertex *v1 = mesh.VertexOnFace(face, 1);
    R3MeshVertex *v2 = mesh.VertexOnFace(face, 2);
    int i0 = mesh.VertexID(v0);
    int i1 = mesh.VertexID(v1);
    int i2 = mesh.VertexID(v2);
    R3MeshVertex *copy_v0 = this->Vertex(i0);
    R3MeshVertex *copy_v1 = this->Vertex(i1);
    R3MeshVertex *copy_v2 = this->Vertex(i2);
    R3MeshFace *copy_face = this->CreateFace(copy_v0, copy_v1, copy_v2, &face_block[i]);
    if (this->FaceID(copy_face) != i) RNAbort("Mismatching face id"); 
    this->SetFaceMaterial(copy_face, mesh.FaceMaterial(face));
    this->SetFaceSegment(copy_face, mesh.FaceSegment(face));
    this->SetFaceCategory(copy_face, mesh.FaceCategory(face));
  }

  // Invalidate GL buffer objects
  InvalidateGLBufferObjects();

  // 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, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
movl $0x100, %esi            # imm = 0x100
leaq (%rbx,%rsi), %rdi
addq %r14, %rsi
callq 0x3c89a
movl $0x118, %esi            # imm = 0x118
leaq (%rbx,%rsi), %rdi
addq %r14, %rsi
callq 0x3c89a
movslq 0x14(%r14), %r13
movl $0x98, %ecx
movq %r13, %rax
mulq %rcx
movq %rax, %r15
seto %al
addq $0x8, %r15
movq $-0x1, %rcx
cmovbq %rcx, %r15
testb %al, %al
cmovneq %rcx, %r15
movq %r15, %rdi
callq 0xe030
movq %rax, %r12
addq $0x8, %rax
movq %r13, (%r12)
testq %r13, %r13
je 0x18691
movq %r15, 0x8(%rsp)
imulq $-0x98, %r13, %r15
movq %rax, %r13
xorl %ebp, %ebp
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x239aa
addq $-0x98, %rbp
addq $0x98, %r13
cmpq %rbp, %r15
jne 0x185ee
cmpl $0x0, 0x14(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rbx)
jle 0x18695
leaq 0x89cc4(%rip), %r15     # 0xa22e4
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %r12
testb $0x2, 0x78(%r12)
jne 0x18644
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
callq *0x2b0(%rax)
leaq 0x18(%r12), %rsi
leaq 0x30(%r12), %rdx
leaq 0x58(%r12), %rcx
addq $0x48, %r12
movq 0x38(%rbx), %r9
addq %r13, %r9
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %r8
callq *0x38(%rax)
movl 0x70(%rax), %eax
cmpq %rax, %rbp
je 0x1867c
movq %r15, %rdi
xorl %eax, %eax
callq 0x718f6
incq %rbp
movslq 0x14(%r14), %rax
addq $0x98, %r13
cmpq %rax, %rbp
jl 0x18625
jmp 0x18695
movq %rax, 0x38(%rbx)
movslq 0x24(%r14), %r15
movl $0x58, %ecx
movq %r15, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
movq $-0x1, %rdi
cmovbq %rdi, %rax
testb %cl, %cl
cmoveq %rax, %rdi
callq 0xe030
leaq 0x8(%rax), %rcx
movq %r15, (%rax)
testq %r15, %r15
je 0x18788
imulq $0x58, %r15, %rax
xorl %edx, %edx
leaq 0xc9042(%rip), %rsi     # 0xe1720
xorps %xmm0, %xmm0
xorl %edi, %edi
movq %rsi, (%rcx,%rdi)
movq %rdx, 0x28(%rcx,%rdi)
movl $0xffffffff, 0x30(%rcx,%rdi) # imm = 0xFFFFFFFF
movq %rdx, 0x50(%rcx,%rdi)
movups %xmm0, 0x8(%rcx,%rdi)
movups %xmm0, 0x18(%rcx,%rdi)
movups %xmm0, 0x38(%rcx,%rdi)
movl $0x0, 0x48(%rcx,%rdi)
addq $0x58, %rdi
cmpq %rdi, %rax
jne 0x186e3
movq %rcx, 0x40(%rbx)
testl %r15d, %r15d
jle 0x1878c
leaq 0x89bd1(%rip), %r15     # 0xa22fa
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rax), %rax
movq (%rbx), %r8
movq 0x8(%rbx), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rdx,%rax,8), %rdx
movq 0x40(%rbx), %rcx
addq %r12, %rcx
movq %rbx, %rdi
callq *0x40(%r8)
movl 0x30(%rax), %eax
cmpq %rax, %r13
je 0x18776
movq %r15, %rdi
xorl %eax, %eax
callq 0x718f6
incq %r13
movslq 0x24(%r14), %rax
addq $0x58, %r12
cmpq %rax, %r13
jl 0x1872f
jmp 0x1878c
movq %rcx, 0x40(%rbx)
movslq 0x34(%r14), %r13
movl $0xc8, %ecx
movq %r13, %rax
mulq %rcx
movq %rax, %r15
seto %al
addq $0x8, %r15
movq $-0x1, %rcx
cmovbq %rcx, %r15
testb %al, %al
cmovneq %rcx, %r15
movq %r15, %rdi
callq 0xe030
movq %rax, %r12
addq $0x8, %rax
movq %r13, (%r12)
testq %r13, %r13
je 0x188b0
movq %r15, 0x8(%rsp)
imulq $-0xc8, %r13, %r15
movq %rax, %r13
xorl %ebp, %ebp
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x23ac2
addq $-0xc8, %rbp
addq $0xc8, %r13
cmpq %rbp, %r15
jne 0x187e8
cmpl $0x0, 0x34(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rbx)
jle 0x188b4
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x28(%r14), %rax
movq (%rax,%rbp,8), %r15
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq 0x18(%r15), %rdx
movslq 0x70(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rdx), %rdi
movq (%rbx), %r9
movq 0x8(%rbx), %r8
movq (%r8,%rax,8), %rsi
movq (%r8,%rcx,8), %rdx
movq (%r8,%rdi,8), %rcx
movq 0x48(%rbx), %r8
addq %r13, %r8
movq %rbx, %rdi
callq *0x48(%r9)
movq %rax, %r12
movl 0xa4(%rax), %eax
cmpq %rax, %rbp
je 0x18879
leaq 0x89a9c(%rip), %rdi     # 0xa230e
xorl %eax, %eax
callq 0x718f6
movq 0x98(%r15), %rax
movq %rax, 0x98(%r12)
movl 0xa0(%r15), %eax
movl %eax, 0xa0(%r12)
incq %rbp
movslq 0x34(%r14), %rax
addq $0xc8, %r13
cmpq %rax, %rbp
jl 0x1881c
jmp 0x188b4
movq %rax, 0x48(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x290(%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0x1893d
negq %rbp
movq %r12, %r14
addq $-0x68, %r14
leaq 0xc8e55(%rip), %r15     # 0xe1740
movq %r15, -0xc0(%r12,%rbp)
leaq (%r14,%rbp), %rdi
callq 0x280f4
addq $-0xc8, %rbp
jne 0x188eb
jmp 0x1893d
movq %rax, %rbx
testq %rbp, %rbp
je 0x1893d
negq %rbp
movq %r12, %r14
addq $-0x88, %r14
leaq 0xc8ddd(%rip), %r15     # 0xe1700
movq %r15, -0x90(%r12,%rbp)
leaq (%r14,%rbp), %rdi
callq 0x6f876
addq $-0x98, %rbp
jne 0x18923
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0xe8c0
movq %rbx, %rdi
callq 0xe7e0