// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rdi, %rbp
leaq 0xcfdc1(%rip), %rax     # 0xe1400
movq %rax, (%rdi)
leaq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq 0x705ec
leaq 0x18(%rbp), %r14
movq %r14, %rdi
callq 0x705ec
leaq 0x28(%rbp), %r15
movq %r15, %rdi
callq 0x705ec
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movl $0xf8, %esi
leaq (%rsi,%rbp), %rdi
addq %r13, %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rbp)
movups %xmm0, 0x58(%rbp)
movups %xmm0, 0x48(%rbp)
movups %xmm0, 0x38(%rbp)
movq %rdi, 0x20(%rsp)
callq 0x274f0
movq $0x0, 0x130(%rbp)
movslq 0x14(%r13), %r15
movl $0x98, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rdi
seto %al
addq $0x8, %rdi
movq $-0x1, %rcx
cmovbq %rcx, %rdi
testb %al, %al
cmovneq %rcx, %rdi
movq %rdi, 0x30(%rsp)
callq 0xe030
movq %rax, %r14
movq %r15, (%rax)
addq $0x8, %rax
movq %rax, 0x28(%rsp)
testl %r15d, %r15d
je 0x1171b
imulq $-0x98, %r15, %rbx
xorl %r12d, %r12d
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x23c38
addq $-0x98, %r12
addq $0x98, %r15
cmpq %r12, %rbx
jne 0x11700
leaq 0x38(%rbp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, (%rax)
cmpl $0x0, 0x14(%r13)
jle 0x117a3
leaq 0x90baf(%rip), %rbx     # 0xa22e4
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%r13), %rax
movq (%rax,%r12,8), %r14
testb $0x2, 0x78(%r14)
jne 0x1175a
movq (%r13), %rax
movq %r13, %rdi
movq %r14, %rsi
callq *0x2b0(%rax)
leaq 0x18(%r14), %rsi
leaq 0x30(%r14), %rdx
leaq 0x58(%r14), %rcx
addq $0x48, %r14
movq 0x38(%rbp), %r9
addq %r15, %r9
movq (%rbp), %rax
movq %rbp, %rdi
movq %r14, %r8
callq *0x38(%rax)
movl 0x70(%rax), %eax
cmpq %rax, %r12
je 0x11790
movq %rbx, %rdi
xorl %eax, %eax
callq 0x72942
incq %r12
movslq 0x14(%r13), %rax
addq $0x98, %r15
cmpq %rax, %r12
jl 0x1173b
movslq 0x24(%r13), %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 0x11822
imulq $0x58, %rbx, %rcx
xorl %edx, %edx
leaq 0xcff39(%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 0x117ec
movq %rax, 0x40(%rbp)
cmpl $0x0, 0x24(%r13)
jle 0x11892
leaq 0x90ac6(%rip), %rbx     # 0xa22fa
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x18(%r13), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq 0x70(%rcx), %rcx
movslq 0x70(%rax), %rax
movq (%rbp), %r8
movq 0x8(%rbp), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rdx,%rax,8), %rdx
movq 0x40(%rbp), %rcx
addq %r14, %rcx
movq %rbp, %rdi
callq *0x40(%r8)
movl 0x30(%rax), %eax
cmpq %rax, %r15
je 0x11882
movq %rbx, %rdi
xorl %eax, %eax
callq 0x72942
incq %r15
movslq 0x24(%r13), %rax
addq $0x58, %r14
cmpq %rax, %r15
jl 0x1183a
movslq 0x34(%r13), %r15
movl $0xc8, %ecx
movq %r15, %rax
mulq %rcx
movq %rax, %rdi
seto %al
addq $0x8, %rdi
movq $-0x1, %rcx
cmovbq %rcx, %rdi
testb %al, %al
cmovneq %rcx, %rdi
movq %rdi, 0x30(%rsp)
callq 0xe030
movq %rax, %r14
movq %r15, (%rax)
addq $0x8, %rax
movq %rax, 0x28(%rsp)
testl %r15d, %r15d
je 0x11904
imulq $-0xc8, %r15, %rbx
xorl %r12d, %r12d
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x23d50
addq $-0xc8, %r12
addq $0xc8, %r15
cmpq %r12, %rbx
jne 0x118e9
movq 0x28(%rsp), %rax
movq %rax, 0x48(%rbp)
cmpl $0x0, 0x34(%r13)
jle 0x119ae
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x28(%r13), %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 (%rbp), %r9
movq 0x8(%rbp), %r8
movq (%r8,%rax,8), %rsi
movq (%r8,%rcx,8), %rdx
movq (%r8,%rdi,8), %rcx
movq 0x48(%rbp), %r8
addq %r15, %r8
movq %rbp, %rdi
callq *0x48(%r9)
movq %rax, %r14
movl 0xa4(%rax), %eax
cmpq %rax, %r12
je 0x1197c
leaq 0x90999(%rip), %rdi     # 0xa230e
xorl %eax, %eax
callq 0x72942
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r14)
movl 0xa0(%rbx), %eax
movl %eax, 0xa0(%r14)
incq %r12
movslq 0x34(%r13), %rax
addq $0xc8, %r15
cmpq %rax, %r12
jl 0x1191e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
jmp 0x11a85
movq %rax, %r13
jmp 0x11a8d
movq %rax, %r13
jmp 0x11a95
jmp 0x11a69
jmp 0x11a69
movq %rax, %r13
testq %r12, %r12
je 0x11a56
negq %r12
movq %r14, %rbx
addq $-0x68, %rbx
leaq 0xcfd3c(%rip), %r15     # 0xe1740
movq %r15, -0xc0(%r14,%r12)
leaq (%rbx,%r12), %rdi
callq 0x28348
addq $-0xc8, %r12
jne 0x11a04
jmp 0x11a56
movq %rax, %r13
testq %r12, %r12
je 0x11a56
negq %r12
movq %r14, %rbx
addq $-0x88, %rbx
leaq 0xcfcc4(%rip), %r15     # 0xe1700
movq %r15, -0x90(%r14,%r12)
leaq (%rbx,%r12), %rdi
callq 0x70656
addq $-0x98, %r12
jne 0x11a3c
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0xe8c0
jmp 0x11a6c
jmp 0x11a69
jmp 0x11a69
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %rdi
callq 0x28348
movq %r15, %rdi
callq 0x70656
movq %r14, %rdi
callq 0x70656
movq %rbx, %rdi
callq 0x70656
movq %r13, %rdi
callq 0xe7e0
nop