// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: ply_header_complete
void ply_header_complete(PlyFile *plyfile)
{
  int i,j;
  FILE *fp = plyfile->fp;
  PlyElement *elem;
  PlyProperty *prop;

  fprintf (fp, "ply\n");

  switch (plyfile->file_type) {
    case PLY_ASCII:
      fprintf (fp, "format ascii 1.0\n");
      break;
    case PLY_BINARY_BE:
      fprintf (fp, "format binary_big_endian 1.0\n");
      break;
    case PLY_BINARY_LE:
      fprintf (fp, "format binary_little_endian 1.0\n");
      break;
    default:
      fprintf (stderr, "ply_header_complete: bad file type = %d\n",
               plyfile->file_type);
      exit (-1);
  }

  /* write out the comments */

  for (i = 0; i < plyfile->num_comments; i++)
    fprintf (fp, "comment %s\n", plyfile->comments[i]);

  /* write out object information */

  for (i = 0; i < plyfile->num_obj_info; i++)
    fprintf (fp, "obj_info %s\n", plyfile->obj_info[i]);

  /* write out information about each element */

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

    elem = plyfile->elems[i];
    fprintf (fp, "element %s %d\n", elem->name, elem->num);

    /* write out each property */
    for (j = 0; j < elem->nprops; j++) {
      prop = elem->props[j];
      if (prop->is_list) {
        fprintf (fp, "property list ");
        write_scalar_type (fp, prop->count_external);
        fprintf (fp, " ");
        write_scalar_type (fp, prop->external_type);
        fprintf (fp, " %s\n", prop->name);
      }
      else {
        fprintf (fp, "property ");
        write_scalar_type (fp, prop->external_type);
        fprintf (fp, " %s\n", prop->name);
      }
    }
  }

  fprintf (fp, "end_header\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r12
movq (%rdi), %rbx
leaq 0x604ed(%rip), %rdi     # 0x99966
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0xe8e0
movl 0x8(%r12), %edx
cmpl $0x3, %edx
je 0x394b5
cmpl $0x2, %edx
je 0x394aa
cmpl $0x1, %edx
jne 0x39622
leaq 0x604c5(%rip), %rdi     # 0x9996b
pushq $0x11
jmp 0x394be
leaq 0x604cc(%rip), %rdi     # 0x9997d
pushq $0x1d
jmp 0x394be
leaq 0x604df(%rip), %rdi     # 0x9999b
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0xe8e0
leaq 0x60514(%rip), %r14     # 0x999e5
xorl %r15d, %r15d
jmp 0x394ef
movq 0x28(%r12), %rax
movq (%rax,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xe6a0
incq %r15
movslq 0x20(%r12), %rax
cmpq %rax, %r15
jl 0x394d6
leaq 0x604f1(%rip), %r14     # 0x999f1
xorl %r15d, %r15d
movslq 0x30(%r12), %rax
cmpq %rax, %r15
jge 0x39528
movq 0x38(%r12), %rax
movq (%rax,%r15,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xe6a0
incq %r15
jmp 0x39503
pushq $0x1
popq %rbp
leaq 0x60f7e(%rip), %r15     # 0x9a4b0
xorl %ecx, %ecx
movq %r12, 0x8(%rsp)
movslq 0x10(%r12), %rax
cmpq %rax, %rcx
jge 0x395ff
movq 0x18(%r12), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %r14
movq (%r14), %rdx
movl 0x8(%r14), %ecx
movq %rbx, %rdi
leaq 0x60498(%rip), %rsi     # 0x999fe
xorl %eax, %eax
callq 0xe6a0
xorl %r12d, %r12d
movslq 0x10(%r14), %rax
cmpq %rax, %r12
jge 0x395ed
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %r13
cmpl $0x0, 0x14(%r13)
je 0x395b6
leaq 0x6047e(%rip), %rdi     # 0x99a0d
pushq $0xe
popq %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0xe8e0
movl 0x18(%r13), %esi
movq %rbx, %rdi
callq 0x39642
pushq $0x20
popq %rdi
movq %rbx, %rsi
callq 0xe5c0
jmp 0x395cb
leaq 0x6045f(%rip), %rdi     # 0x99a1c
pushq $0x9
popq %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0xe8e0
movl 0x8(%r13), %esi
movq %rbx, %rdi
callq 0x39642
movq (%r13), %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0xe6a0
incq %r12
jmp 0x39570
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %r12
jmp 0x39539
leaq 0x60420(%rip), %rdi     # 0x99a26
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8e0
movq 0xa0997(%rip), %rax     # 0xd9fc0
movq (%rax), %rdi
leaq 0x60389(%rip), %rsi     # 0x999bc
xorl %eax, %eax
callq 0xe6a0
pushq $-0x1
popq %rdi
callq 0xe570