// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::EdgeSwapAngleImprovement(gaps::R3MeshEdge const*) const
R3MeshFace *R3Mesh::
CreateFace(R3MeshVertex *v1, R3MeshVertex *v2, R3MeshVertex *v3,
           R3MeshEdge *e1, R3MeshEdge *e2, R3MeshEdge *e3, R3MeshFace *f)
{
  // Check if two faces share same side of same edge
  if ((e1->vertex[0] == v1) && e1->face[0]) return NULL;
  if ((e1->vertex[0] == v2) && e1->face[1]) return NULL;
  if ((e2->vertex[0] == v2) && e2->face[0]) return NULL;
  if ((e2->vertex[0] == v3) && e2->face[1]) return NULL;
  if ((e3->vertex[0] == v3) && e3->face[0]) return NULL;
  if ((e3->vertex[0] == v1) && e3->face[1]) return NULL;

  // Invalidate GL buffer objects
  InvalidateGLBufferObjects();

  // Create face
  if (!f) {
    f = new R3MeshFace();
    f->flags.Add(R3_MESH_FACE_ALLOCATED);
  }

  // Update face pointers
  UpdateFaceRefs(f, v1, v2, v3, e1, e2, e3);

  // Set face ID
  f->id = faces.NEntries();

  // Insert face into array
  faces.Insert(f);

  // Return face
  return f;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq 0x18(%rsi), %rbx
movq 0x20(%rsi), %r13
testq %rbx, %rbx
setne %al
testq %r13, %r13
setne %cl
testb %cl, %al
je 0x164a3
movq %rsi, %r12
movq %rdi, %rbp
movq 0x8(%rsi), %r15
movq 0x10(%rsi), %rax
movq %rax, (%rsp)
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2136e
movq %rax, %r14
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2136e
movq %rax, %r12
movq %r14, %rsi
movq %rax, %rdx
callq 0x12d5a
testq %rax, %rax
jne 0x164a3
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x10dd0
leaq 0xe8(%rsp), %rdi
movq %rax, %rsi
callq 0x3831c
movq %rbp, %rdi
movq %r13, %rsi
callq 0x10dd0
leaq 0xd0(%rsp), %rdi
movq %rax, %rsi
callq 0x3831c
addq $0x18, %r15
movq (%rsp), %rbp
addq $0x18, %rbp
addq $0x18, %r14
addq $0x18, %r12
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x37d29
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
movq %r15, (%rsp)
movq %r15, %rdx
callq 0x37d29
leaq 0x130(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x37d29
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x37d29
leaq 0x100(%rsp), %r13
movq %r13, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x389be
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x389be
movq %r13, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x38586
leaq 0xc4926(%rip), %rbx     # 0xdaba8
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x164a3
leaq 0x100(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x38586
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x164a3
leaq 0xa0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x38586
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x164a3
leaq 0xa0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x38586
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x164a3
leaq 0x160(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq (%rsp), %rdx
callq 0x37d29
leaq 0x148(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x37d29
leaq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x4555f
movapd %xmm0, (%rsp)
leaq 0xb8(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x4555f
movapd %xmm0, 0x90(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x38c72
leaq 0x130(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4555f
movapd %xmm0, 0x80(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x38c72
leaq 0x118(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4555f
movapd %xmm0, 0x70(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x38c72
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4555f
movapd %xmm0, 0x60(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x4555f
movapd %xmm0, 0x50(%rsp)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x38c72
movq %r14, %rdi
movq %r12, %rsi
callq 0x4555f
movapd %xmm0, 0x40(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x4555f
movapd %xmm0, %xmm1
movapd 0x50(%rsp), %xmm2
unpcklpd 0x90(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
movapd 0x60(%rsp), %xmm0
unpcklpd (%rsp), %xmm0           # xmm0 = xmm0[0],mem[0]
minpd %xmm0, %xmm2
movapd 0x40(%rsp), %xmm0
unpcklpd 0x80(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
minpd %xmm2, %xmm0
unpcklpd 0x70(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
minpd %xmm0, %xmm1
movsd (%rbx), %xmm2
movapd 0x7cbdc(%rip), %xmm3    # 0x93030
movapd %xmm2, %xmm0
xorpd %xmm3, %xmm0
leaq 0xc4755(%rip), %rax     # 0xdabb8
movsd (%rax), %xmm4
xorpd %xmm3, %xmm4
movapd %xmm1, %xmm3
unpckhpd %xmm1, %xmm3            # xmm3 = xmm3[1],xmm1[1]
movapd %xmm1, %xmm5
subsd %xmm3, %xmm5
cmpnlesd %xmm1, %xmm0
movapd %xmm0, %xmm3
andpd %xmm5, %xmm3
cmpnlesd %xmm2, %xmm1
andpd %xmm1, %xmm5
andnpd %xmm4, %xmm1
orpd %xmm5, %xmm1
andnpd %xmm1, %xmm0
orpd %xmm3, %xmm0
jmp 0x164b6
leaq 0xc470e(%rip), %rax     # 0xdabb8
movsd (%rax), %xmm0
xorpd 0x7cb7a(%rip), %xmm0    # 0x93030
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq