// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movq %rdi, %r14
xorl %ebx, %ebx
xorl %esi, %esi
movl $0x4, %edx
callq 0xa112
testl %eax, %eax
je 0x91e5
cmpl $0xffff87b2, %eax       # imm = 0xFFFF87B2
cmovnel %eax, %ebx
movq %rbx, %rdi
jmp 0x9451
movq 0x18(%r14), %rax
movq %rax, 0x8(%rsp)
testb $0x4, 0x44(%r14)
je 0x920e
movzwl 0x40(%r14), %eax
testw %ax, %ax
je 0x920e
decw %ax
movw %ax, 0x40(%r14)
je 0x920e
decw 0x42(%r14)
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0xb8b7
movq 0x8(%rsp), %rax
addq $0x28, %rax
movq %rax, (%rsp)
xorl %edi, %edi
movq %r14, 0x10(%rsp)
cmpw $0x0, 0x40(%r14)
je 0x9431
movzwl 0x42(%r14), %eax
movq 0x48(%r14,%rax,8), %rbx
movzwl 0xc(%rbx), %ebp
addl $-0x10, %ebp
movl %ebp, %r12d
shrl %r12d
testb $0x2, 0xa(%rbx)
jne 0x9278
movq (%rsp), %rdi
movl %r12d, %esi
callq 0xbf73
testl %eax, %eax
je 0x9346
movl %eax, %edi
movl $0x7, %ecx
jmp 0x9419
cmpl $0x2, %ebp
jb 0x934d
cmpl $0x1, %r12d
adcl $0x0, %r12d
xorl %ebp, %ebp
movzwl 0x10(%rbx,%rbp,2), %eax
leaq (%rbx,%rax), %rsi
movzwl 0x4(%rbx,%rax), %eax
testb $0x1, %al
jne 0x92cd
testl %r13d, %r13d
je 0x9338
andl $0x2, %eax
je 0x9338
movq %r14, %rdi
callq 0x6663
movq 0x10(%r14), %rdi
xorl %esi, %esi
callq 0x91ac
xorl %edi, %edi
testl %eax, %eax
je 0x9338
jmp 0x9423
movzwl 0x6(%rsi), %eax
movq 0x8(%rsi,%rax), %r15
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x789a
testl %eax, %eax
je 0x92fa
movl %eax, %edi
movl $0x7, %ecx
jmp 0x932a
movq 0x18(%rsp), %rax
testb $0x4, 0xa(%rax)
je 0x9465
movl 0xc(%rax), %edx
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xc0ba
movl %eax, %edi
testl %eax, %eax
sete %r14b
movl %eax, %ecx
movl $0x7, %eax
cmovnel %eax, %ecx
testb %r14b, %r14b
movq 0x10(%rsp), %r14
je 0x9419
incq %rbp
cmpq %rbp, %r12
jne 0x928b
jmp 0x938d
xorl %edi, %edi
cmpl $0x2, %ebp
jae 0x9351
xorl %ebp, %ebp
jmp 0x938d
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x1, %r12d
adcl $0x0, %r12d
xorl %ebp, %ebp
movzwl 0x10(%rbx,%rbp,2), %ecx
movl (%rbx,%rcx), %edx
movzwl 0x4(%rbx,%rcx), %ecx
shlq $0x20, %rcx
orq %rdx, %rcx
movq (%rax), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rax)
movq %rcx, 0x8(%rax,%rdx,8)
incq %rbp
cmpq %rbp, %r12
jne 0x9362
movzwl 0x42(%r14), %eax
testq %rax, %rax
je 0x9414
movw %bp, 0x148(%r14,%rax,2)
movq %r14, %rdi
movl $0x1, %esi
callq 0xaab8
movl %eax, %edi
testl %eax, %eax
je 0x9410
movl $0x7, %ecx
cmpl $0xffff87b2, %edi       # imm = 0xFFFF87B2
jne 0x9419
movzwl 0x40(%r14), %eax
testw %ax, %ax
je 0x93d9
decw %ax
movw %ax, 0x40(%r14)
je 0x93d9
decw 0x42(%r14)
movw $0x0, 0x148(%r14)
movzwl 0x40(%r14), %eax
cmpq $0x2, %rax
jb 0x9410
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 0x93f3
xorl %ecx, %ecx
jmp 0x9419
movl $0x3, %ecx
testl %ecx, %ecx
je 0x922f
jmp 0x942c
movl $0x7, %ecx
movl %eax, %edi
jmp 0x9419
cmpl $0x7, %ecx
je 0x9444
movq 0x28(%r14), %rax
movq 0x28(%rax), %rsi
movq (%rsp), %rdi
callq 0xbfd5
movl %eax, %edi
testl %edi, %edi
je 0x9451
movq 0x8(%rsp), %rax
orb $0x2, 0x7c(%rax)
movl %edi, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x67dc(%rip), %rsi      # 0xfc55
leaq 0x67e6(%rip), %rdx      # 0xfc66
movl $0x2522, %ecx           # imm = 0x2522
callq 0xc43e