// File: /workspace/github_cpp_makefile_star2_O3/nompelis[P]INTecplotLib/intecplot.cpp
// Function: inTec_Zone::ParseKeywords(char*)
int inTec_Zone::ParseKeywords( char *buf )
{
#ifdef _DEBUG_
   printf(" i Parsing zone keywords \n");
#endif
   size_t isize=0;
   while( buf[isize] != '\0' && buf[isize] != '\n' ) ++isize;

   char *data;
   // create a duplicate buffer
   data = (char *) malloc(((size_t) (isize+1))*sizeof(char));
   if( data == NULL ) return(-1);

   // copy line to buffer and add termination character
   memcpy( data, buf, isize );
   data[isize] = '\0';
#ifdef _DEBUG3_
   printf("DATA: %s\n",data);
#endif

   // keep parsing for keywords and values
   int np=0;
   int ipar=0, ibra=0, iquote=0, ikey=0, ierror=0, iparse=0;
   char *s=data, *es=NULL;
   size_t n=0;
   while( n <= isize ) {
#ifdef _DEBUG2_
      printf(" (key: %d, quote: %d)  ", ikey,iquote);
      printf("  %c   s: %c   ", data[n],s[0]);
  //  printf("  %c   s: %c    (key: %d, quote: %d)  ", data[n],s[0],ikey,iquote);
#endif
      // space or comma as keyword delimeter
      if( data[n] == ' ' || data[n] == ',' ) {
         if( ikey == 0 ) {
              s = &( data[n+1] );
         } else if( ikey == 1 ) {
            if( data[n] == ',' ) { ierror = 1;printf("This is in error! (1)"); }
         } else if( ikey == 2 ) {
            if( data[n] == ',' ) { ierror = 1;printf("This is in error! (1b)");}
         } else if( ikey == 3 ) {
            if( iquote == 1 || ibra == 1 || ipar == 1 ) {
               // we continue parsing because the quote/bracket/paren. is open
            } else {
               // this terminates the keyword
               ikey = 0;
               // parsing should take place
               iparse = 1;
            }
         }

      } else 

      // equal sign
      if( data[n] == '=' ) {
         if( ikey == 0 ) {
            ierror = 1; printf("This is in error! (2)");
         } else if( ikey == 1 ) {
            // we are moving to the second stage
            es = &( data[n] );
            ikey = 2;
#ifdef _DEBUG2_
            printf(" (equal sign) ");
#endif
         } else if( ikey == 2 ) {
            ierror = 1; printf("This is in error! (2b)");
         } else if( ikey == 3 ) {
            if( iquote == 1 || ibra == 1 || ipar == 1 ) {
               // we continue parsing because the quote/bracket/paren. is open
#ifdef _DEBUG2_
               printf(" (equal sign in key=3) ");
#endif
            } else {
               ierror = 1; printf("This is in error! (3)");
            }
         }
      } else

      // double quote
      if( data[n] == '\"' ) {
         if( ikey < 2 ) {
            ierror = 1; printf("This is in error! (4) (stray quote) ");
         } else if( ikey == 2 ) {
            // entering data section of this keyword
            ikey = 3;
#ifdef _DEBUG2_
            printf(" (start data of keyword) ");
#endif
            // open quote
            iquote = 1;
         } else {
            if( data[n-1] == '\\' ) {
               // simply pick it up as a character
            } else {
               // it is a functional quote (marker)
               if( iquote == 1 ) {
                  // close the quote
                  iquote = 0;
             //   // indicate that we can parse
             //   ikey = 0;
             //   iparse = 1;
                  // let the next encounter terminate the parsing
               } else {
                  ierror = 1; printf("This is in error! (4b) (stray quote) ");
               }
            }
         }
      } else 

      // newline or null
      if( data[n] == '\n' || data[n] == '\0' ) {
         if( ikey == 3 ) {
            if( iquote == 1 || ibra == 1 || ipar == 1 ) {
               ierror = 1;printf("This is in error! (5) (unterminated quote/bracket/paren.) ");
            } else {
               ikey = 0;
               iparse = 1;
#ifdef _DEBUG2_
               printf(" (parsing ending) ");
#endif
            }
         } else if( ikey == 2 ) {
               ierror = 1; printf("This is in error! (5b) (empty keyword) ");
         } else if( ikey == 1 ) {
               ierror = 1; printf("This is in error! (5b) (empty keyword) ");
         } else {
            // termination of parsing everything
#ifdef _DEBUG2_
            printf(" (parsing ending) ");
#endif
         }
      } else 

      // open bracket
      if( data[n] == '[' ) {
         if( ikey < 2 ) {
            ierror = 1; printf("This is in error! (6) (stray bracket) ");
         } else if( ikey == 2 ) {
            // entering data section of this keyword...
            ikey = 3;
            // ...with an open bracket
            ibra = 1;
#ifdef _DEBUG2_
            printf(" (start data of keyword with bracket) ");
#endif
         } else {
            // simply open bracket
            ibra = 1;
#ifdef _DEBUG2_
            printf(" (open bracket) ");
#endif
         }
      } else 

      // close bracket
      if( data[n] == ']' ) {
         if( ikey < 3 ) {
            ierror = 1; printf("This is in error! (7a) (stray bracket) ");
         } else {
            if( ibra != 1 ) {
               ierror = 1; printf("This is in error! (7b) (stray bracket) ");
            } else {
               // simply close bracket
               ibra = 0;
#ifdef _DEBUG2_
               printf(" (close bracket) ");
#endif
            }
         }
      } else

      // open parenthesis
      if( data[n] == '(' ) {
         if( ikey < 2 ) {
            ierror = 1; printf("This is in error! (8) (stray paren.) ");
         } else if( ikey == 2 ) {
            // entering data section of this keyword...
            ikey = 3;
            // ...with an open parenthesis
            ipar = 1;
#ifdef _DEBUG2_
            printf(" (start data of keyword with paren.) ");
#endif
         } else {
            // simply open parenthesis
            ipar = 1;
#ifdef _DEBUG2_
            printf(" (open paren.) ");
#endif
         }
      } else

      // close parenthesis
      if( data[n] == ')' ) {
         if( ikey < 3 ) {
            ierror = 1; printf("This is in error! (9) (stray paren.) ");
         } else {
            if( ipar != 1 ) {
               ierror = 1; printf("This is in error! (9b) (stray paren.) ");
            } else {
               // simply close parenthesis
               ipar = 0;
#ifdef _DEBUG2_
               printf(" (close paren.) ");
#endif
            }
         }
      } else

      // anything else
      {
         if( ikey == 0 ) {
            // check whether we are in a line of data
            if( CheckCharForNum( data[n] ) == 1 ) {
               // terminate parsing immediately; the zone header must be done
               free( data );
#ifdef _DEBUG2_
               printf(" (numerical string) \n");
#endif
               return( -100 );
            }

            // encountered keyword
            ikey = 1;
#ifdef _DEBUG2_
            printf(" (start keyword) ");
#endif
         } else if( ikey == 2 ) {
            // entering data section of this keyword
            ikey = 3;
#ifdef _DEBUG2_
            printf(" (start data of keyword) ");
#endif
         }
      }

      // provide some output
      if( iparse == 1 ) {
#ifdef _DEBUG2_
         printf(" (parsing now)");
#endif
         data[n+0] = '\0';//HACK

         int iret = HandleKeyword( s );
         // allow for the possibility of dealiing with this differently...
         if( iret == 0 ) ++np;

         iparse = 0;
      }

      ++n;
#ifdef _DEBUG2_
      printf("\n");
#endif
   }

   // drop duplicate buffer
   free( data );

   if( ierror == 0 ) {
      return( np );
   } else {
#ifdef _DEBUG_
      printf(" --- Error returned: %d \n", -10*ierror );
#endif
      return( -10*ierror );
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
leaq 0x8b92(%rip), %rdi      # 0xf157
callq 0x5570
xorl %r14d, %r14d
movzbl (%r12,%r14), %eax
testl %eax, %eax
je 0x65e0
cmpl $0xa, %eax
je 0x65e0
incq %r14
jmp 0x65cd
leaq 0x1(%r14), %rdi
callq 0x54e0
testq %rax, %rax
je 0x6a29
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x52e0
movb $0x0, (%r15,%r14)
xorl %ebp, %ebp
movq %r15, 0x18(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
movzbl (%r15,%rbp), %eax
cmpl $0x2b, %eax
jg 0x666b
leal -0x20(%rax), %ecx
cmpl $0x9, %ecx
ja 0x66b6
leaq 0x7a0f(%rip), %rdx      # 0xe05c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x1, %ebx
jg 0x67d0
leaq 0x7cfb(%rip), %rdi      # 0xe361
jmp 0x69df
cmpl $0x5a, %eax
jg 0x671b
cmpl $0x2c, %eax
je 0x673e
cmpl $0x3d, %eax
jne 0x676d
cmpl $0x3, %ebx
ja 0x69ec
movl $0x2, %r12d
movl %ebx, %eax
leaq 0x79e6(%rip), %rcx      # 0xe084
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %r12d, %r12d
leaq 0x7c6d(%rip), %rdi      # 0xe31e
jmp 0x697c
testl %eax, %eax
je 0x66c3
cmpl $0xa, %eax
jne 0x676d
cmpl $0x1, %ebx
je 0x684d
cmpl $0x2, %ebx
je 0x6834
cmpl $0x3, %ebx
jne 0x69ec
cmpl $0x1, 0x8(%rsp)
sete %al
cmpl $0x1, 0xc(%rsp)
sete %cl
orb %al, %cl
cmpl $0x1, 0x10(%rsp)
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x689c
leaq 0x7ca3(%rip), %rdi      # 0xe3ac
xorl %eax, %eax
callq 0x5060
movl $0x3, %r12d
jmp 0x6983
cmpl $0x5b, %eax
je 0x67a7
cmpl $0x5d, %eax
jne 0x676d
cmpl $0x2, %ebx
jg 0x6804
leaq 0x7cfd(%rip), %rdi      # 0xe436
jmp 0x69df
cmpl $0x3, %ebx
ja 0x69ec
movl %ebx, %ecx
leaq 0x7944(%rip), %rdx      # 0xe094
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq (%r15,%rbp), %rax
incq %rax
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
jmp 0x69ef
testl %ebx, %ebx
je 0x6905
cmpl $0x2, %ebx
movl $0x3, %eax
cmovel %eax, %ebx
jmp 0x69ec
cmpl $0x1, %ebx
jg 0x67b8
leaq 0x7cf5(%rip), %rdi      # 0xe486
jmp 0x69df
cmpl $0x2, %ebx
jg 0x67ec
leaq 0x7d0a(%rip), %rdi      # 0xe4ac
jmp 0x69df
cmpl $0x1, %ebx
jg 0x681c
leaq 0x7c5c(%rip), %rdi      # 0xe40f
jmp 0x69df
cmpl $0x2, %ebx
movl $0x3, %eax
cmovel %eax, %ebx
movl $0x1, 0x10(%rsp)
jmp 0x69ec
cmpl $0x2, %ebx
jne 0x692f
movl $0x1, 0x8(%rsp)
movl $0x3, %r12d
jmp 0x69ef
cmpl $0x1, 0x10(%rsp)
jne 0x6953
movl $0x0, 0x10(%rsp)
jmp 0x69ec
cmpl $0x1, 0xc(%rsp)
jne 0x6964
movl $0x0, 0xc(%rsp)
jmp 0x69ec
cmpl $0x2, %ebx
movl $0x3, %eax
cmovel %eax, %ebx
movl $0x1, 0xc(%rsp)
jmp 0x69ec
leaq 0x7bac(%rip), %rdi      # 0xe3e7
xorl %eax, %eax
callq 0x5060
movl $0x2, %r12d
jmp 0x6983
leaq 0x7b93(%rip), %rdi      # 0xe3e7
jmp 0x68ed
movl $0x2, %r12d
cmpl $0x2c, %eax
jne 0x69ef
leaq 0x7a98(%rip), %rdi      # 0xe307
jmp 0x697c
cmpl $0x1, 0x8(%rsp)
sete %al
cmpl $0x1, 0xc(%rsp)
sete %cl
orb %al, %cl
cmpl $0x1, 0x10(%rsp)
sete %al
orb %cl, %al
movl $0x3, %r12d
jne 0x69ef
movb $0x0, (%r15,%rbp)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x5460
xorl $0x1, %eax
addl %eax, 0x14(%rsp)
xorl %r12d, %r12d
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
jmp 0x69ef
movl $0x1, %r12d
cmpl $0x2c, %eax
jne 0x69ef
leaq 0x7a04(%rip), %rdi      # 0xe2f1
xorl %eax, %eax
callq 0x5060
movl $0x1, %r13d
movl $0x1, %r12d
jmp 0x69ef
movl $0x1, %r12d
cmpl $0x39, %eax
ja 0x69ef
movl %eax, %eax
movabsq $0x3ff680000000000, %rcx # imm = 0x3FF680000000000
btq %rax, %rcx
jae 0x69ef
jmp 0x6a30
cmpb $0x5c, -0x1(%r15,%rbp)
je 0x69ec
cmpl $0x1, 0x8(%rsp)
jne 0x69d0
movl $0x0, 0x8(%rsp)
jmp 0x69ec
movl $0x0, 0x10(%rsp)
leaq 0x7b70(%rip), %rdi      # 0xe4d2
jmp 0x69df
movl $0x0, 0xc(%rsp)
leaq 0x7aeb(%rip), %rdi      # 0xe45e
jmp 0x69df
leaq 0x79b8(%rip), %rdi      # 0xe334
xorl %eax, %eax
callq 0x5060
movl $0x1, %r13d
jmp 0x69ef
cmpl $0x1, 0x8(%rsp)
sete %al
cmpl $0x1, 0xc(%rsp)
sete %cl
orb %al, %cl
cmpl $0x1, 0x10(%rsp)
sete %al
orb %cl, %al
movl $0x3, %r12d
jne 0x69ef
movl $0x0, 0x8(%rsp)
leaq 0x798d(%rip), %rdi      # 0xe34b
xorl %eax, %eax
callq 0x5060
movl $0x1, %r13d
jmp 0x68c2
movl $0x0, 0x8(%rsp)
leaq 0x79a7(%rip), %rdi      # 0xe386
xorl %eax, %eax
callq 0x5060
movl $0x1, %r13d
movl %ebx, %r12d
incq %rbp
movl %r12d, %ebx
cmpq %r14, %rbp
jbe 0x6634
movq %r15, %rdi
callq 0x5420
testl %r13d, %r13d
movl 0x14(%rsp), %ebx
je 0x6a3d
leaq 0x7ae3(%rip), %rdi      # 0xe4f9
movl $0xfffffff6, %ebx       # imm = 0xFFFFFFF6
movl $0xfffffff6, %esi       # imm = 0xFFFFFFF6
xorl %eax, %eax
callq 0x5060
jmp 0x6a3d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x6a3d
movq %r15, %rdi
callq 0x5420
movl $0xffffff9c, %ebx       # imm = 0xFFFFFF9C
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq