// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxHistory.c
// Function: GetWords
static char *
GetWords(
    Interp *iPtr,		/* Hax interpreter in which to place
				 * an error message if needed. */
    char *command,		/* Command string. */
    char *words			/* Description of which words to extract
				 * from the command.  Either num[-num] or
				 * a pattern. */)
{
    Hax_Memoryp *memoryp = iPtr->memoryp;
    char *result;
    char *start, *end, *dst;
    char *next;
    int first;			/* First word desired. -1 means last word
				 * only. */
    int last;			/* Last word desired.  -1 means use everything
				 * up to the end. */
    int index;			/* Index of current word. */
    char *pattern;

    /*
     * Figure out whether we're looking for a numerical range or for
     * a pattern.
     */

    pattern = NULL;
    first = 0;
    last = -1;
    if (*words == '$') {
	if (words[1] != '\0') {
	    goto error;
	}
	first = -1;
    } else if (isdigit(*words)) {
	first = Strtoul(NULL, words, &start, 0);
	if (*start == 0) {
	    last = first;
	} else if (*start == '-') {
	    start++;
	    if (*start == '$') {
		start++;
	    } else if (isdigit(*start)) {
		last = Strtoul(NULL, start, &start, 0);
	    } else {
		goto error;
	    }
	    if (*start != 0) {
		goto error;
	    }
	}
	if ((first > last) && (last != -1)) {
	    goto error;
	}
    } else {
	pattern = words;
    }

    /*
     * Scan through the words one at a time, copying those that are
     * relevant into the result string.  Allocate a result area large
     * enough to hold all the words if necessary.
     */

    result = (char *) ckalloc(memoryp, (unsigned) (strlen(command) + 1));
    dst = result;
    for (next = command; isspace(*next); next++) {
	/* Empty loop body:  just find start of first word. */
    }
    for (index = 0; *next != 0; index++) {
	start = next;
	end = HaxWordEnd(next, 0);
	if (*end != 0) {
	    end++;
	    for (next = end; isspace(*next); next++) {
		/* Empty loop body:  just find start of next word. */
	    }
	}
	if ((first > index) || ((first == -1) && (*next != 0))) {
	    continue;
	}
	if ((last != -1) && (last < index)) {
	    continue;
	}
	if (pattern != NULL) {
	    int match;
	    char savedChar = *end;

	    *end = 0;
	    match = Hax_StringMatch(start, pattern);
	    *end = savedChar;
	    if (!match) {
		continue;
	    }
	}
	if (dst != result) {
	    *dst = ' ';
	    dst++;
	}
	strncpy(dst, start, (end-start));
	dst += end-start;
    }
    *dst = 0;

    /*
     * Check for an out-of-range argument index.
     */

    if ((last >= index) || (first >= index)) {
	ckfree(memoryp, result);
	Hax_AppendResult((Hax_Interp *) iPtr, "word selector \"", words,
		"\" specified non-existent words", (char *) NULL);
	return NULL;
    }
    return result;

    error:
    Hax_AppendResult((Hax_Interp *) iPtr, "bad word selector \"", words,
	    "\":  should be num-num or pattern", (char *) NULL);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x54(%rbp)
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x14c46
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x14c3a
jmp 0x14f56
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
jmp 0x14d3c
callq 0x4630
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x14d32
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq -0x38(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4340
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14c97
movl -0x54(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x14d1d
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x14d1b
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x14cc9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x14d08
callq 0x4630
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x14d01
movq -0x38(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq -0x38(%rbp), %rdx
xorl %ecx, %ecx
callq 0x4340
movl %eax, -0x58(%rbp)
jmp 0x14d06
jmp 0x14f56
jmp 0x14d08
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x14d19
jmp 0x14f56
jmp 0x14d1b
jmp 0x14d1d
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
jle 0x14d30
cmpl $-0x1, -0x58(%rbp)
je 0x14d30
jmp 0x14f56
jmp 0x14d3a
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x14d3c
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x41b0
movq -0x78(%rbp), %rdi
addq $0x1, %rax
movl %eax, %eax
movl %eax, %esi
leaq 0xa078(%rip), %rdx      # 0x1edd8
movl $0x41c, %ecx            # imm = 0x41C
callq 0x44c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x4630
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x14dae
jmp 0x14da0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x14d7e
movl $0x0, -0x5c(%rbp)
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x14ef0
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4190
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x14e2e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x4630
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x14e2c
jmp 0x14e1e
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x14dfc
jmp 0x14e2e
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x14e48
cmpl $-0x1, -0x54(%rbp)
jne 0x14e4d
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x14e4d
jmp 0x14ee2
cmpl $-0x1, -0x58(%rbp)
je 0x14e60
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x14e60
jmp 0x14ee2
cmpq $0x0, -0x68(%rbp)
je 0x14e9a
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, -0x6d(%rbp)
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
movq -0x38(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x4460
movl %eax, -0x6c(%rbp)
movb -0x6d(%rbp), %cl
movq -0x40(%rbp), %rax
movb %cl, (%rax)
cmpl $0x0, -0x6c(%rbp)
jne 0x14e98
jmp 0x14ee2
jmp 0x14e9a
movq -0x48(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x14eb7
movq -0x48(%rbp), %rax
movb $0x20, (%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rax
subq %rax, %rdx
callq 0x4080
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x14db5
movq -0x48(%rbp), %rax
movb $0x0, (%rax)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x14f07
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0x14f4c
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x9ec2(%rip), %rdx      # 0x1edd8
movl $0x449, %ecx            # imm = 0x449
callq 0x4260
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xa0be(%rip), %rsi      # 0x1efed
leaq 0xa094(%rip), %rcx      # 0x1efca
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq $0x0, -0x8(%rbp)
jmp 0x14f80
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14f80
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0xa084(%rip), %rsi      # 0x1efe9
leaq 0xa091(%rip), %rcx      # 0x1effd
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)