// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/kvlds-undump/main.c
// Function: main
int
main(int argc, char * argv[])
{
	/* State variables. */
	void * K;
	struct wire_requestqueue * Q;
	struct undumpstate C;
	struct timeval st, en;

	/* Command-line parameters. */
	char * opt_fs = NULL;
	char * opt_t = NULL;
	int opt_v = 0;

	/* Working variables. */
	const char * ch;

	WARNP_INIT;

	/* Parse the command line. */
	while ((ch = GETOPT(argc, argv)) != NULL) {
		GETOPT_SWITCH(ch) {
		GETOPT_OPTARG("--fs"):
			if (opt_fs != NULL)
				usage();
			if ((opt_fs = strdup(optarg)) == NULL)
				OPT_EPARSE(ch, optarg);
			break;
		GETOPT_OPTARG("-t"):
			if (opt_t != NULL)
				usage();
			if ((opt_t = strdup(optarg)) == NULL)
				OPT_EPARSE(ch, optarg);
			break;
		GETOPT_OPTARG("-v"):
			opt_v++;
			break;
		GETOPT_OPT("--version"):
			fprintf(stderr, "kivaloo-kvlds-undump @VERSION@\n");
			exit(0);
		GETOPT_MISSING_ARG:
			warn0("Missing argument to %s", ch);
			usage();
		GETOPT_DEFAULT:
			warn0("illegal option -- %s", ch);
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	/* We should have processed all the arguments. */
	if (argc != 0)
		usage();
	(void)argv; /* argv is not used beyond this point. */

	/* Sanity-check options. */
	if (opt_t == NULL)
		usage();

	/* Open a connection to KVLDS. */
	if ((K = kivaloo_open(opt_t, &Q)) == NULL) {
		warnp("Could not connect to KVLDS daemon");
		exit(1);
	}

	/*
	 * If we're reading from the filesystem, move to that directory and
	 * start reading it.
	 */
	if (opt_fs) {
		if (chdir(opt_fs)) {
			warnp("chdir(%s)", opt_fs);
			exit(1);
		}
		if ((C.d = opendir(".")) == NULL) {
			warnp("opendir(.)");
			exit(1);
		}
	}

	/* Prepare for undumping key-value pairs. */
	C.N = 0;
	if (!opt_fs)
		C.d = NULL;

	/* Get timestamp. */
	if (monoclock_get(&st)) {
		warnp("monoclock_get");
		exit(1);
	}

	/* Store many key-value pairs. */
	if (kvlds_multiset(Q, callback_pair, &C)) {
		warnp("Error occurred while writing key-value pairs");
		exit(1);
	}

	/* Get timestamp. */
	if (monoclock_get(&en)) {
		warnp("monoclock_get");
		exit(1);
	}

	/* Print statistics if appropriate. */
	if (opt_v) {
		fprintf(stderr,
		    "Stored %" PRIu64 " key-value pairs in %f seconds.",
		    C.N, timeval_diff(en, st));
	}

	/* Close the directory (if applicable). */
	if (opt_fs) {
		if (closedir(C.d)) {
			warnp("closedir");
			exit(1);
		}
	}

	/* Close the connection to KVLDS. */
	kivaloo_close(K);

	/* Free option strings. */
	free(opt_t);
	free(opt_fs);

	/* Success! */
	exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edi, %r15d
movq %rsi, 0x30(%rsp)
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x296f
callq 0x3cf0
movl %r15d, %edi
movq 0x30(%rsp), %rsi
callq 0x34c0
testq %rax, %rax
movl %r15d, 0x10(%rsp)
jne 0x29ac
movb $0x1, %bpl
xorl %r14d, %r14d
xorl %r15d, %r15d
leaq 0xf86a(%rip), %rax      # 0x12200
movl 0x10(%rsp), %ecx
cmpl %ecx, (%rax)
jne 0x29a7
testq %r15, %r15
jne 0x2c56
callq 0x2f10
movq %rax, %r12
movq $0x0, 0x28(%rsp)
leaq 0xfcc1(%rip), %r13      # 0x12680
leaq 0x964a(%rip), %rbx      # 0xc010
leaq 0x96be(%rip), %r14      # 0xc08b
leaq 0x96ba(%rip), %rbp      # 0xc08e
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0xc9, 0x8(%rsp)
movq 0x8(%rsp), %rax
decq %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x14(%rsp)
cmpl $0x0, (%r13)
je 0x2a1a
movq %r12, %rdi
callq 0x37eb
addq 0x8(%rsp), %rax
jmp 0x2a28
movq 0x38(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x38(%rsp)
leaq -0xd6(%rax), %rcx
cmpq $0x9, %rcx
ja 0x2a5b
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpl $0x0, (%r13)
jne 0x2b3d
movl $0xd6, %esi
subq 0x8(%rsp), %rsi
movq %r14, %rdi
jmp 0x2b21
cmpq $0xd0, %rax
je 0x2b05
cmpq $0xca, %rax
jne 0x2a90
cmpl $0x0, (%r13)
jne 0x2b5c
movl $0xca, %esi
subq 0x8(%rsp), %rsi
leaq 0x95da(%rip), %rdi      # 0xc065
jmp 0x2b21
cmpl $0x0, (%r13)
jne 0x2c05
cmpl $0x0, 0x14(%rsp)
jne 0x2a04
movl $0xdf, %edi
subq 0x8(%rsp), %rdi
callq 0x39ff
movl $0x1, 0x14(%rsp)
jmp 0x2a04
cmpl $0x0, (%r13)
jne 0x2c0e
movl $0xdc, %edi
subq 0x8(%rsp), %rdi
callq 0x39bf
jmp 0x2a04
cmpl $0x0, (%r13)
jne 0x2c2f
movl $0xd9, %esi
subq 0x8(%rsp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x38a8
jmp 0x2a04
cmpl $0x0, (%r13)
jne 0x2b92
movl $0xd0, %esi
subq 0x8(%rsp), %rsi
leaq 0x9567(%rip), %rdi      # 0xc088
movl $0x1, %edx
callq 0x38a8
jmp 0x2a04
movl $0x1, (%r13)
jmp 0x2bd4
leaq 0xfb34(%rip), %rax      # 0x12678
cmpq $0x0, (%rax)
je 0x2e54
movq 0x28(%rsp), %rax
incl %eax
movq %rax, 0x28(%rsp)
jmp 0x2bd4
leaq 0xfb15(%rip), %rax      # 0x12678
cmpq $0x0, (%rax)
je 0x2e94
cmpq $0x0, 0x20(%rsp)
jne 0x29a7
leaq 0xfaf8(%rip), %rax      # 0x12678
movq (%rax), %r15
movq %r15, %rdi
callq 0x2390
movq %rax, 0x20(%rsp)
jmp 0x2bc6
leaq 0xfadf(%rip), %rax      # 0x12678
cmpq $0x0, (%rax)
je 0x2eb3
cmpq $0x0, 0x18(%rsp)
jne 0x29a7
leaq 0xfac2(%rip), %rax      # 0x12678
movq (%rax), %r15
movq %r15, %rdi
callq 0x2390
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2e24
movl 0x10(%rsp), %r15d
movl %r15d, %edi
movq 0x30(%rsp), %rsi
callq 0x34c0
movq %rax, %r12
testq %rax, %rax
jne 0x29e6
cmpl $0x0, 0x28(%rsp)
sete %bpl
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
jmp 0x298f
leaq 0x94c3(%rip), %rdi      # 0xc0cf
jmp 0x2c15
leaq 0x94a3(%rip), %rdi      # 0xc0b8
movq %r12, %rsi
xorl %eax, %eax
callq 0x3e8f
callq 0x20a0
movl $0x0, (%rax)
callq 0x2f10
movq 0xf3c2(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x9458(%rip), %rdi      # 0xc098
movl $0x1f, %esi
movl $0x1, %edx
callq 0x2370
xorl %edi, %edi
callq 0x2350
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x40f4
testq %rax, %rax
jne 0x2c82
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2da3
leaq 0x9467(%rip), %rdi      # 0xc0e4
jmp 0x2e05
movq %rax, %rbx
testq %r14, %r14
je 0x2cca
movq %r14, %rdi
callq 0x2150
testl %eax, %eax
jne 0x2dc5
leaq 0x9554(%rip), %rdi      # 0xc1f5
callq 0x2130
movq %rax, 0x40(%rsp)
testq %rax, %rax
jne 0x2cca
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2e73
leaq 0x944b(%rip), %rdi      # 0xc110
jmp 0x2e05
movq $0x0, 0x48(%rsp)
testq %r14, %r14
jne 0x2ce1
movq $0x0, 0x40(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x3ab4
testl %eax, %eax
jne 0x2db2
movq 0x50(%rsp), %rdi
leaq 0x255(%rip), %rsi       # 0x2f54
leaq 0x40(%rsp), %rdx
callq 0x42ac
testl %eax, %eax
jne 0x2df4
leaq 0x58(%rsp), %rdi
callq 0x3ab4
testl %eax, %eax
jne 0x2db2
testb %bpl, %bpl
jne 0x2d6f
movq 0xf2c9(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq 0x58(%rsp), %rax
cvtsi2sd %rax, %xmm1
subq 0x60(%rsp), %rcx
cvtsi2sd %rcx, %xmm0
movq 0x48(%rsp), %rdx
mulsd 0x92ab(%rip), %xmm0     # 0xc008
addsd %xmm1, %xmm0
leaq 0x93ee(%rip), %rsi      # 0xc156
movb $0x1, %al
callq 0x2230
testq %r14, %r14
je 0x2d86
movq 0x40(%rsp), %rdi
callq 0x21f0
testl %eax, %eax
jne 0x2eeb
movq %rbx, %rdi
callq 0x423d
movq %r15, %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
jmp 0x2c4f
movq %rax, %rbx
leaq 0x9337(%rip), %rdi      # 0xc0e4
jmp 0x2e7d
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2de5
leaq 0x9358(%rip), %rdi      # 0xc11b
jmp 0x2e05
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2e0e
leaq 0x9330(%rip), %rdi      # 0xc106
movq %r14, %rsi
xorl %eax, %eax
callq 0x3e8f
jmp 0x2e8a
movq %rax, %rbx
leaq 0x932c(%rip), %rdi      # 0xc11b
jmp 0x2e7d
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2e48
leaq 0x9324(%rip), %rdi      # 0xc129
xorl %eax, %eax
callq 0x3e8f
jmp 0x2e8a
movq %rax, %rbx
leaq 0x92ee(%rip), %rdi      # 0xc106
movq %r14, %rsi
xorl %eax, %eax
callq 0x3d70
jmp 0x2e84
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2ed2
leaq 0x9231(%rip), %rdi      # 0xc06a
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3e8f
jmp 0x2e8a
movq %rax, %rbx
leaq 0x92d7(%rip), %rdi      # 0xc129
jmp 0x2e7d
leaq 0x91dd(%rip), %rdi      # 0xc038
leaq 0x91e5(%rip), %rsi      # 0xc047
leaq 0x91e5(%rip), %rcx      # 0xc04e
movl $0xd6, %edx
callq 0x21a0
movq %rax, %rbx
leaq 0x9293(%rip), %rdi      # 0xc110
xorl %eax, %eax
callq 0x3d70
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x2350
leaq 0x919d(%rip), %rdi      # 0xc038
leaq 0x91a5(%rip), %rsi      # 0xc047
leaq 0x91a5(%rip), %rcx      # 0xc04e
movl $0xca, %edx
callq 0x21a0
leaq 0x917e(%rip), %rdi      # 0xc038
leaq 0x9186(%rip), %rsi      # 0xc047
leaq 0x9186(%rip), %rcx      # 0xc04e
movl $0xd0, %edx
callq 0x21a0
movq %rax, %rbx
leaq 0x918e(%rip), %rdi      # 0xc06a
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3d70
jmp 0x2e84
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2f01
leaq 0x9284(%rip), %rdi      # 0xc180
jmp 0x2e05
movq %rax, %rbx
leaq 0x9275(%rip), %rdi      # 0xc180
jmp 0x2e7d