// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxParse.c
// Function: HaxParseQuotes
int
HaxParseQuotes(
    Hax_Interp *interp,		/* Interpreter to use for nested command
				 * evaluations and error messages. */
    char *string,		/* Character just after opening double-
				 * quote. */
    int termChar,		/* Character that terminates "quoted" string
				 * (usually double-quote, but sometimes
				 * right-paren or something else). */
    int flags,			/* Flags to pass to nested Hax_Eval calls. */
    char **termPtr,		/* Store address of terminating character
				 * here. */
    ParseValue *pvPtr		/* Information about where to place
				 * fully-substituted result of parse. */)
{
    char *src, *dst, c;

    src = string;
    dst = pvPtr->next;

    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;
	}

	c = *src;
	src++;
	if (c == termChar) {
	    *dst = '\0';
	    pvPtr->next = dst;
	    *termPtr = src;
	    return HAX_OK;
	} else if (CHAR_TYPE(c) == HAX_NORMAL) {
	    copy:
	    *dst = c;
	    dst++;
	    continue;
	} else if (c == '$') {
	    int length;
	    char *value;

	    value = Hax_ParseVar(interp, src-1, 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;
	    continue;
	} else if (c == '[') {
	    int result;

	    pvPtr->next = dst;
	    result = HaxParseNestedCmd(interp, src, flags, termPtr, pvPtr);
	    if (result != HAX_OK) {
		return result;
	    }
	    src = *termPtr;
	    dst = pvPtr->next;
	    continue;
	} else if (c == '\\') {
	    int numRead;

	    src--;
	    *dst = Hax_Backslash(src, &numRead);
	    if (*dst != 0) {
		dst++;
	    }
	    src += numRead;
	    continue;
	} else if (c == '\0') {
	    Hax_ResetResult(interp);
	    sprintf(interp->result, "missing %c", termChar);
	    *termPtr = string-1;
	    return HAX_ERROR;
	} else {
	    goto copy;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r15
movq %r8, 0x18(%rsp)
movl %ecx, 0x20(%rsp)
movl %edx, %ebp
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movq 0x8(%r9), %r14
movq 0xc6b6(%rip), %r12      # 0x1bfb0
movq %rsi, 0x30(%rsp)
cmpq 0x10(%r15), %r14
jne 0xf91e
movq %r14, 0x8(%r15)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq *0x18(%r15)
movq 0x8(%r15), %r14
movsbl (%r13), %eax
leaq 0x1(%r13), %rbx
cmpl %ebp, %eax
je 0xfa4f
movslq %eax, %rcx
cmpb $0x0, 0x80(%r12,%rcx)
je 0xf97c
movzbl %al, %ecx
cmpl $0x5b, %ecx
jle 0xf96a
cmpl $0x5c, %ecx
jne 0xf97c
movq %r13, %rdi
leaq 0x24(%rsp), %rsi
callq 0x42c0
movb %al, (%r14)
cmpb $0x1, %al
sbbq $-0x1, %r14
movslq 0x24(%rsp), %rax
addq %rax, %r13
jmp 0xf8ff
testl %ecx, %ecx
je 0xfa61
cmpl $0x24, %ecx
je 0xf98a
cmpl $0x5b, %ecx
je 0xf9f6
movb %al, (%r14)
incq %r14
movq %rbx, %r13
jmp 0xf8ff
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq 0x18(%rsp), %r13
movq %r13, %rdx
callq 0x43f0
testq %rax, %rax
je 0xfa39
movq (%r13), %rbx
movq %rax, %r13
movq %rax, %rdi
callq 0x41d0
movq 0x10(%r15), %rcx
subq %r14, %rcx
movslq %eax, %rdx
movq %rdx, 0x28(%rsp)
cmpq %rdx, %rcx
jg 0xf9e1
movq %r14, 0x8(%r15)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq *0x18(%r15)
movq 0x8(%r15), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x40f0
movq %r13, %rax
addq 0x28(%rsp), %r14
jmp 0xfa41
movq %r14, 0x8(%r15)
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl 0x20(%rsp), %edx
movq 0x18(%rsp), %r13
movq %r13, %rcx
movq %r15, %r8
callq 0x4620
movl %eax, %ecx
testl %eax, %eax
jne 0xfa28
movq (%r13), %rbx
movq 0x8(%r15), %r14
movl 0xc(%rsp), %ecx
movq %rbx, %r13
movl %ecx, 0xc(%rsp)
testl %eax, %eax
je 0xf8ff
jmp 0xfa99
movl $0x1, 0xc(%rsp)
movq %rbx, %r13
testq %rax, %rax
jne 0xf8ff
jmp 0xfa99
movb $0x0, (%r14)
movq %r14, 0x8(%r15)
movl $0x0, 0xc(%rsp)
jmp 0xfa91
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x42d0
movq (%rbx), %rdi
leaq 0x76e8(%rip), %rsi      # 0x17160
movl %ebp, %edx
xorl %eax, %eax
callq 0x45d0
movq 0x30(%rsp), %rbx
decq %rbx
movl $0x1, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq %rbx, (%rax)
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq