// File: /workspace/github_cpp_makefile_star2_O1/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 $0x428, %rsp            # imm = 0x428
movq %rsi, 0x8(%rsp)
leal 0x3d(,%rdi,2), %edi
callq 0x5fce
movq 0x6c57(%rip), %rdi      # 0x9fe0
leaq 0xa0c(%rip), %rsi       # 0x3d9c
xorl %edx, %edx
callq 0x3f38
movq %rax, %r14
movq 0x6c37(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3cd5(%rip), %rdi      # 0x7080
callq 0x31e0
leaq 0x6e09(%rip), %r12      # 0xa1c0
pushq $0x1
popq %r13
movq (%r12), %rsi
leaq 0x6e5a(%rip), %rbx      # 0xa220
movq (%rbx,%r13,8), %rdx
movq %r14, %rdi
callq 0x45a5
movq %r14, %rdi
callq 0x3fa4
movl %eax, %eax
xorl %r15d, %r15d
cmpq %rax, %r13
sete %r15b
movq (%r12), %rbp
movq (%rbx,%r13,8), %rbx
movq %r14, %rdi
callq 0x3fa4
movl %eax, %r10d
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3c8f(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r10
pushq %rbx
pushq %rbp
leaq 0x3c8f(%rip), %r10      # 0x70a8
pushq %r10
pushq $0x2f
leaq 0x3c7c(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x30, %rsp
addq $0x8, %r12
incq %r13
cmpq $0xc, %r13
jne 0x33bb
leaq 0x6d79(%rip), %r13      # 0xa1c0
leaq 0x3c7c(%rip), %rbp      # 0x70ca
leaq 0x3c46(%rip), %rbx      # 0x709b
xorl %r15d, %r15d
movq (%r15,%r13), %rsi
movq %r14, %rdi
callq 0x412b
movq %rax, %r12
testq %rax, %rax
je 0x3484
leaq 0x6dad(%rip), %rax      # 0xa220
movq 0x8(%r15,%rax), %rsi
movq %r12, %rdi
callq 0x3358
testl %eax, %eax
je 0x348e
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
jmp 0x3497
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
xorl %eax, %eax
pushq %r12
pushq (%r15,%r13)
pushq %rbp
pushq $0x33
leaq 0x3bed(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x30, %rsp
addq $0x8, %r15
cmpq $0x58, %r15
jne 0x3458
movq 0x6b09(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3bfa(%rip), %rdi      # 0x70d3
callq 0x31e0
xorl %ebx, %ebx
movq %r14, %r12
leaq 0x6d36(%rip), %r14      # 0xa220
movq (%rbx,%r13), %rsi
movq (%rbx,%r14), %rdx
movq %r12, %rdi
callq 0x45a5
addq $0x8, %rbx
cmpq $0x60, %rbx
jne 0x34ea
leaq 0x3b90(%rip), %rbx      # 0x709b
xorl %r15d, %r15d
movq %r12, %r14
movq (%r15,%r13), %rsi
movq %r14, %rdi
callq 0x412b
testq %rax, %rax
je 0x353c
leaq 0x6cf7(%rip), %rcx      # 0xa220
movq (%r15,%rcx), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x3358
testl %eax, %eax
je 0x355d
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
xorl %eax, %eax
leaq 0x6cc9(%rip), %r10      # 0xa220
pushq (%r15,%r10)
jmp 0x3574
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
xorl %eax, %eax
pushq %r12
pushq (%r15,%r13)
pushq %rbp
pushq $0x3d
leaq 0x3b1e(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x30, %rsp
addq $0x8, %r15
cmpq $0x60, %r15
jne 0x3511
movq %r14, %rdi
callq 0x3fa4
xorl %ebx, %ebx
cmpl $0xc, %eax
sete %bl
movq %r14, %rdi
callq 0x3fa4
movl %eax, %r10d
leaq 0x3b48(%rip), %r11      # 0x7105
leaq 0x3ad7(%rip), %r9       # 0x709b
xorl %r12d, %r12d
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x40
leaq 0x3abe(%rip), %rbx      # 0x70a0
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
movq %r14, %rdi
callq 0x43b4
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x4158
testl %eax, %eax
jne 0x3637
leaq 0x3b17(%rip), %r10      # 0x7128
leaq 0x3a83(%rip), %r9       # 0x709b
cmpl $0xc, %r12d
jne 0x36f5
pushq $0x1
popq %rsi
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq $0xc
jmp 0x3704
xorl %r12d, %r12d
movq 0x20(%rsp), %rbp
xorl %ebx, %ebx
movq (%rbx,%r13), %rdi
movq %rbp, %rsi
callq 0x3358
testl %eax, %eax
je 0x365d
addq $0x8, %rbx
cmpq $0x60, %rbx
jne 0x3641
jmp 0x3679
movq 0x18(%rsp), %r15
leaq 0x6bb7(%rip), %rax      # 0xa220
movq (%rbx,%rax), %rsi
movq %r15, %rdi
callq 0x3358
testl %eax, %eax
je 0x36d7
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3a0c(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq 0x20(%rsp)
pushq 0x30(%rsp)
leaq 0x3a72(%rip), %r10      # 0x7112
pushq %r10
pushq $0x44
leaq 0x39f5(%rip), %rbx      # 0x70a0
pushq %rbx
callq 0x56f8
addq $0x30, %rsp
incl %r12d
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x4158
testl %eax, %eax
jne 0x363a
jmp 0x360a
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x39ad(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %rbp
jmp 0x3699
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r12
pushq %r10
pushq $0x46
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
movq 0x68bf(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3a18(%rip), %rdi      # 0x713b
callq 0x31e0
movq 0x6a91(%rip), %rsi      # 0xa1c0
movq %r14, %rdi
callq 0x43bc
movq 0x6a92(%rip), %rsi      # 0xa1d0
movq %r14, %rdi
callq 0x43bc
movq 0x6a8b(%rip), %rsi      # 0xa1d8
movq %r14, %rdi
callq 0x43bc
movq 0x6a64(%rip), %rsi      # 0xa1c0
movq %r14, %rdi
callq 0x412b
xorl %esi, %esi
testq %rax, %rax
sete %sil
leaq 0x39d8(%rip), %r15      # 0x714c
leaq 0x3920(%rip), %r12      # 0x709b
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq 0x6a31(%rip)            # 0xa1c0
pushq %r15
pushq $0x4d
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
movq 0x6a2c(%rip), %rsi      # 0xa1d0
movq %r14, %rdi
callq 0x412b
xorl %esi, %esi
testq %rax, %rax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq 0x6a07(%rip)            # 0xa1d0
pushq %r15
pushq $0x4e
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
movq 0x69fa(%rip), %rsi      # 0xa1d8
movq %r14, %rdi
callq 0x412b
xorl %esi, %esi
testq %rax, %rax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq 0x69d5(%rip)            # 0xa1d8
pushq %r15
pushq $0x4f
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
movq %r14, %rdi
callq 0x3fa4
xorl %r15d, %r15d
cmpl $0x9, %eax
sete %r15b
movq %r14, %rdi
callq 0x3fa4
movl %eax, %r10d
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq %r10
leaq 0x38bd(%rip), %r10      # 0x7105
pushq %r10
pushq $0x50
pushq %rbx
callq 0x56f8
addq $0x20, %rsp
leaq 0x38fd(%rip), %r12      # 0x715a
xorl %ebp, %ebp
xorl %ebx, %ebx
testb $0xd, %bl
sete %al
cmpq $0x3, %rbx
sete %cl
orb %al, %cl
jne 0x38cb
leaq 0x69a7(%rip), %rax      # 0xa220
movq (%rbp,%rax), %r15
movq (%rbp,%r13), %rsi
movq %r14, %rdi
callq 0x412b
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 0x37ed(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq (%rbp,%r13)
pushq %r12
pushq $0x53
leaq 0x37e0(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x20, %rsp
incq %rbx
addq $0x8, %rbp
cmpq $0xc, %rbx
jne 0x3861
movq %r14, %rdi
callq 0x3fa4
xorl %ebx, %ebx
cmpl $0x9, %eax
sete %bl
movq %r14, %rdi
callq 0x3fa4
movl %eax, %r10d
leaq 0x38a2(%rip), %r11      # 0x719c
leaq 0x379a(%rip), %r9       # 0x709b
xorl %r15d, %r15d
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq %r11
pushq $0x55
leaq 0x3781(%rip), %r12      # 0x70a0
pushq %r12
callq 0x56f8
addq $0x20, %rsp
movq 0x66a7(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x382b(%rip), %rdi      # 0x7166
callq 0x31e0
movq (%r15,%r13), %rsi
movq %r14, %rdi
callq 0x43bc
addq $0x8, %r15
cmpq $0x60, %r15
jne 0x3940
movq %r14, %rdi
callq 0x3fa4
xorl %ebx, %ebx
testl %eax, %eax
sete %bl
movq %r14, %rdi
callq 0x3fa4
movl %eax, %r10d
leaq 0x381f(%rip), %r11      # 0x7196
leaq 0x371d(%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 %r12
callq 0x56f8
addq $0x20, %rsp
movq %r14, %rdi
callq 0x4405
movq 0x8(%rsp), %r14
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x3c09
addq $0x8, %r14
leaq 0x40(%rsp), %rbp
leaq 0x3700(%rip), %r12      # 0x70c7
leaq 0x4287(%rip), %rsi      # 0x7c55
callq 0x31f0
testq %rax, %rax
je 0x3bec
movq %rax, %r13
movq %r14, 0x8(%rsp)
xorl %r15d, %r15d
movq 0x65f2(%rip), %rdi      # 0x9fe0
leaq 0x3a7(%rip), %rsi       # 0x3d9c
xorl %edx, %edx
callq 0x3f38
movq %rax, %rbx
movq %rbp, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %r13, %rdx
callq 0x32a0
movq %r13, 0x10(%rsp)
movl $0x0, %r13d
testq %rax, %rax
leaq 0x37(%rsp), %r14
je 0x3a5f
xorl %edx, %edx
leal 0x1(%rdx), %r13d
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x45a5
movq %rbp, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq 0x10(%rsp), %rdx
callq 0x32a0
movl %r13d, %edx
testq %rax, %rax
jne 0x3a26
movq %rbx, %rdi
callq 0x3fa4
xorl %r12d, %r12d
cmpl %r13d, %eax
sete %r12b
movq %rbx, 0x28(%rsp)
movq %rbx, %rdi
callq 0x3fa4
movl %eax, %r10d
subq $0x8, %rsp
xorl %edi, %edi
movq %r12, %rsi
leaq 0x3636(%rip), %r12      # 0x70c7
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x35fc(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r13
pushq %r10
leaq 0x3714(%rip), %r10      # 0x71c0
pushq %r10
pushq $0x70
leaq 0x35e9(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x30, %rsp
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x3040
movq %rbp, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %rbx, %rdx
callq 0x32a0
movl $0x0, %r13d
testq %rax, %rax
je 0x3b87
xorl %r13d, %r13d
xorl %r15d, %r15d
leaq 0x37(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3050
movq 0x28(%rsp), %rdi
movq %rbp, %r14
movq %rbp, %rsi
callq 0x412b
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3358
testl %eax, %eax
jne 0x3b54
incl %r13d
movq %r14, %rbp
movq %r14, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq 0x10(%rsp), %rdx
callq 0x32a0
incl %r15d
testq %rax, %rax
leaq 0x3577(%rip), %r12      # 0x70c7
jne 0x3af4
jmp 0x3b87
movq 0x647d(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
testq %r12, %r12
leaq 0x369c(%rip), %rax      # 0x7204
cmoveq %rax, %r12
leaq 0x3670(%rip), %rsi      # 0x71e3
movq %r12, %rdx
leaq 0x37(%rsp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x3270
jmp 0x3b2e
xorl %esi, %esi
cmpl %r15d, %r13d
sete %sil
subq $0x8, %rsp
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x34f7(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %r13
leaq 0x365a(%rip), %r10      # 0x720b
pushq %r10
pushq $0x80
leaq 0x34e1(%rip), %r10      # 0x70a0
pushq %r10
callq 0x56f8
addq $0x30, %rsp
movq 0x28(%rsp), %rdi
callq 0x4405
movq 0x8(%rsp), %r14
movq 0x8(%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x39c7
jmp 0x3c09
movq 0x63e5(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x35a8(%rip), %rsi      # 0x71a8
xorl %eax, %eax
callq 0x3270
jmp 0x3bd9
callq 0x6272
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq