// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxCmdIL.c
// Function: Hax_LreplaceCmd
int
Hax_LreplaceCmd(
    ClientData notUsed,			/* Not used. */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    char *p1, *p2, *element, savedChar, *dummy;
    long int i, first, last, count, size;
    int result;

    if (argc < 4) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" list first last ?element element ...?\"", (char *) NULL);
	return HAX_ERROR;
    }
    if (Hax_GetLong(interp, argv[2], &first) != HAX_OK) {
	return HAX_ERROR;
    }
    if (HaxGetListIndex(interp, argv[3], &last) != HAX_OK) {
	return HAX_ERROR;
    }
    if (first < 0) {
	first = 0;
    }
    if (last < 0) {
	last = 0;
    }
    if (first > last) {
	Hax_AppendResult(interp, "first index must not be greater than second",
		(char *) NULL);
	return HAX_ERROR;
    }

    /*
     * Skip over the elements of the list before "first".
     */

    size = 0;
    element = argv[1];
    for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) {
	result = HaxFindElement(interp, p1, &element, &p1, &size,
		(int *) NULL);
	if (result != HAX_OK) {
	    return result;
	}
    }
    if (*p1 == 0) {
	Hax_AppendResult(interp, "list doesn't contain element ",
		argv[2], (char *) NULL);
	return HAX_ERROR;
    }

    /*
     * Skip over the elements of the list up through "last".
     */

    for (p2 = p1 ; (count <= last) && (*p2 != 0); count++) {
	result = HaxFindElement(interp, p2, &dummy, &p2, (long int *) NULL,
		(int *) NULL);
	if (result != HAX_OK) {
	    return result;
	}
    }

    /*
     * Add the elements before "first" to the result.  Be sure to
     * include quote or brace characters that might terminate the
     * last of these elements.
     */

    p1 = element+size;
    if (element != argv[1]) {
	while ((*p1 != 0) && !isspace(*p1)) {
	    p1++;
	}
    }
    savedChar = *p1;
    *p1 = 0;
    Hax_AppendResult(interp, argv[1], (char *) NULL);
    *p1 = savedChar;

    /*
     * Add the new list elements.
     */

    for (i = 4; i < argc; i++) {
	Hax_AppendElement(interp, argv[i], 0);
    }

    /*
     * Append the remainder of the original list.
     */

    if (*p2 != 0) {
	if (*interp->result == 0) {
	    Hax_SetResult(interp, p2, HAX_VOLATILE);
	} else {
	    Hax_AppendResult(interp, " ", p2, (char *) NULL);
	}
    }
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rsi, %rbx
cmpl $0x3, %edx
jg 0x9c22
movq (%r14), %rdx
leaq 0xbc71(%rip), %rsi      # 0x15874
leaq 0xc4fd(%rip), %rcx      # 0x16107
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movl $0x1, %r15d
jmp 0x9e39
movl %edx, %ebp
movq 0x10(%r14), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x44b0
movl $0x1, %r15d
testl %eax, %eax
jne 0x9e39
movq 0x18(%r14), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x4090
testl %eax, %eax
jne 0x9e39
cmpq $0x0, 0x10(%rsp)
jns 0x9c6d
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x8(%rsp)
jns 0x9c7e
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
jle 0x9ca2
leaq 0xc49e(%rip), %rsi      # 0x1612f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x4500
jmp 0x9e39
movq $0x0, 0x20(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x28(%rsp)
movq %rax, (%rsp)
cmpq $0x0, 0x10(%rsp)
jle 0x9cfb
xorl %r13d, %r13d
leaq 0x20(%rsp), %r12
movq (%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x9cfe
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
movq %rsp, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x4360
testl %eax, %eax
jne 0x9e22
incq %r13
cmpq 0x10(%rsp), %r13
jl 0x9cc8
jmp 0x9cfe
xorl %r13d, %r13d
movq (%rsp), %rax
cmpb $0x0, (%rax)
je 0x9e09
movq %rax, 0x18(%rsp)
cmpq 0x8(%rsp), %r13
jg 0x9d51
decq %r13
leaq 0x18(%rsp), %r12
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x9d51
movq %rbx, %rdi
leaq 0x30(%rsp), %rdx
movq %r12, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x4360
testl %eax, %eax
jne 0x9e22
incq %r13
cmpq 0x8(%rsp), %r13
jl 0x9d1f
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
addq %rax, %rcx
movq %rcx, (%rsp)
cmpq 0x8(%r14), %rax
je 0x9d99
movq (%rsp), %r15
movb (%r15), %r12b
testb %r12b, %r12b
je 0x9d99
callq 0x4640
incq %r15
movq (%rax), %rcx
movsbq %r12b, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x9d99
movq %r15, (%rsp)
movb (%r15), %r12b
incq %r15
testb %r12b, %r12b
jne 0x9d7c
movq (%rsp), %rax
movb (%rax), %r12b
movb $0x0, (%rax)
movq 0x8(%r14), %rsi
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x4500
movq (%rsp), %rax
movb %r12b, (%rax)
cmpl $0x4, %ebp
je 0x9deb
cmpl $0x6, %ebp
movl $0x5, %r12d
cmovael %ebp, %r12d
movl $0x4, %r13d
movq (%r14,%r13,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4050
incq %r13
cmpq %r13, %r12
jne 0x9dd5
movq 0x18(%rsp), %rdx
cmpb $0x0, (%rdx)
je 0x9e39
movq (%rbx), %rax
cmpb $0x0, (%rax)
je 0x9e27
leaq 0xd12c(%rip), %rsi      # 0x16f30
xorl %r15d, %r15d
jmp 0x9e14
movq 0x10(%r14), %rdx
leaq 0xc347(%rip), %rsi      # 0x1615b
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4500
jmp 0x9e39
movl %eax, %r15d
jmp 0x9e39
movq %rbx, %rdi
movq %rdx, %rsi
movq $-0x1, %rdx
callq 0x44e0
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq