// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/perftests/kvldsclean/main.c
// Function: main
int
main(int argc, char * argv[])
{
	struct sock_addr ** sas;
	int s;
	struct wire_requestqueue * Q;
	size_t i;
	time_t t_now;
	char datetime[20];

	WARNP_INIT;

	/* Check number of arguments. */
	if (argc != 2) {
		fprintf(stderr, "usage: test_kvlds %s\n", "<socketname>");
		exit(1);
	}

	/* Resolve the socket address and connect. */
	if ((sas = sock_resolve(argv[1])) == NULL) {
		warnp("Error resolving socket address: %s", argv[1]);
		exit(1);
	}
	if (sas[0] == NULL) {
		warn0("No addresses found for %s", argv[1]);
		exit(1);
	}
	if ((s = sock_connect(sas)) == -1)
		exit(1);

	/* Create a request queue. */
	if ((Q = wire_requestqueue_init(s)) == NULL) {
		warnp("Cannot create packet write queue");
		exit(1);
	}

	/* 10 stages of writing new keys followed by existing keys. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: Writing and modifying...", datetime);
	for (i = 0; i < 10; i++) {
		/* Write 1k new keys. */
		if (batch_set(Q, i * 1000, 1000)) {
			warnp("Failure writing new keys");
			exit(1);
		}

		/* Write the same 100k keys each iteration. */
		if (batch_set(Q, 1000000, 100000)) {
			warnp("Failure writing old keys");
			exit(1);
		}
	}

	/* Sleep 1800 seconds so that we can watch the cleaner kick in. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: ... done", datetime);
	sleep(1800);

	/* Delete the 100k repeatedly modified keys. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: Deleting repeatedly modified keys...", datetime);
	if (batch_delete(Q, 1000000, 100000)) {
		warnp("Failure deleting old keys");
		exit(1);
	}

	/* Sleep 1200 seconds so that we can watch the cleaner do more work. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: ... done", datetime);
	sleep(1200);

	/* Delete the 10 x 1k once-written keys. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: Deleting once-written keys...", datetime);
	if (batch_delete(Q, 0, 10000)) {
		warnp("Failure deleting new keys");
		exit(1);
	}

	/* Sleep 10 seconds so that we can see an empty tree. */
	time(&t_now);
	strftime(datetime, 20, "%F %T", gmtime(&t_now));
	warn0("%s: ... done", datetime);
	sleep(10);

	/* Free the request queue. */
	wire_requestqueue_destroy(Q);
	wire_requestqueue_free(Q);

	/* Free socket addresses. */
	sock_addr_freelist(sas);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x249f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x6a40
jmp 0x24a1
cmpl $0x2, -0x8(%rbp)
je 0x24d0
movq 0x12b4a(%rip), %rax     # 0x14ff8
movq (%rax), %rdi
leaq 0xcb4c(%rip), %rsi      # 0xf004
leaq 0xcb5b(%rip), %rdx      # 0xf01a
movb $0x0, %al
callq 0x21c0
movl $0x1, %edi
callq 0x22f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4e90
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2538
jmp 0x24e9
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2516
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xcb25(%rip), %rdi      # 0xf027
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x252c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xcb02(%rip), %rdi      # 0xf027
movb $0x0, %al
callq 0x6d50
jmp 0x252e
movl $0x1, %edi
callq 0x22f0
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x256f
jmp 0x2544
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xcaf7(%rip), %rdi      # 0xf04a
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x22f0
movq -0x18(%rbp), %rdi
callq 0x5d60
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
jne 0x258a
movl $0x1, %edi
callq 0x22f0
movl -0x1c(%rbp), %edi
callq 0x9040
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x25dd
jmp 0x259e
callq 0x20a0
cmpl $0x0, (%rax)
je 0x25c3
leaq 0xcab5(%rip), %rdi      # 0xf064
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x25d1
leaq 0xca9a(%rip), %rdi      # 0xf064
movb $0x0, %al
callq 0x6d50
jmp 0x25d3
movl $0x1, %edi
callq 0x22f0
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xca7b(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xca71(%rip), %rdi      # 0xf08b
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movq $0x0, -0x30(%rbp)
cmpq $0xa, -0x30(%rbp)
jae 0x2707
movq -0x28(%rbp), %rdi
imulq $0x3e8, -0x30(%rbp), %rsi # imm = 0x3E8
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x2990
cmpl $0x0, %eax
je 0x269b
jmp 0x265c
callq 0x20a0
cmpl $0x0, (%rax)
je 0x2681
leaq 0xca3b(%rip), %rdi      # 0xf0a8
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x268f
leaq 0xca20(%rip), %rdi      # 0xf0a8
movb $0x0, %al
callq 0x6d50
jmp 0x2691
movl $0x1, %edi
callq 0x22f0
movq -0x28(%rbp), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
movl $0x186a0, %edx          # imm = 0x186A0
callq 0x2990
cmpl $0x0, %eax
je 0x26f4
jmp 0x26b5
callq 0x20a0
cmpl $0x0, (%rax)
je 0x26da
leaq 0xc9fb(%rip), %rdi      # 0xf0c1
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x26e8
leaq 0xc9e0(%rip), %rdi      # 0xf0c1
movb $0x0, %al
callq 0x6d50
jmp 0x26ea
movl $0x1, %edi
callq 0x22f0
jmp 0x26f6
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2634
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xc951(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xc996(%rip), %rdi      # 0xf0da
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movl $0x708, %edi            # imm = 0x708
callq 0x2340
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xc8f8(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xc94a(%rip), %rdi      # 0xf0e7
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movq -0x28(%rbp), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
movl $0x186a0, %edx          # imm = 0x186A0
callq 0x2b10
cmpl $0x0, %eax
je 0x2808
jmp 0x27c9
callq 0x20a0
cmpl $0x0, (%rax)
je 0x27ee
leaq 0xc936(%rip), %rdi      # 0xf110
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x27fc
leaq 0xc91b(%rip), %rdi      # 0xf110
movb $0x0, %al
callq 0x6d50
jmp 0x27fe
movl $0x1, %edi
callq 0x22f0
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xc850(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xc895(%rip), %rdi      # 0xf0da
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movl $0x4b0, %edi            # imm = 0x4B0
callq 0x2340
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xc7f7(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xc88c(%rip), %rdi      # 0xf12a
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2710, %edx           # imm = 0x2710
callq 0x2b10
cmpl $0x0, %eax
je 0x2908
jmp 0x28c9
callq 0x20a0
cmpl $0x0, (%rax)
je 0x28ee
leaq 0xc872(%rip), %rdi      # 0xf14c
movb $0x0, %al
callq 0x6b00
callq 0x20a0
movl $0x0, (%rax)
jmp 0x28fc
leaq 0xc857(%rip), %rdi      # 0xf14c
movb $0x0, %al
callq 0x6d50
jmp 0x28fe
movl $0x1, %edi
callq 0x22f0
leaq -0x38(%rbp), %rdi
callq 0x21f0
leaq -0x50(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22b0
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl $0x14, %esi
leaq 0xc750(%rip), %rdx      # 0xf085
callq 0x2280
leaq -0x50(%rbp), %rsi
leaq 0xc795(%rip), %rdi      # 0xf0da
movb $0x0, %al
callq 0x6d50
callq 0x20a0
movl $0x0, (%rax)
movl $0xa, %edi
callq 0x2340
movq -0x28(%rbp), %rdi
callq 0x9610
movq -0x28(%rbp), %rdi
callq 0x9650
movq -0x18(%rbp), %rdi
callq 0x5ac0
xorl %edi, %edi
callq 0x22f0
nopw %cs:(%rax,%rax)