// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
callq 0x4630
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x14580
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x14698
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x41a0
cmpl $0x0, %eax
je 0x145a3
movq $0x0, -0x8(%rbp)
jmp 0x14767
cmpl $0x0, -0x1c(%rbp)
jge 0x145b9
movq -0x10(%rbp), %rax
movl 0xec(%rax), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xec(%rcx), %eax
jle 0x145f7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xa98f(%rip), %rsi      # 0x1ef66
leaq 0xa990(%rip), %rcx      # 0x1ef6e
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq $0x0, -0x8(%rbp)
jmp 0x14767
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0xec(%rcx), %ecx
movq -0x10(%rbp), %rdx
subl 0xd8(%rdx), %ecx
cmpl %ecx, %eax
jle 0x14618
cmpl $0x0, -0x1c(%rbp)
jg 0x14647
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xa93f(%rip), %rsi      # 0x1ef66
leaq 0xa956(%rip), %rcx      # 0x1ef84
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq $0x0, -0x8(%rbp)
jmp 0x14767
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rdx
subl 0xec(%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x14679
movq -0x10(%rbp), %rax
movl 0xd8(%rax), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x14767
movq -0x18(%rbp), %rdi
callq 0x41b0
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0xe8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x146ca
movq -0x10(%rbp), %rax
movl 0xd8(%rax), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xe8(%rcx), %eax
jne 0x146db
jmp 0x1473d
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
callq 0x40a0
cmpl $0x0, %eax
je 0x14723
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x4460
cmpl $0x0, %eax
je 0x1472d
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14767
jmp 0x1472f
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x146b4
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xa851(%rip), %rsi      # 0x1ef9d
leaq 0x8b1d(%rip), %rcx      # 0x1d270
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x4500
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)