// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::UpdateFaceRefs(gaps::R3MeshFace*, gaps::R3MeshVertex*, gaps::R3MeshVertex*, gaps::R3MeshVertex*, gaps::R3MeshEdge*, gaps::R3MeshEdge*, gaps::R3MeshEdge*)
void R3Mesh::
UpdateFaceRefs(R3MeshFace *f,
               R3MeshVertex *v1, R3MeshVertex *v2, R3MeshVertex *v3,
               R3MeshEdge *e1, R3MeshEdge *e2, R3MeshEdge *e3)
{
  // Update face-vertex relations
  f->vertex[0] = v1;
  f->vertex[1] = v2;
  f->vertex[2] = v3;

  // Update face-edge relations
  f->edge[0] = e1;
  f->edge[1] = e2;
  f->edge[2] = e3;

  // Update edge-face relations
  if (e1->vertex[0] == v1) e1->face[0] = f;
  else { assert(e1->vertex[1] == v1); e1->face[1] = f; }
  if (e2->vertex[0] == v2) e2->face[0] = f;
  else { assert(e2->vertex[1] == v2); e2->face[1] = f; }
  if (e3->vertex[0] == v3) e3->face[0] = f;
  else { assert(e3->vertex[1] == v3); e3->face[1] = f; }

  // Invalidate face properties
  f->flags.Remove(R3_MESH_FACE_AREA_UPTODATE | R3_MESH_FACE_PLANE_UPTODATE | R3_MESH_FACE_BBOX_UPTODATE);

  // Invalidate vertex properties
  v1->flags.Remove(R3_MESH_VERTEX_NORMAL_UPTODATE);
  v2->flags.Remove(R3_MESH_VERTEX_NORMAL_UPTODATE);
  v3->flags.Remove(R3_MESH_VERTEX_NORMAL_UPTODATE);
}

// Assembly:
subq $0x78, %rsp
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rax
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x58(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x50(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x48(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x80(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x88(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x60(%rsp), %rax
jne 0x35cbc
movq 0x68(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x35cca
movq 0x68(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x58(%rsp), %rax
jne 0x35cf0
movq 0x68(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x35d01
movq 0x68(%rsp), %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x88(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0x50(%rsp), %rax
jne 0x35d27
movq 0x68(%rsp), %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x35d38
movq 0x68(%rsp), %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x68(%rsp), %rax
addq $0xa8, %rax
movq %rax, 0x8(%rsp)
leaq 0x40(%rsp), %rdi
movl $0xe, %esi
callq 0x13d80
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x372b0
movq 0x60(%rsp), %rax
addq $0x78, %rax
movq %rax, 0x10(%rsp)
leaq 0x38(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x372b0
movq 0x58(%rsp), %rax
addq $0x78, %rax
movq %rax, 0x18(%rsp)
leaq 0x30(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x372b0
movq 0x50(%rsp), %rax
addq $0x78, %rax
movq %rax, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
movl $0x2, %esi
callq 0x13d80
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x372b0
addq $0x78, %rsp
retq
nop