// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxHistory.c
// Function: InsertRev
static void
InsertRev(
    Interp *iPtr,			/* Interpreter to use. */
    HistoryRev *revPtr	/* Revision to add to iPtr's list. */)
{
    Hax_Memoryp *memoryp = iPtr->memoryp;
    HistoryRev *curPtr;
    HistoryRev *prevPtr;

    for (curPtr = iPtr->revPtr, prevPtr = NULL; curPtr != NULL;
	    prevPtr = curPtr, curPtr = curPtr->nextPtr) {
	/*
	 * If this revision includes the new one (or vice versa) then
	 * just eliminate the one that is a subset of the other.
	 */

	if ((revPtr->firstIndex <= curPtr->firstIndex)
		&& (revPtr->lastIndex >= curPtr->firstIndex)) {
	    curPtr->firstIndex = revPtr->firstIndex;
	    curPtr->lastIndex = revPtr->lastIndex;
	    curPtr->newSize = revPtr->newSize;
	    ckfree(memoryp, curPtr->newBytes);
	    curPtr->newBytes = revPtr->newBytes;
	    ckfree(memoryp, (char *) revPtr);
	    return;
	}
	if ((revPtr->firstIndex >= curPtr->firstIndex)
		&& (revPtr->lastIndex <= curPtr->lastIndex)) {
	    ckfree(memoryp, revPtr->newBytes);
	    ckfree(memoryp, (char *) revPtr);
	    return;
	}

	if (revPtr->firstIndex < curPtr->firstIndex) {
	    break;
	}
    }

    /*
     * Insert revPtr just after prevPtr.
     */

    if (prevPtr == NULL) {
	revPtr->nextPtr = iPtr->revPtr;
	iPtr->revPtr = revPtr;
    } else {
	revPtr->nextPtr = prevPtr->nextPtr;
	prevPtr->nextPtr = revPtr;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x150e6
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x15065
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x15065
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x9dab(%rip), %rdx      # 0x1edd8
movl $0x24a, %ecx            # imm = 0x24A
callq 0x4260
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq 0x9d82(%rip), %rdx      # 0x1edd8
movl $0x24c, %ecx            # imm = 0x24C
callq 0x4260
jmp 0x1512d
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x150bb
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jg 0x150bb
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x9d42(%rip), %rdx      # 0x1edd8
movl $0x251, %ecx            # imm = 0x251
callq 0x4260
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq 0x9d29(%rip), %rdx      # 0x1edd8
movl $0x252, %ecx            # imm = 0x252
callq 0x4260
jmp 0x1512d
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x150cb
jmp 0x150e6
jmp 0x150cd
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x14fc6
cmpq $0x0, -0x28(%rbp)
jne 0x15111
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xf0(%rax)
jmp 0x1512d
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)