// File: /workspace/github_cpp_makefile_star2_O1/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 0x7754
leaq 0x6a61(%rip), %rdi      # 0xe1ae
xorl %eax, %eax
callq 0x289c
movslq 0x8(%rbx), %r13
movq (%rbx), %r15
movq 0x20(%rbx), %rbp
movslq 0x8(%rbp), %r14
cmpl %r14d, %r13d
jge 0x78ef
movq %r12, 0x10(%rsp)
movq %r15, %rdi
callq 0x2140
cmpl $0x0, 0xc(%rbx)
je 0x7830
testl %r13d, %r13d
je 0x78a6
leaq 0xc(%rbp), %rax
movq %rax, 0x8(%rsp)
movslq 0x8(%rbx), %rax
movl %eax, %r13d
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 0x77dc
movsbl %al, %esi
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
je 0x77dc
movb 0x1(%r14), %al
incq %r14
jmp 0x77bf
addl 0x8(%rsp), %r13d
subl %r13d, %r12d
incl %r12d
setne %bpl
je 0x790e
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x4a2a
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 0x7925
movq %rax, %r12
addq %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 0x792b
movq %r14, %r15
subq %r13, %r15
movq 0x10(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x4a2a
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 0x794a
movsbl 0xc(%rbp), %esi
testl %esi, %esi
sete %r12b
je 0x78ef
leaq 0xc(%rbp), %r13
movq %r15, %rdi
callq 0x2100
movq %r13, 0x8(%rsp)
testq %rax, %rax
je 0x78ea
movq 0x8(%rsp), %r13
movsbl 0x1(%r13), %esi
testl %esi, %esi
sete %r12b
je 0x78ef
incq %r13
movq %r15, %rdi
callq 0x2100
testq %rax, %rax
jne 0x78cd
testb %r12b, %r12b
je 0x795e
testq %r15, %r15
je 0x78fc
movq %r15, %rdi
callq 0x22e0
movq $0x0, (%rbx)
movl $0x0, 0x8(%rbx)
xorl %ebp, %ebp
jmp 0x794d
testq %r15, %r15
je 0x791b
movq %r15, %rdi
callq 0x22e0
movq $0x0, (%rbx)
xorl %r14d, %r14d
movl %r14d, 0x8(%rbx)
jmp 0x794d
addq $0xc, %rbp
subl %ebp, %r12d
addl %r12d, %r14d
movl %r14d, 0x8(%rbx)
leaq 0x677e(%rip), %rsi      # 0xe0be
movq 0x10(%rsp), %rdi
callq 0x4f60
movb $0x1, %bpl
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl 0x8(%rsp), %r13d
movl %r13d, 0x8(%rbx)
jmp 0x778c