// File: /workspace/github_cpp_makefile_star2_O1/nompelis[P]INTecplotLib/intecplot.cpp
// Function: inTec_Zone::ManageInternals()
int inTec_Zone::ManageInternals( void )
{
#ifdef _DEBUG_
   printf(" i Inside ManageInternals() \n");
#endif
   int ierror=0,iret=0;

   // processing individual keywords
   const char *string=NULL,*string2=NULL;
   size_t is;
   int i=0;
   std::map< std::string, std::string > :: iterator imap;
   for( imap = keywords.begin(); imap != keywords.end(); ++imap ) {
      printf("   %d  ", i++ );
      string = (*imap).first.c_str();
      printf("   %s  ", string );
      string2 = (*imap).second.c_str();
      printf("   \"%s\"\n", string2 );

      // keywords by size
      is = strlen( string );

      if( is == 1 ) {
         if( strncasecmp( string, "N", 1 ) == 0 ) {
            iold_n = (unsigned long) atol( string2 );
         }

         if( strncasecmp( string, "E", 1 ) == 0 ) {
            iold_e = (unsigned long) atol( string2 );
         }

         if( strncasecmp( string, "I", 1 ) == 0 ) {
            im = (unsigned long) atol( string2 );
         }
         if( strncasecmp( string, "J", 1 ) == 0 ) {
            jm = (unsigned long) atol( string2 );
         }
         if( strncasecmp( string, "K", 1 ) == 0 ) {
            km = (unsigned long) atol( string2 );
         }
         if( strncasecmp( string, "T", 1 ) == 0 ) {
            iret = HandleKeyword_T( string2 );
            if( iret != 0 ) ierror += 1;
         }
         if( strncasecmp( string, "F", 1 ) == 0 ) {
         // will deal with this later...
         // iret = HandleKeyword_F( string2 );
            if( iret != 0 ) ierror += 1;
         }
      }

      if( is == 2 ) {
         if( strncasecmp( string, "DT", 2 ) == 0 ) {
            // will do this later...
         }

         if( strncasecmp( string, "ET", 2 ) == 0 ) {
            iret = HandleKeyword_ET( string2 );
            if( iret != 0 ) ierror += 1;
         }

         if( strncasecmp( string, "NV", 2 ) == 0 ) {
            // will do this later...
         }

      }

      if( is == 5 ) {
         if( strncasecmp( string, "NODES", 5 ) == 0 ) {
            nodes = (unsigned long) atol( string2 );
         }

      }

      if( is == 8 ) {
         if( strncasecmp( string, "ELEMENTS", 8 ) == 0 ) {
            elems = (unsigned long) atol( string2 );
         }

         if( strncasecmp( string, "ZONETYPE", 8 ) == 0 ) {
            iret = HandleKeyword_Zonetype( string2 );
            if( iret != 0 ) ierror += 1;
         }
      }

      if( is == 10 ) {
         if( strncasecmp( string, "PARENTZONE", 10 ) == 0 ) {
            parent_zone = atoi( string2 );
         }
      }

      if( is == 11 ) {
         if( strncasecmp( string, "VARLOCATION", 11 ) == 0 ) {
            iret = HandleKeyword_Varlocation( string2 );
            if( iret != 0 ) ierror += 1;
         }
         if( strncasecmp( string, "DATAPACKING", 11 ) == 0 ) {
            iret = HandleKeyword_Datapacking( string2 );
            if( iret != 0 ) ierror += 1;
         }

      }

      if( is == 12 ) {
         if( strncasecmp( string, "VARSHARELIST", 12 ) == 0 ) {
            iret = HandleKeyword_Varsharelist( string2 );
            if( iret != 0 ) ierror += 1;
         }
      }

   }

   // sanity checks for the zone's collected keywords
   ierror += ConsistencyCheck();

   // final error check
   if( ierror != 0 ) {
      iret = 1;
#ifdef _DEBUG_
      printf(" e Exiting ManageInternals() in error (return %d) \n",iret);
#endif
      return( iret );
   }

   //
   // allocate memory for variables
   //

   // get a vertex and cell count
   size_t iv=0,ie=0;

   // first try the ordered zone sizes
   if( ietype == ORDERED ) {
      unsigned long imt,jmt,kmt;
#ifdef _DEBUG_
      printf(" i Internal var. \"ietype\" indicates it is an ORDERED zone \n");
#endif
      if( im - 1 == 0 ) { imt = 2; } else { imt = im; }
      if( jm - 1 == 0 ) { jmt = 2; } else { jmt = jm; }
      if( km - 1 == 0 ) { kmt = 2; } else { kmt = km; }

      if( jm > 0 ) {
         if( km > 0 ) {
            iv = (size_t) (im*jm*km);
            ie = (size_t) ((imt-1)*(jmt-1)*(kmt-1));
         } else {
            iv = (size_t) (im*jm);
            ie = (size_t) ((imt-1)*(jmt-1));
         }
      } else {
         iv = (size_t) im;
         ie = (size_t) (imt-1);
      }
   }

   // then try the unstruct. zone sizes
   if( ietype != ORDERED ) {
#ifdef _DEBUG_
      printf(" i Internal var. \"ietype\" indicates it is an unstr. zone \n");
#endif
      iv = (size_t) nodes;
      ie = (size_t) elems;
   }

#ifdef _DEBUG_
   printf(" i Number of vertices  %ld, elements  %ld \n",
          (unsigned long) iv, (unsigned long) ie );
#endif

   // sanity check
   if( iv <= 0 || ie <= 0 ) {
      printf(" e Cannot have zero nodes or zero elements \n");
      iret = 1;
#ifdef _DEBUG_
      printf(" e Exiting ManageInternals() in error (return %d) \n",iret);
#endif
      return( iret );
   }

   // allocate memory for data arrays
   for(int n=1;n<=num_var;++n) {
      if( ivar_loc[n] == 1 ) {
         double *p = (double *) malloc(iv*sizeof(double));
         var_vec.push_back( p );
         if( p == NULL ) ierror += 1;
#ifdef _DEBUG_
         printf(" --- Vertex-data pointer at %p \n", p );
#endif
      } else if( ivar_loc[n] == 2 ) {
         double *p = (double *) malloc(ie*sizeof(double));
         var_vec.push_back( p );
         if( p == NULL ) ierror += 1;
#ifdef _DEBUG_
         printf(" --- Cell-data pointer at %p \n", p );
#endif
      } else {
         // allow for the provision to skip allocating memory for a variable
      }
   }

   // allocate memory for connectivity if needed
   if( ietype != ORDERED ) {
      if( ietype == FETRIANGLE ) ncon = 3;
      if( ietype == FEQUADRILATERAL) ncon = 4;
      if( ietype == FETETRAHEDRON) ncon = 4;
      if( ietype == FEBRICK) ncon = 8;

      size_t isize = (size_t) (elems*ncon);
      if( icon == NULL ) {
         icon = (unsigned long *) malloc(isize*sizeof(unsigned long));
      }
      if( icon == NULL ) ierror += 1;
   }

   // drop all memory on any allocation error
   if( ierror != 0 ) {
#ifdef _DEBUG_
      printf(" e There was an allocation error!\n");
#endif
      if( icon != NULL ) free( icon );

      std::vector< double * > :: iterator dpi;
      for( dpi = var_vec.begin() ; dpi != var_vec.end() ; ++dpi ) {
         if( (*dpi) != NULL ) {
#ifdef _DEBUG_
            printf(" --- Freeing memory at: %p \n", (*dpi) );
#endif
            free( (*dpi) );
         }
      }
      var_vec.clear();

      iret = 1;
#ifdef _DEBUG_
      printf(" e Exiting ManageInternals() in error (return %d) \n",iret);
#endif
   } else {
      istate = 2;    // implies a state of reading numerical values
   }

/*
   // set certain internal counters for numeric data reading (later)
   var_no_cnt = 0;
   var_cc_cnt = 0;
   for(int n=1;n<=num_var;++n) {
      if( ivar_loc[n] == 1 ) {
         var_no_cnt += 1;
      } else if( ivar_loc[n] == 2 ) {
         var_cc_cnt += 1;
      } else {
         // I have not thought about this one...
      }
   }
*///HACK

#ifdef _DEBUG_
   printf(" i Exiting ManageInternals() (return %d) \n",iret);
#endif
//printf("EXITING PREMATURELY IN MANAGE...\n");exit(1);//HACK
   return( iret );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x90bd(%rip), %rdi      # 0xefdf
callq 0x5580
movq 0x100(%rbx), %r14
movq %rbx, 0x8(%rsp)
leaq 0xf0(%rbx), %rbp
cmpq %rbp, %r14
je 0x62da
leaq 0x8202(%rip), %r12      # 0xe14c
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
movq %rbp, 0x30(%rsp)
movl %ebx, 0x14(%rsp)
movq %r12, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x5060
movq 0x20(%r14), %r13
leaq 0x85b6(%rip), %rdi      # 0xe52e
movq %r13, %rsi
xorl %eax, %eax
callq 0x5060
movq 0x40(%r14), %rsi
leaq 0x85a9(%rip), %rdi      # 0xe536
movq %rsi, 0x18(%rsp)
xorl %eax, %eax
callq 0x5060
movq %r13, %rdi
callq 0x5150
movq %rax, %rbx
cmpq $0x1, %rax
jne 0x610a
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8712(%rip), %rsi      # 0xe6cf
callq 0x54a0
testl %eax, %eax
jne 0x5fdc
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0xb0(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x86ef(%rip), %rsi      # 0xe6da
callq 0x54a0
testl %eax, %eax
jne 0x600a
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0xb8(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x84e7(%rip), %rsi      # 0xe500
callq 0x54a0
testl %eax, %eax
jne 0x6035
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0x30(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x84be(%rip), %rsi      # 0xe502
callq 0x54a0
testl %eax, %eax
jne 0x6060
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0x38(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x864c(%rip), %rsi      # 0xe6bb
callq 0x54a0
testl %eax, %eax
jne 0x608b
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0x40(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8173(%rip), %rsi      # 0xe20d
callq 0x54a0
testl %eax, %eax
je 0x60ae
movl 0x4(%rsp), %ebp
movl 0x14(%rsp), %r12d
jmp 0x60cf
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x54d0
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movl 0x14(%rsp), %r12d
addl %ebp, %r12d
negl %ebp
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8426(%rip), %rsi      # 0xe504
callq 0x54a0
testl %eax, %eax
sete %al
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
setne %cl
andb %al, %cl
movzbl %cl, %eax
addl %eax, %r12d
movl %r12d, 0x14(%rsp)
movq 0x30(%rsp), %rbp
leaq 0x8042(%rip), %r12      # 0xe14c
cmpq $0x2, %rbx
jne 0x613f
movl $0x2, %edx
movq %r13, %rdi
leaq 0x83e7(%rip), %rsi      # 0xe506
callq 0x54a0
testl %eax, %eax
jne 0x613f
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x5700
movl $0x0, 0x4(%rsp)
cmpq $0x8, %rbx
je 0x6180
cmpq $0x5, %rbx
jne 0x61da
movl $0x5, %edx
movq %r13, %rdi
leaq 0x83ae(%rip), %rsi      # 0xe50c
callq 0x54a0
testl %eax, %eax
jne 0x617a
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
cmpq $0x8, %rbx
jne 0x61da
movl $0x8, %edx
movq %r13, %rdi
leaq 0x8389(%rip), %rsi      # 0xe518
callq 0x54a0
testl %eax, %eax
jne 0x61ab
movq 0x18(%rsp), %rdi
callq 0x5440
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
movl $0x8, %edx
movq %r13, %rdi
leaq 0x8042(%rip), %rsi      # 0xe1fc
callq 0x54a0
testl %eax, %eax
jne 0x61da
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x53a0
movl %eax, 0x4(%rsp)
addl %eax, 0x14(%rsp)
cmpq $0xb, %rbx
je 0x621a
cmpq $0xa, %rbx
jne 0x6280
movl $0xa, %edx
movq %r13, %rdi
leaq 0x8346(%rip), %rsi      # 0xe53f
callq 0x54a0
testl %eax, %eax
jne 0x6214
movq 0x18(%rsp), %rdi
callq 0x55b0
movq 0x8(%rsp), %rcx
movl %eax, 0x24(%rcx)
cmpq $0xb, %rbx
jne 0x6280
movl $0xb, %edx
movq %r13, %rdi
leaq 0x8000(%rip), %rsi      # 0xe229
callq 0x54a0
testl %eax, %eax
jne 0x624d
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x54c0
movl %eax, 0x4(%rsp)
cmpl $0x1, %eax
sbbl $-0x1, 0x14(%rsp)
movl $0xb, %edx
movq %r13, %rdi
leaq 0x7fb9(%rip), %rsi      # 0xe215
callq 0x54a0
testl %eax, %eax
jne 0x6280
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x50b0
movl %eax, 0x4(%rsp)
cmpl $0x1, %eax
sbbl $-0x1, 0x14(%rsp)
cmpq $0xc, %rbx
jne 0x62bd
movl $0xc, %edx
movq %r13, %rdi
leaq 0x828c(%rip), %rsi      # 0xe521
callq 0x54a0
testl %eax, %eax
movl 0x14(%rsp), %ebx
jne 0x62c1
movq 0x18(%rsp), %rsi
callq 0x5480
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
addl %ecx, %ebx
negl %ecx
movl %ecx, 0x4(%rsp)
jmp 0x62c1
movl 0x14(%rsp), %ebx
movq %r14, %rdi
callq 0x5200
movq %rax, %r14
incl %r15d
cmpq %rbp, %rax
jne 0x5f5c
jmp 0x62e4
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x53f0
addl %ebx, %eax
jne 0x64cc
cmpl $0x0, 0x18(%r12)
je 0x6308
xorl %ebx, %ebx
xorl %r14d, %r14d
jmp 0x636b
leaq 0x8ced(%rip), %rdi      # 0xeffc
callq 0x5580
movq 0x30(%r12), %rdx
movq 0x38(%r12), %rbx
leaq -0x1(%rdx), %r14
cmpq $0x1, %rdx
cmoveq %rdx, %r14
movq 0x40(%r12), %rsi
leaq -0x1(%rsi), %rcx
cmpq $0x1, %rsi
cmoveq %rsi, %rcx
movq %rbx, %rax
subq $0x1, %rax
cmoveq %rbx, %rax
jae 0x634d
movq %rdx, %rbx
jmp 0x636b
imulq %rdx, %rbx
testq %rsi, %rsi
je 0x6367
imulq %rsi, %rbx
imulq %r14, %rax
imulq %rcx, %rax
movq %rax, %r14
jmp 0x636b
imulq %rax, %r14
cmpl $0x0, 0x18(%r12)
je 0x6389
leaq 0x8cbd(%rip), %rdi      # 0xf037
callq 0x5580
movq 0x48(%r12), %rbx
movq 0x50(%r12), %r14
leaq 0x81ee(%rip), %rdi      # 0xe57e
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x5060
testq %rbx, %rbx
je 0x64c0
testq %r14, %r14
je 0x64c0
movl $0x1, 0x24(%rsp)
cmpl $0x0, 0x20(%r12)
jle 0x64e2
leaq 0x58(%r12), %r15
shlq $0x3, %r14
addq $0x88, %r12
shlq $0x3, %rbx
leaq 0x24(%rsp), %r13
xorl %ebp, %ebp
movq %r15, %rdi
movq %r13, %rsi
callq 0x51f0
cmpl $0x1, (%rax)
jne 0x641d
movq %rbx, %rdi
callq 0x54f0
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rcx
movq 0x90(%rcx), %rsi
cmpq 0x98(%rcx), %rsi
je 0x645c
movq %rax, (%rsi)
addq $0x8, 0x90(%rcx)
jmp 0x6469
movq %r15, %rdi
movq %r13, %rsi
callq 0x51f0
cmpl $0x2, (%rax)
jne 0x64a5
movq %r14, %rdi
callq 0x54f0
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rcx
movq 0x90(%rcx), %rsi
cmpq 0x98(%rcx), %rsi
je 0x647e
movq %rax, (%rsi)
addq $0x8, 0x90(%rcx)
jmp 0x648b
movq %r12, %rdi
leaq 0x28(%rsp), %rdx
callq 0x5720
movq 0x28(%rsp), %rsi
cmpq $0x1, %rsi
adcl $0x0, %ebp
leaq 0x812e(%rip), %rdi      # 0xe5aa
jmp 0x649e
movq %r12, %rdi
leaq 0x28(%rsp), %rdx
callq 0x5720
movq 0x28(%rsp), %rsi
cmpq $0x1, %rsi
adcl $0x0, %ebp
leaq 0x812d(%rip), %rdi      # 0xe5cb
xorl %eax, %eax
callq 0x5060
movl 0x24(%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x24(%rsp)
movq 0x8(%rsp), %rcx
cmpl 0x20(%rcx), %eax
jl 0x63de
jmp 0x64e4
leaq 0x8bcc(%rip), %rdi      # 0xf093
callq 0x5580
leaq 0x8077(%rip), %rdi      # 0xe54a
movl $0x1, %ebx
movl $0x1, %esi
jmp 0x65f9
xorl %ebp, %ebp
movq 0x8(%rsp), %r15
movl 0x18(%r15), %eax
cmpq $0x6, %rax
ja 0x651d
leaq 0x7b16(%rip), %rcx      # 0xe010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %eax
jmp 0x6516
movl $0x3, %eax
jmp 0x6516
movl $0x8, %eax
movq %rax, 0xa8(%r15)
cmpq $0x0, 0xa0(%r15)
jne 0x6543
movq 0x50(%r15), %rdi
imulq 0xa8(%r15), %rdi
shlq $0x3, %rdi
callq 0x54f0
movq %rax, 0xa0(%r15)
cmpq $0x1, 0xa0(%r15)
adcl $0x0, %ebp
testl %ebp, %ebp
je 0x65e4
leaq 0x8b14(%rip), %rdi      # 0xf071
callq 0x5580
movq 0xa0(%r15), %rdi
testq %rdi, %rdi
je 0x6573
callq 0x5430
movq 0x88(%r15), %r14
movq 0x90(%r15), %rax
cmpq %rax, %r14
je 0x65b7
leaq 0x805d(%rip), %rbx      # 0xe5ea
movq (%r14), %rsi
testq %rsi, %rsi
je 0x65a7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5060
movq (%r14), %rdi
callq 0x5430
addq $0x8, %r14
movq 0x90(%r15), %rax
cmpq %rax, %r14
jne 0x658d
movq 0x88(%r15), %rcx
cmpq %rcx, %rax
je 0x65ca
movq %rcx, 0x90(%r15)
leaq 0x7f79(%rip), %rdi      # 0xe54a
movl $0x1, %ebx
movl $0x1, %esi
xorl %eax, %eax
callq 0x5060
jmp 0x65f0
movl $0x2, 0x8(%r15)
movl 0x4(%rsp), %ebx
leaq 0x8010(%rip), %rdi      # 0xe607
movl %ebx, %esi
xorl %eax, %eax
callq 0x5060
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop