// File: jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb_dump.c
// Function: dumpit
static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
{
	MDB_cursor *mc;
	MDB_stat ms;
	MDB_val key, data;
	MDB_envinfo info;
	unsigned int flags;
	int rc, i;

	rc = mdb_dbi_flags(txn, dbi, &flags);
	if (rc) return rc;

	rc = mdb_stat(txn, dbi, &ms);
	if (rc) return rc;

	rc = mdb_env_info(mdb_txn_env(txn), &info);
	if (rc) return rc;

	printf("VERSION=3\n");
	printf("format=%s\n", mode & PRINT ? "print" : "bytevalue");
	if (name)
		printf("database=%s\n", name);
	printf("type=btree\n");
	printf("mapsize=%" Z "u\n", info.me_mapsize);
	if (info.me_mapaddr)
		printf("mapaddr=%p\n", info.me_mapaddr);
	printf("maxreaders=%u\n", info.me_maxreaders);

	if (flags & MDB_DUPSORT)
		printf("duplicates=1\n");

	for (i=0; dbflags[i].bit; i++)
		if (flags & dbflags[i].bit)
			printf("%s=1\n", dbflags[i].name);

	printf("db_pagesize=%d\n", ms.ms_psize);
	printf("HEADER=END\n");

	rc = mdb_cursor_open(txn, dbi, &mc);
	if (rc) return rc;

	while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT) == MDB_SUCCESS)) {
		if (gotsig) {
			rc = EINTR;
			break;
		}
		if (mode & PRINT) {
			text(&key);
			text(&data);
		} else {
			byte(&key);
			byte(&data);
		}
	}
	printf("DATA=END\n");
	if (rc == MDB_NOTFOUND)
		rc = MDB_SUCCESS;

	return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x9c(%rbp), %rdx
callq 0xe630
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x2c56
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2ef2
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x50(%rbp), %rdx
callq 0x152e0
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x2c83
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2ef2
movq -0x10(%rbp), %rdi
callq 0x4160
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x15210
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x2cb8
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2ef2
leaq 0x14582(%rip), %rdi     # 0x17241
movb $0x0, %al
callq 0x2130
movl 0x185e8(%rip), %ecx     # 0x1b2b4
andl $0x1, %ecx
leaq 0x14587(%rip), %rsi     # 0x1725d
leaq 0x1457a(%rip), %rax     # 0x17257
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x14561(%rip), %rdi     # 0x1724c
movb $0x0, %al
callq 0x2130
cmpq $0x0, -0x20(%rbp)
je 0x2d0b
movq -0x20(%rbp), %rsi
leaq 0x14563(%rip), %rdi     # 0x17267
movb $0x0, %al
callq 0x2130
leaq 0x14562(%rip), %rdi     # 0x17274
movb $0x0, %al
callq 0x2130
movq -0x90(%rbp), %rsi
leaq 0x14559(%rip), %rdi     # 0x17280
movb $0x0, %al
callq 0x2130
cmpq $0x0, -0x98(%rbp)
je 0x2d4d
movq -0x98(%rbp), %rsi
leaq 0x14547(%rip), %rdi     # 0x1728d
movb $0x0, %al
callq 0x2130
movl -0x78(%rbp), %esi
leaq 0x14542(%rip), %rdi     # 0x17299
movb $0x0, %al
callq 0x2130
movl -0x9c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x2d7a
leaq 0x14535(%rip), %rdi     # 0x172a8
movb $0x0, %al
callq 0x2130
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rcx
leaq 0x184ae(%rip), %rax     # 0x1b240
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x2dfa
movl -0x9c(%rbp), %eax
movslq -0xa4(%rbp), %rdx
leaq 0x1848e(%rip), %rcx     # 0x1b240
shlq $0x4, %rdx
addq %rdx, %rcx
andl (%rcx), %eax
cmpl $0x0, %eax
je 0x2de7
movslq -0xa4(%rbp), %rcx
leaq 0x18472(%rip), %rax     # 0x1b240
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
leaq 0x144d6(%rip), %rdi     # 0x172b6
movb $0x0, %al
callq 0x2130
jmp 0x2de9
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2d84
movl -0x50(%rbp), %esi
leaq 0x144b8(%rip), %rdi     # 0x172bc
movb $0x0, %al
callq 0x2130
leaq 0x144ba(%rip), %rdi     # 0x172cc
movb $0x0, %al
callq 0x2130
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x28(%rbp), %rdx
callq 0xd7f0
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x2e46
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2ef2
jmp 0x2e48
movq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x70(%rbp), %rdx
movl $0x8, %ecx
callq 0x8040
cmpl $0x0, %eax
sete %al
movb %al, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0xa0(%rbp)
testb $0x1, %al
jne 0x2e78
jmp 0x2ec5
movl 0x1843a(%rip), %eax     # 0x1b2b8
cmpl $0x0, %eax
je 0x2e8f
movl $0x4, -0xa0(%rbp)
jmp 0x2ec5
movl 0x1841f(%rip), %eax     # 0x1b2b4
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2eb1
leaq -0x60(%rbp), %rdi
callq 0x2f00
leaq -0x70(%rbp), %rdi
callq 0x2f00
jmp 0x2ec3
leaq -0x60(%rbp), %rdi
callq 0x2fa0
leaq -0x70(%rbp), %rdi
callq 0x2fa0
jmp 0x2e48
leaq 0x1440c(%rip), %rdi     # 0x172d8
movb $0x0, %al
callq 0x2130
cmpl $0xffff87b2, -0xa0(%rbp) # imm = 0xFFFF87B2
jne 0x2ee9
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nop