// File: /workspace/github_cpp_makefile_star2_O3/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_ovpage_free
static int
mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp)
{
	MDB_txn *txn = mc->mc_txn;
	pgno_t pg = mp->mp_pgno;
	unsigned x = 0, ovpages = mp->mp_pages;
	MDB_env *env = txn->mt_env;
	MDB_IDL sl = txn->mt_spill_pgs;
	MDB_ID pn = pg << 1;
	int rc;

	DPRINTF(("free ov page %"Z"u (%d)", pg, ovpages));
	/* If the page is dirty or on the spill list we just acquired it,
	 * so we should give it back to our current free list, if any.
	 * Otherwise put it onto the list of pages we freed in this txn.
	 *
	 * Won't create me_pghead: me_pglast must be inited along with it.
	 * Unsupported in nested txns: They would need to hide the page
	 * range in ancestor txns' dirty and spilled lists.
	 */
	if (env->me_pghead &&
		!txn->mt_parent &&
		((mp->mp_flags & P_DIRTY) ||
		 (sl && (x = mdb_midl_search(sl, pn)) <= sl[0] && sl[x] == pn)))
	{
		unsigned i, j;
		pgno_t *mop;
		MDB_ID2 *dl, ix, iy;
		rc = mdb_midl_need(&env->me_pghead, ovpages);
		if (rc)
			return rc;
		if (!(mp->mp_flags & P_DIRTY)) {
			/* This page is no longer spilled */
			if (x == sl[0])
				sl[0]--;
			else
				sl[x] |= 1;
			goto release;
		}
		/* Remove from dirty list */
		dl = txn->mt_u.dirty_list;
		x = dl[0].mid--;
		for (ix = dl[x]; ix.mptr != mp; ix = iy) {
			if (x > 1) {
				x--;
				iy = dl[x];
				dl[x] = ix;
			} else {
				mdb_cassert(mc, x > 1);
				j = ++(dl[0].mid);
				dl[j] = ix;		/* Unsorted. OK when MDB_TXN_ERROR. */
				txn->mt_flags |= MDB_TXN_ERROR;
				return MDB_CORRUPTED;
			}
		}
		if (!(env->me_flags & MDB_WRITEMAP))
			mdb_dpage_free(env, mp);
release:
		/* Insert in me_pghead */
		mop = env->me_pghead;
		j = mop[0] + ovpages;
		for (i = mop[0]; i && mop[i] < pg; i--)
			mop[j--] = mop[i];
		while (j>i)
			mop[j--] = pg++;
		mop[0] += ovpages;
	} else {
		rc = mdb_midl_append_range(&txn->mt_free_pgs, pg, ovpages);
		if (rc)
			return rc;
	}
	mc->mc_db->md_overflow_pages -= ovpages;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rbp
movq (%rsi), %r15
movl 0xc(%rsi), %r14d
movq 0x20(%rbp), %r13
cmpq $0x0, 0xb0(%r13)
je 0x7789
cmpq $0x0, (%rbp)
je 0x77b8
addq $0x28, %rbp
movq %rbp, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0xbbb9
testl %eax, %eax
jne 0x77a9
movq 0x28(%rbx), %rax
subq %r14, 0x18(%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r12
movq 0x40(%rbp), %rcx
xorl %eax, %eax
testb $0x10, 0xa(%rsi)
jne 0x77f9
testq %rcx, %rcx
je 0x7789
leaq (%r15,%r15), %rsi
movq %rcx, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %rsi, (%rsp)
callq 0xb9bc
movq 0x8(%rsp), %rcx
movl %eax, %edx
cmpq %rdx, (%rcx)
jb 0x7789
movq (%rsp), %rsi
cmpq %rsi, (%rcx,%rdx,8)
jne 0x7789
movl %eax, 0x14(%rsp)
movq %rcx, 0x8(%rsp)
movq %rbx, (%rsp)
leaq 0xb0(%r13), %rbx
movq %rbx, %rdi
movl %r14d, %esi
callq 0xba6f
testl %eax, %eax
jne 0x77a9
testb $0x10, 0xa(%r12)
jne 0x783a
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpq %rax, (%rcx)
jne 0x78ad
decq %rax
movq %rax, (%rcx)
jmp 0x78b1
movq 0x48(%rbp), %rsi
movq (%rsi), %rcx
leaq -0x1(%rcx), %rax
movq %rax, (%rsi)
movl %ecx, %edx
shlq $0x4, %rdx
movq 0x8(%rsi,%rdx), %rax
cmpq %r12, %rax
je 0x7899
addq %rsi, %rdx
movq (%rdx), %rdx
movl %ecx, %edi
leaq 0x1(%rdi), %rcx
shlq $0x4, %rdi
addq %rdi, %rsi
addq $-0x8, %rsi
decq %rcx
cmpq $0x2, %rcx
jb 0x799b
movq -0x8(%rsi), %rdi
movq (%rsi), %r8
movq %rdx, -0x8(%rsi)
movq %rax, (%rsi)
addq $-0x10, %rsi
movq %rdi, %rdx
movq %r8, %rax
cmpq %r12, %r8
jne 0x786f
testb $0x8, 0xe(%r13)
jne 0x78b1
movq %r13, %rdi
movq %r12, %rsi
callq 0x9d02
jmp 0x78b1
orb $0x1, (%rcx,%rax,8)
movq (%rbx), %rax
movl (%rax), %esi
xorl %edx, %edx
testl %esi, %esi
je 0x78de
movq (%rsp), %rbx
leal (%r14,%rsi), %ecx
movl %esi, %edi
movq (%rax,%rdi,8), %rdi
cmpq %r15, %rdi
jae 0x78e9
movl %ecx, %ecx
movq %rdi, (%rax,%rcx,8)
decl %esi
jne 0x78c0
movl %r14d, %ecx
jmp 0x78eb
movl %r14d, %ecx
addl %esi, %ecx
movq (%rsp), %rbx
jmp 0x78eb
movl %esi, %edx
cmpl %edx, %ecx
jbe 0x7993
movl %ecx, %esi
notl %edx
addl %ecx, %edx
leaq 0x2(%rdx), %rcx
andq $-0x2, %rcx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rax,%rsi,8), %rdx
xorl %esi, %esi
movdqa 0x7a27(%rip), %xmm1     # 0xf340
movdqa 0x7a2f(%rip), %xmm2     # 0xf350
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movq %rsi, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edi
notl %edi
testb $0x1, %dil
je 0x796c
leaq (%r15,%rsi), %rdi
movq %rdi, (%rdx)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0x7986
leaq (%r15,%rsi), %rdi
incq %rdi
movq %rdi, -0x8(%rdx)
addq $0x2, %rsi
addq $-0x10, %rdx
cmpq %rsi, %rcx
jne 0x7929
addq %r14, (%rax)
jmp 0x779f
movq (%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x81aa(%rip), %rsi      # 0xfb58
leaq 0x81a9(%rip), %rdx      # 0xfb5e
movl $0x1597, %ecx           # imm = 0x1597
callq 0xbfbd