// File: /workspace/github_cpp_makefile_star2_O2/gpertea[P]gclib/GStr.cpp
// Function: GStr::nextToken(GStr&)
bool GStr::nextToken(GStr& token) {
 if (fTokenDelimiter==NULL) {
    GError("GStr:: no token delimiter; use StartTokenize first\n");
    }
 if (fLastTokenStart>=length()) {//no more
    GFREE(fTokenDelimiter);
    fLastTokenStart=0;
    return false;
    }
 int dlen=strlen(fTokenDelimiter);
 char* delpos=NULL; //delimiter position
 int tlen=0;
 if (fTokenizeMode==tkFullString) { //exact string as a delimiter
   delpos=(char*)strstr(my_data->chars+fLastTokenStart,fTokenDelimiter);
   if (delpos==NULL) delpos=(char*)(my_data->chars+length());
   //empty records may be returned
   if (my_data->chars+fLastTokenStart == delpos) { //empty token
     fLastTokenStart=(delpos-my_data->chars)+dlen;
     token="";
     return true;
     }
    else {
     tlen=delpos-(my_data->chars+fLastTokenStart);
     token.prep_data(tlen);
     ::memcpy(token.chrs(), &my_data->chars[fLastTokenStart], tlen);
     fLastTokenStart=(delpos-my_data->chars)+dlen;
     return true;
     }
   }
  else { //tkCharSet - any character is a delimiter
   //empty records are never returned !
   if (fLastTokenStart==0) {//skip any starting delimiters
     delpos=(char*)my_data->chars;
     while (*delpos!='\0' && strchr(fTokenDelimiter, *delpos)!=NULL)
       delpos++;
     if (*delpos!='\0')
         fLastTokenStart = delpos-my_data->chars;
       else { //only delimiters here,no tokens
         GFREE(fTokenDelimiter);
         fLastTokenStart=0;
         return false;
         }
     }
   //now fLastTokenStart is on a non-delimiter char
   //GMessage("String at fLastTokenStart=%d is %s\n", fLastTokenStart, delpos);
   char* token_end=NULL;
   delpos=(char*)strpbrk(my_data->chars+fLastTokenStart,fTokenDelimiter);
   if (delpos==NULL) delpos=(char*)(my_data->chars+length());
   token_end=delpos-1;
   while (*delpos!='\0' && strchr(fTokenDelimiter, *delpos)!=NULL)
      delpos++; //skip any other delimiters in the set!
   //now we know that delpos is on the beginning of next token
   tlen=(token_end-my_data->chars)-fLastTokenStart+1;
   if (tlen==0) {
       GFREE(fTokenDelimiter);
       fLastTokenStart=0;
       return false;
       }
   token.prep_data(tlen);
   ::memcpy(token.chrs(), &my_data->chars[fLastTokenStart], tlen);
   fLastTokenStart=delpos-my_data->chars;
   return true;
   }
 //return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
cmpq $0x0, (%rdi)
jne 0x6fb2
leaq 0x5211(%rip), %rdi      # 0xc1bc
xorl %eax, %eax
callq 0x25ca
movl 0x8(%rbx), %r13d
movq 0x20(%rbx), %rbp
movslq 0x8(%rbp), %r14
cmpl %r14d, %r13d
jge 0x7005
movq %r15, 0x8(%rsp)
movq (%rbx), %r15
movq %r15, %rdi
callq 0x2140
cmpl $0x0, 0xc(%rbx)
je 0x7018
testl %r13d, %r13d
jne 0x70b6
xorl %r13d, %r13d
movsbl 0xc(%rbp,%r13), %esi
testl %esi, %esi
je 0x7005
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
je 0x70b2
incq %r13
jmp 0x6fe5
movq %rbx, %rdi
callq 0x420d
andl $0x0, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0x715b
movq %rax, %r12
movslq %r13d, %rax
leaq (%rax,%rbp), %r13
addq $0xc, %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2090
testq %rax, %rax
leaq 0xc(%rbp,%r14), %r14
cmovneq %rax, %r14
cmpq %r14, %r13
je 0x708b
movq %r14, %r15
subq %r13, %r15
movq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x45d2
movq 0x20(%r13), %rdi
addq $0xc, %rdi
movq 0x20(%rbx), %rax
movslq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rsi
addq $0xc, %rsi
movslq %r15d, %rdx
callq 0x21e0
addl %r14d, %r12d
subl 0x20(%rbx), %r12d
addl $-0xc, %r12d
movl %r12d, 0x8(%rbx)
jmp 0x70aa
addq $0xc, %rbp
subl %ebp, %r12d
addl %r12d, %r13d
movl %r13d, 0x8(%rbx)
leaq 0x501e(%rip), %rsi      # 0xc0be
movq 0x8(%rsp), %rdi
callq 0x4ab2
movb $0x1, %bpl
jmp 0x715b
movl %r13d, 0x8(%rbx)
leaq 0xc(%rbp), %rax
movq %rax, 0x10(%rsp)
movslq %r13d, %rax
leaq (%rax,%rbp), %rdi
addq $0xc, %rdi
movq %r15, %rsi
callq 0x23f0
testq %rax, %rax
leaq 0xc(%rbp,%r14), %rbp
cmovneq %rax, %rbp
leaq -0x1(%rbp), %r12
leal -0xc(%rbp), %r14d
movsbl (%rbp), %esi
testl %esi, %esi
je 0x7103
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
je 0x7103
incq %rbp
incl %r14d
jmp 0x70e6
addl 0x10(%rsp), %r13d
subl %r13d, %r12d
incl %r12d
setne %bpl
je 0x714c
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x45d2
movq 0x20(%r15), %rdi
addq $0xc, %rdi
movq 0x20(%rbx), %rax
movslq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rsi
addq $0xc, %rsi
movslq %r12d, %rdx
callq 0x21e0
subl 0x20(%rbx), %r14d
jmp 0x7157
movq %rbx, %rdi
callq 0x420d
xorl %r14d, %r14d
movl %r14d, 0x8(%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq