// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxParse.c
// Function: HaxParseBraces
int
HaxParseBraces(
    Hax_Interp *interp,		/* Interpreter to use for nested command
				 * evaluations and error messages. */
    char *string,		/* Character just after opening bracket. */
    char **termPtr,		/* Store address of terminating character
				 * here. */
    ParseValue *pvPtr		/* Information about where to place
				 * result of command. */)
{
    int level;
    char *src, *dst, *end;
    char c;

    src = string;
    dst = pvPtr->next;
    end = pvPtr->end;
    level = 1;

    /*
     * Copy the characters one at a time to the result area, stopping
     * when the matching close-brace is found.
     */

    while (1) {
	c = *src;
	src++;
	if (dst == end) {
	    pvPtr->next = dst;
	    (*pvPtr->expandProc)(interp, pvPtr, 20);
	    dst = pvPtr->next;
	    end = pvPtr->end;
	}
	*dst = c;
	dst++;
	if (CHAR_TYPE(c) == HAX_NORMAL) {
	    continue;
	} else if (c == '{') {
	    level++;
	} else if (c == '}') {
	    level--;
	    if (level == 0) {
		dst--;			/* Don't copy the last close brace. */
		break;
	    }
	} else if (c == '\\') {
	    int count;

	    /*
	     * Must always squish out backslash-newlines, even when in
	     * braces.  This is needed so that this sequence can appear
	     * anywhere in a command, such as the middle of an expression.
	     */

	    if (*src == '\n') {
		dst--;
		src++;
	    } else {
		(void) Hax_Backslash(src-1, &count);
		while (count > 1) {
                    if (dst == end) {
                        pvPtr->next = dst;
                        (*pvPtr->expandProc)(interp, pvPtr, 20);
                        dst = pvPtr->next;
                        end = pvPtr->end;
                    }
		    *dst = *src;
		    dst++;
		    src++;
		    count--;
		}
	    }
	} else if (c == '\0') {
	    Hax_SetResult(interp, (char *) "missing close-brace", HAX_STATIC);
	    *termPtr = string-1;
	    return HAX_ERROR;
	}
    }

    *dst = '\0';
    pvPtr->next = dst;
    *termPtr = src;
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r12
movq %rdx, 0x20(%rsp)
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
movq 0x8(%rcx), %rbp
movq 0x10(%rcx), %rbx
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
movq 0xc522(%rip), %r13      # 0x1afb0
movq %rsi, 0x18(%rsp)
movb (%r14), %r15b
cmpq %rbx, %rbp
je 0xeaa0
movq %rbp, %rax
jmp 0xeabf
movq %rbp, 0x8(%r12)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
pushq $0x14
popq %rdx
callq *0x18(%r12)
movq 0x8(%r12), %rax
movq 0x10(%r12), %rbx
movsbq %r15b, %rcx
incq %r14
movb %r15b, (%rax)
leaq 0x1(%rax), %rbp
cmpb $0x0, 0x80(%r13,%rcx)
je 0xea93
movzbl %r15b, %ecx
cmpl $0x5c, %ecx
je 0xeaf9
testl %ecx, %ecx
je 0xeb74
cmpl $0x7d, %ecx
je 0xeb5e
cmpl $0x7b, %ecx
jne 0xea93
incl 0xc(%rsp)
jmp 0xea93
cmpb $0xa, (%r14)
jne 0xeb07
incq %r14
movq %rax, %rbp
jmp 0xea93
leaq -0x1(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x42c0
movl 0x8(%rsp), %eax
cmpl $0x2, %eax
jl 0xea93
cmpq %rbx, %rbp
jne 0xeb46
movq %rbp, 0x8(%r12)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
pushq $0x14
popq %rdx
callq *0x18(%r12)
movq 0x8(%r12), %rbp
movq 0x10(%r12), %rbx
movb (%r14), %al
movb %al, (%rbp)
incq %rbp
incq %r14
movl 0x8(%rsp), %eax
decl %eax
movl %eax, 0x8(%rsp)
jmp 0xeb19
decl 0xc(%rsp)
jne 0xea93
movb $0x0, (%rax)
movq %rax, 0x8(%r12)
xorl %eax, %eax
jmp 0xeb92
leaq 0x62cf(%rip), %rsi      # 0x14e4a
movq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x4500
movq 0x18(%rsp), %r14
decq %r14
pushq $0x1
popq %rax
movq 0x20(%rsp), %rcx
movq %r14, (%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq