// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/tests/loop_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.set = "set";
	g_config.bin = "value";
	g_config.verbose = false;
	g_config.follow = true;
	g_config.strict = false;
	
	g_config.n_threads = 32;
	g_config.n_keys = 100000;
	g_config.key_len = 10;
	g_config.value_len = 20;
	g_config.pseudo_seed = 0; // means use a real random value
	g_config.timeout_ms = 200; // 200 ms
	
	g_config.values = 0;
	g_config.in_progress_hash = 0;
	

	int		c;
	
	printf("testing the C citrusleaf library\n");
	
	while ((c = getopt(argc, argv, "h:p:H:n:t:k:b:w:K:V:s:r:m:vfS")) != -1) 
	{
		switch (c)
		{
		case 'h':
			g_config.host = strdup(optarg);
			break;
		
		case 'p':
			g_config.port = atoi(optarg);
			if (g_config.port <= 0) {
				fprintf(stderr, "port must be a number\n");
				usage();
				return(0);
			}
			break;

		case 'H':
			g_config.host = malloc(strlen(optarg));
		    char *tp = optarg;
		    while (*tp++) {
		    	if (*tp == ':') break;
		    }
		    if (*tp == ':') *tp = 0;
		    strcpy(g_config.host, optarg);
		    g_config.port = atoi(tp + 1);
		    fprintf(stderr, " host %s port %d\n",g_config.host,g_config.port);
			break;

		case 'n':
			g_config.ns = strdup(optarg);
			break;

		case 's':
			g_config.set = strdup(optarg);
			break;

		case 'b':
			g_config.bin = strdup(optarg);
			break;

		case 't':
			g_config.n_threads = atoi(optarg);
			break;
			
		case 'k':
			g_config.n_keys = atoi(optarg);
			break;


		case 'K':
			g_config.key_len = atoi(optarg);
			break;
			
		case 'V':
			g_config.value_len = atoi(optarg);
			break;

		case 'r':
			g_config.pseudo_seed = atoi(optarg);
			break;
			
		case 'm':
			g_config.timeout_ms = atoi(optarg);
			break;
			
		case 'v':
			g_config.verbose = true;
			break;

		case 'f':
			g_config.follow = false;
			break;

		case 'S':
			g_config.follow = false;
			break;
			
		default:
			usage();
			return(-1);
			
		}
	}
	fprintf(stderr, "testing: host %s port %d ns %s set %s bin %s\n",g_config.host,g_config.port,g_config.ns,g_config.set,g_config.bin);

	if (g_config.pseudo_seed)
		srandom(g_config.pseudo_seed);
	
	citrusleaf_init();

	fprintf(stderr, "key_test: keys: %d threads: %d \n",g_config.n_keys,g_config.n_threads);

	if (0 != do_loop_test()) {
		fprintf(stderr, "could not init test!\n");
		return(-1);
	}

	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
movq %rsi, %rbx
leaq 0x1282d(%rip), %rdi     # 0x152f8
pushq $0xf
popq %rcx
movaps 0xb53b(%rip), %xmm0     # 0xe010
xorl %eax, %eax
leaq 0xb806(%rip), %rdx      # 0xe2e4
rep  stosq %rax, %es:(%rdi)
leaq 0xb7f2(%rip), %rcx      # 0xe2da
leaq 0xb7fe(%rip), %rax      # 0xe2ed
leaq 0xb8a9(%rip), %rdi      # 0xe39f
movq %rcx, 0x127f3(%rip)     # 0x152f0
leaq 0xb7e5(%rip), %rcx      # 0xe2e9
movl $0xbb8, 0x127ea(%rip)   # imm = 0xBB8
movq %rdx, 0x127eb(%rip)     # 0x15300
movq %rcx, 0x127ec(%rip)     # 0x15308
movq %rax, 0x127ed(%rip)     # 0x15310
movb $0x1, 0x127ef(%rip)     # 0x15319
movups %xmm0, 0x127eb(%rip)    # 0x1531c
movl $0xc8, 0x12829(%rip)    # 0x15364
andq $0x0, 0x127ed(%rip)     # 0x15330
andq $0x0, 0x127ed(%rip)     # 0x15338
callq 0x2430
movq 0x12479(%rip), %r15     # 0x14fd0
movq 0x12482(%rip), %r13     # 0x14fe0
leaq 0xb78e(%rip), %r14      # 0xe2f3
leaq 0xb4b4(%rip), %r12      # 0xe020
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2080
leal -0x62(%rax), %ecx
cmpl $0x14, %ecx
ja 0x2b9b
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x12777(%rip)     # 0x15310
jmp 0x2b6c
cmpl $0x4b, %eax
je 0x2c74
cmpl $0x53, %eax
je 0x2bc2
cmpl $0x56, %eax
jne 0x2c87
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x12768(%rip)     # 0x15328
jmp 0x2b6c
movb $0x0, 0x12750(%rip)     # 0x15319
jmp 0x2b6c
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x1272e(%rip)     # 0x15308
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x12732(%rip)     # 0x1531c
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x1276a(%rip)     # 0x15364
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x12713(%rip)     # 0x15320
jmp 0x2b6c
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x126cf(%rip)     # 0x152f0
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x1272c(%rip)     # 0x15360
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
testl %eax, %eax
movl %eax, 0x126af(%rip)     # 0x152f8
jg 0x2b6c
jmp 0x2d39
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x1269d(%rip)     # 0x15300
jmp 0x2b6c
movb $0x1, 0x126a9(%rip)     # 0x15318
jmp 0x2b6c
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x126a2(%rip)     # 0x15324
jmp 0x2b6c
cmpl $0x48, %eax
jne 0x2d1b
movq (%r15), %r13
movq %r13, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x22e0
movq %rax, 0x12646(%rip)     # 0x152f0
movq %r13, %rsi
leaq 0x2(%r13), %rdx
movb (%r13), %cl
testb %cl, %cl
movb -0x1(%rdx), %cl
movq %rdx, %r13
je 0x2cca
leaq 0x1(%r13), %rdx
cmpb $0x3a, %cl
jne 0x2cb5
jmp 0x2ccf
cmpb $0x3a, %cl
jne 0x2cde
movb $0x0, -0x1(%r13)
movq 0x12615(%rip), %rax     # 0x152f0
movq (%r15), %rsi
movq %rax, %rdi
callq 0x2240
movq %r13, %rdi
callq 0x2440
movq 0x122eb(%rip), %r13     # 0x14fe0
movl %eax, 0x125fd(%rip)     # 0x152f8
movl %eax, %ecx
leaq 0xb624(%rip), %rsi      # 0xe328
xorl %eax, %eax
movq 0x125e3(%rip), %rdx     # 0x152f0
movq (%r13), %rdi
callq 0x2380
jmp 0x2b6c
cmpl $-0x1, %eax
je 0x2d58
callq 0x292b
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r13), %rcx
leaq 0xb5cd(%rip), %rdi      # 0xe311
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x2540
callq 0x292b
xorl %ebx, %ebx
jmp 0x2d28
movq 0x125b1(%rip), %rax     # 0x15310
movq (%r13), %rdi
movq 0x12586(%rip), %rdx     # 0x152f0
movl 0x12588(%rip), %ecx     # 0x152f8
movq 0x12589(%rip), %r8      # 0x15300
movq 0x1258a(%rip), %r9      # 0x15308
leaq 0xb5b5(%rip), %rsi      # 0xe33a
xorl %ebx, %ebx
movq %rax, (%rsp)
xorl %eax, %eax
callq 0x2380
movl 0x125c8(%rip), %edi     # 0x15360
testl %edi, %edi
je 0x2da1
callq 0x2090
callq 0x657b
movq (%r13), %rdi
movl 0x12570(%rip), %edx     # 0x15320
movl 0x12566(%rip), %ecx     # 0x1531c
leaq 0xb5ab(%rip), %rsi      # 0xe368
xorl %eax, %eax
callq 0x2380
callq 0x3547
testl %eax, %eax
je 0x2d28
movq (%r13), %rcx
leaq 0xb5ad(%rip), %rdi      # 0xe389
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x2540
jmp 0x2d25