// File: /workspace/github_c_makefile_star2_O2/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, 0x20(%rsp)
movq %rsi, 0x48(%rsp)
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x24f0
callq 0x3a44
xorl %eax, %eax
leaq 0xf187(%rip), %r14      # 0x11680
pushq $0x1
popq %rbx
leaq 0x8b0d(%rip), %r13      # 0xb010
movq $0x0, 0x28(%rsp)
movl $0x0, 0x1c(%rsp)
movq %rax, 0x10(%rsp)
leaq 0x8b6b(%rip), %rbp      # 0xb08b
leaq 0x8b67(%rip), %r15      # 0xb08e
movl 0x20(%rsp), %edi
movq 0x48(%rsp), %rsi
callq 0x2f9c
testq %rax, %rax
je 0x2778
movq %rax, %r12
movq $0xc9, 0x8(%rsp)
movq 0x8(%rsp), %rax
decq %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x0, (%r14)
je 0x2574
movq %r12, %rdi
callq 0x33b1
addq 0x8(%rsp), %rax
jmp 0x2582
movq 0x40(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x40(%rsp)
leaq -0xd6(%rax), %rcx
cmpq $0x9, %rcx
ja 0x25b5
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
cmpl $0x0, (%r14)
jne 0x268a
movl $0xd6, %esi
subq 0x8(%rsp), %rsi
movq %rbp, %rdi
jmp 0x2672
cmpq $0xd0, %rax
je 0x265b
cmpq $0xca, %rax
jne 0x25e9
cmpl $0x0, (%r14)
jne 0x26de
movl $0xca, %esi
subq 0x8(%rsp), %rsi
leaq 0x8a81(%rip), %rdi      # 0xb065
jmp 0x2672
cmpl $0x0, (%r14)
jne 0x272e
cmpl $0x0, 0x24(%rsp)
jne 0x255f
movl $0xdf, %edi
subq 0x8(%rsp), %rdi
callq 0x371e
movl $0x1, 0x24(%rsp)
jmp 0x255f
cmpl $0x0, (%r14)
jne 0x2737
movl $0xdc, %edi
subq 0x8(%rsp), %rdi
callq 0x3693
jmp 0x255f
cmpl $0x0, (%r14)
jne 0x2755
movl $0xd9, %esi
subq 0x8(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x34c9
jmp 0x255f
cmpl $0x0, (%r14)
jne 0x26a4
movl $0xd0, %esi
subq 0x8(%rsp), %rsi
leaq 0x8a16(%rip), %rdi      # 0xb088
movl %ebx, %edx
callq 0x34c9
jmp 0x255f
movl $0x1, (%r14)
jmp 0x2527
leaq 0xefe7(%rip), %rax      # 0x11678
cmpq $0x0, (%rax)
je 0x2796
incl 0x1c(%rsp)
jmp 0x2527
leaq 0xefcd(%rip), %rax      # 0x11678
movq (%rax), %r15
testq %r15, %r15
je 0x2804
cmpq $0x0, 0x28(%rsp)
jne 0x2791
movq %r15, %rdi
callq 0x2380
movq %rax, 0x28(%rsp)
testq %rax, %rax
jne 0x2520
jmp 0x27e1
leaq 0xef93(%rip), %rax      # 0x11678
movq (%rax), %rbp
testq %rbp, %rbp
je 0x2823
cmpq $0x0, 0x10(%rsp)
jne 0x2791
movq %rbp, %rdi
callq 0x2380
testq %rax, %rax
jne 0x2514
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2870
leaq 0x8947(%rip), %rdi      # 0xb06a
movq %r12, %rsi
movq %rbp, %rdx
jmp 0x27f8
leaq 0x899a(%rip), %rdi      # 0xb0cf
jmp 0x273e
leaq 0x897a(%rip), %rdi      # 0xb0b8
movq %r12, %rsi
xorl %eax, %eax
callq 0x3c50
callq 0x20a0
andl $0x0, (%rax)
callq 0x2a61
movq 0xe89c(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x8932(%rip), %rdi      # 0xb098
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x2360
xorl %edi, %edi
callq 0x2340
leaq 0xea81(%rip), %rax      # 0x11200
movl 0x20(%rsp), %ecx
cmpl %ecx, (%rax)
jne 0x2791
movq 0x28(%rsp), %r14
testq %r14, %r14
jne 0x27b5
callq 0x2a61
leaq 0x889b(%rip), %rdi      # 0xb038
leaq 0x88a3(%rip), %rsi      # 0xb047
leaq 0x88a3(%rip), %rcx      # 0xb04e
movl $0xd6, %edx
callq 0x21a0
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x3ed8
testq %rax, %rax
jne 0x2842
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x288c
leaq 0x8908(%rip), %rdi      # 0xb0e4
jmp 0x29f9
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x285e
leaq 0x8878(%rip), %rdi      # 0xb06a
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3c50
jmp 0x2a3a
leaq 0x882d(%rip), %rdi      # 0xb038
leaq 0x8835(%rip), %rsi      # 0xb047
leaq 0x8835(%rip), %rcx      # 0xb04e
movl $0xd0, %edx
callq 0x21a0
leaq 0x880e(%rip), %rdi      # 0xb038
leaq 0x8816(%rip), %rsi      # 0xb047
leaq 0x8816(%rip), %rcx      # 0xb04e
movl $0xca, %edx
callq 0x21a0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x289b
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
jmp 0x2900
movq %rax, %rbx
leaq 0x8802(%rip), %rdi      # 0xb06a
movq %r12, %rsi
movq %r15, %rdx
jmp 0x2880
movq %rax, %rbx
leaq 0x87f0(%rip), %rdi      # 0xb06a
movq %r12, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3ac1
jmp 0x2a37
movq %rax, %rbx
leaq 0x884e(%rip), %rdi      # 0xb0e4
jmp 0x2a30
callq 0x2150
testl %eax, %eax
jne 0x28d4
leaq 0x88d3(%rip), %rdi      # 0xb17e
callq 0x2130
movq %rax, 0x30(%rsp)
testq %rax, %rax
jne 0x28fa
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2a26
leaq 0x8841(%rip), %rdi      # 0xb110
jmp 0x29f9
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2a02
leaq 0x881d(%rip), %rdi      # 0xb106
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3c50
jmp 0x2a3a
andq $0x0, 0x38(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x3848
testl %eax, %eax
jne 0x29c9
movq 0x50(%rsp), %rdi
leaq 0x183(%rip), %rsi       # 0x2aa1
leaq 0x30(%rsp), %rdx
callq 0x4080
testl %eax, %eax
jne 0x29e8
leaq 0x58(%rsp), %rdi
callq 0x3848
testl %eax, %eax
jne 0x29c9
cmpl $0x0, 0x1c(%rsp)
je 0x2990
movq 0xe6a8(%rip), %rax      # 0x10ff8
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 0x38(%rsp), %rdx
mulsd 0x868a(%rip), %xmm0     # 0xb008
addsd %xmm1, %xmm0
leaq 0x87cd(%rip), %rsi      # 0xb156
movb $0x1, %al
callq 0x2220
cmpq $0x0, 0x10(%rsp)
je 0x29aa
movq 0x30(%rsp), %rdi
callq 0x21e0
testl %eax, %eax
jne 0x2a42
movq %rbx, %rdi
callq 0x4013
movq %r14, %rdi
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
jmp 0x2771
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x29dc
leaq 0x8741(%rip), %rdi      # 0xb11b
jmp 0x29f9
movq %rax, %rbx
leaq 0x8735(%rip), %rdi      # 0xb11b
jmp 0x2a30
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2a1a
leaq 0x8730(%rip), %rdi      # 0xb129
xorl %eax, %eax
callq 0x3c50
jmp 0x2a3a
movq %rax, %rbx
leaq 0x86fa(%rip), %rdi      # 0xb106
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3ac1
jmp 0x2a37
movq %rax, %rbx
leaq 0x8705(%rip), %rdi      # 0xb129
jmp 0x2a30
movq %rax, %rbx
leaq 0x86e0(%rip), %rdi      # 0xb110
xorl %eax, %eax
callq 0x3ac1
andl $0x0, (%rbx)
pushq $0x1
popq %rdi
callq 0x2340
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2a55
leaq 0x872d(%rip), %rdi      # 0xb180
jmp 0x29f9
movq %rax, %rbx
leaq 0x8721(%rip), %rdi      # 0xb180
jmp 0x2a30