// File: /workspace/github_cpp_makefile_star2_O3/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), %rbp
movq 0x20(%rsi), %r13
testq %rbp, %rbp
setne %al
testq %r13, %r13
setne %cl
testb %cl, %al
je 0x17946
movq 0x8(%rsi), %rbx
movq 0x10(%rsi), %r8
movq 0x8(%rbp), %r15
cmpq %r15, %rbx
sete %al
cmpq %r15, %r8
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x17598
movq 0x10(%rbp), %r15
cmpq %r15, %rbx
sete %al
cmpq %r15, %r8
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x17598
movq 0x18(%rbp), %rax
xorl %r15d, %r15d
cmpq %rax, %rbx
je 0x17598
cmpq %rax, %r8
cmovneq %rax, %r15
movq 0x8(%r13), %r12
cmpq %r12, %rbx
sete %al
cmpq %r12, %r8
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x175d9
movq 0x10(%r13), %r12
cmpq %r12, %rbx
sete %al
cmpq %r12, %r8
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x175d9
movq 0x18(%r13), %rax
xorl %r12d, %r12d
cmpq %rax, %rbx
je 0x175d9
cmpq %rax, %r8
cmovneq %rax, %r12
cmpq %r12, %r15
je 0x1760d
movslq 0x14(%r15), %rax
testq %rax, %rax
jle 0x1760d
movq 0x8(%r15), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
cmpq %r12, 0x8(%rsi)
je 0x17946
cmpq %r12, 0x10(%rsi)
je 0x17946
incq %rdx
cmpq %rdx, %rax
jne 0x175ed
movq %r8, (%rsp)
movq %rdi, %r14
testb $0x4, 0xa8(%rbp)
jne 0x1762c
movq %r14, %rdi
movq (%r14), %rax
movq %rbp, %rsi
callq *0x2c8(%rax)
addq $0x38, %rbp
leaq 0x100(%rsp), %rdi
movq %rbp, %rsi
callq 0x3cfd6
testb $0x4, 0xa8(%r13)
jne 0x17659
movq (%r14), %rax
movq %r14, %rdi
movq %r13, %rsi
callq *0x2c8(%rax)
addq $0x38, %r13
leaq 0xe8(%rsp), %rdi
movq %r13, %rsi
callq 0x3cfd6
addq $0x18, %rbx
movq (%rsp), %r14
addq $0x18, %r14
addq $0x18, %r15
addq $0x18, %r12
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3c78e
leaq 0xd0(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3c78e
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3c78e
leaq 0x130(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x3c78e
leaq 0x118(%rsp), %rbp
movq %rbp, %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x3d8fa
leaq 0xa0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movq %r13, %rdx
callq 0x3d8fa
leaq 0x100(%rsp), %rsi
movq %rbp, %rdi
callq 0x3d252
leaq 0xce47f(%rip), %r13     # 0xe5b98
movsd (%r13), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17946
leaq 0x118(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3d252
movsd (%r13), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17946
leaq 0xa0(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x3d252
movsd (%r13), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17946
leaq 0xa0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3d252
movsd (%r13), %xmm1
ucomisd %xmm0, %xmm1
jae 0x17946
leaq 0x160(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3c78e
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3c78e
leaq 0x28(%rsp), %rsi
movq %rbp, %r15
movq %rbp, %rdi
callq 0x4bc63
movapd %xmm0, (%rsp)
leaq 0xd0(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4bc63
movapd %xmm0, 0x90(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3dc00
leaq 0xb8(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4bc63
movapd %xmm0, 0x80(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3dc00
leaq 0x130(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4bc63
movapd %xmm0, 0x70(%rsp)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3dc00
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4bc63
movapd %xmm0, 0x60(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bc63
movapd %xmm0, 0x50(%rsp)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3dc00
movq %r14, %rdi
movq %r12, %rsi
callq 0x4bc63
movapd %xmm0, 0x40(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4bc63
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 (%r13), %xmm2
movapd 0x8a729(%rip), %xmm3    # 0xa2020
movapd %xmm2, %xmm0
xorpd %xmm3, %xmm0
leaq 0xce2a2(%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 0x17959
leaq 0xce25b(%rip), %rax     # 0xe5ba8
movsd (%rax), %xmm0
xorpd 0x8a6c7(%rip), %xmm0    # 0xa2020
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop