// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_get_other_element
PlyOtherElems *ply_get_other_element (
  PlyFile *plyfile,
  char *elem_name,
  int elem_count
)
{
  int i;
  PlyElement *elem;
  PlyOtherElems *other_elems;
  OtherElem *other;

  /* look for appropriate element */
  elem = find_element (plyfile, elem_name);
  if (elem == NULL) {
    fprintf (stderr,
             "ply_get_other_element: can't find element '%s'\n", elem_name);
    exit (-1);
  }

  /* create room for the new "other" element, initializing the */
  /* other data structure if necessary */

  if (plyfile->other_elems == NULL) {
    plyfile->other_elems = (PlyOtherElems *) myalloc (sizeof (PlyOtherElems));
    other_elems = plyfile->other_elems;
    other_elems->other_list = (OtherElem *) myalloc (sizeof (OtherElem));
    other = &(other_elems->other_list[0]);
    other_elems->num_elems = 1;
  }
  else {
    other_elems = plyfile->other_elems;
    other_elems->other_list = (OtherElem *) realloc (other_elems->other_list,
                              sizeof (OtherElem) * other_elems->num_elems + 1);
    other = &(other_elems->other_list[other_elems->num_elems]);
    other_elems->num_elems++;
  }

  /* count of element instances in file */
  other->elem_count = elem_count;

  /* save name of element */
  other->elem_name = my_strdup (elem_name);

  /* create a list to hold all the current elements */
  other->other_data = (OtherData **)
                  malloc (sizeof (OtherData *) * other->elem_count);

  /* set up for getting elements */
  other->other_props = ply_get_other_properties (plyfile, elem_name,
                         offsetof(OtherData,other_props));

  /* grab all these elements */
  for (i = 0; i < other->elem_count; i++) {
    /* grab and element from the file */
    other->other_data[i] = (OtherData *) malloc (sizeof (OtherData));
    ply_get_element (plyfile, (void *) other->other_data[i]);
  }

  /* return pointer to the other elements data */
  return (other_elems);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x3e0ee
testq %rax, %rax
je 0x3fde8
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x3fd2a
movq 0x8(%r14), %rdi
movslq (%r14), %rsi
shlq $0x5, %rsi
incq %rsi
callq 0xe7a0
movq %rax, 0x8(%r14)
movslq (%r14), %r12
leal 0x1(%r12), %ecx
shlq $0x5, %r12
addq %rax, %r12
movl %ecx, (%r14)
jmp 0x3fd6a
leaq 0x68bba(%rip), %r12     # 0xa88eb
movl $0x10, %edi
movl $0x506, %esi            # imm = 0x506
movq %r12, %rdx
callq 0x3deec
movq %rax, %r14
movq %rax, 0x48(%rbx)
movl $0x20, %edi
movl $0x508, %esi            # imm = 0x508
movq %r12, %rdx
callq 0x3deec
movq %rax, %r12
movq %rax, 0x8(%r14)
movl $0x1, (%r14)
movl %ebp, 0x8(%r12)
movq %r15, %rdi
callq 0x3df2c
movq %rax, (%r12)
movslq 0x8(%r12), %rdi
shlq $0x3, %rdi
callq 0xe5e0
movq %rax, 0x10(%r12)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3fbab
movq %rax, 0x18(%r12)
cmpl $0x0, 0x8(%r12)
jle 0x3fddc
xorl %r15d, %r15d
movl $0x8, %edi
callq 0xe5e0
movq 0x10(%r12), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x10(%r12), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x3f5d9
incq %r15
movslq 0x8(%r12), %rax
cmpq %rax, %r15
jl 0x3fdab
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0xec6b