// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2526
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x43e0
jmp 0x2528
jmp 0x252a
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x33b0
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x2974
movq $0xc9, -0x78(%rbp)
movq -0x78(%rbp), %rax
decq %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
leaq 0x7(%rip), %rax         # 0x256f
movq %rax, -0x90(%rbp)
leaq 0x1511a(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x2594
movq -0x70(%rbp), %rdi
callq 0x3a70
movq -0x78(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
jmp 0x25aa
movq -0x80(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
addq $-0xca, %rax
movq %rax, -0xa0(%rbp)
subq $0x15, %rax
ja 0x2904
movq -0xa0(%rbp), %rax
leaq 0xea3a(%rip), %rcx      # 0x11010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x150aa(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x261b
leaq 0x15096(%rip), %rax     # 0x17688
cmpq $0x0, (%rax)
je 0x25fa
jmp 0x2619
leaq 0xea67(%rip), %rdi      # 0x11068
leaq 0xea6f(%rip), %rsi      # 0x11077
movl $0xca, %edx
leaq 0xea6a(%rip), %rcx      # 0x1107e
callq 0x21b0
jmp 0x264b
movq -0x78(%rbp), %rax
movl $0xca, %esi
subq %rax, %rsi
leaq 0xea67(%rip), %rdi      # 0x11095
movl $0x1, %edx
callq 0x3bc0
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
cmpq $0x0, -0x58(%rbp)
je 0x2657
callq 0x2cb0
leaq 0x1502a(%rip), %rax     # 0x17688
movq (%rax), %rdi
callq 0x2390
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x26cf
jmp 0x2672
jmp 0x2674
callq 0x20a0
cmpl $0x0, (%rax)
je 0x26a7
movq -0x70(%rbp), %rsi
leaq 0x14fff(%rip), %rax     # 0x17688
movq (%rax), %rdx
leaq 0xea07(%rip), %rdi      # 0x1109a
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x26c3
movq -0x70(%rbp), %rsi
leaq 0x14fd6(%rip), %rax     # 0x17688
movq (%rax), %rdx
leaq 0xe9de(%rip), %rdi      # 0x1109a
movb $0x0, %al
callq 0x46f0
jmp 0x26c5
movl $0x1, %edi
callq 0x2360
jmp 0x296f
leaq 0x14fb5(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x2710
leaq 0x14fa1(%rip), %rax     # 0x17688
cmpq $0x0, (%rax)
je 0x26ef
jmp 0x270e
leaq 0xe972(%rip), %rdi      # 0x11068
leaq 0xe97a(%rip), %rsi      # 0x11077
movl $0xd0, %edx
leaq 0xe975(%rip), %rcx      # 0x1107e
callq 0x21b0
jmp 0x2740
movq -0x78(%rbp), %rax
movl $0xd0, %esi
subq %rax, %rsi
leaq 0xe995(%rip), %rdi      # 0x110b8
movl $0x1, %edx
callq 0x3bc0
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
cmpq $0x0, -0x60(%rbp)
je 0x274c
callq 0x2cb0
leaq 0x14f35(%rip), %rax     # 0x17688
movq (%rax), %rdi
callq 0x2390
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
jne 0x27c4
jmp 0x2767
jmp 0x2769
callq 0x20a0
cmpl $0x0, (%rax)
je 0x279c
movq -0x70(%rbp), %rsi
leaq 0x14f0a(%rip), %rax     # 0x17688
movq (%rax), %rdx
leaq 0xe912(%rip), %rdi      # 0x1109a
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x27b8
movq -0x70(%rbp), %rsi
leaq 0x14ee1(%rip), %rax     # 0x17688
movq (%rax), %rdx
leaq 0xe8e9(%rip), %rdi      # 0x1109a
movb $0x0, %al
callq 0x46f0
jmp 0x27ba
movl $0x1, %edi
callq 0x2360
jmp 0x296f
leaq 0x14ec0(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x2805
leaq 0x14eac(%rip), %rax     # 0x17688
cmpq $0x0, (%rax)
je 0x27e4
jmp 0x2803
leaq 0xe87d(%rip), %rdi      # 0x11068
leaq 0xe885(%rip), %rsi      # 0x11077
movl $0xd6, %edx
leaq 0xe880(%rip), %rcx      # 0x1107e
callq 0x21b0
jmp 0x2835
movq -0x78(%rbp), %rax
movl $0xd6, %esi
subq %rax, %rsi
leaq 0xe8a3(%rip), %rdi      # 0x110bb
movl $0x1, %edx
callq 0x3bc0
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x296f
leaq 0x14e46(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x2851
jmp 0x287e
movq -0x78(%rbp), %rax
movl $0xd9, %esi
subq %rax, %rsi
leaq 0xe85a(%rip), %rdi      # 0x110be
xorl %edx, %edx
callq 0x3bc0
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
movq 0x14773(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
leaq 0xe839(%rip), %rsi      # 0x110c8
movb $0x0, %al
callq 0x2230
xorl %edi, %edi
callq 0x2360
leaq 0x14dec(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x28ab
jmp 0x28cf
movq -0x78(%rbp), %rax
movl $0xdc, %edi
subq %rax, %rdi
callq 0x3e50
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
jmp 0x28d1
movq -0x70(%rbp), %rsi
leaq 0xe80c(%rip), %rdi      # 0x110e8
movb $0x0, %al
callq 0x46f0
callq 0x20a0
movl $0x0, (%rax)
callq 0x2cb0
jmp 0x294b
leaq 0x14d94(%rip), %rax     # 0x17690
movl $0x1, (%rax)
jmp 0x296f
leaq 0x14d85(%rip), %rax     # 0x17690
cmpl $0x0, (%rax)
je 0x2912
jmp 0x294b
movl -0x84(%rbp), %eax
cmpl $0x0, %eax
jne 0x2938
movq -0x78(%rbp), %rax
movl $0xdf, %edi
subq %rax, %rdi
callq 0x3f10
movl $0x1, -0x84(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2c9f
jmp 0x294d
movq -0x70(%rbp), %rsi
leaq 0xe7a7(%rip), %rdi      # 0x110ff
movb $0x0, %al
callq 0x46f0
callq 0x20a0
movl $0x0, (%rax)
callq 0x2cb0
jmp 0x252a
leaq 0x14885(%rip), %rax     # 0x17200
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
leaq 0x14874(%rip), %rax     # 0x17200
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x29ab
callq 0x2cb0
cmpq $0x0, -0x60(%rbp)
jne 0x29b7
callq 0x2cb0
movq -0x60(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4b90
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2a0f
jmp 0x29d0
callq 0x20a0
cmpl $0x0, (%rax)
je 0x29f5
leaq 0xe733(%rip), %rdi      # 0x11114
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2a03
leaq 0xe718(%rip), %rdi      # 0x11114
movb $0x0, %al
callq 0x46f0
jmp 0x2a05
movl $0x1, %edi
callq 0x2360
cmpq $0x0, -0x58(%rbp)
je 0x2aca
movq -0x58(%rbp), %rdi
callq 0x2150
cmpl $0x0, %eax
je 0x2a71
jmp 0x2a2a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2a53
movq -0x58(%rbp), %rsi
leaq 0xe6f7(%rip), %rdi      # 0x11136
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2a65
movq -0x58(%rbp), %rsi
leaq 0xe6d8(%rip), %rdi      # 0x11136
movb $0x0, %al
callq 0x46f0
jmp 0x2a67
movl $0x1, %edi
callq 0x2360
leaq 0xe7ad(%rip), %rdi      # 0x11225
callq 0x2130
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x2ac8
jmp 0x2a89
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2aae
leaq 0xe6a6(%rip), %rdi      # 0x11140
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2abc
leaq 0xe68b(%rip), %rdi      # 0x11140
movb $0x0, %al
callq 0x46f0
jmp 0x2abe
movl $0x1, %edi
callq 0x2360
jmp 0x2aca
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x2ae1
movq $0x0, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x40c0
cmpl $0x0, %eax
je 0x2b30
jmp 0x2af1
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2b16
leaq 0xe649(%rip), %rdi      # 0x1114b
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2b24
leaq 0xe62e(%rip), %rdi      # 0x1114b
movb $0x0, %al
callq 0x46f0
jmp 0x2b26
movl $0x1, %edi
callq 0x2360
movq -0x20(%rbp), %rdi
leaq 0x1b5(%rip), %rsi       # 0x2cf0
leaq -0x30(%rbp), %rdx
callq 0x4df0
cmpl $0x0, %eax
je 0x2b8a
jmp 0x2b4b
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2b70
leaq 0xe5fd(%rip), %rdi      # 0x11159
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2b7e
leaq 0xe5e2(%rip), %rdi      # 0x11159
movb $0x0, %al
callq 0x46f0
jmp 0x2b80
movl $0x1, %edi
callq 0x2360
leaq -0x50(%rbp), %rdi
callq 0x40c0
cmpl $0x0, %eax
je 0x2bd9
jmp 0x2b9a
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2bbf
leaq 0xe5a0(%rip), %rdi      # 0x1114b
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2bcd
leaq 0xe585(%rip), %rdi      # 0x1114b
movb $0x0, %al
callq 0x46f0
jmp 0x2bcf
movl $0x1, %edi
callq 0x2360
cmpl $0x0, -0x64(%rbp)
je 0x2c25
movq 0x14412(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
movq -0x40(%rbp), %rax
subq -0x50(%rbp), %rax
cvtsi2sd %rax, %xmm1
movq -0x38(%rbp), %rax
subq -0x48(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0xe3f9(%rip), %xmm2     # 0x11008
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
leaq 0xe568(%rip), %rsi      # 0x11186
movb $0x1, %al
callq 0x2230
cmpq $0x0, -0x58(%rbp)
je 0x2c7d
movq -0x30(%rbp), %rdi
callq 0x21f0
cmpl $0x0, %eax
je 0x2c7b
jmp 0x2c3c
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2c61
leaq 0xe563(%rip), %rdi      # 0x111b0
movb $0x0, %al
callq 0x44a0
callq 0x20a0
movl $0x0, (%rax)
jmp 0x2c6f
leaq 0xe548(%rip), %rdi      # 0x111b0
movb $0x0, %al
callq 0x46f0
jmp 0x2c71
movl $0x1, %edi
callq 0x2360
jmp 0x2c7d
movq -0x18(%rbp), %rdi
callq 0x4d50
movq -0x60(%rbp), %rdi
callq 0x2040
movq -0x58(%rbp), %rdi
callq 0x2040
xorl %edi, %edi
callq 0x2360
movq -0xa8(%rbp), %rax
jmpq *%rax
nopl (%rax,%rax)