// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_get_other_properties
PlyOtherProp *ply_get_other_properties(
  PlyFile *plyfile,
  char *elem_name,
  int offset
)
{
  int i;
  PlyElement *elem;
  PlyOtherProp *other;
  PlyProperty *prop;
  int nprops;

  /* find information about the element */
  elem = find_element (plyfile, elem_name);
  if (elem == NULL) {
    fprintf (stderr, "ply_get_other_properties: Can't find element '%s'\n",
             elem_name);
    return (NULL);
  }

  /* remember that this is the "current" element */
  plyfile->which_elem = elem;

  /* save the offset to where to store the other_props */
  elem->other_offset = offset;

  /* place the appropriate pointers, etc. in the element's property list */
  setup_other_props (elem);

  /* create structure for describing other_props */
  other = (PlyOtherProp *) myalloc (sizeof (PlyOtherProp));
  other->name = my_strdup (elem_name);
#if 0
  if (elem->other_offset == NO_OTHER_PROPS) {
    other->size = 0;
    other->props = NULL;
    other->nprops = 0;
    return (other);
  }
#endif
  other->size = elem->other_size;
  other->props = (PlyProperty **) myalloc (sizeof(PlyProperty) * elem->nprops);
  
  /* save descriptions of each "other" property */
  nprops = 0;
  for (i = 0; i < elem->nprops; i++) {
    if (elem->store_prop[i])
      continue;
    prop = (PlyProperty *) myalloc (sizeof (PlyProperty));
    copy_property (prop, elem->props[i]);
    other->props[nprops] = prop;
    nprops++;
  }
  other->nprops = nprops;

#if 1
  /* set other_offset pointer appropriately if there are NO other properties */
  if (other->nprops == 0) {
    elem->other_offset = NO_OTHER_PROPS;
  }
#endif
  
  /* return structure */
  return (other);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x71970
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x747e9
movq 0xfa803(%rip), %rax     # 0x16efc8
movq (%rax), %rdi
movq 0x30(%rsp), %rdx
leaq 0xc0e74(%rip), %rsi     # 0x135648
movb $0x0, %al
callq 0xf730
movq $0x0, 0x40(%rsp)
jmp 0x74943
movq 0x20(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rax)
movl 0x2c(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x20(%rsp), %rdi
callq 0x74610
movl $0x18, %edi
movl $0x4b4, %esi            # imm = 0x4B4
leaq 0xc0ad1(%rip), %rdx     # 0x1352ef
callq 0x71630
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rdi
callq 0x71680
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movl 0x2c(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x20(%rsp), %rax
movslq 0x10(%rax), %rax
imulq $0x28, %rax, %rax
movl %eax, %edi
movl $0x4bf, %esi            # imm = 0x4BF
leaq 0xc0a87(%rip), %rdx     # 0x1352ef
callq 0x71630
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x74916
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x28(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x748ad
jmp 0x74906
movl $0x28, %edi
movl $0x4c6, %esi            # imm = 0x4C6
leaq 0xc0a31(%rip), %rdx     # 0x1352ef
callq 0x71630
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x71a00
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x74889
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x18(%rsp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x74939
movq 0x20(%rsp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax)