// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::CreateIcosahedron(gaps::R3Sphere const&)
void R3Mesh::
CreateIcosahedron(const R3Sphere& sphere)
{
  // Create mesh elements for a sphere and add to mesh
  int saved_nvertices = NVertices();
  R3Point c = sphere.Centroid();
  RNLength r = sphere.Radius();
  
  // Create mesh elements for a icosahedron and add to mesh
  R3MeshVertex *v0 = CreateVertex(R3Point(0, -0.5257311, 0.8506508));
  R3MeshVertex *v1 = CreateVertex(R3Point(0, 0.5257311, 0.8506508));
  R3MeshVertex *v2 = CreateVertex(R3Point(0, -0.5257311, -0.8506508));
  R3MeshVertex *v3 = CreateVertex(R3Point(0, 0.5257311, -0.8506508));
  R3MeshVertex *v4 = CreateVertex(R3Point(0.8506508, 0, 0.5257311));
  R3MeshVertex *v5 = CreateVertex(R3Point(0.8506508, 0, -0.5257311));
  R3MeshVertex *v6 = CreateVertex(R3Point(-0.8506508, 0, 0.5257311));
  R3MeshVertex *v7 = CreateVertex(R3Point(-0.8506508, 0, -0.5257311));
  R3MeshVertex *v8 = CreateVertex(R3Point(0.5257311, 0.8506508, 0));
  R3MeshVertex *v9 = CreateVertex(R3Point(0.5257311, -0.8506508, 0));
  R3MeshVertex *v10 = CreateVertex(R3Point(-0.5257311, 0.8506508, 0));
  R3MeshVertex *v11 = CreateVertex(R3Point(-0.5257311, -0.8506508, 0));
  CreateFace(v0, v4, v1);
  CreateFace(v0, v9, v4);
  CreateFace(v9, v5, v4);
  CreateFace(v4, v5, v8);
  CreateFace(v4, v8, v1);
  CreateFace(v8, v10, v1);
  CreateFace(v8, v3, v10);
  CreateFace(v5, v3, v8);
  CreateFace(v5, v2, v3);
  CreateFace(v2, v7, v3);
  CreateFace(v7, v10, v3);
  CreateFace(v7, v6, v10);
  CreateFace(v7, v11, v6);
  CreateFace(v11, v0, v6);
  CreateFace(v0, v1, v6);
  CreateFace(v6, v1, v10);
  CreateFace(v9, v0, v11);
  CreateFace(v9, v11, v2);
  CreateFace(v9, v2, v5);
  CreateFace(v7, v2, v11);

  // Map vertices to sphere
  for (int i = saved_nvertices; i < NVertices(); i++) {
    R3MeshVertex *v = Vertex(i);
    R3Point p = VertexPosition(v);
    RNLength d = p.Vector().Length();
    if (RNIsPositive(d)) p = c+(r/d)*p;
    SetVertexPosition(v, p);
  }
}

// Assembly:
subq $0x248, %rsp            # imm = 0x248
movq %rdi, 0x240(%rsp)
movq %rsi, 0x238(%rsp)
movq 0x240(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x135e0
movl %eax, 0x234(%rsp)
movq 0x238(%rsp), %rsi
movq (%rsi), %rax
leaq 0x218(%rsp), %rdi
callq *0x68(%rax)
movq 0x238(%rsp), %rdi
callq 0x39f50
movsd %xmm0, 0x210(%rsp)
leaq 0x1f0(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x109219(%rip), %xmm1   # 0x133238
movsd 0x109221(%rip), %xmm2   # 0x133248
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x1f0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x208(%rsp)
leaq 0x1d0(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x1091f2(%rip), %xmm1   # 0x133250
movsd 0x1091e2(%rip), %xmm2   # 0x133248
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x1d0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x1e8(%rsp)
leaq 0x1b0(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x10919b(%rip), %xmm1   # 0x133238
movsd 0x10919b(%rip), %xmm2   # 0x133240
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x1b0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x1c8(%rsp)
leaq 0x190(%rsp), %rdi
xorps %xmm0, %xmm0
movsd 0x109174(%rip), %xmm1   # 0x133250
movsd 0x10915c(%rip), %xmm2   # 0x133240
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x190(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x1a8(%rsp)
leaq 0x170(%rsp), %rdi
movsd 0x109130(%rip), %xmm0   # 0x133248
xorps %xmm1, %xmm1
movsd 0x10912d(%rip), %xmm2   # 0x133250
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x170(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x188(%rsp)
leaq 0x150(%rsp), %rdi
movsd 0x1090f1(%rip), %xmm0   # 0x133248
xorps %xmm1, %xmm1
movsd 0x1090d6(%rip), %xmm2   # 0x133238
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x150(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x168(%rsp)
leaq 0x130(%rsp), %rdi
movsd 0x1090aa(%rip), %xmm0   # 0x133240
xorps %xmm1, %xmm1
movsd 0x1090af(%rip), %xmm2   # 0x133250
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x130(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x148(%rsp)
leaq 0x110(%rsp), %rdi
movsd 0x10906b(%rip), %xmm0   # 0x133240
xorps %xmm1, %xmm1
movsd 0x109058(%rip), %xmm2   # 0x133238
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x110(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x128(%rsp)
leaq 0xf0(%rsp), %rdi
movsd 0x10903c(%rip), %xmm0   # 0x133250
movsd 0x10902c(%rip), %xmm1   # 0x133248
xorps %xmm2, %xmm2
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0xf0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0x108(%rsp)
leaq 0xd0(%rsp), %rdi
movsd 0x108ffd(%rip), %xmm0   # 0x133250
movsd 0x108fe5(%rip), %xmm1   # 0x133240
xorps %xmm2, %xmm2
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0xd0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0xe8(%rsp)
leaq 0xb0(%rsp), %rdi
movsd 0x108fa6(%rip), %xmm0   # 0x133238
movsd 0x108fae(%rip), %xmm1   # 0x133248
xorps %xmm2, %xmm2
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0xb0(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq %rax, 0xc8(%rsp)
leaq 0x90(%rsp), %rdi
movsd 0x108f67(%rip), %xmm0   # 0x133238
movsd 0x108f67(%rip), %xmm1   # 0x133240
xorps %xmm2, %xmm2
callq 0x6eb50
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x90(%rsp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x20(%rax)
movq 0x10(%rsp), %rdi
movq %rax, 0xa8(%rsp)
movq 0x208(%rsp), %rsi
movq 0x188(%rsp), %rdx
movq 0x1e8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x208(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq 0x188(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x168(%rsp), %rdx
movq 0x188(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x188(%rsp), %rsi
movq 0x168(%rsp), %rdx
movq 0x108(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x188(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq 0x1e8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0x1e8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x1a8(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x168(%rsp), %rsi
movq 0x1a8(%rsp), %rdx
movq 0x108(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x168(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
movq 0x1a8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x1c8(%rsp), %rsi
movq 0x128(%rsp), %rdx
movq 0x1a8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x128(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0x1a8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x128(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x128(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0x148(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x208(%rsp), %rdx
movq 0x148(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x208(%rsp), %rsi
movq 0x1e8(%rsp), %rdx
movq 0x148(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq 0x1e8(%rsp), %rdx
movq 0xc8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x208(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0x1c8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
movq 0x168(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movq 0x10(%rsp), %rdi
movq 0x128(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movq (%rdi), %rax
xorl %r8d, %r8d
callq *0x48(%rax)
movl 0x234(%rsp), %eax
movl %eax, 0x8c(%rsp)
movq 0x10(%rsp), %rdi
movl 0x8c(%rsp), %eax
movl %eax, 0xc(%rsp)
callq 0x135e0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x2a70c
movq 0x10(%rsp), %rdi
movl 0x8c(%rsp), %esi
callq 0x13630
movq 0x10(%rsp), %rdi
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rsi
callq 0x13660
movq %rax, %rsi
leaq 0x68(%rsp), %rdi
callq 0x6eb90
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x36d10
leaq 0x48(%rsp), %rdi
callq 0x6fe90
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
leaq 0x14de53(%rip), %rax    # 0x1784e0
movsd (%rax), %xmm1
callq 0x36d50
cmpl $0x0, %eax
je 0x2a6df
movsd 0x210(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
leaq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x36b10
leaq 0x30(%rsp), %rdi
leaq 0x218(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x6fa40
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6f1e0
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x18060
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x2a606
addq $0x248, %rsp            # imm = 0x248
retq
nopw %cs:(%rax,%rax)