// File: /workspace/github_cpp_makefile_star2_O3/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, 0x8(%rsp)
movq %r8, 0x10(%rsp)
movq %rcx, %r15
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rcx
movslq %edx, %r14
leaq 0xa59b2(%rip), %rbx     # 0xe5a70
movslq (%rbx,%r14,4), %rsi
movq %rsp, %r13
movl $0x1, %edx
movq %r13, %rdi
callq 0xe6c0
cmpq $0x1, %rax
jne 0x401f4
movzbl 0x4a6a85(%rip), %eax    # 0x4e6b68
decl %eax
orl $0x3, %eax
cmpl %ebp, %eax
je 0x4011b
movslq (%rbx,%r14,4), %rcx
cmpq $0x2, %rcx
jl 0x4011b
movl %ecx, %eax
shrl %eax
addq %r13, %rcx
decq %rcx
xorl %edx, %edx
movb (%rsp,%rdx), %sil
movb (%rcx), %dil
movb %dil, (%rsp,%rdx)
movb %sil, (%rcx)
incq %rdx
decq %rcx
cmpq %rdx, %rax
jne 0x40102
leal -0x1(%r12), %eax
cmpl $0x7, %eax
ja 0x401fb
leaq 0x68710(%rip), %rcx     # 0xa8840
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl (%rsp), %eax
jmp 0x40182
movzwl (%rsp), %eax
jmp 0x4019d
movl (%rsp), %eax
movl %eax, (%r15)
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
jmp 0x4018c
movzbl (%rsp), %eax
jmp 0x4019d
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax)
cvttsd2si %xmm0, %eax
movl %eax, (%r15)
xorpd %xmm1, %xmm1
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
jmp 0x401de
movswl (%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl %eax, (%r15)
cmovnsl %eax, %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
cvtsi2sdl (%r15), %xmm0
jmp 0x401ae
movl (%rsp), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %eax, (%r15)
movl (%rcx), %eax
cvtsi2sd %rax, %xmm0
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x401e5
movss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x8(%rsp), %rax
movsd %xmm1, (%rax)
cvttss2si %xmm0, %eax
movl %eax, (%r15)
xorps %xmm1, %xmm1
maxss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xed51
jmp 0x401e5
movl %r12d, %edi
callq 0xed6d