// File: /workspace/github_cpp_makefile_star2_O3/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 0x600e
movq 0x6c57(%rip), %rdi      # 0x9fe0
leaq 0xa6c(%rip), %rsi       # 0x3dfc
xorl %edx, %edx
callq 0x3f98
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 0x45d4
movq %r14, %rdi
callq 0x3ffb
movl %eax, %eax
xorl %r15d, %r15d
cmpq %rax, %r13
sete %r15b
movq (%r12), %rbp
movq (%rbx,%r13,8), %rbx
movq %r14, %rdi
callq 0x3ffb
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 0x5728
addq $0x30, %rsp
addq $0x8, %r12
incq %r13
cmpq $0xc, %r13
jne 0x33bb
leaq 0x6d79(%rip), %rbx      # 0xa1c0
leaq 0x3c7c(%rip), %rbp      # 0x70ca
leaq 0x3c46(%rip), %r15      # 0x709b
xorl %r13d, %r13d
movq (%r13,%rbx), %rsi
movq %r14, %rdi
callq 0x4177
movq %rax, %r12
testq %rax, %rax
je 0x3485
leaq 0x6dac(%rip), %rax      # 0xa220
movq 0x8(%r13,%rax), %rsi
movq %r12, %rdi
callq 0x3358
testl %eax, %eax
je 0x348f
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
jmp 0x3498
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 0x3beb(%rip), %r10      # 0x70a0
pushq %r10
callq 0x5728
addq $0x30, %rsp
addq $0x8, %r13
cmpq $0x58, %r13
jne 0x3458
movq 0x6b07(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3bf8(%rip), %rdi      # 0x70d3
callq 0x31e0
xorl %r15d, %r15d
movq %r14, %r12
leaq 0x6d33(%rip), %r14      # 0xa220
movq (%r15,%rbx), %rsi
movq (%r15,%r14), %rdx
movq %r12, %rdi
callq 0x45d4
addq $0x8, %r15
cmpq $0x60, %r15
jne 0x34ed
leaq 0x3b8d(%rip), %r15      # 0x709b
xorl %r13d, %r13d
movq %r12, %r14
movq (%r13,%rbx), %rsi
movq %r14, %rdi
callq 0x4177
leaq 0x6cf8(%rip), %rcx      # 0xa220
movq (%r13,%rcx), %r12
testq %rax, %rax
je 0x3544
movq %rax, %rdi
movq %r12, %rsi
callq 0x3358
pushq $0x1
popq %rsi
testl %eax, %eax
je 0x3546
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 0x3b37(%rip), %r10      # 0x70a0
pushq %r10
callq 0x5728
addq $0x30, %rsp
addq $0x8, %r13
cmpq $0x60, %r13
jne 0x3514
movq %r14, %rdi
callq 0x3ffb
xorl %r15d, %r15d
cmpl $0xc, %eax
sete %r15b
movq %r14, %rdi
callq 0x3ffb
movl %eax, %r10d
leaq 0x3b63(%rip), %rbp      # 0x7105
leaq 0x3af2(%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 %rbp
pushq $0x40
leaq 0x3ada(%rip), %r13      # 0x70a0
pushq %r13
callq 0x5728
addq $0x20, %rsp
movq %r14, %rdi
callq 0x43fd
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x41a4
testl %eax, %eax
je 0x36f1
xorl %r12d, %r12d
movq 0x38(%rsp), %rbp
xorl %r13d, %r13d
movq (%r13,%rbx), %rdi
movq %rbp, %rsi
callq 0x3358
testl %eax, %eax
je 0x3620
addq $0x8, %r13
cmpq $0x60, %r13
jne 0x35fe
movq 0x18(%rsp), %r15
jmp 0x363d
movq 0x18(%rsp), %r15
leaq 0x6bf4(%rip), %rax      # 0xa220
movq (%r13,%rax), %rsi
movq %r15, %rdi
callq 0x3358
testl %eax, %eax
je 0x3694
leaq 0x3a5c(%rip), %r13      # 0x70a0
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x3a41(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %rbp
leaq 0x3aac(%rip), %r10      # 0x7112
pushq %r10
pushq $0x44
pushq %r13
callq 0x5728
addq $0x30, %rsp
incl %r12d
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x41a4
testl %eax, %eax
jne 0x35f6
jmp 0x36c4
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x39f0(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %rbp
leaq 0x3a5b(%rip), %r10      # 0x7112
pushq %r10
pushq $0x44
leaq 0x39de(%rip), %r13      # 0x70a0
jmp 0x366a
cmpl $0xc, %r12d
leaq 0x3a36(%rip), %rbp      # 0x7105
jne 0x36f1
leaq 0x3a50(%rip), %r10      # 0x7128
leaq 0x39bc(%rip), %r9       # 0x709b
pushq $0x1
popq %rsi
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq $0xc
jmp 0x370e
leaq 0x3a30(%rip), %r10      # 0x7128
leaq 0x399c(%rip), %r9       # 0x709b
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 %r13
callq 0x5728
addq $0x20, %rsp
movq 0x68b4(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3a0d(%rip), %rdi      # 0x713b
callq 0x31e0
movq 0x6a86(%rip), %rsi      # 0xa1c0
movq %r14, %rdi
callq 0x4405
movq 0x6a87(%rip), %rsi      # 0xa1d0
movq %r14, %rdi
callq 0x4405
movq 0x6a80(%rip), %rsi      # 0xa1d8
movq %r14, %rdi
callq 0x4405
movq 0x6a59(%rip), %rsi      # 0xa1c0
movq %r14, %rdi
callq 0x4177
xorl %esi, %esi
testq %rax, %rax
sete %sil
leaq 0x39cd(%rip), %r15      # 0x714c
leaq 0x3915(%rip), %r12      # 0x709b
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq 0x6a26(%rip)            # 0xa1c0
pushq %r15
pushq $0x4d
pushq %r13
callq 0x5728
addq $0x20, %rsp
movq 0x6a20(%rip), %rsi      # 0xa1d0
movq %r14, %rdi
callq 0x4177
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 0x69fb(%rip)            # 0xa1d0
pushq %r15
pushq $0x4e
pushq %r13
callq 0x5728
addq $0x20, %rsp
movq 0x69ed(%rip), %rsi      # 0xa1d8
movq %r14, %rdi
callq 0x4177
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 0x69c8(%rip)            # 0xa1d8
pushq %r15
pushq $0x4f
pushq %r13
callq 0x5728
addq $0x20, %rsp
movq %r14, %rdi
callq 0x3ffb
xorl %r15d, %r15d
cmpl $0x9, %eax
sete %r15b
movq %r14, %rdi
callq 0x3ffb
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
pushq %rbp
pushq $0x50
pushq %r13
callq 0x5728
addq $0x20, %rsp
leaq 0x38f6(%rip), %r13      # 0x715a
xorl %ebp, %ebp
xorl %r12d, %r12d
testb $0xd, %r12b
sete %al
cmpq $0x3, %r12
sete %cl
orb %al, %cl
jne 0x38d3
leaq 0x699e(%rip), %rax      # 0xa220
movq (%rbp,%rax), %r15
movq (%rbp,%rbx), %rsi
movq %r14, %rdi
callq 0x4177
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 0x37e4(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq (%rbp,%rbx)
pushq %r13
pushq $0x53
leaq 0x37d8(%rip), %r10      # 0x70a0
pushq %r10
callq 0x5728
addq $0x20, %rsp
incq %r12
addq $0x8, %rbp
cmpq $0xc, %r12
jne 0x3869
movq %r14, %rdi
callq 0x3ffb
xorl %r15d, %r15d
cmpl $0x9, %eax
sete %r15b
movq %r14, %rdi
callq 0x3ffb
movl %eax, %r10d
leaq 0x3898(%rip), %r11      # 0x719c
leaq 0x3790(%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 0x3777(%rip), %r15      # 0x70a0
pushq %r15
callq 0x5728
addq $0x20, %rsp
movq 0x669d(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
leaq 0x3821(%rip), %rdi      # 0x7166
callq 0x31e0
movq (%r12,%rbx), %rsi
movq %r14, %rdi
callq 0x4405
addq $0x8, %r12
cmpq $0x60, %r12
jne 0x394a
movq %r14, %rdi
callq 0x3ffb
xorl %ebx, %ebx
testl %eax, %eax
sete %bl
movq %r14, %rdi
callq 0x3ffb
movl %eax, %r10d
leaq 0x3815(%rip), %r11      # 0x7196
leaq 0x3713(%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 0x5728
addq $0x20, %rsp
movq %r14, %rdi
callq 0x444e
movq 0x8(%rsp), %r14
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x3c6c
addq $0x8, %r14
leaq 0x36fb(%rip), %r12      # 0x70c7
leaq 0x27(%rsp), %rbp
leaq 0x427d(%rip), %rsi      # 0x7c55
callq 0x31f0
testq %rax, %rax
je 0x3c4f
movq %rax, %rbx
movq %r14, 0x8(%rsp)
xorl %r15d, %r15d
movq 0x65e8(%rip), %rdi      # 0x9fe0
leaq 0x3fd(%rip), %rsi       # 0x3dfc
xorl %edx, %edx
callq 0x3f98
movq %rbx, %rdx
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %rdx, 0x30(%rsp)
callq 0x32a0
movl $0x0, %r13d
testq %rax, %rax
je 0x3a6b
xorl %edx, %edx
leal 0x1(%rdx), %r13d
movq %rbp, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
movq %rbp, %rdx
callq 0x45d4
movq %r14, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq 0x30(%rsp), %rdx
callq 0x32a0
movl %r13d, %edx
testq %rax, %rax
jne 0x3a2d
movq %rbx, %r14
movq %rbx, %rdi
callq 0x3ffb
xorl %r12d, %r12d
cmpl %r13d, %eax
sete %r12b
movq %rbx, %rdi
callq 0x3ffb
movl %eax, %r10d
subq $0x8, %rsp
xorl %edi, %edi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x35f9(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r13
pushq %r10
leaq 0x3711(%rip), %r10      # 0x71c0
pushq %r10
pushq $0x70
leaq 0x35e6(%rip), %r12      # 0x70a0
pushq %r12
callq 0x5728
addq $0x30, %rsp
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x3040
leaq 0x40(%rsp), %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %rbx, %rdx
callq 0x32a0
testq %rax, %rax
je 0x3baa
movq %r14, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
leaq 0x35c8(%rip), %r12      # 0x70c7
leaq 0x40(%rsp), %r14
leaq 0x27(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3050
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4177
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3358
testl %eax, %eax
jne 0x3b61
incl %r13d
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl $0x3e7, %esi            # imm = 0x3E7
movq %rbx, %rdx
callq 0x32a0
incl %r15d
testq %rax, %rax
leaq 0x356a(%rip), %r12      # 0x70c7
jne 0x3b04
jmp 0x3b99
movq 0x6470(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
testq %r12, %r12
leaq 0x368f(%rip), %rax      # 0x7204
cmoveq %rax, %r12
leaq 0x3663(%rip), %rsi      # 0x71e3
movq %r12, %rdx
leaq 0x27(%rsp), %rcx
leaq 0x40(%rsp), %r14
movq %r14, %r8
xorl %eax, %eax
callq 0x3270
jmp 0x3b40
cmpl %r13d, %r15d
jne 0x3be9
leaq 0x34fb(%rip), %r12      # 0x70a0
movq 0x10(%rsp), %r14
subq $0x8, %rsp
xorl %edi, %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x34da(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %r15
leaq 0x363d(%rip), %r10      # 0x720b
pushq %r10
pushq $0x80
pushq %r12
callq 0x5728
addq $0x30, %rsp
leaq 0x34e0(%rip), %r12      # 0x70c7
jmp 0x3c2a
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x349c(%rip), %r9       # 0x709b
xorl %eax, %eax
pushq %r15
pushq %r13
leaq 0x35ff(%rip), %r10      # 0x720b
pushq %r10
pushq $0x80
leaq 0x3486(%rip), %r10      # 0x70a0
pushq %r10
callq 0x5728
addq $0x30, %rsp
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x444e
movq 0x8(%rsp), %r14
leaq 0x27(%rsp), %rbp
movq 0x8(%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x39d1
jmp 0x3c6c
movq 0x6382(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x3545(%rip), %rsi      # 0x71a8
xorl %eax, %eax
callq 0x3270
jmp 0x3c3c
callq 0x62b0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq