// File: jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb_copy.c
// Function: main
int main(int argc,char * argv[])
{
	int rc;
	MDB_env *env;
	const char *progname = argv[0], *act;
	unsigned flags = MDB_RDONLY;
	unsigned cpflags = 0;

	for (; argc > 1 && argv[1][0] == '-'; argc--, argv++) {
		if (argv[1][1] == 'n' && argv[1][2] == '\0')
			flags |= MDB_NOSUBDIR;
		else if (argv[1][1] == 'c' && argv[1][2] == '\0')
			cpflags |= MDB_CP_COMPACT;
		else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
			printf("%s\n", MDB_VERSION_STRING);
			exit(0);
		} else
			argc = 0;
	}

	if (argc<2 || argc>3) {
		fprintf(stderr, "usage: %s [-V] [-c] [-n] srcpath [dstpath]\n", progname);
		exit(EXIT_FAILURE);
	}

#ifdef SIGPIPE
	signal(SIGPIPE, sighandle);
#endif
#ifdef SIGHUP
	signal(SIGHUP, sighandle);
#endif
	signal(SIGINT, sighandle);
	signal(SIGTERM, sighandle);

	act = "opening environment";
	rc = mdb_env_create(&env);
	if (rc == MDB_SUCCESS) {
		rc = mdb_env_open(env, argv[1], flags, 0600);
	}
	if (rc == MDB_SUCCESS) {
		act = "copying";
		if (argc == 2)
			rc = mdb_env_copyfd2(env, MDB_STDOUT, cpflags);
		else
			rc = mdb_env_copy2(env, argv[2], cpflags);
	}
	if (rc)
		fprintf(stderr, "%s: %s failed, error %d (%s)\n",
			progname, act, rc, mdb_strerror(rc));
	mdb_env_close(env);

	return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x20000, -0x34(%rbp)   # imm = 0x20000
movl $0x0, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x8(%rbp)
movb %al, -0x39(%rbp)
jle 0x255e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x256a
jmp 0x262b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6e, %eax
jne 0x2599
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x2599
movl -0x34(%rbp), %eax
orl $0x4000, %eax           # imm = 0x4000
movl %eax, -0x34(%rbp)
jmp 0x260f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x63, %eax
jne 0x25c6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x25c6
movl -0x38(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x260d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x56, %eax
jne 0x2604
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x2604
leaq 0x14a15(%rip), %rdi     # 0x17004
leaq 0x14a12(%rip), %rsi     # 0x17008
movb $0x0, %al
callq 0x2120
xorl %edi, %edi
callq 0x2360
movl $0x0, -0x8(%rbp)
jmp 0x260d
jmp 0x260f
jmp 0x2611
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x253f
cmpl $0x2, -0x8(%rbp)
jl 0x2637
cmpl $0x3, -0x8(%rbp)
jle 0x265d
movq 0x189ba(%rip), %rax     # 0x1aff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x149db(%rip), %rsi     # 0x17027
movb $0x0, %al
callq 0x2210
movl $0x1, %edi
callq 0x2360
movl $0xd, %edi
leaq 0x137(%rip), %rsi       # 0x27a0
callq 0x21f0
movl $0x1, %edi
leaq 0x126(%rip), %rsi       # 0x27a0
callq 0x21f0
movl $0x2, %edi
leaq 0x115(%rip), %rsi       # 0x27a0
callq 0x21f0
movl $0xf, %edi
leaq 0x104(%rip), %rsi       # 0x27a0
callq 0x21f0
leaq 0x149ab(%rip), %rax     # 0x17053
movq %rax, -0x30(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x12a70
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x26da
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x34(%rbp), %edx
movl $0x180, %ecx            # imm = 0x180
callq 0x12e70
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x2720
leaq 0x14980(%rip), %rax     # 0x17067
movq %rax, -0x30(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x2707
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %edx
movl $0x1, %esi
callq 0x13df0
movl %eax, -0x14(%rbp)
jmp 0x271e
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x38(%rbp), %edx
callq 0x14530
movl %eax, -0x14(%rbp)
jmp 0x2720
cmpl $0x0, -0x14(%rbp)
je 0x2773
movq 0x188cb(%rip), %rax     # 0x1aff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x14(%rbp), %edi
callq 0x27b0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl -0x40(%rbp), %r8d
movq %rax, %r9
leaq 0x14903(%rip), %rsi     # 0x1706f
movb $0x0, %al
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x13d80
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)