// File: /workspace/github_c_makefile_star2_O3/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, 0x40(%rsp)
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x29af
callq 0x3db0
movl %r15d, %edi
movq 0x40(%rsp), %rsi
callq 0x34dc
testq %rax, %rax
jne 0x29d0
leaq 0xf838(%rip), %rax      # 0x12200
cmpl %r15d, (%rax)
callq 0x2f45
movq %rax, %r12
movq $0x0, 0x28(%rsp)
leaq 0xfc9d(%rip), %r13      # 0x12680
leaq 0x9626(%rip), %rbx      # 0xc010
leaq 0x969a(%rip), %r14      # 0xc08b
leaq 0x9696(%rip), %rbp      # 0xc08e
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movl %r15d, 0x20(%rsp)
movq $0xc9, 0x8(%rsp)
movq 0x8(%rsp), %rax
decq %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x0, (%r13)
je 0x2a43
movq %r12, %rdi
callq 0x3823
addq 0x8(%rsp), %rax
jmp 0x2a51
movq 0x48(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x48(%rsp)
leaq -0xd6(%rax), %rcx
cmpq $0x9, %rcx
ja 0x2a84
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpl $0x0, (%r13)
jne 0x2b66
movl $0xd6, %esi
subq 0x8(%rsp), %rsi
movq %r14, %rdi
jmp 0x2b4a
cmpq $0xd0, %rax
je 0x2b2e
cmpq $0xca, %rax
jne 0x2ab9
cmpl $0x0, (%r13)
jne 0x2b85
movl $0xca, %esi
subq 0x8(%rsp), %rsi
leaq 0x95b1(%rip), %rdi      # 0xc065
jmp 0x2b4a
cmpl $0x0, (%r13)
jne 0x2c5d
cmpl $0x0, 0x24(%rsp)
jne 0x2a2d
movl $0xdf, %edi
subq 0x8(%rsp), %rdi
callq 0x3a31
movl $0x1, 0x24(%rsp)
jmp 0x2a2d
cmpl $0x0, (%r13)
jne 0x2c66
movl $0xdc, %edi
subq 0x8(%rsp), %rdi
callq 0x39f1
jmp 0x2a2d
cmpl $0x0, (%r13)
jne 0x2c87
movl $0xd9, %esi
subq 0x8(%rsp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x38e0
jmp 0x2a2d
cmpl $0x0, (%r13)
jne 0x2bbc
movl $0xd0, %esi
subq 0x8(%rsp), %rsi
leaq 0x953e(%rip), %rdi      # 0xc088
movl $0x1, %edx
callq 0x38e0
jmp 0x2a2d
movl $0x1, (%r13)
jmp 0x2bf6
leaq 0xfb0b(%rip), %rax      # 0x12678
cmpq $0x0, (%rax)
je 0x2cd1
movq 0x28(%rsp), %rax
incl %eax
movq %rax, 0x28(%rsp)
jmp 0x2bf6
leaq 0xfaec(%rip), %rax      # 0x12678
movq (%rax), %r15
testq %r15, %r15
je 0x2cf0
cmpq $0x0, 0x10(%rsp)
jne 0x29cb
movq %r15, %rdi
callq 0x2390
testq %rax, %rax
je 0x2cae
movq %rax, 0x10(%rsp)
jmp 0x2bf1
leaq 0xfab5(%rip), %rax      # 0x12678
movq (%rax), %r15
testq %r15, %r15
je 0x2d0f
cmpq $0x0, 0x18(%rsp)
jne 0x29cb
movq %r15, %rdi
callq 0x2390
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x2cae
movl 0x20(%rsp), %r15d
movl %r15d, %edi
movq 0x40(%rsp), %rsi
callq 0x34dc
movq %rax, %r12
testq %rax, %rax
jne 0x2a0f
leaq 0xf5ea(%rip), %rax      # 0x12200
cmpl %r15d, (%rax)
jne 0x29cb
cmpq $0x0, 0x18(%rsp)
je 0x29cb
leaq 0x50(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x41b0
testq %rax, %rax
jne 0x2d4a
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2d63
leaq 0x948c(%rip), %rdi      # 0xc0e4
jmp 0x2ed8
leaq 0x946b(%rip), %rdi      # 0xc0cf
jmp 0x2c6d
leaq 0x944b(%rip), %rdi      # 0xc0b8
movq %r12, %rsi
xorl %eax, %eax
callq 0x3f4f
callq 0x20a0
movl $0x0, (%rax)
callq 0x2f45
movq 0xf36a(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x9400(%rip), %rdi      # 0xc098
movl $0x1f, %esi
movl $0x1, %edx
callq 0x2370
xorl %edi, %edi
callq 0x2350
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2d2e
leaq 0x93ab(%rip), %rdi      # 0xc06a
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3f4f
jmp 0x2f1c
leaq 0x9360(%rip), %rdi      # 0xc038
leaq 0x9368(%rip), %rsi      # 0xc047
leaq 0x9368(%rip), %rcx      # 0xc04e
movl $0xd6, %edx
callq 0x21a0
leaq 0x9341(%rip), %rdi      # 0xc038
leaq 0x9349(%rip), %rsi      # 0xc047
leaq 0x9349(%rip), %rcx      # 0xc04e
movl $0xca, %edx
callq 0x21a0
leaq 0x9322(%rip), %rdi      # 0xc038
leaq 0x932a(%rip), %rsi      # 0xc047
leaq 0x932a(%rip), %rcx      # 0xc04e
movl $0xd0, %edx
callq 0x21a0
movq %rax, %rbx
leaq 0x9332(%rip), %rdi      # 0xc06a
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3e30
jmp 0x2f16
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x2d72
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
jmp 0x2dda
movq %rax, %rbx
leaq 0x9377(%rip), %rdi      # 0xc0e4
jmp 0x2f0f
callq 0x2150
testl %eax, %eax
jne 0x2dab
leaq 0x93fc(%rip), %rdi      # 0xc17e
callq 0x2130
movq %rax, 0x30(%rsp)
testq %rax, %rax
jne 0x2dd1
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2f05
leaq 0x936a(%rip), %rdi      # 0xc110
jmp 0x2ed8
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2ee1
leaq 0x9346(%rip), %rdi      # 0xc106
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3f4f
jmp 0x2f1c
movq $0x0, 0x38(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x3b74
testl %eax, %eax
jne 0x2ea8
movq 0x50(%rsp), %rdi
leaq 0x191(%rip), %rsi       # 0x2f89
leaq 0x30(%rsp), %rdx
callq 0x4368
testl %eax, %eax
jne 0x2ec7
leaq 0x58(%rsp), %rdi
callq 0x3b74
testl %eax, %eax
jne 0x2ea8
cmpl $0x0, 0x28(%rsp)
je 0x2e6d
movq 0xf1ce(%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
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movq 0x38(%rsp), %rdx
mulsd 0x91ad(%rip), %xmm0     # 0xc008
addsd %xmm1, %xmm0
leaq 0x92f0(%rip), %rsi      # 0xc156
movb $0x1, %al
callq 0x2230
cmpq $0x0, 0x10(%rsp)
je 0x2e87
movq 0x30(%rsp), %rdi
callq 0x21f0
testl %eax, %eax
jne 0x2f26
movq %rbx, %rdi
callq 0x42f9
movq 0x18(%rsp), %rdi
callq 0x2040
movq 0x10(%rsp), %rdi
callq 0x2040
jmp 0x2ca7
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2ebb
leaq 0x9262(%rip), %rdi      # 0xc11b
jmp 0x2ed8
movq %rax, %rbx
leaq 0x9256(%rip), %rdi      # 0xc11b
jmp 0x2f0f
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2ef9
leaq 0x9251(%rip), %rdi      # 0xc129
xorl %eax, %eax
callq 0x3f4f
jmp 0x2f1c
movq %rax, %rbx
leaq 0x921b(%rip), %rdi      # 0xc106
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x3e30
jmp 0x2f16
movq %rax, %rbx
leaq 0x9226(%rip), %rdi      # 0xc129
jmp 0x2f0f
movq %rax, %rbx
leaq 0x9201(%rip), %rdi      # 0xc110
xorl %eax, %eax
callq 0x3e30
movl $0x0, (%rbx)
movl $0x1, %edi
callq 0x2350
callq 0x20a0
cmpl $0x0, (%rax)
jne 0x2f39
leaq 0x9249(%rip), %rdi      # 0xc180
jmp 0x2ed8
movq %rax, %rbx
leaq 0x923d(%rip), %rdi      # 0xc180
jmp 0x2f0f