// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rdi, %rbx
leaq 0x915b(%rip), %rdi      # 0xf077
callq 0x5570
movq 0x100(%rbx), %r14
movq %rbx, 0x8(%rsp)
leaq 0xf0(%rbx), %rbp
cmpq %rbp, %r14
je 0x628c
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
leaq 0x8293(%rip), %rdi      # 0xe1e4
movl %r15d, %esi
xorl %eax, %eax
callq 0x5060
movq 0x20(%r14), %r13
leaq 0x8660(%rip), %rdi      # 0xe5c6
movq %r13, %rsi
xorl %eax, %eax
callq 0x5060
movq 0x40(%r14), %r12
leaq 0x8653(%rip), %rdi      # 0xe5ce
movq %r12, %rsi
xorl %eax, %eax
callq 0x5060
movq %r13, %rdi
callq 0x5150
decq %rax
cmpq $0xb, %rax
ja 0x6273
leaq 0x806f(%rip), %rcx      # 0xe010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, %edx
movq %r13, %rdi
leaq 0x87ae(%rip), %rsi      # 0xe767
callq 0x5490
testl %eax, %eax
jne 0x5fd6
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0xb0(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x878d(%rip), %rsi      # 0xe772
callq 0x5490
testl %eax, %eax
jne 0x6002
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0xb8(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8587(%rip), %rsi      # 0xe598
callq 0x5490
testl %eax, %eax
jne 0x602b
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0x30(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8560(%rip), %rsi      # 0xe59a
callq 0x5490
testl %eax, %eax
jne 0x6054
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0x38(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x86f0(%rip), %rsi      # 0xe753
callq 0x5490
testl %eax, %eax
jne 0x607d
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0x40(%rcx)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8219(%rip), %rsi      # 0xe2a5
callq 0x5490
testl %eax, %eax
je 0x622c
movl 0x4(%rsp), %r12d
jmp 0x6248
movl $0xb, %edx
movq %r13, %rdi
leaq 0x820f(%rip), %rsi      # 0xe2c1
callq 0x5490
testl %eax, %eax
jne 0x60d2
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x54b0
movl %eax, 0x4(%rsp)
cmpl $0x1, %eax
sbbl $-0x1, %ebx
movl $0xb, %edx
movq %r13, %rdi
leaq 0x81cc(%rip), %rsi      # 0xe2ad
callq 0x5490
testl %eax, %eax
jne 0x6273
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x50b0
movl %eax, 0x4(%rsp)
cmpl $0x1, %eax
sbbl $-0x1, %ebx
jmp 0x6273
movl $0x2, %edx
movq %r13, %rdi
leaq 0x8485(%rip), %rsi      # 0xe59e
callq 0x5490
testl %eax, %eax
jne 0x6273
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x56f0
movl $0x0, 0x4(%rsp)
jmp 0x6273
movl $0xc, %edx
movq %r13, %rdi
leaq 0x846a(%rip), %rsi      # 0xe5b9
callq 0x5490
testl %eax, %eax
jne 0x6273
movq %r12, %rsi
callq 0x5470
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
addl %ecx, %ebx
negl %ecx
movl %ecx, 0x4(%rsp)
jmp 0x6273
movl $0x5, %edx
movq %r13, %rdi
leaq 0x841d(%rip), %rsi      # 0xe5a4
callq 0x5490
testl %eax, %eax
jne 0x6273
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0x48(%rcx)
jmp 0x6273
movl $0x8, %edx
movq %r13, %rdi
leaq 0x83f7(%rip), %rsi      # 0xe5b0
callq 0x5490
testl %eax, %eax
jne 0x61d3
movq %r12, %rdi
callq 0x5430
movq 0x8(%rsp), %rcx
movq %rax, 0x50(%rcx)
movl $0x8, %edx
movq %r13, %rdi
leaq 0x80b2(%rip), %rsi      # 0xe294
callq 0x5490
testl %eax, %eax
jne 0x6273
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x5390
movl %eax, 0x4(%rsp)
jmp 0x6271
movl $0xa, %edx
movq %r13, %rdi
leaq 0x83c6(%rip), %rsi      # 0xe5d7
callq 0x5490
testl %eax, %eax
jne 0x6273
movq %r12, %rdi
callq 0x55a0
movq 0x8(%rsp), %rcx
movl %eax, 0x24(%rcx)
jmp 0x6273
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x54c0
xorl %r12d, %r12d
testl %eax, %eax
setne %r12b
addl %r12d, %ebx
negl %r12d
movl $0x1, %edx
movq %r13, %rdi
leaq 0x8345(%rip), %rsi      # 0xe59c
callq 0x5490
testl %eax, %eax
sete %al
movl %r12d, 0x4(%rsp)
testl %r12d, %r12d
setne %cl
andb %al, %cl
movzbl %cl, %eax
addl %eax, %ebx
movq %r14, %rdi
callq 0x5200
movq %rax, %r14
incl %r15d
cmpq %rbp, %rax
jne 0x5f4a
jmp 0x6296
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x53e0
addl %ebx, %eax
jne 0x6469
cmpl $0x0, 0x18(%r14)
movq %r14, %rbx
jne 0x631b
leaq 0x8dd8(%rip), %rdi      # 0xf094
callq 0x5570
movq 0x30(%rbx), %rdx
movq 0x38(%rbx), %r14
leaq -0x1(%rdx), %r15
cmpq $0x1, %rdx
cmoveq %rdx, %r15
movq 0x40(%rbx), %rsi
leaq -0x1(%rsi), %rcx
cmpq $0x1, %rsi
cmoveq %rsi, %rcx
movq %r14, %rax
subq $0x1, %rax
cmoveq %r14, %rax
jae 0x62f7
movq %rdx, %r14
jmp 0x6315
imulq %rdx, %r14
testq %rsi, %rsi
je 0x6311
imulq %rsi, %r14
imulq %r15, %rax
imulq %rcx, %rax
movq %rax, %r15
jmp 0x6315
imulq %rax, %r15
cmpl $0x0, 0x18(%rbx)
je 0x632f
leaq 0x8dad(%rip), %rdi      # 0xf0cf
callq 0x5570
movq 0x48(%rbx), %r14
movq 0x50(%rbx), %r15
leaq 0x82e0(%rip), %rdi      # 0xe616
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5060
testq %r14, %r14
je 0x645d
testq %r15, %r15
je 0x645d
movl $0x1, 0x14(%rsp)
cmpl $0x0, 0x20(%rbx)
jle 0x647f
leaq 0x58(%rbx), %r12
shlq $0x3, %r15
leaq 0x88(%rbx), %rax
movq %rax, 0x20(%rsp)
shlq $0x3, %r14
leaq 0x14(%rsp), %r13
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
callq 0x51f0
cmpl $0x1, (%rax)
jne 0x63c0
movq %r14, %rdi
callq 0x54e0
movq %rax, 0x18(%rsp)
movq 0x90(%rbx), %rsi
cmpq 0x98(%rbx), %rsi
je 0x63fa
movq %rax, (%rsi)
addq $0x8, 0x90(%rbx)
jmp 0x6409
movq %r12, %rdi
movq %r13, %rsi
callq 0x51f0
cmpl $0x2, (%rax)
jne 0x6447
movq %r15, %rdi
callq 0x54e0
movq %rax, 0x18(%rsp)
movq 0x90(%rbx), %rsi
cmpq 0x98(%rbx), %rsi
je 0x641e
movq %rax, (%rsi)
addq $0x8, 0x90(%rbx)
jmp 0x642d
movq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x5710
movq 0x18(%rsp), %rsi
cmpq $0x1, %rsi
adcl $0x0, %ebp
leaq 0x8226(%rip), %rdi      # 0xe642
jmp 0x6440
movq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x5710
movq 0x18(%rsp), %rsi
cmpq $0x1, %rsi
adcl $0x0, %ebp
leaq 0x8223(%rip), %rdi      # 0xe663
xorl %eax, %eax
callq 0x5060
movl 0x14(%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%rsp)
cmpl 0x20(%rbx), %eax
jl 0x6386
jmp 0x6481
leaq 0x8cc7(%rip), %rdi      # 0xf12b
callq 0x5570
leaq 0x8172(%rip), %rdi      # 0xe5e2
movl $0x1, %ebx
movl $0x1, %esi
jmp 0x6590
xorl %ebp, %ebp
movl 0x18(%rbx), %eax
cmpq $0x6, %rax
ja 0x64b4
leaq 0x7baf(%rip), %rcx      # 0xe040
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %eax
jmp 0x64ad
movl $0x3, %eax
jmp 0x64ad
movl $0x8, %eax
movq %rax, 0xa8(%rbx)
xorl %ecx, %ecx
cmpq $0x0, 0xa0(%rbx)
jne 0x64e4
movq 0x50(%rbx), %rdi
imulq 0xa8(%rbx), %rdi
shlq $0x3, %rdi
callq 0x54e0
movq %rax, 0xa0(%rbx)
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
addl %ecx, %ebp
testl %ebp, %ebp
je 0x657c
leaq 0x8c14(%rip), %rdi      # 0xf109
callq 0x5570
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x650b
callq 0x5420
movq 0x88(%rbx), %r15
movq 0x90(%rbx), %rax
cmpq %rax, %r15
je 0x6562
leaq 0x815d(%rip), %r14      # 0xe682
movq (%r15), %rsi
testq %rsi, %rsi
je 0x6546
movq %r14, %rdi
xorl %eax, %eax
callq 0x5060
movq (%r15), %rdi
callq 0x5420
movq 0x90(%rbx), %rax
addq $0x8, %r15
cmpq %rax, %r15
jne 0x6525
movq 0x88(%rbx), %rcx
cmpq %rcx, %rax
je 0x6562
movq %rcx, 0x90(%rbx)
leaq 0x8079(%rip), %rdi      # 0xe5e2
movl $0x1, %ebx
movl $0x1, %esi
xorl %eax, %eax
callq 0x5060
jmp 0x6587
movl $0x2, 0x8(%rbx)
movl 0x4(%rsp), %ebx
leaq 0x8111(%rip), %rdi      # 0xe69f
movl %ebx, %esi
xorl %eax, %eax
callq 0x5060
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq