// File: /workspace/github_c_makefile_star2_O1/haxlang[P]hax/haxHistory.c
// Function: GetEvent
static HistoryEvent *
GetEvent(
    Interp *iPtr,		/* Interpreter in which to look. */
    char *string		/* Description of event. */)
{
    int eventNum, index;
    HistoryEvent *eventPtr;
    int length;

    /*
     * First check for a numeric specification of an event.
     */

    if (isdigit(*string) || (*string == '-')) {
	if (Hax_GetInt((Hax_Interp *) iPtr, string, &eventNum) != HAX_OK) {
	    return NULL;
	}
	if (eventNum < 0) {
	    eventNum += iPtr->curEventNum;
        }
	if (eventNum > iPtr->curEventNum) {
	    Hax_AppendResult((Hax_Interp *) iPtr, "event \"", string,
		    "\" hasn't occurred yet", (char *) NULL);
	    return NULL;
	}
	if ((eventNum <= iPtr->curEventNum-iPtr->numEvents)
		|| (eventNum <= 0)) {
	    Hax_AppendResult((Hax_Interp *) iPtr, "event \"", string,
		    "\" is too far in the past", (char *) NULL);
	    return NULL;
	}
	index = iPtr->curEvent + (eventNum - iPtr->curEventNum);
	if (index < 0) {
	    index += iPtr->numEvents;
	}
	return &iPtr->events[index];
    }

    /*
     * Next, check for an event that contains the string as a prefix or
     * that matches the string in the sense of Hax_StringMatch.
     */

    length = strlen(string);
    for (index = iPtr->curEvent - 1; ; index--) {
	if (index < 0) {
	    index += iPtr->numEvents;
	}
	if (index == iPtr->curEvent) {
	    break;
	}
	eventPtr = &iPtr->events[index];
	if ((strncmp(eventPtr->command, string, length) == 0)
		|| Hax_StringMatch(eventPtr->command, string)) {
	    return eventPtr;
	}
    }

    Hax_AppendResult((Hax_Interp *) iPtr, "no event matches \"", string,
	    "\"", (char *) NULL);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x4640
movsbq (%r14), %rcx
cmpq $0x2d, %rcx
je 0xeedc
movq (%rax), %rax
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
jne 0xeedc
movq %r14, %rdi
callq 0x41d0
movl 0xe8(%rbx), %ebp
movslq %eax, %r12
movl %ebp, %eax
leal -0x1(%rax), %ebp
testl %eax, %eax
jg 0xee90
addl 0xd8(%rbx), %ebp
cmpl 0xe8(%rbx), %ebp
je 0xef27
movq 0xe0(%rbx), %rax
movslq %ebp, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r15
movq (%rax,%rcx), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x40c0
testl %eax, %eax
je 0xef70
movq %r13, %rdi
movq %r14, %rsi
callq 0x4460
testl %eax, %eax
je 0xee81
jmp 0xef70
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41c0
testl %eax, %eax
je 0xeef5
xorl %r15d, %r15d
jmp 0xef70
movl 0x4(%rsp), %eax
testl %eax, %eax
jns 0xef07
addl 0xec(%rbx), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %edx
movl 0xec(%rbx), %esi
movl %edx, %eax
subl %esi, %eax
jle 0xef37
leaq 0x80f5(%rip), %rsi      # 0x17013
leaq 0x80f6(%rip), %rcx      # 0x1701b
jmp 0xef5d
leaq 0x811c(%rip), %rsi      # 0x1704a
leaq 0x637a(%rip), %rcx      # 0x152af
jmp 0xef5d
movl 0xd8(%rbx), %ecx
subl %ecx, %esi
cmpl %esi, %edx
setg %sil
testl %edx, %edx
setg %dl
testb %sil, %dl
jne 0xef82
leaq 0x80bd(%rip), %rsi      # 0x17013
leaq 0x80d4(%rip), %rcx      # 0x17031
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r14, %rdx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x4500
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl 0xe8(%rbx), %eax
movl %eax, %edx
sarl $0x1f, %edx
andl %ecx, %edx
addl %eax, %edx
movslq %edx, %r15
shlq $0x4, %r15
addq 0xe0(%rbx), %r15
jmp 0xef70