// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxHistory.c
// Function: Hax_RecordAndEval
int
Hax_RecordAndEval(
    Hax_Interp *interp,		/* Token for interpreter in which command
				 * will be executed. */
    char *cmd,			/* Command to record. */
    int flags			/* Additional flags to pass to Hax_Eval.
				 * HAX_NO_EVAL means only record: don't
				 * execute command. */)
{
    Interp *iPtr = (Interp *) interp;
    HistoryEvent *eventPtr;
    int length, result;

    if (iPtr->numEvents == 0) {
	Hax_InitHistory(interp);
    }
    DoRevs(iPtr);

    /*
     * Don't record empty commands.
     */

    while (isspace(*cmd)) {
	cmd++;
    }
    if (*cmd == '\0') {
	Hax_ResetResult(interp);
	return HAX_OK;
    }

    iPtr->curEventNum++;
    iPtr->curEvent++;
    if (iPtr->curEvent >= iPtr->numEvents) {
	iPtr->curEvent = 0;
    }
    eventPtr = &iPtr->events[iPtr->curEvent];

    /*
     * Chop off trailing newlines before recording the command.
     */

    length = strlen(cmd);
    while (cmd[length-1] == '\n') {
	length--;
    }
    MakeSpace(iPtr, eventPtr, length + 1);
    strncpy(eventPtr->command, cmd, length);
    eventPtr->command[length] = 0;

    /*
     * Execute the command.  Note: history revision isn't possible after
     * a nested call to this procedure, because the event at the top of
     * the history list no longer corresponds to what's going on when
     * a nested call here returns.  Thus, must leave history revision
     * disabled when we return.
     */

    result = HAX_OK;
    if (flags != HAX_NO_EVAL) {
	iPtr->historyFirst = cmd;
	iPtr->revDisables = 0;
	result = Hax_Eval(interp, NULL, cmd, flags | HAX_RECORD_BOUNDS,
		(char **) NULL);
    }
    iPtr->revDisables = 1;
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
jne 0x140d1
movq -0x10(%rbp), %rdi
callq 0x43d0
movq -0x28(%rbp), %rdi
callq 0x14260
callq 0x4630
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x14108
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x140da
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14129
movq -0x10(%rbp), %rdi
callq 0x42b0
movl $0x0, -0x4(%rbp)
jmp 0x14256
movq -0x28(%rbp), %rax
movl 0xec(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xec(%rax)
movq -0x28(%rbp), %rax
movl 0xe8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe8(%rax)
movq -0x28(%rbp), %rax
movl 0xe8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0xd8(%rcx), %eax
jl 0x14173
movq -0x28(%rbp), %rax
movl $0x0, 0xe8(%rax)
movq -0x28(%rbp), %rax
movq 0xe0(%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0xe8(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x41b0
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x141c1
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x141a0
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %edx
addl $0x1, %edx
callq 0x144c0
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x4080
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x38(%rbp)
cmpl $-0x1, -0x1c(%rbp)
je 0x14242
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0xf8(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x100(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
orl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
callq 0x45b0
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl $0x1, 0x100(%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop