// File: /workspace/github_cpp_makefile_star2_O2/nompelis[P]INTecplotLib/intecplot.cpp
// Function: inTec_File::ParseComponent_Geometry()
int inTec_File::ParseComponent_Geometry()
{
#ifdef _DEBUG_
   printf(" i Inside \"ParseComponent_Geometry()\" \n");
#endif

   // seek back to the begining of the line that got us here so we can re-parse
   int iret = fseek( fp, ipos, SEEK_SET );
   if( iret != 0 ) {
      printf(" e Error seeking to proper parsing position: %ld \n", ipos);
      return(1);
   }
   // retract line-number as the line will be re-read
   --iline;

   // Looking to parse multiple keywords and over multiple lines
   // T= <string>
   // ZN= <zone to associate the string>
   // X=
   // Y=
   // Z=
   // R=



   // The idea here is to keep ingesting in lines until we find a new component
   // We ingest comments that can interrupt the geometry component
   // Once a new component is detected, we wrap up the process

   char *field=NULL;
   size_t ifield_size=0,ifield_pos=0;

   char *buf=NULL;
   size_t ibuf_size=0;

   int idone_geom = 0;   // flag for present geometry component termination
   while( !feof( fp ) && idone_geom <= 1 ) {
      int ic;

      // information about the position in the file
      ipos = ftell( fp );
#ifdef _DEBUG_
      printf(" i Position in file at %ld bytes, line %ld \n", ipos, iline+1 );
#endif

      // prepare the buffer
      memset( buf, '\0', ibuf_size );
      // read a line of data; get count of bytes read
      ic = inUtils_ReadTextline( &ibuf_size, &buf, fp );
      // check error code

      // sanitize the line
      inUtils_TrimLeadingSpaceTextline( buf );
      size_t isize=0;
      while( isize < ibuf_size && buf[isize] != '\n' ) ++isize;
      if( buf[isize] == '\n' ) buf[isize] = '\0';
#ifdef _DEBUG3_
      printf("STRING (%p, %ld):%s\n", buf, isize, buf );
#endif

      // attempt to identify this line as a new component to terminate parsing
      int iparse_line=1;    // default is to parse the line
      iret = IdentifyComponent( buf );
#ifdef _DEBUG3_
printf("FOUND iret=%d idone_geom=%d \n", iret,idone_geom);
#endif
      // check if we have jumped to a new component under certain conditions...
      if( iret > 0 ) {             // we found a component
         // only allow "stray" comment components to pass through
         if( iret == Comment ) {
#ifdef _DEBUG_
            printf(" --- Found comment (inside Geometry component) \n");
#endif
            ++iline;
            // we will not be parsing this line
            iparse_line = 0;
            // store comment in strings
            buf[ strlen(buf) ] = '\n';
            strings[ iline ] = buf;
         } else {
#ifdef _DEBUG2_
            printf(" --- Found component (at _or_ after Geometry component)\n");
#endif
            // increment termination condition variable
            ++idone_geom;
            // will not parse new components
            if( idone_geom > 1) iparse_line = 0;
         }
      } else {
#ifdef _DEBUG2_
         printf(" --- The line is part of the Geometry component \n");
#endif
        iparse_line = 1;
      }

      // parse the line only if we are still parsing the current geometry field
      if( iparse_line == 1 ) {
         ++iline;

         // keep enlarging the "field" block
         ifield_size += isize;
         char *tmpf = (char *) realloc(field, (ifield_size+1)*sizeof(char));
         if( tmpf == NULL ) {
            free( field );
            free( buf );
            return(-2);
         }
         field = tmpf;
         tmpf = &( field[ifield_pos] );
         memset(tmpf, '\0', isize+1);
         for(size_t n=0;n<isize;++n) field[ ifield_pos + n ] = buf[n];
         ifield_pos = ifield_size;
         field[ ifield_pos ] = '\0';

#ifdef _DEBUG2_
         printf(" --- The field so far: |%s|\n", field);
#endif
      }
   }

   // drop the buffer
   free( buf );



   // set all parameters of the geometry component


   // drop the text storage
   free( field );

   // seek back to the begining of this line and terminate this operation
   iret = fseek( fp, ipos, SEEK_SET );
   if( iret != 0 ) {
      printf(" e Error seeking to proper parsing position: %ld \n", ipos);
      return(2);
   }

#ifdef _DEBUG_
   printf(" i *** Skipping storing of GEOMETRY component *** \n");
   // we do this by returning control to the main parsing loop
#endif

   return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x3a69(%rip), %rdi      # 0x10ad1
callq 0x77b0
movq 0x110(%rbx), %rdi
movq 0x128(%rbx), %rsi
xorl %edx, %edx
callq 0x7540
testl %eax, %eax
je 0xd0a2
movq 0x128(%rbx), %rsi
leaq 0x2db8(%rip), %rdi      # 0xfe4c
xorl %eax, %eax
callq 0x7060
pushq $0x1
jmp 0xd2c5
decq 0x120(%rbx)
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
leaq 0x18(%rsp), %rax
andq $0x0, (%rax)
leaq 0x130(%rbx), %r12
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movl %eax, %r13d
movq 0x110(%rbx), %rdi
callq 0x77c0
testl %eax, %eax
jne 0xd27f
cmpl $0x1, %r13d
jg 0xd27f
movq 0x110(%rbx), %rdi
callq 0x7030
movq %rax, 0x128(%rbx)
movq 0x120(%rbx), %rdx
incq %rdx
leaq 0x2e6f(%rip), %rdi      # 0xff84
movq %rax, %rsi
xorl %eax, %eax
callq 0x7060
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rdx
xorl %esi, %esi
callq 0x72a0
movq 0x110(%rbx), %rdx
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7250
movq 0x8(%rsp), %rdi
callq 0x7050
movq 0x18(%rsp), %r15
movq 0x8(%rsp), %rbp
xorl %eax, %eax
cmpq %rax, %r15
je 0xd16d
cmpb $0xa, (%rbp,%rax)
je 0xd177
incq %rax
jmp 0xd15c
cmpb $0xa, (%rbp,%r15)
je 0xd17a
jmp 0xd185
movq %rax, %r15
movb $0x0, (%rbp,%r15)
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
callq 0x7580
testl %eax, %eax
jle 0xd201
cmpl $0x64, %eax
jne 0xd1ef
leaq 0x398e(%rip), %rdi      # 0x10b2b
callq 0x77b0
incq 0x120(%rbx)
movq %r14, %r15
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x71f0
movb $0xa, (%r14,%rax)
movq 0x8(%rsp), %r14
movq 0x120(%rbx), %rax
movq %rax, 0x30(%rsp)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x77a0
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %r14
callq 0x7990
jmp 0xd0d3
leal 0x1(%r13), %eax
testl %r13d, %r13d
movl %eax, %r13d
jg 0xd0d3
jmp 0xd204
movl %r13d, %eax
movl %eax, 0x24(%rsp)
incq 0x120(%rbx)
leaq (%r15,%r14), %rsi
incq %rsi
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x7850
testq %rax, %rax
je 0xd2e5
movq %r14, %rcx
movq %rax, %r14
leaq (%r15,%rcx), %rax
movq %rax, 0x28(%rsp)
movq %r14, %r13
addq %rcx, %r13
leaq 0x1(%r15), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x72a0
xorl %eax, %eax
cmpq %rax, %r15
je 0xd264
movb (%rbp,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xd251
movq 0x28(%rsp), %rax
movb $0x0, (%r14,%rax)
movq %r14, 0x10(%rsp)
movq %rax, %r14
movl 0x24(%rsp), %eax
jmp 0xd0d0
movq 0x8(%rsp), %rdi
callq 0x75c0
movq 0x10(%rsp), %rdi
callq 0x75c0
movq 0x110(%rbx), %rdi
movq 0x128(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x7540
testl %eax, %eax
je 0xd2d7
movq 0x128(%rbx), %rsi
leaq 0x2b90(%rip), %rdi      # 0xfe4c
xorl %eax, %eax
callq 0x7060
pushq $0x2
popq %rbp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x381a(%rip), %rdi      # 0x10af8
callq 0x77b0
jmp 0xd2c6
movq %r13, %rdi
callq 0x75c0
movq %rbp, %rdi
callq 0x75c0
pushq $-0x2
jmp 0xd2c5
nop