// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0xc68b
jmp 0xc84c
movq -0x18(%rbp), %rdi
leaq 0x17fc1(%rip), %rsi     # 0x24657
callq 0x5160
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0xc6ce
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movl %eax, -0x40(%rbp)
jmp 0xc84c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0xc6e7
leaq 0xf79c(%rip), %rax      # 0x1be7d
movq %rax, -0x48(%rbp)
jmp 0xc707
movq -0x18(%rbp), %rax
movsbl (%rax), %edx
leaq 0x17f62(%rip), %rax     # 0x24657
leaq 0x188ce(%rip), %rcx     # 0x24fca
cmpl $0x27, %edx
cmoveq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xc7a4
callq 0x52e0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xc7a4
movq -0x18(%rbp), %rax
movb 0x2(%rax), %al
movb %al, -0x39(%rbp)
movsbl %al, %eax
cmpl $0x22, %eax
je 0xc75b
movsbl -0x39(%rbp), %eax
cmpl $0x27, %eax
jne 0xc7a4
movsbl -0x39(%rbp), %edx
leaq 0x18864(%rip), %rax     # 0x24fca
leaq 0xf710(%rip), %rcx      # 0x1be7d
cmpl $0x22, %edx
cmoveq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x2(%rax)
movq -0x18(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x18(%rbp)
jmp 0xc7c4
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0xc7c2
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xc7c4
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x5180
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x39(%rbp)
movsbl %al, %eax
cmpl $0x5c, %eax
jne 0xc813
movq -0x18(%rbp), %rax
movsbl -0x2(%rax), %eax
cmpl $0x5c, %eax
jne 0xc805
jmp 0xc81e
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xc813
jmp 0xc815
movsbl -0x39(%rbp), %eax
cmpl $0x5c, %eax
je 0xc7cf
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0xc839
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb $0x0, (%rax)
jmp 0xc83b
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0xc680
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0xc8cf
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %al
movq -0x38(%rbp), %rcx
movb %al, (%rcx)
movb %al, -0x39(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
je 0xc8bf
movsbl -0x39(%rbp), %eax
cmpl $0x5c, %eax
jne 0xc8af
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0xc8b1
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xc86d
jmp 0xc8c1
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0xc854
movl -0x40(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)