// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: get_binary_item(_IO_FILE*, int, int, int*, unsigned int*, double*)
void get_binary_item(
  FILE *fp,
  int file_type,
  int type,
  int *int_val,
  unsigned int *uint_val,
  double *double_val
)
{
  char c[8];
  void *ptr;

  ptr = (void *) c;

  if (fread (ptr, ply_type_size[type], 1, fp) != (unsigned int) 1) {
    fprintf(stderr, "Unable to read item from ply file\n");
    return;
  }
  
  if ((file_type != native_binary_type) && (ply_type_size[type] > 1))
     swap_bytes((char *)ptr, ply_type_size[type]);

  switch (type) {
    case PLY_CHAR:
      *int_val = *((char *) ptr);
      *uint_val = (*int_val >= 0) ? *int_val : 0;
      *double_val = *int_val;
      break;
    case PLY_UCHAR:
      *uint_val = *((unsigned char *) ptr);
      *int_val = *uint_val;
      *double_val = *uint_val;
      break;
    case PLY_SHORT:
      *int_val = *((short int *) ptr);
      *uint_val = (*int_val >= 0) ? *int_val : 0;
      *double_val = *int_val;
      break;
    case PLY_USHORT:
      *uint_val = *((unsigned short int *) ptr);
      *int_val = *uint_val;
      *double_val = *uint_val;
      break;
    case PLY_INT:
      *int_val = *((int *) ptr);
      *uint_val = (*int_val >= 0) ? *int_val : 0;
      *double_val = *int_val;
      break;
    case PLY_UINT:
      *uint_val = *((unsigned int *) ptr);
      *int_val = *uint_val;
      *double_val = *uint_val;
      break;
    case PLY_FLOAT:
      *double_val = *((float *) ptr);
      *int_val = (int) *double_val;
      *uint_val = (*double_val >= 0) ? (unsigned int) *double_val : 0;
      break;
    case PLY_DOUBLE:
      *double_val = *((double *) ptr);
      *int_val = (int) *double_val;
      *uint_val = (*double_val >= 0) ? (unsigned int) *double_val : 0;
      break;
    default:
      fprintf (stderr, "get_binary_item: bad type = %d\n", type);
      exit (-1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %rbx
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rcx
movslq %edx, %r13
leaq 0x9fa36(%rip), %r14     # 0xdaa80
movslq (%r14,%r13,4), %rsi
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0xe6f0
cmpq $0x1, %rax
jne 0x3b15a
movzbl 0x4a0b0c(%rip), %eax    # 0x4dbb78
decl %eax
orl $0x3, %eax
cmpl %ebp, %eax
je 0x3b088
movl (%r14,%r13,4), %esi
cmpl $0x2, %esi
jl 0x3b088
leaq 0x8(%rsp), %rdi
callq 0x3b1a7
leal -0x1(%r12), %eax
cmpl $0x7, %eax
ja 0x3b184
leaq 0x5e753(%rip), %rcx     # 0x997f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl 0x8(%rsp), %eax
jmp 0x3b0f5
movzwl 0x8(%rsp), %eax
jmp 0x3b10c
movl 0x8(%rsp), %eax
movl %eax, (%r15)
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
jmp 0x3b0ff
movzbl 0x8(%rsp), %eax
jmp 0x3b10c
movsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax)
cvttsd2si %xmm0, %eax
movl %eax, (%r15)
xorpd %xmm1, %xmm1
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
jmp 0x3b149
movswl 0x8(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl %eax, (%r15)
cmovnsl %eax, %ecx
movl %ecx, (%rbx)
cvtsi2sdl (%r15), %xmm0
jmp 0x3b118
movl 0x8(%rsp), %eax
movl %eax, (%rbx)
movl %eax, (%r15)
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x3b14b
movss 0x8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x10(%rsp), %rax
movsd %xmm1, (%rax)
cvttss2si %xmm0, %eax
movl %eax, (%r15)
xorps %xmm1, %xmm1
maxss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movl %eax, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9ee5f(%rip), %rax     # 0xd9fc0
movq (%rax), %rcx
leaq 0x5ec1f(%rip), %rdi     # 0x99d8a
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8e0
movq 0x9ee35(%rip), %rax     # 0xd9fc0
movq (%rax), %rdi
leaq 0x5ec18(%rip), %rsi     # 0x99dad
movl %r12d, %edx
xorl %eax, %eax
callq 0xe6a0
pushq $-0x1
popq %rdi
callq 0xe570