// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxParse.c
// Function: HaxParseWords
int
HaxParseWords(
    Hax_Interp *interp,		/* Interpreter to use for nested command
				 * evaluations and error messages. */
    char *string,		/* First character of word. */
    int flags,			/* Flags to control parsing (same values as
				 * passed to Hax_Eval). */
    int maxWords,		/* Maximum number of words to parse. */
    char **termPtr,		/* Store address of terminating character
				 * here. */
    int *argcPtr,		/* Filled in with actual number of words
				 * parsed. */
    char **argv,		/* Store addresses of individual words here. */
    ParseValue *pvPtr		/* Information about where to place
				 * fully-substituted word. */)
{
    char *src, *dst;
    char c;
    int type, result, argc;
    char *oldBuffer;		/* Used to detect when pvPtr's buffer gets
				 * reallocated, so we can adjust all of the
				 * argv pointers. */

    src = string;
    oldBuffer = pvPtr->buffer;
    dst = pvPtr->next;
    for (argc = 0; argc < maxWords; argc++) {
	argv[argc] = dst;

	/*
	 * Skip leading space.
	 */

	skipSpace:
	c = *src;
	type = CHAR_TYPE(c);
	while (type == HAX_SPACE) {
	    src++;
	    c = *src;
	    type = CHAR_TYPE(c);
	}

	/*
	 * Handle the normal case (i.e. no leading double-quote or brace).
	 */

	if (type == HAX_NORMAL) {
	    normalArg:
	    while (1) {
		if (dst == pvPtr->end) {
		    /*
		     * Target buffer space is about to run out.  Make
		     * more space.
		     */

		    pvPtr->next = dst;
		    (*pvPtr->expandProc)(interp, pvPtr, 1);
		    dst = pvPtr->next;
		}

		if (type == HAX_NORMAL) {
		    copy:
		    *dst = c;
		    dst++;
		    src++;
		} else if (type == HAX_SPACE) {
		    goto wordEnd;
		} else if (type == HAX_DOLLAR) {
		    int length;
		    char *value;

		    value = Hax_ParseVar(interp, src, termPtr);
		    if (value == NULL) {
			return HAX_ERROR;
		    }
		    src = *termPtr;
		    length = strlen(value);
		    if ((pvPtr->end - dst) <= length) {
			pvPtr->next = dst;
			(*pvPtr->expandProc)(interp, pvPtr, length);
			dst = pvPtr->next;
		    }
		    strcpy(dst, value);
		    dst += length;
		} else if (type == HAX_COMMAND_END) {
		    if ((c == ']') && !(flags & HAX_BRACKET_TERM)) {
			goto copy;
		    }

		    /*
		     * End of command;  simulate a word-end first, so
		     * that the end-of-command can be processed as the
		     * first thing in a new word.
		     */

		    goto wordEnd;
		} else if (type == HAX_OPEN_BRACKET) {
		    pvPtr->next = dst;
		    result = HaxParseNestedCmd(interp, src+1, flags, termPtr,
			    pvPtr);
		    if (result != HAX_OK) {
			return result;
		    }
		    src = *termPtr;
		    dst = pvPtr->next;
		} else if (type == HAX_BACKSLASH) {
		    int numRead;

		    *dst = Hax_Backslash(src, &numRead);
		    if (*dst != 0) {
			dst++;
		    }
		    src += numRead;
		} else {
		    goto copy;
		}
		c = *src;
		type = CHAR_TYPE(c);
	    }
	} else {

	    /*
	     * Check for the end of the command.
	     */

	    if (type == HAX_COMMAND_END) {
		if (flags & HAX_BRACKET_TERM) {
		    if (c == '\0') {
			Hax_SetResult(interp, (char *) "missing close-bracket",
				HAX_STATIC);
			return HAX_ERROR;
		    }
		} else {
		    if (c == ']') {
			goto normalArg;
		    }
		}
		goto done;
	    }

	    /*
	     * Now handle the special cases: open braces, double-quotes,
	     * and backslash-newline.
	     */

	    pvPtr->next = dst;
	    if (type == HAX_QUOTE) {
		result = HaxParseQuotes(interp, src+1, '"', flags,
			termPtr, pvPtr);
	    } else if (type == HAX_OPEN_BRACE) {
		result = HaxParseBraces(interp, src+1, termPtr, pvPtr);
	    } else if ((type == HAX_BACKSLASH) && (src[1] == '\n')) {
		src += 2;
		goto skipSpace;
	    } else {
		goto normalArg;
	    }
	    if (result != HAX_OK) {
		return result;
	    }

	    /*
	     * Back from quotes or braces;  make sure that the terminating
	     * character was the end of the word.  Have to be careful here
	     * to handle continuation lines (i.e. lines ending in backslash).
	     */

	    c = **termPtr;
	    if ((c == '\\') && ((*termPtr)[1] == '\n')) {
		c = (*termPtr)[2];
	    }
	    type = CHAR_TYPE(c);
	    if ((type != HAX_SPACE) && (type != HAX_COMMAND_END)) {
		if (*src == '"') {
		    Hax_SetResult(interp,
			    (char *) "extra characters after close-quote",
			    HAX_STATIC);
		} else {
		    Hax_SetResult(interp,
			    (char *) "extra characters after close-brace",
			    HAX_STATIC);
		}
		return HAX_ERROR;
	    }
	    src = *termPtr;
	    dst = pvPtr->next;

	}

	/*
	 * We're at the end of a word, so add a null terminator.  Then
	 * see if the buffer was re-allocated during this word.  If so,
	 * update all of the argv pointers.
	 */

	wordEnd:
	*dst = '\0';
	dst++;
	if (oldBuffer != pvPtr->buffer) {
	    int i;

	    for (i = 0; i <= argc; i++) {
		argv[i] = pvPtr->buffer + (argv[i] - oldBuffer);
	    }
	    oldBuffer = pvPtr->buffer;
	}
    }

    done:
    pvPtr->next = dst;
    *termPtr = src;
    *argcPtr = argc;
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x40(%rsp)
movq %r8, 0x18(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, %r13
movq %rdi, (%rsp)
movq 0x88(%rsp), %rbp
movq 0x80(%rsp), %r8
movq (%rbp), %r9
movq 0x8(%rbp), %rbx
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
pushq $0x1
popq %r10
leaq 0x621e(%rip), %r12      # 0x14e14
movq %rcx, 0x20(%rsp)
cmpq %rcx, %rdi
je 0xeeaa
movq %r10, 0x28(%rsp)
movq %r9, 0x30(%rsp)
movq %rdi, 0x10(%rsp)
movq %rbx, (%r8,%rdi,8)
movsbq (%r13), %r15
movq 0xc38d(%rip), %rax      # 0x1afb0
movzbl 0x80(%rax,%r15), %r14d
cmpl $0x1, %r14d
je 0xec54
testl %r14d, %r14d
je 0xec9f
cmpl $0x2, %r14d
je 0xec8a
movq %rbx, 0x8(%rbp)
cmpl $0x7, %r14d
jne 0xec59
cmpb $0xa, 0x1(%r13)
jne 0xec9f
addq $0x2, %r13
jmp 0xec17
incq %r13
jmp 0xec17
cmpl $0x5, %r14d
je 0xedd6
cmpl $0x3, %r14d
jne 0xec9f
leaq 0x1(%r13), %rsi
movq (%rsp), %rdi
pushq $0x22
popq %rdx
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %r8
movq %rbp, %r9
callq 0x4490
jmp 0xedeb
testb $0x1, 0xc(%rsp)
jne 0xee92
cmpb $0x5d, %r15b
jne 0xeea5
cmpq 0x10(%rbp), %rbx
jne 0xecba
movq %rbx, 0x8(%rbp)
movq (%rsp), %rdi
movq %rbp, %rsi
pushq $0x1
popq %rdx
callq *0x18(%rbp)
movq 0x8(%rbp), %rbx
movzbl %r14b, %eax
decl %eax
cmpl $0x7, %eax
ja 0xece3
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
testb $0x1, 0xc(%rsp)
jne 0xedb8
cmpb $0x5d, %r15b
jne 0xedb8
movb %r15b, (%rbx)
incq %rbx
incq %r13
jmp 0xed9f
movq %rbx, 0x8(%rbp)
incq %r13
movq (%rsp), %rdi
movq %r13, %rsi
movl 0xc(%rsp), %edx
movq 0x18(%rsp), %rbx
movq %rbx, %rcx
movq %rbp, %r8
callq 0x4640
testl %eax, %eax
jne 0xeed6
movq (%rbx), %r13
movq 0x8(%rbp), %rbx
jmp 0xed9f
movq (%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %r14
movq %r14, %rdx
callq 0x4410
testq %rax, %rax
je 0xeed3
movq %rax, %r15
movq (%r14), %r13
movq %rax, %rdi
callq 0x41d0
movq 0x10(%rbp), %rcx
subq %rbx, %rcx
movslq %eax, %r14
cmpq %r14, %rcx
jg 0xed72
movq %rbx, 0x8(%rbp)
movq (%rsp), %rdi
movq %rbp, %rsi
movl %eax, %edx
callq *0x18(%rbp)
movq 0x8(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40f0
addq %r14, %rbx
jmp 0xed9f
movq %r13, %rdi
leaq 0x3c(%rsp), %rsi
callq 0x42c0
movb %al, (%rbx)
cmpb $0x1, %al
sbbq $-0x1, %rbx
movslq 0x3c(%rsp), %rax
addq %rax, %r13
movsbq (%r13), %r15
movq 0xc205(%rip), %rax      # 0x1afb0
movb 0x80(%rax,%r15), %r14b
jmp 0xec9f
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %r8
movq 0x30(%rsp), %r9
movq 0x28(%rsp), %r10
jmp 0xee4a
leaq 0x1(%r13), %rsi
movq (%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rbp, %rcx
callq 0x45e0
testl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x80(%rsp), %r8
movq 0x30(%rsp), %r9
movq 0x28(%rsp), %r10
jne 0xeed6
movq 0x18(%rsp), %rax
movq (%rax), %rax
movb (%rax), %dl
cmpb $0x5c, %dl
jne 0xee29
movb $0x5c, %dl
cmpb $0xa, 0x1(%rax)
jne 0xee29
movb 0x2(%rax), %dl
movsbq %dl, %rdx
movq 0xc17c(%rip), %rsi      # 0x1afb0
movb 0x80(%rsi,%rdx), %dl
addb $-0x3, %dl
cmpb $-0x3, %dl
jbe 0xee82
movq 0x8(%rbp), %rbx
movq %rax, %r13
movb $0x0, (%rbx)
cmpq (%rbp), %r9
je 0xee74
xorl %eax, %eax
movq (%rbp), %rsi
cmpq %rax, %r10
je 0xee71
movq (%r8,%rax,8), %rdx
subq %r9, %rdx
addq %rdx, %rsi
movq %rsi, (%r8,%rax,8)
incq %rax
jmp 0xee55
movq %rsi, %r9
incq %rbx
incq %rdi
incq %r10
jmp 0xebfb
cmpb $0x22, (%r13)
jne 0xeec1
leaq 0x5fe4(%rip), %rsi      # 0x14e74
jmp 0xeec8
movq 0x10(%rsp), %rcx
testb %r15b, %r15b
jne 0xeeaa
leaq 0x5fbb(%rip), %rsi      # 0x14e5e
jmp 0xeec8
movq 0x10(%rsp), %rcx
movq %rbx, 0x8(%rbp)
movq 0x18(%rsp), %rax
movq %r13, (%rax)
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
xorl %eax, %eax
jmp 0xeed6
leaq 0x5fcf(%rip), %rsi      # 0x14e97
movq (%rsp), %rdi
xorl %edx, %edx
callq 0x4500
pushq $0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq