// File: /workspace/github_cpp_makefile_star2_O1/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), %r12
movq 0x20(%rsi), %r13
testq %r12, %r12
setne %al
testq %r13, %r13
setne %cl
testb %cl, %al
je 0x17a06
movq 0x8(%rsi), %rbx
movq 0x8(%r12), %r14
cmpq %r14, %rbx
je 0x17627
cmpq %r14, 0x10(%rsi)
jne 0x1764c
movq 0x10(%r12), %r14
cmpq %r14, %rbx
je 0x17637
cmpq %r14, 0x10(%rsi)
jne 0x1764c
movq 0x18(%r12), %rax
xorl %r14d, %r14d
cmpq %rax, %rbx
je 0x1764c
cmpq %rax, 0x10(%rsi)
cmovneq %rax, %r14
movq 0x8(%r13), %r15
cmpq %r15, %rbx
je 0x1765b
cmpq %r15, 0x10(%rsi)
jne 0x1767e
movq 0x10(%r13), %r15
cmpq %r15, %rbx
je 0x1766a
cmpq %r15, 0x10(%rsi)
jne 0x1767e
movq 0x18(%r13), %rax
xorl %r15d, %r15d
cmpq %rax, %rbx
je 0x1767e
cmpq %rax, 0x10(%rsi)
cmovneq %rax, %r15
movq 0x10(%rsi), %r9
cmpq %r15, %r14
je 0x176c9
movslq 0x14(%r14), %rax
testq %rax, %rax
jle 0x176c9
movq 0x8(%r14), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %r10
cmpq %r15, 0x8(%r10)
je 0x176aa
cmpq %r15, 0x10(%r10)
setne %r8b
jmp 0x176ad
xorl %r8d, %r8d
testb %r8b, %r8b
cmoveq %r10, %rcx
je 0x176c0
incq %rsi
cmpq %rsi, %rax
jne 0x17696
xorl %ecx, %ecx
testq %rcx, %rcx
jne 0x17a06
movq %rdi, %rbp
movq %r9, (%rsp)
testb $0x4, 0xa8(%r12)
jne 0x176eb
movq %rbp, %rdi
movq (%rbp), %rax
movq %r12, %rsi
callq *0x2c8(%rax)
addq $0x38, %r12
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x3d4ce
testb $0x4, 0xa8(%r13)
jne 0x17719
movq (%rbp), %rax
movq %rbp, %rdi
movq %r13, %rsi
callq *0x2c8(%rax)
addq $0x38, %r13
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
callq 0x3d4ce
addq $0x18, %rbx
movq (%rsp), %r13
addq $0x18, %r13
addq $0x18, %r14
addq $0x18, %r15
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3cc88
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3cc88
leaq 0x130(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x3cc88
leaq 0x118(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, (%rsp)
movq %r13, %rdx
callq 0x3cc88
leaq 0x100(%rsp), %r13
movq %r13, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x3de12
leaq 0xa0(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x3de12
leaq 0xe8(%rsp), %rsi
movq %r13, %rdi
callq 0x3d756
leaq 0xce3bd(%rip), %r12     # 0xe5b98
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17a06
leaq 0x100(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x3d756
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17a06
leaq 0xa0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3d756
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17a06
leaq 0xa0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x3d756
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17a06
leaq 0x160(%rsp), %r13
movq %r13, %rdi
movq (%rsp), %rsi
movq %rbx, %rdx
callq 0x3cc88
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3cc88
leaq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x4c77b
movapd %xmm0, (%rsp)
leaq 0xb8(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x4c77b
movapd %xmm0, 0x90(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e154
leaq 0x130(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4c77b
movapd %xmm0, 0x80(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e154
leaq 0x118(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4c77b
movapd %xmm0, 0x70(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3e154
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4c77b
movapd %xmm0, 0x60(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c77b
movapd %xmm0, 0x50(%rsp)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3e154
movq %r14, %rdi
movq %r15, %rsi
callq 0x4c77b
movapd %xmm0, 0x40(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4c77b
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 (%r12), %xmm2
movapd 0x8a669(%rip), %xmm3    # 0xa2020
movapd %xmm2, %xmm0
xorpd %xmm3, %xmm0
leaq 0xce1e2(%rip), %rax     # 0xe5ba8
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 0x17a19
leaq 0xce19b(%rip), %rax     # 0xe5ba8
movsd (%rax), %xmm0
xorpd 0x8a607(%rip), %xmm0    # 0xa2020
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop