// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: get_stored_item(void*, int, int*, unsigned int*, double*)
void get_stored_item(
  void *ptr,
  int type,
  int *int_val,
  unsigned int *uint_val,
  double *double_val
)
{
  switch (type) {
    case PLY_CHAR:
      *int_val = *((char *) ptr);
      *uint_val = *int_val;
      *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_stored_item: bad type = %d\n", type);
      exit (-1);
  }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movl 0x3c(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x18(%rsp)
subl $0x7, %eax
ja 0x72924
movq 0x18(%rsp), %rax
leaq 0xc2b1a(%rip), %rcx     # 0x135208
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x40(%rsp), %rax
movsbl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
movl (%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
cvtsi2sdl (%rax), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movzbl (%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movswl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jl 0x72788
movq 0x30(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x72790
xorl %eax, %eax
movl %eax, 0x14(%rsp)
jmp 0x72790
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
cvtsi2sdl (%rax), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movzwl (%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
cmpl $0x0, (%rax)
jl 0x7280e
movq 0x30(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x10(%rsp)
jmp 0x72816
xorl %eax, %eax
movl %eax, 0x10(%rsp)
jmp 0x72816
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
cvtsi2sdl (%rax), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movl (%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rax
cvttsd2si (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x728b6
movq 0x20(%rsp), %rax
cvttsd2si (%rax), %rax
movl %eax, 0xc(%rsp)
jmp 0x728be
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x728be
movl 0xc(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
jmp 0x7294a
movq 0x40(%rsp), %rax
movsd (%rax), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rax
cvttsd2si (%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x7290f
movq 0x20(%rsp), %rax
cvttsd2si (%rax), %rax
movl %eax, 0x8(%rsp)
jmp 0x72917
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x72917
movl 0x8(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
jmp 0x7294a
movq 0xfc69d(%rip), %rax     # 0x16efc8
movq (%rax), %rdi
movl 0x3c(%rsp), %edx
leaq 0xc2f35(%rip), %rsi     # 0x13586e
movb $0x0, %al
callq 0xf730
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xf600
addq $0x48, %rsp
retq
nop