// File: /workspace/github_c_makefile_star2_O3/sharpyfox[P]citrusleaf-client/example/main.c
// Function: main
int
main(int argc, char **argv)
{
	config g_config;
	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 = "example_set";
	g_config.verbose = false;
	g_config.follow = true;
	
	bool use_shm = false;
	int	c;
	
	printf("example of the C citrusleaf library\n");
	
	while ((c = getopt(argc, argv, "h:p:n:s:b:m:vr")) != -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.set = strdup(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 'r':
			use_shm = true;
			break;

		default:
			usage();
			return(-1);
			
		}
	}

	fprintf(stderr, "example: host %s port %d ns %s set %s\n",
		g_config.host,g_config.port,g_config.ns,g_config.set);

	if (use_shm) {
		citrusleaf_use_shm(10,788722985);
	}

	// init the unit before creating any clusters
	int rv = citrusleaf_init();
	if(rv!=0) {
		fprintf(stderr,"Citrusleaf init failed\n");
	}
	
	// Create a citrusleaf cluster object for subsequent requests
	g_config.asc = citrusleaf_cluster_create();
	if (!g_config.asc) {
		fprintf(stderr, "could not create cluster, internal error\n");
		return(-1);
	}
	if (g_config.follow == false)
		citrusleaf_cluster_follow(g_config.asc, false);
	
	citrusleaf_cluster_add_host(g_config.asc, g_config.host, g_config.port, 200 /*timeout*/);

	// Make some example requests against the cluster
	if (0 != do_example(&g_config)) {
		fprintf(stderr, "example failed!\n");
		return(-1);
	}
	fprintf(stderr, "example succeeded!\n");
	citrusleaf_shutdown();
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r12
movl %edi, %r13d
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0xc86c(%rip), %rdi      # 0x12378
callq 0x53f0
movb $0x1, %al
movl %eax, 0x8(%rsp)
leaq 0xc7b1(%rip), %rax      # 0x122cf
movq %rax, 0x18(%rsp)
leaq 0xc7a0(%rip), %rax      # 0x122ca
movq %rax, 0x10(%rsp)
movl $0xbb8, 0xc(%rsp)       # imm = 0xBB8
leaq 0xc782(%rip), %rax      # 0x122c0
movq %rax, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
leaq 0xc789(%rip), %rbp      # 0x122db
leaq 0xc4ab(%rip), %r15      # 0x12004
movq 0x13470(%rip), %rbx     # 0x18fd0
movl $0x0, (%rsp)
xorl %eax, %eax
movl %eax, %r14d
movl %r13d, %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x5080
leal -0x66(%rax), %ecx
cmpl $0x10, %ecx
ja 0x5c06
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
movb $0x1, %al
jmpq *%rcx
movl $0x0, 0x8(%rsp)
movl %r14d, %eax
jmp 0x5b69
movq (%rbx), %rdi
callq 0x5400
movl %eax, 0x4(%rsp)
movl %r14d, %eax
jmp 0x5b69
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x10(%rsp)
movl %r14d, %eax
jmp 0x5b69
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x18(%rsp)
movl %r14d, %eax
jmp 0x5b69
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x20(%rsp)
movl %r14d, %eax
jmp 0x5b69
movq (%rbx), %rdi
callq 0x5400
movl %eax, 0xc(%rsp)
movl %r14d, %eax
jmp 0x5b69
movb $0x1, %al
movl %eax, (%rsp)
movl %r14d, %eax
jmp 0x5b69
cmpl $-0x1, %eax
jne 0x5ca4
movl 0x4(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x8(%rsp), %r13d
movb %r13b, 0x49(%rsp)
movl (%rsp), %eax
movb %al, 0x48(%rsp)
movq 0x18(%rsp), %r9
movq %r9, 0x40(%rsp)
movq 0x10(%rsp), %r8
movq %r8, 0x38(%rsp)
movl 0xc(%rsp), %ebp
movl %ebp, 0x30(%rsp)
movq 0x20(%rsp), %r12
movq %r12, 0x28(%rsp)
movq 0x1338b(%rip), %r15     # 0x18fe0
movq (%r15), %rdi
leaq 0xc68b(%rip), %rsi      # 0x122ea
movq %r12, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x5350
testb $0x1, %r14b
je 0x5c80
movl $0xa, %edi
movl $0x2f02f529, %esi       # imm = 0x2F02F529
callq 0xc5a0
callq 0x806e
testl %eax, %eax
je 0x5c8e
callq 0x56a1
callq 0x819a
movq %rax, 0x50(%rsp)
testq %rax, %rax
jne 0x5cbd
callq 0x56ee
jmp 0x5ca9
callq 0x5510
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testb %r13b, %r13b
jne 0x5ccf
movq %rbx, %rdi
xorl %esi, %esi
callq 0x913a
movswl %bp, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0xc8, %ecx
callq 0x8458
leaq 0x28(%rsp), %rdi
callq 0x58cc
movq (%r15), %rdi
testl %eax, %eax
jne 0x5cfc
callq 0x56d2
xorl %eax, %eax
jmp 0x5cae
callq 0x56bd
jmp 0x5ca9
nop