// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rdi, %rbx
cmpq $0x0, (%rdi)
jne 0x75f0
leaq 0x6bc5(%rip), %rdi      # 0xe1ae
xorl %eax, %eax
callq 0x286c
movl 0x8(%rbx), %r13d
movq 0x20(%rbx), %rbp
movslq 0x8(%rbp), %r14
movq (%rbx), %r15
cmpl %r14d, %r13d
jge 0x7768
movq %r12, 0x8(%rsp)
movq %r15, %rdi
callq 0x2140
cmpl $0x0, 0xc(%rbx)
je 0x76c8
testl %r13d, %r13d
je 0x7742
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), %r14
cmovneq %rax, %r14
leaq -0x1(%r14), %r12
movb (%r14), %al
testb %al, %al
je 0x7674
movsbl %al, %esi
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
je 0x7674
movb 0x1(%r14), %al
incq %r14
jmp 0x7657
addl 0x10(%rsp), %r13d
subl %r13d, %r12d
incl %r12d
setne %bpl
je 0x7787
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x497c
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
addl $-0xc, %r14d
jmp 0x779e
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 0x77a4
movq %r14, %r15
subq %r13, %r15
movq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x497c
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 0x77c3
movb 0xc(%rbp), %al
testb %al, %al
je 0x7768
xorl %r13d, %r13d
movsbl %al, %esi
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
je 0x77d7
movb 0xd(%rbp,%r13), %al
incq %r13
testb %al, %al
jne 0x774c
testq %r15, %r15
je 0x7775
movq %r15, %rdi
callq 0x22e0
movq $0x0, (%rbx)
movl $0x0, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0x77c6
testq %r15, %r15
je 0x7794
movq %r15, %rdi
callq 0x22e0
movq $0x0, (%rbx)
xorl %r14d, %r14d
movl %r14d, 0x8(%rbx)
jmp 0x77c6
addq $0xc, %rbp
subl %ebp, %r12d
addl %r12d, %r13d
movl %r13d, 0x8(%rbx)
leaq 0x6905(%rip), %rsi      # 0xe0be
movq 0x8(%rsp), %rdi
callq 0x4e8c
movb $0x1, %bpl
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, 0x8(%rbx)
jmp 0x7628