// File: /workspace/github_c_makefile_star2_O3/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 0x9862
movq (%r14), %rdx
leaq 0xb01d(%rip), %rsi      # 0x14860
leaq 0xb719(%rip), %rcx      # 0x14f63
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4510
movl $0x1, %r15d
jmp 0x9a64
movl %edx, %ebp
movq 0x10(%r14), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x44c0
movl $0x1, %r15d
testl %eax, %eax
jne 0x9a64
movq 0x18(%r14), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x4090
testl %eax, %eax
jne 0x9a64
movq 0x10(%rsp), %rax
testq %rax, %rax
jns 0x98b1
movq $0x0, 0x10(%rsp)
xorl %eax, %eax
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jns 0x98c6
movq $0x0, 0x8(%rsp)
xorl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x98e3
leaq 0xb6b9(%rip), %rsi      # 0x14f8b
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x4510
jmp 0x9a64
movq $0x0, 0x20(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x28(%rsp)
movq %rcx, (%rsp)
xorl %r13d, %r13d
testq %rax, %rax
je 0x993f
leaq 0x20(%rsp), %r12
movq (%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x99dc
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
movq %rsp, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x4370
testl %eax, %eax
jne 0x99e9
incq %r13
cmpq 0x10(%rsp), %r13
jl 0x9906
movq (%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x99dc
movq %rcx, 0x18(%rsp)
cmpq 0x8(%rsp), %r13
jg 0x998a
decq %r13
leaq 0x18(%rsp), %r12
movq 0x18(%rsp), %rsi
cmpb $0x0, (%rsi)
je 0x998a
movq %rbx, %rdi
leaq 0x30(%rsp), %rdx
movq %r12, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x4370
testl %eax, %eax
jne 0x99e9
incq %r13
cmpq 0x8(%rsp), %r13
jl 0x995c
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r13
leaq (%r15,%r13), %rcx
movq %rcx, (%rsp)
movb (%r15,%r13), %r12b
cmpq 0x8(%r14), %r15
je 0x99f1
testb %r12b, %r12b
je 0x99d7
callq 0x4650
leaq (%r15,%r13), %rcx
incq %rcx
movq (%rax), %rdx
movsbq %r12b, %rsi
testb $0x20, 0x1(%rdx,%rsi,2)
jne 0x99ee
movq %rcx, (%rsp)
movb (%rcx), %r12b
incq %rcx
testb %r12b, %r12b
jne 0x99b7
decq %rcx
xorl %r12d, %r12d
jmp 0x99f1
movq 0x10(%r14), %rdx
leaq 0xb5d0(%rip), %rsi      # 0x14fb7
jmp 0x9a58
movl %eax, %r15d
jmp 0x9a64
decq %rcx
movb $0x0, (%rcx)
movq 0x8(%r14), %rsi
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x4510
movq (%rsp), %rax
movb %r12b, (%rax)
cmpl $0x4, %ebp
je 0x9a3c
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 0x9a26
movq 0x18(%rsp), %rdx
cmpb $0x0, (%rdx)
je 0x9a64
movq (%rbx), %rax
cmpb $0x0, (%rax)
je 0x9a76
leaq 0xc1df(%rip), %rsi      # 0x15c34
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x4510
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %rdx, %rsi
movq $-0x1, %rdx
callq 0x44f0
jmp 0x9a64