// File: /workspace/github_c_makefile_star2_O3/mmayer[P]pcal/src/pcalutil.c
// Function: loadwords
int loadwords (char **words, char *buf)
{
   register char *ptok;
   char *delim, **ap, *p1, *p2, c;
   int nwords;
   
   for (ptok = buf, ap = words; TRUE; ap++) {

      ptok += strspn(ptok, WHITESPACE); /* find next token */

      if (! *ptok) {   /* end of buf? */
         *ap = NULL;   /* add null ptr at end */
         nwords = ap - words;   /* number of non-null ptrs */
         break;   /* exit loop */
      }
      
      delim = *ptok == '"'  ? "\"" :   /* set closing delimiter */
         *ptok == '\'' ? "'"  : WHITESPACE;

      /* split flag followed by quoted string into two words */
      if (*ptok == '-' && isalpha((int)ptok[1]) &&
          ((c = ptok[2]) == '"' || c == '\'')) {
         delim = c == '"' ? "\"" : "'";
         *ap++ = ptok;
         ptok[2] = '\0';   /* terminate first token */
         ptok += 3;   /* start second token */
      }
      else if (*ptok == *delim) ptok++;   /* skip opening quote */
      
      *ap = ptok;   /* save token ptr */

      /* find first unescaped string delimiter - handle special case where
         preceding backslash is itself escaped
      */
      do {
         ptok += strcspn(ptok, delim);
         if ((c = ptok[-1]) == '\\') {
            if (ptok[-2] == '\\') break;   /* stop on \\" or \\' */
            else ptok++;
         }
      } while (c == '\\');
      
      if (*ptok) *ptok++ = '\0';   /* terminate token */
   }
   
   /* now reprocess the word list, removing remaining escapes */
   for (ap = words; *ap; ap++) {
      for (p1 = p2 = *ap; (c = *p2 = *p1++) != '\0'; p2++) {
         if (c == '\\') *p2 = *p1++;
      }
   }
   
   return nwords;   /* return word count */

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbp
movq %rdi, %r14
leaq 0x1462b(%rip), %r15     # 0x1f57e
leaq 0xbf6f(%rip), %rbx      # 0x16ec9
movq %rdi, (%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x51a0
leaq (%rax,%rbp), %r13
movzbl (%rbp,%rax), %ebp
movq %rbx, %r12
cmpl $0x22, %ebp
je 0xafdd
testl %ebp, %ebp
je 0xb037
cmpb $0x27, %bpl
movq %r15, %r12
leaq 0x14f5e(%rip), %rax     # 0x1feee
cmoveq %rax, %r12
cmpb $0x2d, %bpl
jne 0xafdd
callq 0x5340
movq (%rax), %rax
movsbq 0x1(%r13), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0xafdd
movzbl 0x2(%r13), %eax
cmpl $0x27, %eax
je 0xafbd
cmpl $0x22, %eax
jne 0xafdd
cmpb $0x22, %al
leaq 0x14f28(%rip), %r12     # 0x1feee
cmoveq %rbx, %r12
movq %r13, (%r14)
addq $0x8, %r14
movb $0x0, 0x2(%r13)
movl $0x3, %eax
jmp 0xafe6
xorl %eax, %eax
cmpb (%r12), %bpl
sete %al
addq %rax, %r13
movq %r13, (%r14)
movq %r13, %rdi
movq %r12, %rsi
callq 0x51d0
leaq (%rax,%r13), %rbp
cmpb $0x5c, -0x1(%rax,%r13)
jne 0xb021
cmpb $0x5c, -0x2(%rbp)
je 0xb021
leaq 0x1(%rbp), %rdi
movq %r12, %rsi
callq 0x51d0
addq %rax, %rbp
incq %rbp
cmpb $0x5c, -0x1(%rbp)
je 0xb003
cmpb $0x0, (%rbp)
je 0xb02e
movb $0x0, (%rbp)
incq %rbp
addq $0x8, %r14
jmp 0xaf5e
movq $0x0, (%r14)
movq (%rsp), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0xb081
movq %rdi, %rcx
movq %rax, %rdx
movzbl (%rax), %esi
movb %sil, (%rdx)
cmpl $0x5c, %esi
je 0xb064
testl %esi, %esi
je 0xb074
incq %rax
jmp 0xb06f
movb 0x1(%rax), %sil
addq $0x2, %rax
movb %sil, (%rdx)
incq %rdx
jmp 0xb050
movq 0x8(%rcx), %rax
addq $0x8, %rcx
testq %rax, %rax
jne 0xb04d
subq %rdi, %r14
shrq $0x3, %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq