// File: /workspace/github_c_makefile_star2_O3/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 0x4650
movq %rax, %r14
movq (%rax), %rax
movsbq (%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0xfcd9
movzbl %cl, %eax
cmpl $0x22, %eax
je 0xfd40
decq %r15
cmpl $0x7b, %eax
jne 0xfd5c
movl $0x1, %ebp
leaq 0x4(%rsp), %r12
incq %r15
movzbl (%r15), %eax
cmpl $0x5c, %eax
jne 0xfd22
movq %r15, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
addq %rax, %r15
jmp 0xfd04
testl %eax, %eax
je 0xfe2d
cmpl $0x7b, %eax
je 0xfd38
cmpl $0x7d, %eax
jne 0xfd3a
decl %ebp
jmp 0xfd3a
incl %ebp
testl %ebp, %ebp
jne 0xfd01
jmp 0xfd59
movq %r15, %rdi
movl $0x22, %esi
callq 0xfe3f
movq %rax, %r15
cmpb $0x0, (%rax)
je 0xfe2d
incq %r15
leaq 0x4(%rsp), %r12
movq %r15, %r13
movzbl (%r15), %eax
cmpl $0x5a, %eax
jle 0xfda2
cmpl $0x5c, %eax
je 0xfdbc
cmpl $0x5b, %eax
jne 0xfdf0
movq %r13, %r15
cmpb $0x5d, 0x1(%r15)
je 0xfe15
incq %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x41b0
movq %rax, %r15
cmpb $0x0, (%rax)
jne 0xfd7a
jmp 0xfe2d
cmpl $0x24, %eax
jne 0xfdeb
movq %r13, %rdi
callq 0xfede
movq %rax, %r15
cmpb $0x0, (%rax)
je 0xfe2d
incq %r15
jmp 0xfd61
movq %r13, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
leaq (%rax,%r13), %r15
cmpq $0x2, %rax
jne 0xfd61
cmpb $0x0, (%r13,%rax)
jne 0xfd61
cmpb $0xa, -0x1(%r15)
jne 0xfd61
jmp 0xfe2d
cmpl $0x3b, %eax
je 0xfe2a
movsbq %al, %rcx
movq (%r14), %rdx
testb $0x20, 0x1(%rdx,%rcx,2)
jne 0xfe1e
testl %ebx, %ebx
je 0xfe06
cmpb $0x5d, %al
je 0xfe1e
testb %al, %al
je 0xfe23
incq %r13
movq %r13, %r15
jmp 0xfd61
addq $0x2, %r15
jmp 0xfd61
decq %r13
jmp 0xfe2a
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