// File: /workspace/github_cpp_makefile_star2_O2/ctSkennerton[P]fxtract/util/map_x.c
// Function: main
int
main(int argc, char **argv)
{
    int	i, j;
    char	*skey, *sval;

    plan_tests(5*NKEYS + 3 + 2*(argc - 1));
    KVS	sh = kvs_create();

    fputs("# pass 1: add 11 kv pairs\n", stderr);
    for (i = 0; i < NKEYS-1; ++i) {
	kvs_set(sh, keyv[i], valv[i+1]);
	ok(kvs_count(sh) == i+1, "adding (%s => %s) makes count: %d", 
	    keyv[i], valv[i+1], kvs_count(sh));
    }
    for (i = 0; i < NKEYS-1; ++i) {
	const char *vp = kvs_get(sh, keyv[i]);
	ok(vp && !strcmp(vp, valv[i+1]), "%s => %s", keyv[i], vp);
    }

    fputs("# pass 2: add 12 kv pairs, with different values\n", stderr);
    for (i = 0; i < NKEYS; ++i) {
	kvs_set(sh, keyv[i], valv[i]);
    }

    for (i = 0; i < NKEYS; ++i) {
	const char *vp = kvs_get(sh, keyv[i]);
	ok(vp && !strcmp(vp, valv[i]), "%s => %s", keyv[i], valv[i]);
    }

    ok(kvs_count(sh) == NKEYS, "kvs_count %d", kvs_count(sh));

    for (i = 0, kvs_start(sh);  kvs_next(sh, &skey, &sval); ++i) {
	for (j = 0; j < NKEYS && strcmp(keyv[j], skey); ++j);
	ok(j < NKEYS && !strcmp(sval, valv[j]), "scan finds (%s => %s)", skey, sval);
    }
    ok(i == NKEYS, "scan finds %d keys", i);

    fputs("# Delete 3 keys\n", stderr);
    kvs_del(sh, keyv[0]);
    kvs_del(sh, keyv[2]);
    kvs_del(sh, keyv[3]);

    ok(!kvs_get(sh, keyv[0]), "%s deleted ok", keyv[0]);
    ok(!kvs_get(sh, keyv[2]), "%s deleted ok", keyv[2]);
    ok(!kvs_get(sh, keyv[3]), "%s deleted ok", keyv[3]);
    ok(kvs_count(sh) == NKEYS - 3, "kvs_count %d", kvs_count(sh));
    for (i = 0; i < NKEYS; ++i) {
	if (i == 0 || i == 2 || i == 3) continue;
	ok(!strcmp(valv[i], kvs_get(sh, keyv[i])), "%s still ok", keyv[i]);
    }
    ok(kvs_count(sh) == 9, "count is %d", kvs_count(sh));

    fputs("# Delete all keys, including 3 already deleted\n", stderr);
    for (i = 0; i < NKEYS; ++i) {
	kvs_del(sh, keyv[i]);
    }    
    ok(kvs_count(sh) == 0, "final count is %d", kvs_count(sh));

    kvs_destroy(sh);
    while (*++argv) {
	char    val[9], buf[999];;
	int	    num = 0;

	FILE    *fp = fopen(*argv, "r");
	if (!fp) {
	    fprintf(stderr, "t.map: %s: cannot open\n", *argv);
	    continue;
	}

	sh = kvs_create();

	while (fgets(buf, sizeof(buf), fp)) {
	    sprintf(val, "%d", num++);
	    kvs_set(sh, buf, val);
	}

	ok(kvs_count(sh) == num, "kvs_count %d matches file count %d", 
	    kvs_count(sh), num);

	rewind(fp);
	num = 0;
	int	    found = 0;
	while (fgets(buf, sizeof(buf), fp)) {
	    sprintf(val, "%d", num++);
	    const char *ret = kvs_get(sh,buf);

	    if (!strcmp(ret, val)) {
		++found;
	    } else {
		fprintf(stderr, "retrieved %s, not %s, for key %s", 
			ret ? ret : "<NULL>", val, buf);
	    }
	}
	ok(found == num, "found %d of %d values in kvs",  found, num);
	kvs_destroy(sh);
    }

    return exit_status();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rsi, 0x8(%rsp)
leal 0x3d(,%rdi,2), %edi
callq 0x5ccb
callq 0x3c66
movq %rax, %r14
movq 0x7b5b(%rip), %rax      # 0xafd8
movq (%rax), %rsi
leaq 0x3bf9(%rip), %rdi      # 0x7080
callq 0x31e0
pushq $0x1
popq %r12
leaq 0x7d29(%rip), %r13      # 0xb1c0
cmpq $0xc, %r12
je 0x3521
movq (%r13), %rsi
leaq 0x7d74(%rip), %rbx      # 0xb220
movq (%rbx,%r12,8), %rdx
movq %r14, %rdi
callq 0x432d
movq %r14, %rdi
callq 0x3e3f
movl %eax, %eax
xorl %r15d, %r15d
cmpq %rax, %r12
sete %r15b
movq (%r13), %rbp
movq (%rbx,%r12,8), %rbx
movq %r14, %rdi
callq 0x3e3f
movl %eax, %r10d
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3ba9(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r10
pushq %rbx
pushq %rbp
leaq 0x3ba9(%rip), %r10      # 0x70a8
pushq %r10
pushq $0x2f
leaq 0x3b96(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x30, %rsp
incq %r12
addq $0x8, %r13
jmp 0x3497
leaq 0x7c98(%rip), %rbx      # 0xb1c0
leaq 0x3b9b(%rip), %rbp      # 0x70ca
leaq 0x3b65(%rip), %r15      # 0x709b
xorl %r13d, %r13d
cmpq $0x58, %r13
je 0x35ad
movq (%r13,%rbx), %rsi
movq %r14, %rdi
callq 0x3f80
movq %rax, %r12
testq %rax, %rax
je 0x356c
leaq 0x7cc5(%rip), %rax      # 0xb220
movq 0x8(%r13,%rax), %rsi
movq %r12, %rdi
callq 0x3358
testl %eax, %eax
je 0x3576
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
jmp 0x357f
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
xorl %eax, %eax
pushq %r12
pushq (%r13,%rbx)
pushq %rbp
pushq $0x33
leaq 0x3b04(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x30, %rsp
addq $0x8, %r13
jmp 0x3539
movq 0x7a24(%rip), %rax      # 0xafd8
movq (%rax), %rsi
leaq 0x3b15(%rip), %rdi      # 0x70d3
callq 0x31e0
xorl %r15d, %r15d
cmpq $0x60, %r15
je 0x35e9
movq (%r15,%rbx), %rsi
leaq 0x7c49(%rip), %rax      # 0xb220
movq (%r15,%rax), %rdx
movq %r14, %rdi
callq 0x432d
addq $0x8, %r15
jmp 0x35c6
leaq 0x3aab(%rip), %r15      # 0x709b
xorl %r13d, %r13d
cmpq $0x60, %r13
je 0x365f
movq (%r13,%rbx), %rsi
movq %r14, %rdi
callq 0x3f80
leaq 0x7c13(%rip), %rcx      # 0xb220
movq (%r13,%rcx), %r12
testq %rax, %rax
je 0x3629
movq %rax, %rdi
movq %r12, %rsi
callq 0x3358
pushq $0x1
popq %rsi
testl %eax, %eax
je 0x362b
xorl %esi, %esi
subq $0x8, %rsp
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
xorl %eax, %eax
pushq %r12
pushq (%r13,%rbx)
pushq %rbp
pushq $0x3d
leaq 0x3a52(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x30, %rsp
addq $0x8, %r13
jmp 0x35f3
movq %r14, %rdi
callq 0x3e3f
xorl %r15d, %r15d
cmpl $0xc, %eax
sete %r15b
movq %r14, %rdi
callq 0x3e3f
movl %eax, %r10d
leaq 0x3a82(%rip), %r11      # 0x7105
leaq 0x3a11(%rip), %r9       # 0x709b
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x40
leaq 0x39fb(%rip), %r12      # 0x70a0
pushq %r12
callq 0x53bc
addq $0x20, %rsp
movq %r14, %rdi
callq 0x41ce
xorl %r15d, %r15d
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x3fad
testl %eax, %eax
je 0x3764
movq 0x18(%rsp), %rbp
xorl %r12d, %r12d
cmpq $0x60, %r12
je 0x371f
movq (%r12,%rbx), %rdi
movq %rbp, %rsi
callq 0x3358
addq $0x8, %r12
testl %eax, %eax
jne 0x36dd
movq 0x10(%rsp), %r13
leaq 0x7b1d(%rip), %rax      # 0xb220
movq -0x8(%r12,%rax), %rsi
movq %r13, %rdi
callq 0x3358
testl %eax, %eax
jne 0x3724
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
jmp 0x372c
movq 0x10(%rsp), %r13
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3961(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r13
pushq %rbp
leaq 0x39cc(%rip), %r10      # 0x7112
pushq %r10
pushq $0x44
leaq 0x394f(%rip), %r12      # 0x70a0
pushq %r12
callq 0x53bc
addq $0x30, %rsp
incl %r15d
jmp 0x36bb
leaq 0x39bd(%rip), %r10      # 0x7128
leaq 0x3929(%rip), %r9       # 0x709b
cmpl $0xc, %r15d
jne 0x378a
pushq $0x1
popq %rsi
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq $0xc
jmp 0x3799
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r15
pushq %r10
pushq $0x46
pushq %r12
callq 0x53bc
addq $0x20, %rsp
movq 0x7829(%rip), %rax      # 0xafd8
movq (%rax), %rsi
leaq 0x3982(%rip), %rdi      # 0x713b
callq 0x31e0
movq 0x79fb(%rip), %rsi      # 0xb1c0
movq %r14, %rdi
callq 0x41d3
movq 0x79fc(%rip), %rsi      # 0xb1d0
movq %r14, %rdi
callq 0x41d3
movq 0x79f5(%rip), %rsi      # 0xb1d8
movq %r14, %rdi
callq 0x41d3
movq 0x79ce(%rip), %rsi      # 0xb1c0
movq %r14, %rdi
callq 0x3f80
xorl %esi, %esi
testq %rax, %rax
sete %sil
leaq 0x3942(%rip), %r15      # 0x714c
leaq 0x388a(%rip), %r13      # 0x709b
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
xorl %eax, %eax
pushq 0x799b(%rip)            # 0xb1c0
pushq %r15
pushq $0x4d
pushq %r12
callq 0x53bc
addq $0x20, %rsp
movq 0x7995(%rip), %rsi      # 0xb1d0
movq %r14, %rdi
callq 0x3f80
xorl %esi, %esi
testq %rax, %rax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
xorl %eax, %eax
pushq 0x7970(%rip)            # 0xb1d0
pushq %r15
pushq $0x4e
pushq %r12
callq 0x53bc
addq $0x20, %rsp
movq 0x7962(%rip), %rsi      # 0xb1d8
movq %r14, %rdi
callq 0x3f80
xorl %esi, %esi
testq %rax, %rax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
xorl %eax, %eax
pushq 0x793d(%rip)            # 0xb1d8
pushq %r15
pushq $0x4f
pushq %r12
callq 0x53bc
addq $0x20, %rsp
movq %r14, %rdi
callq 0x3e3f
xorl %r15d, %r15d
cmpl $0x9, %eax
sete %r15b
movq %r14, %rdi
callq 0x3e3f
movl %eax, %r10d
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
xorl %eax, %eax
pushq %r10
leaq 0x3824(%rip), %r10      # 0x7105
pushq %r10
pushq $0x50
pushq %r12
callq 0x53bc
addq $0x20, %rsp
leaq 0x3863(%rip), %r13      # 0x715a
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq $0xc, %r12
je 0x3975
testb $0xd, %r12b
sete %al
cmpq $0x3, %r12
sete %cl
orb %al, %cl
jne 0x396c
leaq 0x7905(%rip), %rax      # 0xb220
movq (%rbp,%rax), %r15
movq (%rbp,%rbx), %rsi
movq %r14, %rdi
callq 0x3f80
movq %r15, %rdi
movq %rax, %rsi
callq 0x3358
xorl %esi, %esi
testl %eax, %eax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x374b(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq (%rbp,%rbx)
pushq %r13
pushq $0x53
leaq 0x373f(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x20, %rsp
incq %r12
addq $0x8, %rbp
jmp 0x38fc
movq %r14, %rdi
callq 0x3e3f
xorl %r15d, %r15d
cmpl $0x9, %eax
sete %r15b
movq %r14, %rdi
callq 0x3e3f
movl %eax, %r10d
leaq 0x3803(%rip), %r11      # 0x719c
leaq 0x36fb(%rip), %r9       # 0x709b
xorl %r12d, %r12d
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x55
leaq 0x36e2(%rip), %r15      # 0x70a0
pushq %r15
callq 0x53bc
addq $0x20, %rsp
movq 0x7608(%rip), %rax      # 0xafd8
movq (%rax), %rsi
leaq 0x378c(%rip), %rdi      # 0x7166
callq 0x31e0
cmpq $0x60, %r12
je 0x39f7
movq (%r12,%rbx), %rsi
movq %r14, %rdi
callq 0x41d3
addq $0x8, %r12
jmp 0x39df
movq %r14, %rdi
callq 0x3e3f
xorl %ebx, %ebx
testl %eax, %eax
sete %bl
movq %r14, %rdi
callq 0x3e3f
movl %eax, %r10d
leaq 0x377e(%rip), %r11      # 0x7196
leaq 0x367c(%rip), %r9       # 0x709b
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x5b
pushq %r15
callq 0x53bc
addq $0x20, %rsp
movq %r14, %rdi
callq 0x4211
leaq 0x30(%rsp), %r13
leaq 0x27(%rsp), %rbp
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x3c4f
addq $0x8, %rbx
leaq 0x41e8(%rip), %rsi      # 0x7c55
callq 0x31f0
testq %rax, %rax
jne 0x3a94
movq 0x755a(%rip), %rax      # 0xafd8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x371d(%rip), %rsi      # 0x71a8
xorl %eax, %eax
callq 0x3270
jmp 0x3a55
movq %rax, %r15
movq %rbx, 0x8(%rsp)
xorl %r12d, %r12d
callq 0x3c66
movq %rax, %rbx
movq %r13, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %r15, %rdx
callq 0x32a0
testq %rax, %rax
je 0x3ae8
leal 0x1(%r12), %r14d
movq %rbp, %rdi
leaq 0x35fc(%rip), %rsi      # 0x70c7
movl %r12d, %edx
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x432d
movl %r14d, %r12d
jmp 0x3aa7
movq %rbx, %rdi
callq 0x3e3f
xorl %ecx, %ecx
cmpl %r12d, %eax
sete %cl
movq %rcx, (%rsp)
movq %rbx, %rdi
callq 0x3e3f
movl %eax, %r10d
subq $0x8, %rsp
xorl %r14d, %r14d
xorl %edi, %edi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3578(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r12
pushq %r10
leaq 0x3690(%rip), %r10      # 0x71c0
pushq %r10
pushq $0x70
leaq 0x3565(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x30, %rsp
movq %r15, %rdi
callq 0x3040
movq $0x0, (%rsp)
movq %r13, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %r15, %rdx
callq 0x32a0
testq %rax, %rax
je 0x3be2
movq %rbp, %rdi
leaq 0x3552(%rip), %rsi      # 0x70c7
movl %r14d, %edx
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3f80
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3358
testl %eax, %eax
je 0x3bd0
movq 0x7435(%rip), %rax      # 0xafd8
movq (%rax), %rdi
testq %r12, %r12
leaq 0x3654(%rip), %rax      # 0x7204
cmoveq %rax, %r12
leaq 0x3628(%rip), %rsi      # 0x71e3
movq %r12, %rdx
movq %rbp, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x3270
incl %r14d
jmp 0x3b56
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
incl %r14d
jmp 0x3b56
movq (%rsp), %r10
subq $0x8, %rsp
cmpl %r14d, %r10d
jne 0x3c0a
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3499(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r14
pushq %r14
jmp 0x3c22
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x347f(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r14
pushq %r10
leaq 0x35e2(%rip), %r10      # 0x720b
pushq %r10
pushq $0x80
leaq 0x3469(%rip), %r10      # 0x70a0
pushq %r10
callq 0x53bc
addq $0x30, %rsp
movq %rbx, %rdi
callq 0x4211
jmp 0x3a50
callq 0x5f69
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq