// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1a8, %rsp            # imm = 0x1A8
movl %esi, %ebx
movq %rdi, %r14
xorl %r12d, %r12d
xorl %esi, %esi
movl $0x4, %edx
callq 0x9d28
testl %eax, %eax
je 0x8e7d
cmpl $0xffff87b2, %eax       # imm = 0xFFFF87B2
cmovnel %eax, %r12d
jmp 0x90ae
movl %ebx, 0x14(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x8(%rsp)
testb $0x4, 0x44(%r14)
je 0x8eaa
movzwl 0x40(%r14), %eax
testw %ax, %ax
je 0x8eaa
decw %ax
movw %ax, 0x40(%r14)
je 0x8eaa
decw 0x42(%r14)
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0xb444
movq 0x8(%rsp), %rax
addq $0x28, %rax
movq %rax, (%rsp)
cmpw $0x0, 0x40(%r14)
je 0x9084
movzwl 0x42(%r14), %eax
movq 0x48(%r14,%rax,8), %rbp
movzwl 0xc(%rbp), %ebx
addl $-0x10, %ebx
movl %ebx, %r13d
shrl %r13d
testb $0x2, 0xa(%rbp)
jne 0x8f45
movq (%rsp), %rdi
movl %r13d, %esi
callq 0xba6f
testl %eax, %eax
jne 0x90a2
cmpl $0x2, %ebx
jb 0x8f4e
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x1, %r13d
adcl $0x0, %r13d
xorl %ecx, %ecx
movzwl 0x10(%rbp,%rcx,2), %edx
movl (%rbp,%rdx), %esi
movzwl 0x4(%rbp,%rdx), %edx
shlq $0x20, %rdx
orq %rsi, %rdx
movq (%rax), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rax)
movq %rdx, 0x8(%rax,%rsi,8)
incq %rcx
cmpq %rcx, %r13
jne 0x8f17
jmp 0x8f51
cmpl $0x2, %ebx
jae 0x8fea
xorl %r13d, %r13d
movzwl 0x42(%r14), %eax
testq %rax, %rax
je 0x9084
movw %r13w, 0x148(%r14,%rax,2)
movq %r14, %rdi
movl $0x1, %esi
callq 0xa6a4
testl %eax, %eax
je 0x8ec4
movl %eax, %r12d
cmpl $0xffff87b2, %eax       # imm = 0xFFFF87B2
jne 0x9098
movzwl 0x40(%r14), %eax
testw %ax, %ax
je 0x9075
decw %ax
movw %ax, 0x40(%r14)
je 0x9075
decw 0x42(%r14)
movw $0x0, 0x148(%r14)
cmpw $0x1, %ax
je 0x8ec4
movzwl %ax, %eax
decq %rax
xorl %ecx, %ecx
movw $0x0, 0x14a(%r14,%rcx,2)
movq 0x70(%rsp,%rcx,8), %rdx
movq %rdx, 0x50(%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x8fc8
jmp 0x8ec4
cmpl $0x1, %r13d
adcl $0x0, %r13d
xorl %r15d, %r15d
movzwl 0x10(%rbp,%r15,2), %eax
leaq (%rax,%rbp), %rsi
movzwl 0x4(%rbp,%rax), %eax
testb $0x1, %al
jne 0x9029
cmpl $0x0, 0x14(%rsp)
je 0x9068
andl $0x2, %eax
je 0x9068
movq %r14, %rdi
callq 0x633e
movq 0x10(%r14), %rdi
xorl %esi, %esi
callq 0x8e46
jmp 0x9064
movzwl 0x6(%rsi), %eax
movq 0x8(%rsi,%rax), %rbx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x74c4
testl %eax, %eax
jne 0x90a2
movq 0x18(%rsp), %rax
testb $0x4, 0xa(%rax)
je 0x90c3
movl 0xc(%rax), %edx
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0xbbb9
testl %eax, %eax
jne 0x90a2
incq %r15
cmpq %r15, %r13
jne 0x8ff5
jmp 0x8f51
movw $0x0, 0x148(%r14)
jmp 0x8ec4
movq 0x28(%r14), %rax
movq 0x28(%rax), %rsi
movq (%rsp), %rdi
callq 0xbad1
movl %eax, %r12d
testl %r12d, %r12d
jne 0x90a5
xorl %r12d, %r12d
jmp 0x90ae
movl %eax, %r12d
movq 0x8(%rsp), %rax
orb $0x2, 0x7c(%rax)
movl %r12d, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%r14), %rax
movq 0x20(%rax), %rdi
leaq 0x6bc3(%rip), %rsi      # 0xfc95
leaq 0x6bcd(%rip), %rdx      # 0xfca6
movl $0x2522, %ecx           # imm = 0x2522
callq 0xbfbd