// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxHistory.c
// Function: SubsAndEval
static int
SubsAndEval(
    Interp *iPtr,		/* Interpreter in which to execute
				 * new command. */
    char *cmd,			/* Command in which to substitute. */
    char *oldStr,		/* String to search for in command. */
    char *newStr		/* Replacement string for "old". */)
{
    Hax_Memoryp *memoryp = iPtr->memoryp;
    char *src, *dst, *newCmd;
    int count, oldLength, newLength, length, result;

    /*
     * Figure out how much space it will take to hold the
     * substituted command (and complain if the old string
     * doesn't appear in the original command).
     */

    oldLength = strlen(oldStr);
    newLength = strlen(newStr);
    src = cmd;
    count = 0;
    while (1) {
	src = strstr(src, oldStr);
	if (src == NULL) {
	    break;
	}
	src += oldLength;
	count++;
    }
    if (count == 0) {
	Hax_AppendResult((Hax_Interp *) iPtr, "\"", oldStr,
		"\" doesn't appear in event", (char *) NULL);
	return HAX_ERROR;
    }
    length = strlen(cmd) + count*(newLength - oldLength);

    /*
     * Generate a substituted command.
     */

    newCmd = (char *) ckalloc(memoryp, (unsigned) (length + 1));
    dst = newCmd;
    while (1) {
	src = strstr(cmd, oldStr);
	if (src == NULL) {
	    strcpy(dst, cmd);
	    break;
	}
	strncpy(dst, cmd, src-cmd);
	dst += src-cmd;
	strcpy(dst, newStr);
	dst += newLength;
	cmd = src + oldLength;
    }

    RevCommand(iPtr, newCmd);
    result = Hax_Eval((Hax_Interp *) iPtr, NULL, newCmd, 0, (char **) NULL);
    ckfree(memoryp, newCmd);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
callq 0x41b0
movl %eax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
callq 0x41b0
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4610
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x14a68
jmp 0x14a84
movl -0x50(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x14a4e
cmpl $0x0, -0x4c(%rbp)
jne 0x14ab8
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x87d7(%rip), %rsi      # 0x1d270
leaq 0xa510(%rip), %rcx      # 0x1efb0
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movl $0x1, -0x4(%rbp)
jmp 0x14bcb
movq -0x18(%rbp), %rdi
callq 0x41b0
movl -0x4c(%rbp), %ecx
movl -0x54(%rbp), %edx
subl -0x50(%rbp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq 0xa2ed(%rip), %rdx      # 0x1edd8
movl $0x3b3, %ecx            # imm = 0x3B3
callq 0x44c0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4610
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x14b28
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x40d0
jmp 0x14b85
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
callq 0x4080
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x40d0
movl -0x54(%rbp), %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movslq -0x50(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
jmp 0x14b01
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x148f0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
xorl %ecx, %ecx
movq %r8, %rsi
callq 0x45b0
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0xa21d(%rip), %rdx      # 0x1edd8
movl $0x3c4, %ecx            # imm = 0x3C4
callq 0x4260
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)