// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x142c9(%rip), %rdi     # 0x172f0
xorl %edx, %edx
movl $0x10, %ecx
xorl %eax, %eax
rep  stosq %rax, %es:(%rdi)
leaq 0xd2a0(%rip), %rax      # 0x102da
movq %rax, 0x142af(%rip)     # 0x172f0
movl $0xbb8, 0x142ad(%rip)   # imm = 0xBB8
leaq 0xd292(%rip), %rax      # 0x102e4
movq %rax, 0x142a7(%rip)     # 0x17300
leaq 0xd289(%rip), %rax      # 0x102e9
movq %rax, 0x142a1(%rip)     # 0x17308
leaq 0xd27f(%rip), %rax      # 0x102ed
movq %rax, 0x1429b(%rip)     # 0x17310
movb %dl, 0x1429d(%rip)      # 0x17318
movb $0x1, 0x14297(%rip)     # 0x17319
movb %dl, 0x14292(%rip)      # 0x1731a
movaps 0xcf81(%rip), %xmm0     # 0x10010
movups %xmm0, 0x14286(%rip)    # 0x1731c
movabsq $0xc800000000, %rax     # imm = 0xC800000000
movq %rax, 0x142b9(%rip)     # 0x17360
movq %rdx, 0x14282(%rip)     # 0x17330
movq %rdx, 0x14283(%rip)     # 0x17338
leaq 0xd2e3(%rip), %rdi      # 0x1039f
callq 0x2430
leaq 0xd22b(%rip), %r14      # 0x102f3
movq 0x13f01(%rip), %r15     # 0x16fd0
leaq 0xcf4a(%rip), %r12      # 0x10020
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2080
cmpl $0x52, %eax
jle 0x310a
leal -0x62(%rax), %ecx
cmpl $0x14, %ecx
ja 0x3123
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x14208(%rip)     # 0x17310
jmp 0x30d6
cmpl $0x4b, %eax
jne 0x31f9
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x14203(%rip)     # 0x17324
jmp 0x30d6
cmpl $0x53, %eax
je 0x3141
cmpl $0x56, %eax
jne 0x321e
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x141e9(%rip)     # 0x17328
jmp 0x30d6
movb $0x0, 0x141d1(%rip)     # 0x17319
jmp 0x30d6
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x141c4(%rip)     # 0x1731c
jmp 0x30d6
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x1418d(%rip)     # 0x172f8
testl %eax, %eax
jg 0x30d6
jmp 0x322a
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x14169(%rip)     # 0x172f0
jmp 0x30d6
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x141ca(%rip)     # 0x17364
jmp 0x30d6
movb $0x1, 0x14172(%rip)     # 0x17318
jmp 0x30d6
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x14167(%rip)     # 0x17320
jmp 0x30d6
movq (%r15), %rdi
callq 0x2440
movl %eax, 0x14194(%rip)     # 0x17360
jmp 0x30d6
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x14120(%rip)     # 0x17300
jmp 0x30d6
movq (%r15), %rdi
callq 0x24f0
movq %rax, 0x14114(%rip)     # 0x17308
jmp 0x30d6
cmpl $0x48, %eax
jne 0x3208
callq 0x281a
jmp 0x30d6
cmpl $-0x1, %eax
jne 0x321e
leaq 0xc(%rsp), %rbx
movq %rbx, %rdi
callq 0x28c8
movl (%rbx), %eax
jmp 0x3231
callq 0x2570
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x3231
callq 0x28a5
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop