// File: /workspace/github_cpp_makefile_star2_O2/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_drop0
static int
mdb_drop0(MDB_cursor *mc, int subs)
{
	int rc;

	rc = mdb_page_search(mc, NULL, MDB_PS_FIRST);
	if (rc == MDB_SUCCESS) {
		MDB_txn *txn = mc->mc_txn;
		MDB_node *ni;
		MDB_cursor mx;
		unsigned int i;

		/* DUPSORT sub-DBs have no ovpages/DBs. Omit scanning leaves.
		 * This also avoids any P_LEAF2 pages, which have no nodes.
		 */
		if (mc->mc_flags & C_SUB)
			mdb_cursor_pop(mc);

		mdb_cursor_copy(mc, &mx);
		while (mc->mc_snum > 0) {
			MDB_page *mp = mc->mc_pg[mc->mc_top];
			unsigned n = NUMKEYS(mp);
			if (IS_LEAF(mp)) {
				for (i=0; i<n; i++) {
					ni = NODEPTR(mp, i);
					if (ni->mn_flags & F_BIGDATA) {
						MDB_page *omp;
						pgno_t pg;
						memcpy(&pg, NODEDATA(ni), sizeof(pg));
						rc = mdb_page_get(txn, pg, &omp, NULL);
						if (rc != 0)
							goto done;
						mdb_cassert(mc, IS_OVERFLOW(omp));
						rc = mdb_midl_append_range(&txn->mt_free_pgs,
							pg, omp->mp_pages);
						if (rc)
							goto done;
					} else if (subs && (ni->mn_flags & F_SUBDATA)) {
						mdb_xcursor_init1(mc, ni);
						rc = mdb_drop0(&mc->mc_xcursor->mx_cursor, 0);
						if (rc)
							goto done;
					}
				}
			} else {
				if ((rc = mdb_midl_need(&txn->mt_free_pgs, n)) != 0)
					goto done;
				for (i=0; i<n; i++) {
					pgno_t pg;
					ni = NODEPTR(mp, i);
					pg = NODEPGNO(ni);
					/* free it */
					mdb_midl_xappend(txn->mt_free_pgs, pg);
				}
			}
			if (!mc->mc_top)
				break;
			mc->mc_ki[mc->mc_top] = i;
			rc = mdb_cursor_sibling(mc, 1);
			if (rc) {
				if (rc != MDB_NOTFOUND)
					goto done;
				/* no more siblings, go back to beginning
				 * of previous level.
				 */
				mdb_cursor_pop(mc);
				mc->mc_ki[0] = 0;
				for (i=1; i<mc->mc_snum; i++) {
					mc->mc_ki[i] = 0;
					mc->mc_pg[i] = mx.mc_pg[i];
				}
			}
		}
		/* free it */
		rc = mdb_midl_append(&txn->mt_free_pgs, mc->mc_db->md_root);
done:
		if (rc)
			txn->mt_flags |= MDB_TXN_ERROR;
	} else if (rc == MDB_NOTFOUND) {
		rc = MDB_SUCCESS;
	}
	return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %esi, %ebx
movq %rdi, %r14
xorl %r13d, %r13d
pushq $0x4
popq %rdx
xorl %esi, %esi
callq 0x958a
testl %eax, %eax
je 0x891d
cmpl $0xffff87b2, %eax       # imm = 0xFFFF87B2
cmovnel %eax, %r13d
jmp 0x8b03
movq 0x18(%r14), %rax
movq %rax, 0x18(%rsp)
testb $0x4, 0x44(%r14)
je 0x8935
movq %r14, %rdi
callq 0x9f86
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0xac08
movq 0x18(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x8(%rsp)
movq %r14, 0x10(%rsp)
cmpw $0x0, 0x40(%r14)
je 0x8b18
movzwl 0x42(%r14), %eax
movq 0x48(%r14,%rax,8), %rbp
movzwl 0xc(%rbp), %r14d
addl $-0x10, %r14d
shrl %r14d
testb $0x2, 0xa(%rbp)
movl %r14d, %r12d
movl %r14d, 0x24(%rsp)
jne 0x89d6
movq 0x8(%rsp), %rdi
movl %r14d, %esi
callq 0xb1eb
testl %eax, %eax
jne 0x8af7
xorl %eax, %eax
cmpq %rax, %r12
je 0x8a79
movzwl 0x10(%rbp,%rax,2), %ecx
movl (%rbp,%rcx), %edx
movzwl 0x4(%rbp,%rcx), %ecx
shlq $0x20, %rcx
orq %rdx, %rcx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movq (%rdx), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rdx)
movq %rcx, 0x8(%rdx,%rsi,8)
incq %rax
jmp 0x899c
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x8a79
movzwl 0x10(%rbp,%r15,2), %eax
leaq (%rax,%rbp), %rsi
movzwl 0x4(%rbp,%rax), %eax
testb $0x1, %al
jne 0x8a1f
testl %ebx, %ebx
je 0x8a71
andl $0x2, %eax
je 0x8a71
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x5e86
movq 0x10(%r14), %rdi
xorl %esi, %esi
callq 0x88e8
testl %eax, %eax
je 0x8a71
jmp 0x8af7
movl %ebx, %r14d
movzwl 0x6(%rsi), %eax
movq 0x8(%rsi,%rax), %rbx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
leaq 0x28(%rsp), %rdx
xorl %ecx, %ecx
callq 0x6fba
testl %eax, %eax
jne 0x8af7
movq 0x28(%rsp), %rax
testb $0x4, 0xa(%rax)
je 0x8b37
movl 0xc(%rax), %edx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xb32d
testl %eax, %eax
movl %r14d, %ebx
jne 0x8af7
incq %r15
jmp 0x89d9
movq 0x10(%rsp), %r14
movzwl 0x42(%r14), %eax
testq %rax, %rax
je 0x8b18
movl 0x24(%rsp), %ecx
movw %cx, 0x148(%r14,%rax,2)
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x9e6c
testl %eax, %eax
je 0x8955
movl %eax, %r13d
cmpl $0xffff87b2, %eax       # imm = 0xFFFF87B2
jne 0x8b2d
movq %r14, %rdi
callq 0x9f86
andw $0x0, 0x148(%r14)
movzwl 0x40(%r14), %eax
xorl %ecx, %ecx
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
jae 0x8955
andw $0x0, 0x14a(%r14,%rcx,2)
movq 0x80(%rsp,%rcx,8), %rsi
movq %rsi, 0x50(%r14,%rcx,8)
movq %rdx, %rcx
jmp 0x8ace
movl %eax, %r13d
movq 0x18(%rsp), %rax
orb $0x2, 0x7c(%rax)
movl %r13d, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%r14), %rax
movq 0x28(%rax), %rsi
movq 0x8(%rsp), %rdi
callq 0xb24b
movl %eax, %r13d
testl %r13d, %r13d
jne 0x8afa
xorl %r13d, %r13d
jmp 0x8b03
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x612a(%rip), %rsi      # 0xec75
leaq 0x6134(%rip), %rdx      # 0xec86
movl $0x2522, %ecx           # imm = 0x2522
callq 0xb672