// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
callq 0x4630
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x16495
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x16467
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x164e1
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
movl $0x22, %esi
callq 0x16760
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x164d0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x16598
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x16596
movl $0x1, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x1658a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x1653a
movq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x42a0
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1650e
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7d, %eax
jne 0x16551
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x16585
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x16568
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x16583
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16581
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
jmp 0x16583
jmp 0x16585
jmp 0x164f8
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x16598
jmp 0x1659a
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x1660a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
je 0x165f9
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x4190
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x165e9
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
jmp 0x165eb
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x165b2
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x16751
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x16665
movq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x42a0
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16660
cmpl $0x2, -0x24(%rbp)
jne 0x16660
movq -0x20(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0xa, %eax
jne 0x16660
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
jmp 0x1674f
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x166a8
movq -0x20(%rbp), %rdi
callq 0x168b0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16697
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1674d
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3b, %eax
jne 0x166c1
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
callq 0x4630
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x166ef
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0x1670f
cmpl $0x0, -0x14(%rbp)
je 0x1670f
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16739
cmpl $0x0, -0x14(%rbp)
je 0x1672b
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x16756
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x16747
jmp 0x16749
jmp 0x1674b
jmp 0x1674d
jmp 0x1674f
jmp 0x16751
jmp 0x1659a
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq