// File: /workspace/github_c_makefile_star2_O1/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 0x4640
movq %rax, %r14
movq (%rax), %rax
movsbq (%r15), %rcx
incq %r15
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x10359
movzbl %cl, %eax
cmpl $0x22, %eax
je 0x103c7
decq %r15
cmpl $0x7b, %eax
jne 0x103e3
movl $0x1, %ebp
xorl %r13d, %r13d
leaq 0x4(%rsp), %r12
incq %r15
movzbl (%r15), %eax
cmpl $0x5c, %eax
jne 0x103a5
movq %r15, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
addq %rax, %r15
jmp 0x10387
testl %eax, %eax
je 0x103e8
cmpl $0x7b, %eax
je 0x103b7
cmpl $0x7d, %eax
jne 0x103b9
decl %ebp
jmp 0x103b9
incl %ebp
testl %ebp, %ebp
sete %r13b
jne 0x10384
leaq 0x1(%r15), %rax
jmp 0x103eb
movq %r15, %rdi
movl $0x22, %esi
callq 0x104db
movq %rax, %r15
cmpb $0x0, (%rax)
je 0x104c9
incq %r15
movq %r15, %rax
jmp 0x103f5
movq %r15, %rax
testb $0x1, %r13b
je 0x104c9
leaq 0x4(%rsp), %r12
movq %rax, %r15
movq %r15, %r13
movzbl (%r15), %eax
cmpl $0x5a, %eax
jle 0x1043e
cmpl $0x5c, %eax
je 0x10458
cmpl $0x5b, %eax
jne 0x1048c
movq %r13, %r15
cmpb $0x5d, 0x1(%r15)
je 0x104b1
incq %r15
movq %r15, %rdi
movl $0x1, %esi
callq 0x41b0
movq %rax, %r15
cmpb $0x0, (%rax)
jne 0x10416
jmp 0x104c9
cmpl $0x24, %eax
jne 0x10487
movq %r13, %rdi
callq 0x1057a
movq %rax, %r15
cmpb $0x0, (%rax)
je 0x104c9
incq %r15
jmp 0x103fd
movq %r13, %rdi
movq %r12, %rsi
callq 0x42c0
movslq 0x4(%rsp), %rax
leaq (%rax,%r13), %r15
cmpq $0x2, %rax
jne 0x103fd
cmpb $0x0, (%r13,%rax)
jne 0x103fd
cmpb $0xa, -0x1(%r15)
jne 0x103fd
jmp 0x104c9
cmpl $0x3b, %eax
je 0x104c6
movsbq %al, %rcx
movq (%r14), %rdx
testb $0x20, 0x1(%rdx,%rcx,2)
jne 0x104ba
testl %ebx, %ebx
je 0x104a2
cmpb $0x5d, %al
je 0x104ba
testb %al, %al
je 0x104bf
incq %r13
movq %r13, %r15
jmp 0x103fd
addq $0x2, %r15
jmp 0x103fd
decq %r13
jmp 0x104c6
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