// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxParse.c
// Function: HaxWordEnd
char *
HaxWordEnd(
    char *start,		/* Beginning of a word of a Hax command. */
    int nested			/* Zero means this is a top-level command.
				 * One means this is a nested command (close
				 * brace is a word terminator). */)
{
    char *p;
    int count;

    p = start;
    while (isspace(*p)) {
	p++;
    }

    /*
     * Handle words beginning with a double-quote or a brace.
     */

    if (*p == '"') {
	p = QuoteEnd(p+1, '"');
	if (*p == 0) {
	    return p;
	}
	p++;
    } else if (*p == '{') {
	int braces = 1;
	while (braces != 0) {
	    p++;
	    while (*p == '\\') {
		(void) Hax_Backslash(p, &count);
		p += count;
	    }
	    if (*p == '}') {
		braces--;
	    } else if (*p == '{') {
		braces++;
	    } else if (*p == 0) {
		return p;
	    }
	}
	p++;
    }

    /*
     * Handle words that don't start with a brace or double-quote.
     * This code is also invoked if the word starts with a brace or
     * double-quote and there is garbage after the closing brace or
     * quote.  This is an error as far as Hax_Eval is concerned, but
     * for here the garbage is treated as part of the word.
     */

    while (1) {
	if (*p == '[') {
	    for (p++; *p != ']'; p++) {
		p = HaxWordEnd(p, 1);
		if (*p == 0) {
		    return p;
		}
	    }
	    p++;
	} else if (*p == '\\') {
	    (void) Hax_Backslash(p, &count);
	    p += count;
	    if ((*p == 0) && (count == 2) && (p[-1] == '\n')) {
		return p;
	    }
	} else if (*p == '$') {
	    p = VarNameEnd(p);
	    if (*p == 0) {
		return p;
	    }
	    p++;
	} else if (*p == ';') {
	    /*
	     * Include the semi-colon in the word that is returned.
	     */

	    return p;
	} else if (isspace(*p)) {
	    return p-1;
	} else if ((*p == ']') && nested) {
	    return p-1;
	} else if (*p == 0) {
	    if (nested) {
		/*
		 * Nested commands can't end because of the end of the
		 * string.
		 */
		return p;
	    }
	    return p-1;
	} else {
	    p++;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r15
callq 0x4660
movq %rax, %r14
movq (%rax), %rax
movsbq (%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0xefa5
movzbl %cl, %eax
cmpl $0x22, %eax
je 0xf00a
decq %r15
cmpl $0x7b, %eax
jne 0xf024
pushq $0x1
popq %rbp
leaq 0x4(%rsp), %r12
incq %r15
testl %ebp, %ebp
jne 0xefe7
jmp 0xf024
movq %r15, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
addq %rax, %r15
movzbl (%r15), %eax
cmpl $0x5c, %eax
je 0xefd4
testl %eax, %eax
je 0xf101
cmpl $0x7b, %eax
je 0xf006
cmpl $0x7d, %eax
jne 0xefcb
decl %ebp
jmp 0xefcb
incl %ebp
jmp 0xefcb
pushq $0x22
popq %rsi
movq %r15, %rdi
callq 0xf113
movq %rax, %r15
cmpb $0x0, (%rax)
je 0xf101
incq %r15
pushq $0x1
popq %rbp
leaq 0x4(%rsp), %r12
movq %r15, %r13
movzbl (%r15), %eax
cmpl $0x24, %eax
je 0xf09a
cmpl $0x5b, %eax
je 0xf079
cmpl $0x5c, %eax
je 0xf0b2
cmpl $0x3b, %eax
je 0xf0fe
movsbq %al, %rcx
movq (%r14), %rdx
testb $0x20, 0x1(%rdx,%rcx,2)
jne 0xf0f2
testl %ebx, %ebx
je 0xf069
cmpb $0x5d, %al
je 0xf0f2
testb %al, %al
je 0xf0f7
incq %r13
movq %r13, %r15
jmp 0xf02c
movq %r13, %r15
cmpb $0x5d, 0x1(%r15)
je 0xf0e9
incq %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x41b0
movq %rax, %r15
cmpb $0x0, (%rax)
jne 0xf07c
jmp 0xf101
movq %r13, %rdi
callq 0xf1a4
movq %rax, %r15
cmpb $0x0, (%rax)
je 0xf101
incq %r15
jmp 0xf02c
movq %r13, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
leaq (%rax,%r13), %r15
cmpq $0x2, %rax
jne 0xf02c
cmpb $0x0, (%r13,%rax)
jne 0xf02c
cmpb $0xa, -0x1(%r15)
jne 0xf02c
jmp 0xf101
addq $0x2, %r15
jmp 0xf02c
decq %r13
jmp 0xf0fe
cmpl $0x1, %ebx
sbbq $0x0, %r13
movq %r13, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq