// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_pages_xkeep
static int
mdb_pages_xkeep(MDB_cursor *mc, unsigned pflags, int all)
{
	enum { Mask = P_SUBP|P_DIRTY|P_LOOSE|P_KEEP };
	MDB_txn *txn = mc->mc_txn;
	MDB_cursor *m3;
	MDB_xcursor *mx;
	MDB_page *dp, *mp;
	MDB_node *leaf;
	unsigned i, j;
	int rc = MDB_SUCCESS, level;

	/* Mark pages seen by cursors */
	if (mc->mc_flags & C_UNTRACK)
		mc = NULL;				/* will find mc in mt_cursors */
	for (i = txn->mt_numdbs;; mc = txn->mt_cursors[--i]) {
		for (; mc; mc=mc->mc_next) {
			if (!(mc->mc_flags & C_INITIALIZED))
				continue;
			for (m3 = mc;; m3 = &mx->mx_cursor) {
				mp = NULL;
				for (j=0; j<m3->mc_snum; j++) {
					mp = m3->mc_pg[j];
					if ((mp->mp_flags & Mask) == pflags)
						mp->mp_flags ^= P_KEEP;
				}
				mx = m3->mc_xcursor;
				/* Proceed to mx if it is at a sub-database */
				if (! (mx && (mx->mx_cursor.mc_flags & C_INITIALIZED)))
					break;
				if (! (mp && (mp->mp_flags & P_LEAF)))
					break;
				leaf = NODEPTR(mp, m3->mc_ki[j-1]);
				if (!(leaf->mn_flags & F_SUBDATA))
					break;
			}
		}
		if (i == 0)
			break;
	}

	if (all) {
		/* Mark dirty root pages */
		for (i=0; i<txn->mt_numdbs; i++) {
			if (txn->mt_dbflags[i] & DB_DIRTY) {
				pgno_t pgno = txn->mt_dbs[i].md_root;
				if (pgno == P_INVALID)
					continue;
				if ((rc = mdb_page_get(txn, pgno, &dp, &level)) != MDB_SUCCESS)
					break;
				if ((dp->mp_flags & Mask) == pflags && level <= 1)
					dp->mp_flags ^= P_KEEP;
			}
		}
	}

	return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
xorl %eax, %eax
testb $0x40, 0x44(%rdi)
movq 0x18(%rdi), %r14
cmovneq %rax, %rdi
movl 0x78(%r14), %eax
testq %rdi, %rdi
je 0xaccd
testb $0x1, 0x44(%rdi)
jne 0xac36
movq (%rdi), %rdi
jmp 0xac22
movq %rdi, %rcx
movzwl 0x40(%rcx), %r9d
testq %r9, %r9
je 0xac84
negq %r9
movq $-0x1, %rsi
movq 0x50(%rcx,%rsi,8), %r8
movzwl 0xa(%r8), %r10d
movl %r10d, %r11d
andl $0xc050, %r11d          # imm = 0xC050
cmpl %ebx, %r11d
jne 0xac72
xorl $0x8000, %r10d          # imm = 0x8000
movw %r10w, 0xa(%r8)
leaq (%r9,%rsi), %r10
incq %r10
incq %rsi
cmpq $-0x1, %r10
jne 0xac4d
jmp 0xac8c
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
movq 0x10(%rcx), %r9
testq %r9, %r9
je 0xac31
testq %r8, %r8
je 0xac31
movl 0x44(%r9), %r10d
andl $0x1, %r10d
je 0xac31
testb $0x2, 0xa(%r8)
je 0xac31
movzwl 0x148(%rcx,%rsi,2), %ecx
movzwl 0x10(%r8,%rcx,2), %ecx
testb $0x2, 0x4(%r8,%rcx)
movq %r9, %rcx
jne 0xac39
jmp 0xac31
subq $0x1, %rax
jb 0xace0
movq 0x68(%r14), %rcx
movq (%rcx,%rax,8), %rdi
jmp 0xac22
xorl %eax, %eax
testl %edx, %edx
je 0xad7f
cmpl $0x0, 0x78(%r14)
je 0xad7f
xorl %r13d, %r13d
movl $0x28, %ebp
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
xorl %eax, %eax
movq 0x70(%r14), %rcx
testb $0x1, (%rcx,%r13)
je 0xad6f
movq 0x58(%r14), %rcx
movq (%rcx,%rbp), %rsi
cmpq $-0x1, %rsi
je 0xad68
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x789a
testl %eax, %eax
je 0xad39
movb $0x1, %sil
jmp 0xad6a
movq 0x10(%rsp), %rcx
movzwl 0xa(%rcx), %edx
movl %edx, %esi
andl $0xc050, %esi           # imm = 0xC050
xorl %eax, %eax
cmpl %ebx, %esi
jne 0xad68
cmpl $0x1, 0xc(%rsp)
movl $0x0, %esi
jg 0xad6a
xorl $0x8000, %edx           # imm = 0x8000
movw %dx, 0xa(%rcx)
xorl %eax, %eax
xorl %esi, %esi
testb %sil, %sil
jne 0xad7f
incq %r13
movl 0x78(%r14), %ecx
addq $0x30, %rbp
cmpq %rcx, %r13
jb 0xad09
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq