// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdi, %rbx
leaq 0x13b6a(%rip), %r15     # 0x1e507
leaq 0xb4cd(%rip), %rbp      # 0x15e71
movq %rdi, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x51a0
movzbl (%r12,%rax), %r14d
movq %rbp, %r13
cmpl $0x22, %r14d
je 0xa9dc
testl %r14d, %r14d
je 0xaa79
cmpb $0x27, %r14b
movq %r15, %r13
leaq 0x144a2(%rip), %rcx     # 0x1ee7a
cmoveq %rcx, %r13
addq %rax, %r12
cmpb $0x2d, %r14b
jne 0xaa2b
callq 0x5340
movq (%rax), %rax
movsbq 0x1(%r12), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0xaa2b
movzbl 0x2(%r12), %eax
cmpl $0x27, %eax
je 0xaa0a
cmpl $0x22, %eax
jne 0xaa2b
cmpb $0x22, %al
leaq 0x14467(%rip), %r13     # 0x1ee7a
cmoveq %rbp, %r13
movq %r12, (%rbx)
addq $0x8, %rbx
movb $0x0, 0x2(%r12)
movl $0x3, %eax
jmp 0xaa34
xorl %eax, %eax
cmpb (%r13), %r14b
sete %al
addq %rax, %r12
movq %r12, (%rbx)
movq %r12, %rdi
movq %r13, %rsi
callq 0x51d0
leaq (%r12,%rax), %rcx
movb -0x1(%r12,%rax), %al
cmpb $0x5c, %al
jne 0xaa5b
cmpb $0x5c, -0x2(%rcx)
je 0xaa62
incq %rcx
movq %rcx, %r12
cmpb $0x5c, %al
je 0xaa3a
cmpb $0x0, (%rcx)
je 0xaa6d
movb $0x0, (%rcx)
incq %rcx
addq $0x8, %rbx
movq %rcx, %r12
jmp 0xa9a8
movq $0x0, (%rbx)
movq (%rsp), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0xaac3
movq %rdi, %rcx
movq %rax, %rdx
movzbl (%rax), %esi
movb %sil, (%rdx)
cmpl $0x5c, %esi
je 0xaaa6
testl %esi, %esi
je 0xaab6
incq %rax
jmp 0xaab1
movb 0x1(%rax), %sil
addq $0x2, %rax
movb %sil, (%rdx)
incq %rdx
jmp 0xaa92
movq 0x8(%rcx), %rax
addq $0x8, %rcx
testq %rax, %rax
jne 0xaa8f
subq %rdi, %rbx
shrq $0x3, %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq