// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/tests/key_c/src/main.c
// Function: main
int
main(int argc, char **argv)
{
	memset(&g_config, 0, sizeof(g_config));
	
	g_config.host = "127.0.0.1";
	g_config.port = 3000;
	g_config.ns = "test";
	g_config.table = "";
	g_config.bin = "value";
	g_config.verbose = false;
	g_config.host_direct = false;
	g_config.continuous = false;
	g_config.parallel = false;
	g_config.server_validate = false;
	g_config.timeout = 600;
	g_config.key_type = CL_STR;
	g_config.value_type = CL_STR;
	g_config.delay = 0;
	g_config.record_ttl = 0;
	g_config.ttl_range = 0;
	g_config.zero = 0;
	g_config.value_factor = 1;
	g_config.read_modify_write = false;
	
	// parameters for key-test
	int		n_reads = 10000;
	int		n_writes = 10000;
	int		n_deletes = 0;
	int		n_keys = 10000;
	int 		n_threads = 32;
	int		key_len = 100;
	int 		value_len = 128;
	int 		writesper100 = 20;
	int		n_ops = 0;
	// or maybe to simply do one-test
	int		one_test = 0;

	int		c;
	
	printf("testing the C citrusleaf library\n");
	
	while ((c = getopt(argc, argv, "h:p:n:S:t:k:r:w:e:K:V:m:D:T:U:f:z:A:N:W:o:1vdiPIbBCcsMR")) != -1)
	{
		switch (c)
		{
		case 'h':
			g_config.host = strdup(optarg);
			break;
		
		case 'p':
			g_config.port = atoi(optarg);
			break;
		
		case 'n':
			g_config.ns = strdup(optarg);
			break;

		case 'S':
			g_config.table = strdup(optarg);
			break;

		case 't':
			n_threads = atoi(optarg);
			break;
			
		case 'k':
			n_keys = atoi(optarg);
			break;
		
		case 'r':
			n_reads = atoi(optarg);
			break;
		
		case 'w':
			n_writes = atoi(optarg);
			break;

		case 'e':
			n_deletes = atoi(optarg);
			break;
			
		case 'K':
			key_len = atoi(optarg);
			break;

        case 'V':
            value_len = atoi(optarg);
            break;

		case '1':
			one_test = 1;
			break;
			
		case 'v':
			g_config.verbose = true;
			break;

		case 's':
			g_config.silent = true;
			break;
			
		case 'd':
			g_config.host_direct = true;
			break;

		case 'm':
			g_config.timeout = atoi(optarg);
			break;

		case 'f':
			g_config.value_factor = atoi(optarg);
			break;
			
		case 'D':
			g_config.delay = atoi(optarg);
			break;

		case 'T':
			g_config.record_ttl = atoi(optarg);
			break;

		case 'U':
			g_config.ttl_range = atoi(optarg);
			break;

		case 'z':
			g_config.zero = atoi(optarg);
			break;

		case 'i':
			g_config.value_type = CL_INT;
			break;

		case 'I':
			g_config.key_type = CL_INT;
			break;

		case 'b':
			g_config.value_type = CL_BLOB;
			break;
		
		case 'B':
			g_config.key_type = CL_BLOB;
			break;
			
		case 'C':
			g_config.continuous = true;
			break;

		case 'P':
			g_config.parallel = true;
			break;
			
		case 'c':
			g_config.server_validate = true;
			break;
			
		case 'M':
			g_config.read_modify_write = true;
			break;
			
		case 'A':
			g_config.n_batch = atoi(optarg);
			break;

		case 'R':
			g_config.use_shm = true;
			break;

		case 'N':
			g_config.bin = strdup(optarg);
			break;
		case 'W':
			writesper100 = atof(optarg);
			break;

		case 'o':
			n_ops = atof(optarg);
			break;
	
		default:
			usage();
			return(-1);
			
		}
	}
	fprintf(stderr, "testing: host %s port %d namespace %s set %s\n",g_config.host,g_config.port,g_config.ns, g_config.table);
	
	if (g_config.use_shm) {
		//first parameter is maximum number of nodes allowed for this cluster 
		//(shared memory size is accordingly allocated)
		//second parameter is shm_key
		citrusleaf_use_shm(32,788722985);
	}

	citrusleaf_init();

	if (one_test) {
		test_one_key();
	}
	else {
		fprintf(stderr, "key_test: keys: %d reads: %d writes: %d threads: %d\n",n_keys,n_reads,n_writes,n_threads);
		do_key_test(n_keys, n_reads, n_writes, n_deletes, n_threads, key_len, value_len, n_ops, writesper100, g_config.parallel);
	}

	citrusleaf_shutdown();
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebp
movq %rsi, %r14
leaq 0x1751e(%rip), %rdi     # 0x1a338
movq $0x0, 0x28(%rsp)
pushq $0xb
popq %rcx
xorl %eax, %eax
leaq 0xda16(%rip), %rdx      # 0x10845
movapd 0xd1d9(%rip), %xmm0     # 0x10010
rep  stosq %rax, %es:(%rdi)
leaq 0xd9fa(%rip), %rcx      # 0x1083b
leaq 0xd385(%rip), %rax      # 0x101cd
leaq 0xda96(%rip), %rdi      # 0x108e5
movq %rcx, 0x174da(%rip)     # 0x1a330
leaq 0xe599(%rip), %rcx      # 0x113f6
movl $0xbb8, 0x174d1(%rip)   # imm = 0xBB8
movq %rdx, 0x174d2(%rip)     # 0x1a340
movq %rcx, 0x174d3(%rip)     # 0x1a348
movq %rax, 0x174d4(%rip)     # 0x1a350
andl $0x0, 0x174d7(%rip)     # 0x1a35a
movq $0x258, 0x174d6(%rip) # imm = 0x258
movupd %xmm0, 0x174da(%rip)    # 0x1a370
callq 0x2440
pushq $0x14
popq %rax
movq %rax, 0x30(%rsp)
movl $0x80, %eax
movq %rax, 0x20(%rsp)
pushq $0x64
popq %rax
movl %eax, 0x14(%rsp)
pushq $0x20
popq %rax
leaq 0xd98c(%rip), %r15      # 0x1084a
movl %eax, 0x10(%rsp)
movl $0x2710, 0xc(%rsp)      # imm = 0x2710
pushq $0x1
popq %r12
leaq 0xd14b(%rip), %r13      # 0x10020
xorl %eax, %eax
movl $0x2710, 0x8(%rsp)      # imm = 0x2710
movl $0x2710, 0x4(%rsp)      # imm = 0x2710
movq $0x0, 0x18(%rsp)
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
movl %eax, %ebx
callq 0x2080
leal -0x31(%rax), %ecx
cmpl $0x49, %ecx
ja 0x320d
movslq (%r13,%rcx,4), %rcx
movl %r12d, %eax
addq %r13, %rcx
jmpq *%rcx
movq 0x150b1(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x17433(%rip)     # 0x1a360
movl %ebx, %eax
jmp 0x2ef0
movq 0x15098(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x30(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x17408(%rip)     # 0x1a35c
movl %ebx, %eax
jmp 0x2ef0
movq 0x15071(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x173cb(%rip)     # 0x1a338
movl %ebx, %eax
jmp 0x2ef0
movq 0x15055(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x18(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x173ef(%rip)     # 0x1a389
movl %ebx, %eax
jmp 0x2ef0
movq 0x15028(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x10(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movl $0x1, 0x173b7(%rip)     # 0x1a37c
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x173b5(%rip)     # 0x1a388
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x1737a(%rip)     # 0x1a35b
movl %ebx, %eax
jmp 0x2ef0
movl $0x4, 0x1738a(%rip)     # 0x1a37c
movl %ebx, %eax
jmp 0x2ef0
movq 0x14fd0(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x17356(%rip)     # 0x1a364
movl %ebx, %eax
jmp 0x2ef0
movq 0x14fb4(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x1735a(%rip)     # 0x1a384
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f98(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0xc(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f7e(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x4(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f64(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x14(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f4a(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x172ab(%rip)     # 0x1a340
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x172ba(%rip)     # 0x1a35d
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f1f(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x8(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movq 0x14f05(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x1728f(%rip)     # 0x1a368
movl %ebx, %eax
jmp 0x2ef0
movl $0x4, 0x1728e(%rip)     # 0x1a378
movl %ebx, %eax
jmp 0x2ef0
movq 0x14ed8(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x17249(%rip)     # 0x1a350
movl %ebx, %eax
jmp 0x2ef0
movl $0x1, 0x17260(%rip)     # 0x1a378
movl %ebx, %eax
jmp 0x2ef0
movq 0x14eaa(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x17238(%rip)     # 0x1a36c
movl %ebx, %eax
jmp 0x2ef0
movq 0x14e8e(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x171f7(%rip)     # 0x1a348
movl %ebx, %eax
jmp 0x2ef0
movq 0x14e71(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x17207(%rip)     # 0x1a374
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x171df(%rip)     # 0x1a35a
movl %ebx, %eax
jmp 0x2ef0
movq 0x14e47(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x28(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movq 0x14e2c(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x20(%rsp)
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x1719a(%rip)     # 0x1a359
movl %ebx, %eax
jmp 0x2ef0
movq 0x14e03(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x17154(%rip)     # 0x1a330
movl %ebx, %eax
jmp 0x2ef0
movq 0x14de6(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x17178(%rip)     # 0x1a370
movl %ebx, %eax
jmp 0x2ef0
movb $0x1, 0x17152(%rip)     # 0x1a358
movl %ebx, %eax
jmp 0x2ef0
cmpl $-0x1, %eax
je 0x3229
callq 0x2b03
pushq $-0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x14db0(%rip), %r14     # 0x17fe0
movq 0x170f9(%rip), %rdx     # 0x1a330
movl 0x170fb(%rip), %ecx     # 0x1a338
movq 0x170fc(%rip), %r8      # 0x1a340
movq 0x170fd(%rip), %r9      # 0x1a348
leaq 0xd630(%rip), %rsi      # 0x10882
xorl %eax, %eax
movq (%r14), %rdi
callq 0x2390
cmpb $0x1, 0x17126(%rip)     # 0x1a389
jne 0x3272
pushq $0x20
popq %rdi
movl $0x2f02f529, %esi       # imm = 0x2F02F529
callq 0xb868
callq 0x7917
testl %ebx, %ebx
je 0x3289
callq 0x2935
callq 0x7968
xorl %eax, %eax
jmp 0x321a
movq (%r14), %rdi
movl 0x4(%rsp), %r15d
movl 0xc(%rsp), %ebp
movl 0x8(%rsp), %r14d
movl 0x10(%rsp), %ebx
leaq 0xd60b(%rip), %rsi      # 0x108b0
xorl %eax, %eax
movl %r15d, %edx
movl %ebp, %ecx
movl %r14d, %r8d
movl %ebx, %r9d
callq 0x2390
movzbl 0x1709f(%rip), %eax     # 0x1a35d
movl 0x14(%rsp), %r9d
movq 0x28(%rsp), %rcx
movl %r15d, %edi
movl %ebp, %esi
movl %r14d, %edx
movl %ebx, %r8d
pushq %rax
pushq 0x38(%rsp)
pushq 0x28(%rsp)
pushq 0x38(%rsp)
callq 0x4b51
addq $0x20, %rsp
jmp 0x3280
nop