// File: /workspace/github_c_makefile_star2_O3/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
movapd 0xeb9b(%rip), %xmm0     # 0x12010
movl %edi, %ebp
leaq 0x18eba(%rip), %rdi     # 0x1c338
movl $0xb, %ecx
xorl %eax, %eax
movq $0x0, 0x30(%rsp)
leaq 0xf3b0(%rip), %rdx      # 0x12845
movq %rsi, %r14
rep  stosq %rax, %es:(%rdi)
leaq 0xf399(%rip), %rcx      # 0x1283b
leaq 0xf43c(%rip), %rdi      # 0x128e5
leaq 0xed1d(%rip), %rax      # 0x121cd
movq %rcx, 0x18e79(%rip)     # 0x1c330
leaq 0xff38(%rip), %rcx      # 0x133f6
movl $0xbb8, 0x18e70(%rip)   # imm = 0xBB8
movq %rdx, 0x18e71(%rip)     # 0x1c340
movq %rcx, 0x18e72(%rip)     # 0x1c348
movq %rax, 0x18e73(%rip)     # 0x1c350
movl $0x0, 0x18e73(%rip)     # 0x1c35a
movq $0x258, 0x18e72(%rip) # imm = 0x258
movupd %xmm0, 0x18e76(%rip)    # 0x1c370
callq 0x2440
movl $0x14, %eax
leaq 0xf33f(%rip), %r15      # 0x1284a
leaq 0xeb0e(%rip), %r12      # 0x12020
movl $0x2710, %ebx           # imm = 0x2710
movl $0x64, 0x14(%rsp)
movl $0x20, 0x10(%rsp)
movl $0x2710, 0xc(%rsp)      # imm = 0x2710
movl $0x2710, 0x8(%rsp)      # imm = 0x2710
movq $0x0, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movl $0x80, %eax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
movl %eax, %r13d
callq 0x2080
leal -0x31(%rax), %ecx
cmpl $0x49, %ecx
ja 0x388c
movslq (%r12,%rcx,4), %rcx
movl $0x1, %eax
addq %r12, %rcx
jmpq *%rcx
movq 0x16a4e(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18dd0(%rip)     # 0x1c360
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18dbd(%rip)     # 0x1c359
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18db0(%rip)     # 0x1c358
movl %r13d, %eax
jmp 0x3551
movq 0x16a1c(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, %ebx
movl %r13d, %eax
jmp 0x3551
movq 0x16a06(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0xc(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x169eb(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18d4c(%rip)     # 0x1c340
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18d57(%rip)     # 0x1c35a
movl %r13d, %eax
jmp 0x3551
movq 0x169be(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18d4c(%rip)     # 0x1c36c
movl %r13d, %eax
jmp 0x3551
movq 0x169a1(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18d0a(%rip)     # 0x1c348
movl %r13d, %eax
jmp 0x3551
movq 0x16983(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x20(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x16963(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18cb4(%rip)     # 0x1c330
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18cd2(%rip)     # 0x1c35d
movl %r13d, %eax
jmp 0x3551
movq 0x16936(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x22d0
cvttsd2si %xmm0, %eax
movq %rax, 0x18(%rsp)
movl %r13d, %eax
jmp 0x3551
movl $0x1, 0x18cbb(%rip)     # 0x1c378
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18c90(%rip)     # 0x1c35c
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18c80(%rip)     # 0x1c35b
movl %r13d, %eax
jmp 0x3551
movl $0x1, 0x18c8f(%rip)     # 0x1c37c
movl %r13d, %eax
jmp 0x3551
movq 0x168d4(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18c5e(%rip)     # 0x1c368
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18c70(%rip)     # 0x1c389
movl %r13d, %eax
jmp 0x3551
movl $0x4, 0x18c4d(%rip)     # 0x1c378
movl %r13d, %eax
jmp 0x3551
movq 0x16896(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x28(%rsp)
movl %r13d, %eax
jmp 0x3551
movl $0x4, 0x18c23(%rip)     # 0x1c37c
movl %r13d, %eax
jmp 0x3551
movb $0x1, 0x18c20(%rip)     # 0x1c388
movl %r13d, %eax
jmp 0x3551
movq 0x16859(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18bff(%rip)     # 0x1c384
movl %r13d, %eax
jmp 0x3551
movq 0x1683c(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18bd2(%rip)     # 0x1c374
movl %r13d, %eax
jmp 0x3551
movq 0x1681f(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2500
movq %rax, 0x18b90(%rip)     # 0x1c350
movl %r13d, %eax
jmp 0x3551
movq 0x16801(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x14(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x167e6(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x8(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x167cb(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x10(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x167b0(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18b0a(%rip)     # 0x1c338
movl %r13d, %eax
jmp 0x3551
movq 0x16793(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movq %rax, 0x30(%rsp)
movl %r13d, %eax
jmp 0x3551
movq 0x16777(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18afd(%rip)     # 0x1c364
movl %r13d, %eax
jmp 0x3551
movq 0x1675a(%rip), %rax     # 0x19fd0
movq (%rax), %rdi
callq 0x2450
movl %eax, 0x18aec(%rip)     # 0x1c370
movl %r13d, %eax
jmp 0x3551
cmpl $-0x1, %eax
jne 0x38f4
movq 0x16748(%rip), %r14     # 0x19fe0
movq 0x18a91(%rip), %rdx     # 0x1c330
movl 0x18a93(%rip), %ecx     # 0x1c338
movq 0x18a94(%rip), %r8      # 0x1c340
movq 0x18a95(%rip), %r9      # 0x1c348
leaq 0xefc8(%rip), %rsi      # 0x12882
xorl %eax, %eax
movq (%r14), %rdi
callq 0x2390
cmpb $0x1, 0x18abe(%rip)     # 0x1c389
jne 0x38dc
movl $0x20, %edi
movl $0x2f02f529, %esi       # imm = 0x2F02F529
callq 0xc658
callq 0x8126
testl %r13d, %r13d
je 0x390d
callq 0x32a3
callq 0x8179
xorl %eax, %eax
jmp 0x38fe
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
movl 0xc(%rsp), %r14d
movl 0x10(%rsp), %ebp
movl %ebx, %r15d
movl %ebx, %edx
movl 0x8(%rsp), %ebx
leaq 0xef87(%rip), %rsi      # 0x128b0
xorl %eax, %eax
movl %r14d, %ecx
movl %ebx, %r8d
movl %ebp, %r9d
callq 0x2390
movzbl 0x18a1d(%rip), %eax     # 0x1c35d
movl 0x14(%rsp), %r9d
movq 0x30(%rsp), %rcx
movl %r15d, %edi
movl %r14d, %esi
movl %ebx, %edx
movl %ebp, %r8d
pushq %rax
pushq 0x28(%rsp)
pushq 0x28(%rsp)
pushq 0x40(%rsp)
callq 0x52d7
addq $0x20, %rsp
jmp 0x38eb