// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x39180
testq %rax, %rax
je 0x3ace6
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x3ac2a
movq 0x8(%r14), %rdi
movslq (%r14), %rsi
shlq $0x5, %rsi
incq %rsi
callq 0xe7d0
movq %rax, 0x8(%r14)
movslq (%r14), %r12
leal 0x1(%r12), %ecx
shlq $0x5, %r12
addq %rax, %r12
movl %ecx, (%r14)
jmp 0x3ac66
leaq 0x5ec6a(%rip), %r12     # 0x9989b
pushq $0x10
popq %rdi
movl $0x506, %esi            # imm = 0x506
movq %r12, %rdx
callq 0x38f69
movq %rax, %r14
movq %rax, 0x48(%rbx)
pushq $0x20
popq %rdi
movl $0x508, %esi            # imm = 0x508
movq %r12, %rdx
callq 0x38f69
movq %rax, %r12
movq %rax, 0x8(%r14)
movl $0x1, (%r14)
movl %ebp, 0x8(%r12)
movq %r15, %rdi
callq 0x38fa9
movq %rax, (%r12)
movslq 0x8(%r12), %rdi
shlq $0x3, %rdi
callq 0xe600
movq %rax, 0x10(%r12)
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3aac5
movq %rax, 0x18(%r12)
pushq $0x8
popq %r15
movslq 0x8(%r12), %rax
cmpq %rax, %r13
jge 0x3acd4
movq %r15, %rdi
callq 0xe600
movq 0x10(%r12), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x10(%r12), %rax
movq (%rax,%r13,8), %rsi
movq %rbx, %rdi
callq 0x3a53e
incq %r13
jmp 0x3aca3
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9f2d3(%rip), %rax     # 0xd9fc0
movq (%rax), %rdi
leaq 0x5eed1(%rip), %rsi     # 0x99bc8
movq %r15, %rdx
xorl %eax, %eax
callq 0xe6a0
pushq $-0x1
popq %rdi
callq 0xe570