// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, %r14
movl %edi, %ebp
leaq 0x18eb6(%rip), %rdi     # 0x1c330
xorl %edx, %edx
movl $0xc, %ecx
xorl %eax, %eax
rep  stosq %rax, %es:(%rdi)
leaq 0xf3b2(%rip), %rax      # 0x1283f
movq %rax, 0x18e9c(%rip)     # 0x1c330
movl $0xbb8, 0x18e9a(%rip)   # imm = 0xBB8
leaq 0xf3a4(%rip), %rax      # 0x12849
movq %rax, 0x18e94(%rip)     # 0x1c340
leaq 0xff25(%rip), %rax      # 0x133d8
movq %rax, 0x18e8e(%rip)     # 0x1c348
leaq 0xed10(%rip), %rax      # 0x121d1
movq %rax, 0x18e88(%rip)     # 0x1c350
movb %dl, 0x18e8a(%rip)      # 0x1c358
movl %edx, 0x18e86(%rip)     # 0x1c35a
movl $0x3, 0x18e9e(%rip)     # 0x1c37c
movl %edx, 0x18ea0(%rip)     # 0x1c384
movss 0xeb34(%rip), %xmm0     # 0x12020
movupd %xmm0, 0x18e70(%rip)    # 0x1c364
movabsq $0x300000001, %rax      # imm = 0x300000001
movq %rax, 0x18e6f(%rip)     # 0x1c374
movq $0x0, 0x30(%rsp)
movb %dl, 0x18e74(%rip)      # 0x1c388
leaq 0xf3ce(%rip), %rdi      # 0x128e9
callq 0x2440
movl $0x14, %eax
movq %rax, 0x20(%rsp)
movl $0x80, %eax
movq %rax, 0x28(%rsp)
movl $0x64, 0x14(%rsp)
movl $0x20, 0x10(%rsp)
movl $0x2710, 0xc(%rsp)      # imm = 0x2710
leaq 0xf2fb(%rip), %r15      # 0x1284e
leaq 0xeaca(%rip), %r12      # 0x12024
movl $0x2710, 0x8(%rsp)      # imm = 0x2710
movl $0x2710, %ebx           # imm = 0x2710
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
movl %eax, %r13d
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2080
leal -0x31(%rax), %ecx
cmpl $0x49, %ecx
ja 0x38ad
movl $0x1, %eax
movslq (%r12,%rcx,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movq 0x16a2d(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18daf(%rip)     # 0x1c360
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18d9c(%rip)     # 0x1c359
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18d8f(%rip)     # 0x1c358
movl %r13d, %eax
jmp 0x3572
movq 0x169fb(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, %ebx
movl %r13d, %eax
jmp 0x3572
movq 0x169e5(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0xc(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x169ca(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18d2b(%rip)     # 0x1c340
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18d36(%rip)     # 0x1c35a
movl %r13d, %eax
jmp 0x3572
movq 0x1699d(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18d2b(%rip)     # 0x1c36c
movl %r13d, %eax
jmp 0x3572
movq 0x16980(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18ce9(%rip)     # 0x1c348
movl %r13d, %eax
jmp 0x3572
movq 0x16962(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x20(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x16942(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18c93(%rip)     # 0x1c330
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18cb1(%rip)     # 0x1c35d
movl %r13d, %eax
jmp 0x3572
movq 0x16915(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x18(%rsp)
movl %r13d, %eax
jmp 0x3572
movl $0x1, 0x18c9a(%rip)     # 0x1c378
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18c6f(%rip)     # 0x1c35c
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18c5f(%rip)     # 0x1c35b
movl %r13d, %eax
jmp 0x3572
movl $0x1, 0x18c6e(%rip)     # 0x1c37c
movl %r13d, %eax
jmp 0x3572
movq 0x168b3(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18c3d(%rip)     # 0x1c368
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18c4f(%rip)     # 0x1c389
movl %r13d, %eax
jmp 0x3572
movl $0x4, 0x18c2c(%rip)     # 0x1c378
movl %r13d, %eax
jmp 0x3572
movq 0x16875(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x28(%rsp)
movl %r13d, %eax
jmp 0x3572
movl $0x4, 0x18c02(%rip)     # 0x1c37c
movl %r13d, %eax
jmp 0x3572
movb $0x1, 0x18bff(%rip)     # 0x1c388
movl %r13d, %eax
jmp 0x3572
movq 0x16838(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18bde(%rip)     # 0x1c384
movl %r13d, %eax
jmp 0x3572
movq 0x1681b(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18bb1(%rip)     # 0x1c374
movl %r13d, %eax
jmp 0x3572
movq 0x167fe(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18b6f(%rip)     # 0x1c350
movl %r13d, %eax
jmp 0x3572
movq 0x167e0(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x14(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x167c5(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x8(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x167aa(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x10(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x1678f(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18ae9(%rip)     # 0x1c338
movl %r13d, %eax
jmp 0x3572
movq 0x16772(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x30(%rsp)
movl %r13d, %eax
jmp 0x3572
movq 0x16756(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18adc(%rip)     # 0x1c364
movl %r13d, %eax
jmp 0x3572
movq 0x16739(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18acb(%rip)     # 0x1c370
movl %r13d, %eax
jmp 0x3572
cmpl $-0x1, %eax
jne 0x3915
movq 0x16727(%rip), %r14     # 0x19fe0
movq (%r14), %rdi
movq 0x18a6d(%rip), %rdx     # 0x1c330
movl 0x18a6f(%rip), %ecx     # 0x1c338
movq 0x18a70(%rip), %r8      # 0x1c340
movq 0x18a71(%rip), %r9      # 0x1c348
leaq 0xefa8(%rip), %rsi      # 0x12886
xorl %eax, %eax
callq 0x2390
cmpb $0x1, 0x18a9d(%rip)     # 0x1c389
jne 0x38fd
movl $0x20, %edi
movl $0x2f02f529, %esi       # imm = 0x2F02F529
callq 0xca40
callq 0x829e
testl %r13d, %r13d
je 0x392e
callq 0x32a1
callq 0x82f1
xorl %eax, %eax
jmp 0x391f
callq 0x2580
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
leaq 0xef7c(%rip), %rsi      # 0x128b4
movl %ebx, %r15d
movl %ebx, %edx
movl 0xc(%rsp), %r14d
movl %r14d, %ecx
movl 0x8(%rsp), %ebx
movl %ebx, %r8d
movl 0x10(%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
callq 0x2390
movzbl 0x189fc(%rip), %eax     # 0x1c35d
movl %r15d, %edi
movl %r14d, %esi
movl %ebx, %edx
movq 0x30(%rsp), %rcx
movl %ebp, %r8d
movl 0x14(%rsp), %r9d
pushq %rax
pushq 0x28(%rsp)
pushq 0x28(%rsp)
pushq 0x40(%rsp)
callq 0x5389
addq $0x20, %rsp
jmp 0x390c
nopl (%rax)