// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::R3Mesh(gaps::R3Mesh const&)
R3Mesh::
R3Mesh(const R3Mesh& mesh)
  : vertex_block(NULL),
    edge_block(NULL),
    face_block(NULL),
    vbo_face_position_buffer(0),
    vbo_face_normal_buffer(0),
    vbo_face_texcoord_buffer(0),
    vbo_face_rgb_color_buffer(0),
    vbo_face_pick_color_buffer(0),
    vbo_vertex_position_buffer(0),
    vbo_vertex_normal_buffer(0),
    vbo_vertex_texcoord_buffer(0),
    vbo_vertex_rgb_color_buffer(0),
    vbo_vertex_pick_color_buffer(0),
    bbox(mesh.bbox),
    data(NULL)
{
  // 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));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbp
movq %rdi, %r13
leaq 0xcfe11(%rip), %rax     # 0xe1400
movq %rax, (%rdi)
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x6f80c
leaq 0x18(%r13), %r14
movq %r14, %rdi
movq %rbx, 0x30(%rsp)
callq 0x6f80c
leaq 0x28(%r13), %r15
movq %r15, %rdi
movq %r14, 0x28(%rsp)
callq 0x6f80c
movq %r15, 0x20(%rsp)
movl $0xf8, %esi
leaq (%rsi,%r13), %rdi
addq %rbp, %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%r13)
movups %xmm0, 0x58(%r13)
movups %xmm0, 0x48(%r13)
movups %xmm0, 0x38(%r13)
movq %rdi, 0x18(%rsp)
callq 0x272d4
movq $0x0, 0x130(%r13)
movslq 0x14(%rbp), %r15
movl $0x98, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rbx
seto %al
addq $0x8, %rbx
movq $-0x1, %rcx
cmovbq %rcx, %rbx
testb %al, %al
cmovneq %rcx, %rbx
movq %rbx, %rdi
callq 0xe030
movq %rax, %r14
leaq 0x38(%r13), %rax
movq %r15, (%r14)
leaq 0x8(%r14), %rcx
testl %r15d, %r15d
je 0x11765
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
imulq $-0x98, %r15, %rbx
movq %rcx, %r15
xorl %r12d, %r12d
movq %rcx, (%rsp)
movq %r15, %rdi
callq 0x239aa
addq $-0x98, %r12
addq $0x98, %r15
cmpq %r12, %rbx
jne 0x116c1
cmpl $0x0, 0x14(%rbp)
movq 0x8(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, (%rax)
jle 0x11768
leaq 0x90bef(%rip), %rbx     # 0xa22e4
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rbp), %rax
movq (%rax,%r12,8), %r14
testb $0x2, 0x78(%r14)
jne 0x1171a
movq (%rbp), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x2b0(%rax)
leaq 0x18(%r14), %rsi
leaq 0x30(%r14), %rdx
leaq 0x58(%r14), %rcx
addq $0x48, %r14
movq 0x38(%r13), %r9
addq %r15, %r9
movq (%r13), %rax
movq %r13, %rdi
movq %r14, %r8
callq *0x38(%rax)
movl 0x70(%rax), %eax
cmpq %rax, %r12
je 0x11750
movq %rbx, %rdi
xorl %eax, %eax
callq 0x718f6
incq %r12
movslq 0x14(%rbp), %rax
addq $0x98, %r15
cmpq %rax, %r12
jl 0x116fb
jmp 0x11768
movq %rcx, (%rax)
movslq 0x24(%rbp), %rbx
movl $0x58, %ecx
movq %rbx, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
movq $-0x1, %rdi
cmovbq %rdi, %rax
testb %cl, %cl
cmoveq %rax, %rdi
callq 0xe030
movq %rbx, (%rax)
addq $0x8, %rax
testl %ebx, %ebx
je 0x1185a
imulq $0x58, %rbx, %rcx
xorl %edx, %edx
leaq 0xcff70(%rip), %rsi     # 0xe1720
xorps %xmm0, %xmm0
xorl %edi, %edi
movq %rsi, (%rax,%rdi)
movq %rdx, 0x28(%rax,%rdi)
movl $0xffffffff, 0x30(%rax,%rdi) # imm = 0xFFFFFFFF
movq %rdx, 0x50(%rax,%rdi)
movups %xmm0, 0x8(%rax,%rdi)
movups %xmm0, 0x18(%rax,%rdi)
movups %xmm0, 0x38(%rax,%rdi)
movl $0x0, 0x48(%rax,%rdi)
addq $0x58, %rdi
cmpq %rdi, %rcx
jne 0x117b5
movq %rax, 0x40(%r13)
testl %ebx, %ebx
jle 0x1185e
leaq 0x90b00(%rip), %rbx     # 0xa22fa
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x18(%rbp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rax), %rax
movq (%r13), %r8
movq 0x8(%r13), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rdx,%rax,8), %rdx
movq 0x40(%r13), %rcx
addq %r14, %rcx
movq %r13, %rdi
callq *0x40(%r8)
movl 0x30(%rax), %eax
cmpq %rax, %r15
je 0x11848
movq %rbx, %rdi
xorl %eax, %eax
callq 0x718f6
incq %r15
movslq 0x24(%rbp), %rax
addq $0x58, %r14
cmpq %rax, %r15
jl 0x11800
jmp 0x1185e
movq %rax, 0x40(%r13)
movslq 0x34(%rbp), %r15
movl $0xc8, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rbx
seto %al
addq $0x8, %rbx
movq $-0x1, %rcx
cmovbq %rcx, %rbx
testb %al, %al
cmovneq %rcx, %rbx
movq %rbx, %rdi
callq 0xe030
movq %rax, %r14
movq %r15, (%rax)
addq $0x8, %rax
testl %r15d, %r15d
je 0x1197f
movq %rbx, (%rsp)
imulq $-0xc8, %r15, %rbx
movq %rax, %r15
xorl %r12d, %r12d
movq %rax, 0x8(%rsp)
movq %r15, %rdi
callq 0x23ac2
addq $-0xc8, %r12
addq $0xc8, %r15
cmpq %r12, %rbx
jne 0x118b9
cmpl $0x0, 0x34(%rbp)
movq 0x8(%rsp), %rax
movq %rax, 0x48(%r13)
jle 0x11983
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x28(%rbp), %rax
movq (%rax,%r12,8), %rbx
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rdx
movslq 0x70(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rdx), %rdi
movq (%r13), %r9
movq 0x8(%r13), %r8
movq (%r8,%rax,8), %rsi
movq (%r8,%rcx,8), %rdx
movq (%r8,%rdi,8), %rcx
movq 0x48(%r13), %r8
addq %r15, %r8
movq %r13, %rdi
callq *0x48(%r9)
movq %rax, %r14
movl 0xa4(%rax), %eax
cmpq %rax, %r12
je 0x1194b
leaq 0x909ca(%rip), %rdi     # 0xa230e
xorl %eax, %eax
callq 0x718f6
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r14)
movl 0xa0(%rbx), %eax
movl %eax, 0xa0(%r14)
incq %r12
movslq 0x34(%rbp), %rax
addq $0xc8, %r15
cmpq %rax, %r12
jl 0x118ed
jmp 0x11983
movq %rax, 0x48(%r13)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
jmp 0x11a40
movq %rax, %r13
jmp 0x11a4a
movq %rax, %r13
jmp 0x11a54
jmp 0x119b2
jmp 0x119b2
jmp 0x119b2
jmp 0x119b2
movq %rax, %r13
jmp 0x11a36
movq %rax, %r13
testq %r12, %r12
je 0x119ea
negq %r12
movq %r14, %rbx
addq $-0x68, %rbx
leaq 0xcfd70(%rip), %r15     # 0xe1740
movq %r15, -0xc0(%r14,%r12)
leaq (%rbx,%r12), %rdi
callq 0x280f4
addq $-0xc8, %r12
jne 0x119d0
movq %r14, %rdi
movq (%rsp), %rsi
jmp 0x11a31
movq %rax, %r13
testq %r12, %r12
je 0x11a29
negq %r12
movq %r14, %rbx
addq $-0x88, %rbx
leaq 0xcfcf1(%rip), %r15     # 0xe1700
movq %r15, -0x90(%r14,%r12)
leaq (%rbx,%r12), %rdi
callq 0x6f876
addq $-0x98, %r12
jne 0x11a0f
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0xe8c0
movq 0x18(%rsp), %rdi
callq 0x280f4
movq 0x20(%rsp), %rdi
callq 0x6f876
movq 0x28(%rsp), %rdi
callq 0x6f876
movq 0x30(%rsp), %rdi
callq 0x6f876
movq %r13, %rdi
callq 0xe7e0