// File: /workspace/github_c_makefile_star2_O2/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 0x13409(%rip), %r15     # 0x1d52e
leaq 0xad45(%rip), %rbx      # 0x14e71
movq %rdi, (%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x5190
leaq (%rax,%rbp), %r12
movzbl (%rbp,%rax), %ebp
movq %rbx, %r13
cmpl $0x22, %ebp
je 0xa1b0
testl %ebp, %ebp
je 0xa1fa
cmpb $0x27, %bpl
movq %r15, %r13
leaq 0x13d3c(%rip), %rax     # 0x1de9e
cmoveq %rax, %r13
cmpb $0x2d, %bpl
jne 0xa1b0
callq 0x5330
movq (%rax), %rax
movsbq 0x1(%r12), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0xa1b0
movzbl 0x2(%r12), %eax
cmpl $0x27, %eax
je 0xa191
cmpl $0x22, %eax
jne 0xa1b0
cmpb $0x22, %al
leaq 0x13d04(%rip), %r13     # 0x1de9e
cmoveq %rbx, %r13
movq %r12, (%r14)
addq $0x8, %r14
movb $0x0, 0x2(%r12)
pushq $0x3
popq %rax
jmp 0xa1b9
xorl %eax, %eax
cmpb (%r13), %bpl
sete %al
addq %rax, %r12
movq %r12, (%r14)
movq %r12, %rdi
movq %r13, %rsi
callq 0x51c0
leaq (%r12,%rax), %rbp
cmpb $0x5c, -0x1(%r12,%rax)
jne 0xa1e4
cmpb $0x5c, -0x2(%rbp)
je 0xa1e4
incq %rbp
movq %rbp, %r12
jmp 0xa1bf
cmpb $0x0, (%rbp)
je 0xa1f1
movb $0x0, (%rbp)
incq %rbp
addq $0x8, %r14
jmp 0xa130
andq $0x0, (%r14)
movq (%rsp), %rdi
movq %rdi, %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0xa23a
movq %rcx, %rdx
movzbl (%rcx), %esi
movb %sil, (%rdx)
cmpl $0x5c, %esi
je 0xa224
testl %esi, %esi
je 0xa234
incq %rcx
jmp 0xa22f
movb 0x1(%rcx), %sil
addq $0x2, %rcx
movb %sil, (%rdx)
incq %rdx
jmp 0xa210
addq $0x8, %rax
jmp 0xa205
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