LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: find_property(PlyElement*, char*, int*)
PlyProperty *find_property(PlyElement *elem, char *prop_name, int *index)
{
  int i;

  for (i = 0; i < elem->nprops; i++)
    if (equal_strings (prop_name, elem->props[i]->name)) {
      *index = i;
      return (elem->props[i]);
    }

  *index = -1;
  return (NULL);
}

// Assembly:
movslq 0x10(%rdi), %r8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %r8, %r8
jle 0x3f545
pushq %rbp
pushq %rbx
movq 0x18(%rdi), %rdi
xorl %r9d, %r9d
movq (%rdi,%r9,8), %rax
movq (%rax), %r10
xorl %r11d, %r11d
movb (%rsi,%r11), %bl
movb (%r10,%r11), %bpl
testb %bl, %bl
je 0x3f534
testb %bpl, %bpl
je 0x3f534
incq %r11
cmpb %bpl, %bl
je 0x3f519
jmp 0x3f539
cmpb %bpl, %bl
je 0x3f549
incq %r9
cmpq %r8, %r9
jne 0x3f50f
xorl %eax, %eax
jmp 0x3f54c
xorl %eax, %eax
jmp 0x3f54e
movl %r9d, %ecx
popq %rbx
popq %rbp
movl %ecx, (%rdx)
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_get_property
void ply_get_property(
  PlyFile *plyfile,
  char *elem_name,
  PlyProperty *prop
)
{
  PlyElement *elem;
  PlyProperty *prop_ptr;
  int index;

  /* find information about the element */
  elem = find_element (plyfile, elem_name);
  plyfile->which_elem = elem;

  /* deposit the property information into the element's description */

  prop_ptr = find_property (elem, prop->name, &index);
  if (prop_ptr == NULL) {
    fprintf (stderr, "Warning:  Can't find property '%s' in element '%s'\n",
             prop->name, elem_name);
    return;
  }
  prop_ptr->internal_type  = prop->internal_type;
  prop_ptr->offset         = prop->offset;
  prop_ptr->count_internal = prop->count_internal;
  prop_ptr->count_offset   = prop->count_offset;

  /* specify that the user wants this property */
  elem->store_prop[index] = STORE_PROP;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
callq 0x3e0ee
movq %rax, %r15
movq %rax, 0x40(%r12)
movq (%r14), %r12
leaq 0x4(%rsp), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3f4f8
testq %rax, %rax
je 0x3f5b0
movq 0xc(%r14), %rcx
movq %rcx, 0xc(%rax)
movq 0x1c(%r14), %rcx
movq %rcx, 0x1c(%rax)
movq 0x20(%r15), %rax
movslq 0x4(%rsp), %rcx
movb $0x1, (%rax,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xa5a01(%rip), %rax     # 0xe4fb8
movq (%rax), %rdi
leaq 0x695f0(%rip), %rsi     # 0xa8bb1
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe670
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_describe_other_elements
void ply_describe_other_elements (
  PlyFile *plyfile,
  PlyOtherElems *other_elems
)
{
  int i;
  OtherElem *other;
  PlyElement *elem;
  
  /* ignore this call if there is no other element */
  if (other_elems == NULL)
    return;

  /* save pointer to this information */
  plyfile->other_elems = other_elems;

  /* describe the other properties of this element */
  /* store them in the main element list as elements with
     only other properties */
  
  REALLOCN(plyfile->elems, PlyElement *,
	   plyfile->nelems, plyfile->nelems + other_elems->num_elems);
  for (i = 0; i < other_elems->num_elems; i++) {
      other = &(other_elems->other_list[i]);
      elem = (PlyElement *) myalloc (sizeof (PlyElement));
      plyfile->elems[plyfile->nelems++] = elem;
      elem->name = my_strdup (other->elem_name);
      elem->num = other->elem_count;
      elem->nprops = 0;
      ply_describe_other_properties (plyfile, other->other_props,
				     offsetof(OtherData,other_props));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x3fefe
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, 0x48(%rdi)
movslq 0x10(%rdi), %rax
testq %rax, %rax
je 0x3fe3b
leaq 0x10(%r14), %r15
movq 0x18(%r14), %rdi
movslq (%rbx), %rsi
addq %rax, %rsi
shlq $0x3, %rsi
callq 0xe7a0
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x3fe62
movl (%rbx), %ecx
jmp 0x3fe6f
movl (%rbx), %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0xe2f0
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x3ff0d
testl %r15d, %r15d
jg 0x3fe8b
jmp 0x3fefe
movl (%rbx), %ecx
movl (%r15), %edx
addl %ecx, %edx
jne 0x3ff12
testl %ecx, %ecx
jle 0x3fefe
movslq (%r15), %rdx
leaq (%rax,%rdx,8), %rdi
movl %ecx, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0xe260
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%rbx), %r15
movl $0x30, %edi
movl $0x54f, %esi            # imm = 0x54F
leaq 0x68a46(%rip), %rdx     # 0xa88eb
callq 0x3deec
movq %rax, %r12
movq 0x18(%r14), %rax
movslq 0x10(%r14), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%r14)
movq %r12, (%rax,%rcx,8)
movq (%r15,%r13), %rdi
callq 0x3df2c
movq %rax, (%r12)
movl 0x8(%r15,%r13), %eax
movl %eax, 0x8(%r12)
movl $0x0, 0x10(%r12)
movq 0x18(%r15,%r13), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3e254
incq %rbp
movslq (%rbx), %rax
addq $0x20, %r13
cmpq %rax, %rbp
jl 0x3fe90
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xecde
movq %r15, %rdi
movq %rbx, %rsi
callq 0xec8f
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_put_other_elements
void ply_put_other_elements (PlyFile *plyfile)
{
  int i,j;
  OtherElem *other;

  /* make sure we have other elements to write */
  if (plyfile->other_elems == NULL)
    return;

  /* write out the data for each "other" element */

  for (i = 0; i < plyfile->other_elems->num_elems; i++) {

    other = &(plyfile->other_elems->other_list[i]);
    ply_put_element_setup (plyfile, other->elem_name);

    /* write out each instance of the current element */
    for (j = 0; j < other->elem_count; j++)
      ply_put_element (plyfile, (void *) other->other_data[j]);
  }
}

// Assembly:
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x3ff94
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x0, (%rax)
jle 0x3ff89
movq %rdi, %rbx
xorl %r14d, %r14d
movq 0x8(%rax), %r15
movq %r14, %r12
shlq $0x5, %r12
movq (%r15,%r12), %rsi
movq %rbx, %rdi
callq 0x3e5c9
cmpl $0x0, 0x8(%r15,%r12)
jle 0x3ff7a
addq %r12, %r15
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
callq 0x3e5f1
incq %r12
movslq 0x8(%r15), %rax
cmpq %rax, %r12
jl 0x3ff5e
incq %r14
movq 0x48(%rbx), %rax
movslq (%rax), %rcx
cmpq %rcx, %r14
jl 0x3ff39
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: get_ascii_item(char*, int, int*, unsigned int*, double*)
void get_ascii_item(
  char *word,
  int type,
  int *int_val,
  unsigned int *uint_val,
  double *double_val
)
{
  switch (type) {
    case PLY_CHAR:
    case PLY_UCHAR:
    case PLY_SHORT:
    case PLY_USHORT:
    case PLY_INT:
      *int_val = atoi (word);
      *uint_val = (*int_val >= 0) ? (unsigned int) *int_val : 0;
      *double_val = (double) *int_val;
      break;

    case PLY_UINT:
      *uint_val = strtol (word, (char **) NULL, 10);
      *int_val = (int) *uint_val;
      *double_val = (double) *uint_val;
      break;

    case PLY_FLOAT:
    case PLY_DOUBLE:
      *double_val = atof (word);
      *int_val = (int) *double_val;
      *uint_val = (*double_val >= 0) ? (unsigned int) *double_val : 0;
      break;

    default:
      fprintf (stderr, "get_ascii_item: bad type = %d\n", type);
      exit (-1);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r15
leal -0x1(%rsi), %eax
cmpl $0x5, %eax
jae 0x3fffb
callq 0xe700
movl %eax, (%r15)
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, (%rbx)
cvtsi2sdl (%r15), %xmm0
movsd %xmm0, (%r14)
jmp 0x40023
leal -0x7(%rsi), %eax
cmpl $0x2, %eax
jae 0x40029
callq 0xe580
movsd %xmm0, (%r14)
cvttsd2si %xmm0, %eax
movl %eax, (%r15)
xorpd %xmm1, %xmm1
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x6, %esi
jne 0x40048
xorl %esi, %esi
movl $0xa, %edx
callq 0xe650
movl %eax, (%rbx)
movl %eax, (%r15)
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
jmp 0x3fff4
movl %esi, %edi
callq 0xed0b
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: swap_bytes(char*, int)
void swap_bytes(char *bytes, int num_bytes)
{
    int i;
    char temp;
    
    for (i=0; i < num_bytes/2; i++)
    {
	temp = bytes[i];
	bytes[i] = bytes[(num_bytes-1)-i];
	bytes[(num_bytes-1)-i] = temp;
    }
}

// Assembly:
cmpl $0x2, %esi
jl 0x4022e
movl %esi, %eax
shrl %esi
addq %rdi, %rax
decq %rax
negq %rsi
xorl %ecx, %ecx
movb (%rdi), %dl
movb (%rax,%rcx), %r8b
movb %r8b, (%rdi)
movb %dl, (%rax,%rcx)
incq %rdi
decq %rcx
cmpq %rcx, %rsi
jne 0x40217
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: get_prop_type(char*)
int get_prop_type(char *type_name)
{
  int i;

  for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++)
    if (equal_strings (type_name, type_names[i]))
      return (i);

  static char *new_type_names[] = {
    "invalid",
    "int8", "int16", "int32",
    "uint8", "uint16", "uint32",
    "float32", "float64",
  };

  for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++)
    if (equal_strings (type_name, new_type_names[i]))
      return (i);

  /* if we get here, we didn't find the type */
  return (0);
}

// Assembly:
movl $0x1, %eax
leaq 0xa5704(%rip), %rcx     # 0xe5a20
movq (%rcx,%rax,8), %rdx
xorl %esi, %esi
movb (%rdi,%rsi), %r8b
movb (%rdx,%rsi), %r9b
testb %r8b, %r8b
je 0x4033e
testb %r9b, %r9b
je 0x4033e
incq %rsi
cmpb %r9b, %r8b
je 0x40322
jmp 0x40343
cmpb %r9b, %r8b
je 0x4038e
incq %rax
cmpq $0x9, %rax
jne 0x4031c
movl $0x1, %eax
leaq 0x68548(%rip), %rcx     # 0xa88a0
movslq (%rcx,%rax,4), %rdx
xorl %esi, %esi
movb (%rdi,%rsi), %r8b
leaq (%rdx,%rsi), %r9
movb (%rcx,%r9), %r9b
testb %r8b, %r8b
je 0x4037e
testb %r9b, %r9b
je 0x4037e
incq %rsi
cmpb %r9b, %r8b
je 0x4035e
jmp 0x40383
cmpb %r9b, %r8b
je 0x4038e
incq %rax
cmpq $0x9, %rax
jne 0x40358
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Triad::Draw() const
void R3Triad::
Draw(void) const
{
    // Draw three rays
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_X)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_Y)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + Axis(RN_Z)));
    R3EndLine();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl $0x3, %edi
callq 0xe110
leaq 0x4a6627(%rip), %r14    # 0x4e6a60
movq %r14, %rdi
callq 0xe130
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3c877
movq %r15, %rdi
callq 0xe130
callq 0xe5d0
movl $0x3, %edi
callq 0xe110
movq %r14, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3c877
movq %r15, %rdi
callq 0xe130
callq 0xe5d0
movl $0x3, %edi
callq 0xe110
movq %r14, %rdi
callq 0xe130
addq $0x30, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3c877
movq %r15, %rdi
callq 0xe130
callq 0xe5d0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3CoordSystem::Draw() const
void R3CoordSystem::
Draw(void) const
{
    // Draw three rays
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_X)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Y)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Z)));
    R3EndLine();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x3, %edi
callq 0xe110
movq %rbx, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c877
movq %r14, %rdi
callq 0xe130
callq 0xe5d0
movl $0x3, %edi
callq 0xe110
movq %rbx, %rdi
callq 0xe130
leaq 0x30(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c877
movq %r14, %rdi
callq 0xe130
callq 0xe5d0
movl $0x3, %edi
callq 0xe110
movq %rbx, %rdi
callq 0xe130
leaq 0x48(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c877
movq %r14, %rdi
callq 0xe130
callq 0xe5d0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Load() const
void R3Affine::
Load(void) const
{
    // Load matrix onto stack
    Matrix().Load();

    // Set mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2ca38
movq %r14, %rdi
callq 0xe4f0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x405cb
xorl %edi, %edi
cmpl $0x0, 0x4a65ba(%rip)    # 0x4e6b70
sete %dil
movl %edi, 0x4a65b0(%rip)    # 0x4e6b70
xorl $0x901, %edi            # imm = 0x901
callq 0xe0d0
addq $0x88, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Draw() const
void R3Affine::
Draw(void) const
{
    // Multiply top of stack by matrix
    Matrix().Draw();

    // Set mirror flag - this screws up Push/Pop ???
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2ca38
movq %r14, %rdi
callq 0xe050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x40627
xorl %edi, %edi
cmpl $0x0, 0x4a655e(%rip)    # 0x4e6b70
sete %dil
movl %edi, 0x4a6554(%rip)    # 0x4e6b70
xorl $0x901, %edi            # imm = 0x901
callq 0xe0d0
addq $0x88, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Push() const
void R3Affine::
Push(void) const
{
    // Push matrix onto stack
    Matrix().Push();

    // Set mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x8, %rdi
callq 0x403e0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x4066b
xorl %edi, %edi
cmpl $0x0, 0x4a651b(%rip)    # 0x4e6b70
sete %dil
movl %edi, 0x4a6511(%rip)    # 0x4e6b70
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Affine::Pop() const
void R3Affine::
Pop(void) const
{
    // Pop matrix off stack
    Matrix().Pop();

    // Restore mirror flag
    if (IsMirrored()) {
        R3draw_mirrored = !R3draw_mirrored;
#if (RN_3D_GRFX == RN_OPENGL)
        glFrontFace((R3draw_mirrored) ? GL_CW : GL_CCW);
#else
	RNAbort("Not Implemented");
#endif
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0xe850
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
testl %eax, %eax
je 0x406a3
xorl %edi, %edi
cmpl $0x0, 0x4a64e3(%rip)    # 0x4e6b70
sete %dil
movl %edi, 0x4a64d9(%rip)    # 0x4e6b70
xorl $0x901, %edi            # imm = 0x901
popq %rbx
jmp 0xe0d0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Vector::Draw() const
void R3Vector::
Draw(void) const
{
    // Draw vector from (0,0,0)
    R3BeginLine();
    R3LoadPoint(R3zero_point);
    R3LoadPoint((R3zero_point + *this));
    R3EndLine();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl $0x3, %edi
callq 0xe110
leaq 0x4a639d(%rip), %r14    # 0x4e6a60
movq %r14, %rdi
callq 0xe130
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x3c877
movq %r15, %rdi
callq 0xe130
callq 0xe5d0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Line::Draw() const
void R3Line::
Draw(void) const
{
    // Draw line
    R3BeginLine();
    R3LoadPoint(Point());
    R3LoadPoint(Point() + Vector());
    R3EndLine();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x3, %edi
callq 0xe110
movq %rbx, %rdi
callq 0xe130
leaq 0x18(%rbx), %rdx
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3c877
movq %r14, %rdi
callq 0xe130
callq 0xe5d0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Circle::Draw(gaps::RNFlags) const
void R3Circle::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix (Zaxis -> ScaledNormal + OffsetToCenter)
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Rotate(R3posz_vector, Normal());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	// Load normal
	if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) 
	    R3LoadNormal(R3posz_vector);

	// Draw circle in XY plane
	R3BeginPolygon();
	for (int i = 0; i < R3circle_npoints; i++) {
	    if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) 
		R3LoadTextureCoords(R3circle_texcoords[i]);
	    R3LoadPoint(R3circle_points[i] * radius);
	}
	R3EndPolygon();
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	R3BeginLoop();
	for (int i = 0; i < R3circle_npoints; i++) 
	    R3LoadPoint(R3circle_points[i] * radius);
	R3EndLoop();
    }

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x62076(%rip), %rsi     # 0xa2e40
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x2c2be
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x18(%rbx), %xmm2
movq %rsp, %r12
movq %r12, %rdi
callq 0x3cfc6
movq %r15, %rdi
movq %r12, %rsi
callq 0x2d3f8
leaq 0x28(%rbx), %rdx
leaq 0x67939(%rip), %rsi     # 0xa8740
movq %r15, %rdi
callq 0x2dbe4
movq %r15, %rdi
callq 0x403e0
testb $0x2, %r14b
je 0x40e92
testb $0x20, %r14b
je 0x40e2f
leaq 0x67916(%rip), %rdi     # 0xa8740
callq 0xe6b0
movl $0x9, %edi
callq 0xe110
leaq 0x682d0(%rip), %rax     # 0xa9110
movslq (%rax), %rbp
testq %rbp, %rbp
jle 0x40e8d
leaq 0x4a6521(%rip), %r15    # 0x4e7370
leaq 0x4a621a(%rip), %r12    # 0x4e7070
movq %rsp, %r13
btl $0x9, %r14d
jae 0x40e68
movq %r15, %rdi
callq 0xe120
movsd 0x20(%rbx), %xmm0
movq %r13, %rdi
movq %r12, %rsi
callq 0x3cf76
movq %r13, %rdi
callq 0xe130
addq $0x10, %r15
addq $0x18, %r12
decq %rbp
jne 0x40e59
callq 0xe5d0
testb $0x1, %r14b
je 0x40ee1
movl $0x2, %edi
callq 0xe110
leaq 0x68267(%rip), %rax     # 0xa9110
movslq (%rax), %r12
testq %r12, %r12
jle 0x40edc
leaq 0x4a61b8(%rip), %r14    # 0x4e7070
movq %rsp, %r15
movsd 0x20(%rbx), %xmm0
movq %r15, %rdi
movq %r14, %rsi
callq 0x3cf76
movq %r15, %rdi
callq 0xe130
addq $0x18, %r14
decq %r12
jne 0x40ebb
callq 0xe5d0
callq 0xe850
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Ellipse::Draw(gaps::RNFlags) const
void R3Ellipse::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix
    R4Matrix matrix = R4identity_matrix;
    matrix.Transform(cs.Matrix());
    matrix.Scale(R3Vector(radii.X(), radii.Y(), 1.0));
    matrix.Push();

    // Draw unit sphere
    R3unit_circle.Draw(draw_flags);

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x180, %rsp            # imm = 0x180
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x61f2b(%rip), %rsi     # 0xa2e40
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x2c2be
leaq 0x8(%r15), %rsi
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0x2a74e
movq %rsp, %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2e2af
movq %r14, %rdi
movq %r13, %rsi
callq 0x2dea2
movsd 0x68(%r15), %xmm0
movsd 0x70(%r15), %xmm1
movq %rsp, %r15
movsd 0x610cc(%rip), %xmm2    # 0xa2038
movq %r15, %rdi
callq 0x3cfc6
movq %r14, %rdi
movq %r15, %rsi
callq 0x2d5fe
movq %r14, %rdi
callq 0x403e0
leaq 0x4a5f52(%rip), %rdi    # 0x4e6ee0
movq %rbx, %rsi
callq 0x40dac
callq 0xe850
addq $0x180, %rsp            # imm = 0x180
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Polygon::Draw(gaps::RNFlags) const
void R3Polygon::
Draw(const R3DrawFlags draw_flags) const
{
    // Draw polygon
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
        R3BeginPolygon();
        if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG] ||
            draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG])
            R3LoadNormal(plane.Normal());
        for (int i = 0; i < npoints; i++) {
            R3LoadPoint(points[i]);
        }
        R3EndPolygon();
    }
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
        R3BeginLoop();
        for (int i = 0; i < npoints; i++) {
            R3LoadPoint(points[i]);
        }
        R3EndLoop();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testb $0x2, %r14b
je 0x413c7
movl $0x9, %edi
callq 0xe110
testl $0x120, %r14d           # imm = 0x120
je 0x4139a
leaq 0x18(%rbx), %rdi
callq 0xe6b0
cmpl $0x0, 0x10(%rbx)
jle 0x413c2
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rbx), %rdi
addq %r15, %rdi
callq 0xe130
incq %r12
movslq 0x10(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x413a6
callq 0xe5d0
testb $0x1, %r14b
jne 0x413d9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x2, %edi
callq 0xe110
cmpl $0x0, 0x10(%rbx)
jle 0x4140b
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8(%rbx), %rdi
addq %r14, %rdi
callq 0xe130
incq %r15
movslq 0x10(%rbx), %rax
addq $0x18, %r14
cmpq %rax, %r15
jl 0x413ef
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe5d0
nop
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Sphere::Draw(gaps::RNFlags) const
void R3Sphere::
Draw(const R3DrawFlags draw_flags) const
{
    // Draw sphere - sphdraw uses n3f only ???
#if (RN_3D_GRFX == RN_OPENGL)
    // Create GLU quadric
    static GLUquadricObj *sphere = gluNewQuadric(); // ???

    // Push matrix 
    R4Matrix matrix = R4identity_matrix;
    matrix.Translate(center.Vector());
    matrix.Push();

    // Draw surface
    if (draw_flags[R3_SURFACES_DRAW_FLAG]) {
	if (draw_flags[R3_VERTEX_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_SMOOTH);
	else if (draw_flags[R3_SURFACE_NORMALS_DRAW_FLAG]) gluQuadricNormals(sphere, (GLenum) GLU_FLAT);
	if (draw_flags[R3_VERTEX_TEXTURE_COORDS_DRAW_FLAG]) gluQuadricTexture(sphere, GL_TRUE);
	else gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_FILL);
	gluSphere(sphere, radius, 16, 8);
    }

    // Draw edges
    if (draw_flags[R3_EDGES_DRAW_FLAG]) {
	gluQuadricNormals(sphere, (GLenum) GLU_NONE);
	gluQuadricTexture(sphere, GL_FALSE);
	gluQuadricDrawStyle(sphere, (GLenum) GLU_SILHOUETTE);
	gluSphere(sphere, radius, 16, 8);
    }

    // Pop matrix
    matrix.Pop();
#else
    RNAbort("Not Implemented");
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb 0x4a4e48(%rip), %al     # 0x4e6d30
testb %al, %al
je 0x42000
leaq 0x60f49(%rip), %rsi     # 0xa2e40
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x2c2be
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movsd 0x18(%rbx), %xmm2
movq %rsp, %r12
movq %r12, %rdi
callq 0x3cfc6
movq %r15, %rdi
movq %r12, %rsi
callq 0x2d3f8
movq %r15, %rdi
callq 0x403e0
testb $0x2, %r14b
je 0x41f9b
movl $0x186a0, %esi          # imm = 0x186A0
btl $0x8, %r14d
jb 0x41f4e
movl $0x186a1, %esi          # imm = 0x186A1
testb $0x20, %r14b
je 0x41f5a
movq 0x4a4dd3(%rip), %rdi    # 0x4e6d28
callq 0xe1d0
movl %r14d, %esi
shrl $0x9, %esi
movq 0x4a4dc1(%rip), %rdi    # 0x4e6d28
andl $0x1, %esi
callq 0xe830
movq 0x4a4db2(%rip), %rdi    # 0x4e6d28
movl $0x186ac, %esi          # imm = 0x186AC
callq 0xe770
movq 0x4a4da1(%rip), %rdi    # 0x4e6d28
movsd 0x20(%rbx), %xmm0
movl $0x10, %esi
movl $0x8, %edx
callq 0xe220
testb $0x1, %r14b
je 0x41fec
movq 0x4a4d80(%rip), %rdi    # 0x4e6d28
movl $0x186a2, %esi          # imm = 0x186A2
callq 0xe1d0
movq 0x4a4d6f(%rip), %rdi    # 0x4e6d28
xorl %esi, %esi
callq 0xe830
movq 0x4a4d61(%rip), %rdi    # 0x4e6d28
movl $0x186ad, %esi          # imm = 0x186AD
callq 0xe770
movq 0x4a4d50(%rip), %rdi    # 0x4e6d28
movsd 0x20(%rbx), %xmm0
movl $0x10, %esi
movl $0x8, %edx
callq 0xe220
callq 0xe850
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x4a4d29(%rip), %rdi    # 0x4e6d30
callq 0xe810
testl %eax, %eax
je 0x41ef0
callq 0xe500
movq %rax, 0x4a4d08(%rip)    # 0x4e6d28
leaq 0x4a4d09(%rip), %rdi    # 0x4e6d30
callq 0xe2e0
jmp 0x41ef0
movq %rax, %rbx
leaq 0x4a4cf5(%rip), %rdi    # 0x4e6d30
callq 0xe2d0
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Draw.cpp
// Function: gaps::R3Ellipsoid::Draw(gaps::RNFlags) const
void R3Ellipsoid::
Draw(const R3DrawFlags draw_flags) const
{
    // Push matrix
    R4Matrix matrix = R4identity_matrix;
    matrix.Transform(cs.Matrix());
    matrix.Scale(radii);
    matrix.Push();

    // Draw unit sphere
    R3unit_sphere.Draw(draw_flags);

    // Pop matrix
    matrix.Pop();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x180, %rsp            # imm = 0x180
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x60ddb(%rip), %rsi     # 0xa2e40
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x2c2be
leaq 0x8(%r15), %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0x2a74e
leaq 0x100(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2e2af
movq %r14, %rdi
movq %r13, %rsi
callq 0x2dea2
addq $0x68, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2d5fe
movq %r14, %rdi
callq 0x403e0
leaq 0xa3ccd(%rip), %rdi     # 0xe5d90
movq %rbx, %rsi
callq 0x41ece
callq 0xe850
addq $0x180, %rsp            # imm = 0x180
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Span const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Line& line, const R3Span& span, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Intersect line with span's ray
    RNScalar s;
    switch (R3Intersects(line, span.Ray(), hit_point, &s)) {
    case RN_NULL_CLASS_ID:
	// Span and line do not intersect
	return RN_NULL_CLASS_ID;

    case R3_RAY_CLASS_ID:
	// Line contains span
	return R3_SPAN_CLASS_ID;

    case R3_POINT_CLASS_ID: 
	// Check if intersection point is on span
	if (RNIsGreater(s, span.Length())) {
	    // Span's ray intersects line beyond span endpoint
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Span and line intersect at point
	    if (hit_t) *hit_t = s;
	    return R3_POINT_CLASS_ID;
	}
	break;

    default:
	RNAbort("Illegal intersection");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %r14
movq %rsi, %r15
leaq 0x8(%rsp), %rcx
callq 0x424bb
movl %eax, %ebx
movl %eax, %eax
leaq 0x668b9(%rip), %rcx     # 0xa8f58
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x8(%rsp), %xmm0
leaq 0xa34e3(%rip), %rax     # 0xe5b98
movapd %xmm0, %xmm1
subsd 0x48(%r15), %xmm1
xorl %ebx, %ebx
ucomisd (%rax), %xmm1
ja 0x426fd
movl $0x1, %ebx
testq %r14, %r14
je 0x426fd
movsd %xmm0, (%r14)
jmp 0x426fd
leaq 0x668ed(%rip), %rdi     # 0xa8fcc
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x718f6
leaq 0x668f2(%rip), %rdi     # 0xa8fe1
xorl %eax, %eax
callq 0x718f6
jmp 0x426fd
movl $0x4, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Plane const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Plane& plane, 
    R3Point *hit_point)
{
    // Compute dot product of line vector and plane normal
    RNScalar denom = plane.Normal().Dot(line.Vector());

    // Check if line and plane are parallel
    if (RNIsZero(denom)) {
	// Check if line lies in plane	
	if (R3Contains(plane, line.Point())) {
	    // Line lies in plane
	    return R3_LINE_CLASS_ID;
	}
	else {
	    // Line is parallel to plane, but not in it
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Line and plane are not parallel - they must intersect at a point
	if (hit_point) {
	    RNScalar t = -(R3SignedDistance(plane, line.Point())) / denom;
	    *hit_point = line.Point() + line.Vector() * t;
	}
	return R3_POINT_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x18(%rdi), %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x3d252
leaq 0xa3464(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm2
movapd 0x5f8e0(%rip), %xmm1    # 0xa2020
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x42767
ucomisd %xmm0, %xmm2
jb 0x42767
movq %r12, %rdi
movq %r14, %rsi
callq 0x46f51
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
addl %ebp, %ebp
jmp 0x427be
movl $0x1, %ebp
testq %rbx, %rbx
je 0x427be
movq %r12, %rdi
movq %r14, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0x49617
xorpd 0x5f896(%rip), %xmm0    # 0xa2020
divsd 0x8(%rsp), %xmm0
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x3d962
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3c877
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c89a
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Triangle const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Triangle& triangle, 
    R3Point *hit_point)
{
    // Find intersection of line and plane
    R3Point p;
    switch (R3Intersects(line, triangle.Plane(), &p)) {
    case RN_NULL_CLASS_ID:
	// Line does not intersect triangle plane
	return RN_NULL_CLASS_ID;
	
    case R3_POINT_CLASS_ID:
	// Line intersects triangle plane in a single point
	// Check whether triangle contains intersection point
	if (!R3Contains(triangle, p)) return RN_NULL_CLASS_ID;
	if (hit_point) *hit_point = p;
	return R3_POINT_CLASS_ID;

    case R3_LINE_CLASS_ID: 
	// Line lies in triangle plane 
	// Intersect line and triangle in 2D
        // RNAbort("Case not implemented");
	return R3_SPAN_CLASS_ID;

    default:
	RNAbort("Invalid intersection result");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x3c530
leaq 0x20(%r14), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x42709
movl %eax, %ebp
testl %eax, %eax
je 0x4283c
cmpl $0x2, %ebp
jne 0x42810
movl $0x4, %ebp
jmp 0x4283c
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x4732f
testl %eax, %eax
je 0x4283a
movl $0x1, %ebp
testq %rbx, %rbx
je 0x4283c
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x3c89a
jmp 0x4283c
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Halfspace const&, gaps::R3Ray*)
RNClassID R3Intersects(const R3Line& line, const R3Halfspace& halfspace, 
    R3Ray *result)
{
    // Compute dot product of line vector and halfspace plane normal
    RNScalar denom = halfspace.Plane().Normal().Dot(line.Vector());

    // Check if line and halfspace plane are parallel
    if (RNIsZero(denom)) {
	// Check if line lies in halfspace
	if (R3Contains(halfspace, line.Point())) {
	    // Line lies in halfspace
	    return R3_LINE_CLASS_ID;
	}
	else {
	    // Line is parallel to halfspace plane, but not in halfspace
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Line and halfspace plane are not parallel - intersection must be a ray
	if (result) {
	    RNScalar t = -(R3SignedDistance(halfspace.Plane(), line.Point())) / denom;
	    R3Point point = line.Point() + line.Vector() * t;
	    R3Vector vector = (RNIsPositive(denom)) ? line.Vector() : -(line.Vector());
	    *result = R3Ray(point, vector);
	}
	return R3_RAY_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
leaq 0x18(%rdi), %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x3d252
leaq 0xa3320(%rip), %r13     # 0xe5b98
movsd (%r13), %xmm2
movapd 0x5f79a(%rip), %xmm1    # 0xa2020
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x428b0
ucomisd %xmm0, %xmm2
jb 0x428b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x47a86
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
addl %ebp, %ebp
jmp 0x42959
movl $0x3, %ebp
testq %rbx, %rbx
je 0x42959
movq %r12, %rdi
movq %r15, %rsi
movsd %xmm0, (%rsp)
callq 0x49617
xorpd 0x5f74a(%rip), %xmm0    # 0xa2020
divsd (%rsp), %xmm0
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x3d962
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3c877
movsd (%rsp), %xmm0
ucomisd (%r13), %xmm0
ja 0x42917
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3dc00
jmp 0x42924
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3cfd6
leaq 0x38(%rsp), %r14
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3c120
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c89a
addq $0x18, %rbx
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x3d752
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3OrientedBox const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3OrientedBox& box, 
    R3Point *hit_point)
{
    // Check if box is empty
    if (box.IsEmpty()) return RN_NULL_CLASS_ID;

    // Transform line into std coordinate system
    R3Line transformed_line = line;
    R3Affine cs_to_std_xform(box.CoordSystem().InverseMatrix());
    transformed_line.Transform(cs_to_std_xform);

    // Intersect in std coordinate system
    R3Box axis_aligned_box(-box.Radius(0), -box.Radius(1), -box.Radius(2), box.Radius(0), box.Radius(1), box.Radius(2));
    int status = R3Intersects(transformed_line, axis_aligned_box, hit_point);
    if (status == RN_NULL_CLASS_ID) return RN_NULL_CLASS_ID;

    // Compute hit point
    if (hit_point) {
      R3Affine std_to_cs_xform(box.CoordSystem().Matrix());
      hit_point->Transform(std_to_cs_xform);
    }

    // Return whether hit
    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rsi, %r15
movsd 0x70(%rsi), %xmm0
movsd 0x78(%rsi), %xmm1
minsd 0x68(%rsi), %xmm0
minsd %xmm0, %xmm1
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x42c02
movq %rdx, %rbx
movq %rdi, %rsi
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x3c21e
leaq 0x8(%r15), %r14
leaq 0x68(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x2a7d6
leaq 0x1f8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x29fda
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3c42c
movsd 0x68(%r15), %xmm3
movsd 0x70(%r15), %xmm4
movapd 0x5f4b1(%rip), %xmm2    # 0xa2020
movapd %xmm3, %xmm0
xorpd %xmm2, %xmm0
movapd %xmm4, %xmm1
xorpd %xmm2, %xmm1
movsd 0x78(%r15), %xmm5
xorpd %xmm5, %xmm2
movq %rsp, %rdi
callq 0x27374
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
movq %rbx, %rdx
callq 0x4296a
movl %eax, %ebp
testl %eax, %eax
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x42bed
leaq 0x178(%rsp), %rdi
movq %r14, %rsi
callq 0x2a74e
leaq 0x68(%rsp), %rdi
leaq 0x178(%rsp), %rsi
xorl %edx, %edx
callq 0x29fda
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x3ce48
leaq 0x68(%rsp), %rdi
callq 0x2a028
movq %rsp, %rdi
callq 0x280f4
leaq 0x1f8(%rsp), %rdi
callq 0x2a028
movl %ebp, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2a028
jmp 0x42c2a
jmp 0x42c27
movq %rax, %rbx
movq %rsp, %rdi
callq 0x280f4
jmp 0x42c39
jmp 0x42c36
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x2a028
movq %rbx, %rdi
callq 0xe7e0
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3Sphere const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3Sphere& sphere, 
    R3Point *hit_point)
{
    // Check if sphere contains line point
    if (R3Contains(sphere, line.Point())) {
	if (hit_point) *hit_point = line.Point();
	return R3_SPAN_CLASS_ID;
    }
    else {
	// Check if line points towards sphere
	R3Vector EO = sphere.Center() - line.Point();
	RNScalar v = EO.Dot(line.Vector());

	// Compute possible intersection -- Graphics Gems I, p. 388    
	RNScalar disc = sphere.Radius() * sphere.Radius() - (EO.Dot(EO) - v*v);
	if (RNIsNegative(disc)) {
	    // No intersection
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Line intersects sphere (it grazes if disc is zero)
	    if (hit_point) {
		RNScalar d = sqrt(disc);
		RNScalar t = v - d;
		*hit_point = line.Point() + t * line.Vector();
	    }
	    
	    // Return result
	    if (RNIsZero(disc)) return R3_POINT_CLASS_ID;
	    else return R3_SPAN_CLASS_ID;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x48b4d
testl %eax, %eax
je 0x42c92
movl $0x4, %ebp
testq %rbx, %rbx
je 0x42da5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c89a
jmp 0x42da5
leaq 0x8(%r12), %rsi
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
callq 0x3c78e
leaq 0x18(%r14), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x3d252
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%r12), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
movq %r13, %rsi
callq 0x3d252
movsd (%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm1
subsd %xmm1, %xmm0
mulsd %xmm2, %xmm2
subsd %xmm0, %xmm2
leaq 0xa2ea3(%rip), %r13     # 0xe5b98
movsd (%r13), %xmm1
movapd 0x5f31d(%rip), %xmm0    # 0xa2020
xorpd %xmm1, %xmm0
xorl %ebp, %ebp
ucomisd %xmm2, %xmm0
ja 0x42da5
testq %rbx, %rbx
je 0x42d8c
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
movsd %xmm2, (%rsp)
jb 0x42d30
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x42d39
movapd %xmm2, %xmm0
callq 0xe340
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movapd %xmm1, %xmm0
callq 0x3d962
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3c877
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c89a
movsd (%r13), %xmm1
movapd 0x5f29d(%rip), %xmm0    # 0xa2020
xorpd %xmm1, %xmm0
movsd (%rsp), %xmm2
xorl %eax, %eax
ucomisd %xmm2, %xmm1
setb %al
ucomisd %xmm0, %xmm2
leal 0x1(%rax,%rax,2), %eax
movl $0x4, %ebp
cmovael %eax, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Span const&, gaps::R3Point*, double*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Span& span, 
    R3Point *hit_point, RNScalar *hit_tray, RNScalar *hit_tspan)
{
    // Intersect ray with span's ray
    RNScalar s1 = 0, s2 = 0;
    switch (R3Intersects(ray, span.Ray(), hit_point, &s1, &s2)) {
    case RN_NULL_CLASS_ID:
	// Span and ray do not intersect
	return RN_NULL_CLASS_ID;

    case R3_SPAN_CLASS_ID:
	// Ray and span point at each other on same line
	return R3_SPAN_CLASS_ID;

    case R3_RAY_CLASS_ID:
	// Ray and span point in same direction on same line
	if (RNIsGreater(s2, span.Length())) {
	    // Intersection is beyond span endpoint 
	    return RN_NULL_CLASS_ID;
	}
	else if (RNIsEqual(s2, span.Length())) {
	    // Span endpoint is ray start point
	    if (hit_tray) *hit_tray = s1;
	    if (hit_tspan) *hit_tspan = s2;
	    return R3_POINT_CLASS_ID;
	}
	else {
	    // Span and ray have non-null intersection in same line
	    return R3_SPAN_CLASS_ID;
	}
	break;

    case R3_POINT_CLASS_ID: 
	// Check if intersection point is on span
	if (RNIsGreater(s2, span.Length())) {
	    // Intersection is beyond span endpoint 
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Span and ray intersect at point
	    if (hit_tray) *hit_tray = s1;
	    if (hit_tspan) *hit_tspan = s2;
	    return R3_POINT_CLASS_ID;
	}
	break;

    default:
	RNAbort("Illegal intersection");
	break;
    }

    // Should never get here
    RNAbort("Should never get here");
    return RN_NULL_CLASS_ID;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rsi, %r15
xorl %eax, %eax
leaq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq %rsp, %r8
movq %rax, (%r8)
callq 0x42dde
cmpl $0x4, %eax
ja 0x42fee
movl %eax, %ecx
leaq 0x6600e(%rip), %rdx     # 0xa8f78
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
subsd 0x48(%r15), %xmm1
leaq 0xa2c0f(%rip), %rax     # 0xe5b98
ucomisd (%rax), %xmm1
jbe 0x42fce
jmp 0x4300a
movsd (%rsp), %xmm0
leaq 0xa2bfb(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
movapd %xmm0, %xmm2
subsd 0x48(%r15), %xmm2
ucomisd %xmm1, %xmm2
ja 0x4300a
movapd 0x5f067(%rip), %xmm3    # 0xa2020
xorpd %xmm1, %xmm3
ucomisd %xmm3, %xmm2
movl $0x4, %eax
jb 0x4300c
ucomisd %xmm2, %xmm1
jb 0x4300c
testq %r14, %r14
je 0x42fde
movsd 0x8(%rsp), %xmm1
movsd %xmm1, (%r14)
movl $0x1, %eax
testq %rbx, %rbx
je 0x4300c
movsd %xmm0, (%rbx)
jmp 0x4300c
leaq 0x65fd7(%rip), %rdi     # 0xa8fcc
xorl %eax, %eax
callq 0x718f6
leaq 0x65fde(%rip), %rdi     # 0xa8fe1
xorl %eax, %eax
callq 0x718f6
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Plane const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Plane& plane, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Compute dot product of ray vector and plane normal
    RNScalar denom = plane.Normal().Dot(ray.Vector());

    // Check if ray and plane are parallel
    if (RNIsZero(denom)) {
	// Check if ray lies in plane	
	if (R3Contains(plane, ray.Start())) {
	    // Ray lies in plane
	    return R3_RAY_CLASS_ID;
	}
	else {
	    // Ray is parallel to plane, but not in it
	    return RN_NULL_CLASS_ID;
	}
    }
    else {
	// Ray and plane are not parallel - compute parametric value on ray
	RNScalar s = -(R3SignedDistance(plane, ray.Start())) / denom;
	if (RNIsNegative(s)) {
	    // Ray is directed away from plane
	    return RN_NULL_CLASS_ID;
	}
	else {
	    // Ray is not parallel to plane and is pointing at plane - it must intersect
	    if (hit_point) *hit_point = ray.Start() + ray.Vector() * s;
	    if (hit_t) *hit_t = s;
	    return R3_POINT_CLASS_ID;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
leaq 0x18(%rdi), %r12
movq %rsi, %rdi
movq %r12, %rsi
callq 0x3d252
leaq 0xa2b52(%rip), %rbp     # 0xe5b98
movsd (%rbp), %xmm2
movapd 0x5efcd(%rip), %xmm1    # 0xa2020
xorpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4307a
ucomisd %xmm0, %xmm2
jb 0x4307a
movq %r13, %rdi
movq %r15, %rsi
callq 0x46f51
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
leal (%rcx,%rcx,2), %eax
jmp 0x430f7
movq %r13, %rdi
movq %r15, %rsi
movsd %xmm0, (%rsp)
callq 0x49617
movapd 0x5ef8e(%rip), %xmm2    # 0xa2020
xorpd %xmm2, %xmm0
divsd (%rsp), %xmm0
movsd (%rbp), %xmm1
xorpd %xmm2, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
ja 0x430f7
testq %r14, %r14
je 0x430e9
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movapd %xmm0, (%rsp)
callq 0x3d962
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3c877
movq %r14, %rdi
movq %r12, %rsi
callq 0x3c89a
movapd (%rsp), %xmm0
movl $0x1, %eax
testq %rbx, %rbx
je 0x430f7
movsd %xmm0, (%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Ray const&, gaps::R3Halfspace const&, gaps::R3Point*, double*)
RNClassID R3Intersects(const R3Ray& ray, const R3Halfspace& halfspace, 
    R3Point *hit_point, RNScalar *hit_t)
{
    // Check if halfspace contains point
    RNBoolean pinside = R3Contains(halfspace, ray.Start());

    // Check whether vectors point in same direction
    RNBoolean vinside = RNIsPositive(halfspace.Normal().Dot(ray.Vector()));

    // Classify ray with respect to halfspace
    if (pinside) {
	// Start point of ray is inside halfspace
	if (hit_point) *hit_point = ray.Start();
	if (hit_t) *hit_t = 0.0;
	if (vinside) return R3_RAY_CLASS_ID;
	else return R3_SPAN_CLASS_ID;
    }
    else {
	if (vinside) return R3Intersects(ray, halfspace.Plane(), hit_point, hit_t);
	else return RN_NULL_CLASS_ID;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq %rsi, %rdi
movq %r15, %rsi
callq 0x47a86
movl %eax, %ebp
leaq 0x18(%r15), %rsi
movq %r12, %rdi
callq 0x3d252
leaq 0xa2a5a(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
testl %ebp, %ebp
je 0x43186
testq %r14, %r14
je 0x4316c
movq %r14, %rdi
movq %r15, %rsi
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, (%rsp)
callq 0x3c89a
movsd (%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
testq %rbx, %rbx
je 0x43178
movq $0x0, (%rbx)
xorl %eax, %eax
ucomisd %xmm1, %xmm0
setbe %al
addl $0x3, %eax
jmp 0x4318e
xorl %eax, %eax
ucomisd %xmm1, %xmm0
ja 0x4319b
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x43016