// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/ply.cpp
// Function: get_item_value(char*, int)
double get_item_value(char *item, int type)
{
  unsigned char *puchar;
  char *pchar;
  short int *pshort;
  unsigned short int *pushort;
  int *pint;
  unsigned int *puint;
  float *pfloat;
  double *pdouble;
  int int_value;
  unsigned int uint_value;
  double double_value;

  switch (type) {
    case PLY_CHAR:
      pchar = (char *) item;
      int_value = *pchar;
      return ((double) int_value);
    case PLY_UCHAR:
      puchar = (unsigned char *) item;
      int_value = *puchar;
      return ((double) int_value);
    case PLY_SHORT:
      pshort = (short int *) item;
      int_value = *pshort;
      return ((double) int_value);
    case PLY_USHORT:
      pushort = (unsigned short int *) item;
      int_value = *pushort;
      return ((double) int_value);
    case PLY_INT:
      pint = (int *) item;
      int_value = *pint;
      return ((double) int_value);
    case PLY_UINT:
      puint = (unsigned int *) item;
      uint_value = *puint;
      return ((double) uint_value);
    case PLY_FLOAT:
      pfloat = (float *) item;
      double_value = *pfloat;
      return (double_value);
    case PLY_DOUBLE:
      pdouble = (double *) item;
      double_value = *pdouble;
      return (double_value);
    default:
      fprintf (stderr, "get_item_value: bad type = %d\n", type);
      exit (-1);
      return 0.0;
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movl 0x64(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x7, %eax
ja 0x75712
movq 0x8(%rsp), %rax
leaq 0xbfcb9(%rip), %rcx     # 0x135288
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x68(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movsbl (%rax), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movzbl (%rax), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movswl (%rax), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movzwl (%rax), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sdl 0x1c(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0x68(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x75738
movq 0xf98af(%rip), %rax     # 0x16efc8
movq (%rax), %rdi
movl 0x64(%rsp), %edx
leaq 0xc00d9(%rip), %rsi     # 0x135800
movb $0x0, %al
callq 0xf730
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xf600
movsd 0x70(%rsp), %xmm0
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)