// File: nompelis[P]INTecplotLib/intecplot.cpp
// Function: inTec_Zone::ParseNumericData(char*)
int inTec_Zone::ParseNumericData( char *buf )
{
#ifdef _DEBUG2_
   printf(" i Parsing numeric data \n");
#endif
   // set the numeric parsing state when we first try to parse data
   if( iparse_num == 0 ) {
      iparse_num = 1;      // indicates that we are begining to parse data
   } else if( iparse_num == 1 ) {

   } else if( iparse_num == 2 ) {
      iparse_num = 3;
#ifdef _DEBUG_
   printf(" i Switched to parsing connectivity data \n");
#endif
   } else {
      // now that the check completed; reset bounds?????
   }


#ifdef _DEBUG2_
   printf(" --- String to parse: --->|%s|<---\n", buf );
#endif

   // clean-up all fortran double-precision formatting
   size_t i=0;
   while( buf[i] != '\0' && buf[i] != '\n' ) {
      if( buf[i] == 'd' || buf[i] == 'D' ) buf[i] = 'e';
   // if( buf[i] == ',' ) buf[i] = ' ';
      ++i;
   }

   // parse segments separated by spaces or commas (expecting reals/doubles)
   if( iparse_num == 1 ) {
      char *string,*token,*sr;
      for( i=0, string = buf; ; ++i, string = NULL ) {
         token = strtok_r( string, " ,", &sr );
         if( token == NULL ) break;
#ifdef _DEBUG2_
         printf(" --- token: --->|%s|<--- \n", token );
#endif

         char *c;
         double d = strtod( token, &c );
#ifdef _DEBUG2_
         printf(" --- value: %lf \n", d );
#endif

#ifdef _DEBUG2_
         // display internal counter states
         printf(" --- node_cnt: %ld  elem_cnt: %ld  var_cnt: %d (prior) \n",
                node_cnt, elem_cnt, var_cnt );
#endif

         // get pointer to data array for variable
         double *dp = var_vec[ var_cnt ];
#ifdef _DEBUG2_
         printf(" --- pointer: %p    (varloc.: %d) \n", dp,ivar_loc[var_cnt+1]);
#endif

         if( idatapack == 1 ) {   // POINT
            dp[ node_cnt ] = d;

            // update counters
            ++var_cnt;
            if( var_cnt == num_var ) {
               ++node_cnt;

               // check for a termination condition
               if( node_cnt == nodes ) {
                  node_cnt = 0;
#ifdef _DEBUG_
                  printf(" --- Parsing of variable data ending \n");
#endif
                  if( ietype != ORDERED ) {
                     iparse_num = 2;
                  } else {
                     // set state of zone to "loaded and ready" (ordered zone)
                     istate = 3;
                  }
               }

               var_cnt = 0;
            }

         } else {   // BLOCK
            int iloc = ivar_loc[ var_cnt+1 ];
            if( iloc == 1 ) {
               dp[ node_cnt ] = d;

               ++node_cnt;
               if( node_cnt == nodes ) {
                  ++var_cnt;
                  node_cnt = 0;
               }
            } else if( iloc == 2 ) {
               dp[ elem_cnt ] = d;

               ++elem_cnt;
               if( elem_cnt == elems ) {
                  ++var_cnt;
                  elem_cnt = 0;
               }
            } else {
               // I have not thought about how to do this...
            }

            // termination condition
            if( var_cnt == num_var ) {
               var_cnt = 0;
#ifdef _DEBUG_
               printf(" --- Parsing of numeric data ending \n");
#endif
               if( ietype != ORDERED ) {
                  iparse_num = 2;
               } else {
                  // set state of zone to "loaded and ready" (ordered zone)
                  istate = 3;
               }
            }
         }

      }  // strtok loop
   }  // iparse_num=1

   // parse segments separated by spaces (expecting connectivity in one line)
   if( iparse_num == 3 ) {
      unsigned long n1,n2,n3,n4,n5,n6,n7,n8;
      int ic=0;

      if( ietype == FETRIANGLE ) 
         ic = sscanf( buf, "%ld %ld %ld", &n1,&n2,&n3 );
      if( ietype == FEQUADRILATERAL ) 
         ic = sscanf( buf, "%ld %ld %ld %ld", &n1,&n2,&n3,&n4 );
      if( ietype == FETETRAHEDRON ) 
         ic = sscanf( buf, "%ld %ld %ld %ld", &n1,&n2,&n3,&n4 );
      if( ietype == FEBRICK ) 
         ic = sscanf( buf, "%ld %ld %ld %ld %ld %ld %ld %ld",
                            &n1,&n2,&n3,&n4,&n5,&n6,&n7,&n8 );

#ifdef _DEBUG2_
         printf(" --- Connectivity elements picked: %d \n", ic);
#endif
      if( ic > 0 ) {
         unsigned long n = ncon*icon_cnt;

         if( ic >= 3 ) {
            icon[ n+0 ] = n1;
            icon[ n+1 ] = n2;
            icon[ n+2 ] = n3;
         }
         if( ic >= 4 ) {
            icon[ n+3 ] = n4;
         }
         if( ic >= 8 ) {
            icon[ n+4 ] = n5;
            icon[ n+5 ] = n6;
            icon[ n+6 ] = n7;
            icon[ n+7 ] = n8;
         }

         icon_cnt += 1;
      }

      // indicate that the zone has been filled with data and is ready
      if( icon_cnt == elems ) istate = 3;
   }

   return(0);
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x118(%rax)
jne 0x19d6f
movq 0x28(%rsp), %rax
movl $0x1, 0x118(%rax)
jmp 0x19db2
movq 0x28(%rsp), %rax
cmpl $0x1, 0x118(%rax)
jne 0x19d7f
jmp 0x19db0
movq 0x28(%rsp), %rax
cmpl $0x2, 0x118(%rax)
jne 0x19dac
movq 0x28(%rsp), %rax
movl $0x3, 0x118(%rax)
leaq 0xef4e(%rip), %rdi      # 0x28cf1
movb $0x0, %al
callq 0x13070
jmp 0x19dae
jmp 0x19dae
jmp 0x19db0
jmp 0x19db2
movq $0x0, 0xb8(%rsp)
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x27(%rsp)
je 0x19dfb
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x19e05
jmp 0x19e64
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x64, %eax
je 0x19e37
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x44, %eax
jne 0x19e4b
movq 0xc0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movb $0x65, (%rax,%rcx)
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x19dbe
movq 0x28(%rsp), %rax
cmpl $0x1, 0x118(%rax)
jne 0x1a168
movq $0x0, 0xb8(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0xee7b(%rip), %rsi      # 0x28d1c
leaq 0xa0(%rsp), %rdx
callq 0x14de0
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x19ec6
jmp 0x1a166
movq 0xa8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x13b50
movq 0x28(%rsp), %rax
movsd %xmm0, 0x90(%rsp)
movq %rax, %rdi
addq $0x88, %rdi
movslq 0x130(%rax), %rsi
callq 0x14c90
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq (%rcx), %rcx
movq %rcx, 0x88(%rsp)
cmpl $0x1, 0x1c(%rax)
jne 0x19fd8
movq 0x28(%rsp), %rcx
movsd 0x90(%rsp), %xmm0
movq 0x88(%rsp), %rax
movq 0x120(%rcx), %rdx
movsd %xmm0, (%rax,%rdx,8)
movl 0x130(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x130(%rcx)
movl 0x130(%rcx), %eax
cmpl 0x20(%rcx), %eax
jne 0x19fd3
movq 0x28(%rsp), %rcx
movq 0x120(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x120(%rcx)
movq 0x120(%rcx), %rax
cmpq 0x48(%rcx), %rax
jne 0x19fc4
movq 0x28(%rsp), %rax
movq $0x0, 0x120(%rax)
leaq 0xed8c(%rip), %rdi      # 0x28d1f
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rax
cmpl $0x0, 0x18(%rax)
je 0x19fb6
movq 0x28(%rsp), %rax
movl $0x2, 0x118(%rax)
jmp 0x19fc2
movq 0x28(%rsp), %rax
movl $0x3, 0x8(%rax)
jmp 0x19fc4
movq 0x28(%rsp), %rax
movl $0x0, 0x130(%rax)
jmp 0x1a13f
movq 0x28(%rsp), %rax
movq %rax, %rdi
addq $0x58, %rdi
movl 0x130(%rax), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
leaq 0x80(%rsp), %rsi
callq 0x14210
movl (%rax), %eax
movl %eax, 0x84(%rsp)
cmpl $0x1, 0x84(%rsp)
jne 0x1a076
movq 0x28(%rsp), %rcx
movsd 0x90(%rsp), %xmm0
movq 0x88(%rsp), %rax
movq 0x120(%rcx), %rdx
movsd %xmm0, (%rax,%rdx,8)
movq 0x120(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x120(%rcx)
movq 0x120(%rcx), %rax
cmpq 0x48(%rcx), %rax
jne 0x1a074
movq 0x28(%rsp), %rax
movl 0x130(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x130(%rax)
movq $0x0, 0x120(%rax)
jmp 0x1a0e6
cmpl $0x2, 0x84(%rsp)
jne 0x1a0e2
movq 0x28(%rsp), %rcx
movsd 0x90(%rsp), %xmm0
movq 0x88(%rsp), %rax
movq 0x128(%rcx), %rdx
movsd %xmm0, (%rax,%rdx,8)
movq 0x128(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x128(%rcx)
movq 0x128(%rcx), %rax
cmpq 0x50(%rcx), %rax
jne 0x1a0e0
movq 0x28(%rsp), %rax
movl 0x130(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x130(%rax)
movq $0x0, 0x128(%rax)
jmp 0x1a0e4
jmp 0x1a0e4
jmp 0x1a0e6
movq 0x28(%rsp), %rcx
movl 0x130(%rcx), %eax
cmpl 0x20(%rcx), %eax
jne 0x1a13d
movq 0x28(%rsp), %rax
movl $0x0, 0x130(%rax)
leaq 0xec3a(%rip), %rdi      # 0x28d46
movb $0x0, %al
callq 0x13070
movq 0x28(%rsp), %rax
cmpl $0x0, 0x18(%rax)
je 0x1a12f
movq 0x28(%rsp), %rax
movl $0x2, 0x118(%rax)
jmp 0x1a13b
movq 0x28(%rsp), %rax
movl $0x3, 0x8(%rax)
jmp 0x1a13d
jmp 0x1a13f
jmp 0x1a141
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movq $0x0, 0xb0(%rsp)
jmp 0x19e92
jmp 0x1a168
movq 0x28(%rsp), %rax
cmpl $0x3, 0x118(%rax)
jne 0x1a3b6
movq 0x28(%rsp), %rax
movl $0x0, 0x3c(%rsp)
cmpl $0x2, 0x18(%rax)
jne 0x1a1b6
movq 0xc0(%rsp), %rdi
leaq 0xebe4(%rip), %rsi      # 0x28d80
leaq 0x78(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x68(%rsp), %r8
movb $0x0, %al
callq 0x13f40
movl %eax, 0x3c(%rsp)
movq 0x28(%rsp), %rax
cmpl $0x3, 0x18(%rax)
jne 0x1a1ef
movq 0xc0(%rsp), %rdi
leaq 0xebac(%rip), %rsi      # 0x28d7c
leaq 0x78(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x68(%rsp), %r8
leaq 0x60(%rsp), %r9
movb $0x0, %al
callq 0x13f40
movl %eax, 0x3c(%rsp)
movq 0x28(%rsp), %rax
cmpl $0x5, 0x18(%rax)
jne 0x1a228
movq 0xc0(%rsp), %rdi
leaq 0xeb73(%rip), %rsi      # 0x28d7c
leaq 0x78(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x68(%rsp), %r8
leaq 0x60(%rsp), %r9
movb $0x0, %al
callq 0x13f40
movl %eax, 0x3c(%rsp)
movq 0x28(%rsp), %rax
cmpl $0x6, 0x18(%rax)
jne 0x1a288
movq 0xc0(%rsp), %rdi
leaq 0xeb2a(%rip), %rsi      # 0x28d6c
leaq 0x78(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x68(%rsp), %r8
leaq 0x60(%rsp), %r9
leaq 0x58(%rsp), %rbx
leaq 0x50(%rsp), %r11
leaq 0x48(%rsp), %r10
leaq 0x40(%rsp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x13f40
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
jle 0x1a396
movq 0x28(%rsp), %rcx
movq 0xa8(%rcx), %rax
imulq 0x138(%rcx), %rax
movq %rax, 0x30(%rsp)
cmpl $0x3, 0x3c(%rsp)
jl 0x1a2f9
movq 0x28(%rsp), %rax
movq 0x78(%rsp), %rsi
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x70(%rsp), %rsi
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rdx
movq %rsi, 0x8(%rcx,%rdx,8)
movq 0x68(%rsp), %rdx
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
cmpl $0x4, 0x3c(%rsp)
jl 0x1a31b
movq 0x28(%rsp), %rax
movq 0x60(%rsp), %rdx
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
cmpl $0x8, 0x3c(%rsp)
jl 0x1a37f
movq 0x28(%rsp), %rax
movq 0x58(%rsp), %rsi
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rdx
movq %rsi, 0x20(%rcx,%rdx,8)
movq 0x50(%rsp), %rsi
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rdx
movq %rsi, 0x28(%rcx,%rdx,8)
movq 0x48(%rsp), %rsi
movq 0xa0(%rax), %rcx
movq 0x30(%rsp), %rdx
movq %rsi, 0x30(%rcx,%rdx,8)
movq 0x40(%rsp), %rdx
movq 0xa0(%rax), %rax
movq 0x30(%rsp), %rcx
movq %rdx, 0x38(%rax,%rcx,8)
movq 0x28(%rsp), %rax
movq 0x138(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x138(%rax)
movq 0x28(%rsp), %rcx
movq 0x138(%rcx), %rax
cmpq 0x50(%rcx), %rax
jne 0x1a3b4
movq 0x28(%rsp), %rax
movl $0x3, 0x8(%rax)
jmp 0x1a3b6
xorl %eax, %eax
addq $0xd0, %rsp
popq %rbx
retq
nopw %cs:(%rax,%rax)