// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, 0x50(%rsp)
leaq 0xba0d(%rip), %rdi      # 0x11378
callq 0x53f0
movb $0x1, %al
movl %eax, 0x8(%rsp)
leaq 0xb952(%rip), %rax      # 0x112cf
movq %rax, 0x18(%rsp)
leaq 0xb941(%rip), %rax      # 0x112ca
movq %rax, 0x10(%rsp)
movl $0xbb8, 0xc(%rsp)       # imm = 0xBB8
leaq 0xb923(%rip), %rax      # 0x112c0
movq %rax, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
leaq 0xb92a(%rip), %rbp      # 0x112db
leaq 0xb64c(%rip), %r15      # 0x11004
movq 0x12611(%rip), %rbx     # 0x17fd0
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 0x5a65
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
movb $0x1, %al
jmpq *%rcx
movl $0x0, 0x8(%rsp)
movl %r14d, %eax
jmp 0x59c8
movb $0x1, %al
movl %eax, (%rsp)
movl %r14d, %eax
jmp 0x59c8
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x18(%rsp)
movl %r14d, %eax
jmp 0x59c8
movq (%rbx), %rdi
callq 0x5400
movl %eax, 0xc(%rsp)
movl %r14d, %eax
jmp 0x59c8
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x20(%rsp)
movl %r14d, %eax
jmp 0x59c8
movq (%rbx), %rdi
callq 0x5400
movl %eax, 0x4(%rsp)
movl %r14d, %eax
jmp 0x59c8
movq (%rbx), %rdi
callq 0x5490
movq %rax, 0x10(%rsp)
movl %r14d, %eax
jmp 0x59c8
cmpl $-0x1, %eax
je 0x5a81
callq 0x5868
pushq $-0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x12519(%rip), %r15     # 0x17fe0
movq (%r15), %rdi
leaq 0xb819(%rip), %rsi      # 0x112ea
movq %r12, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x5350
testb $0x1, %r14b
je 0x5af0
pushq $0xa
popq %rdi
movl $0x2f02f529, %esi       # imm = 0x2F02F529
callq 0xbdc0
callq 0x7e6f
testl %eax, %eax
je 0x5b0e
movq (%r15), %rcx
leaq 0xb80e(%rip), %rdi      # 0x11311
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
callq 0x7fd1
movq %rax, 0x50(%rsp)
testq %rax, %rax
jne 0x5b2b
movq (%r15), %rcx
leaq 0xb802(%rip), %rdi      # 0x11329
pushq $0x29
jmp 0x5b88
movq %rax, %rbx
testb %r13b, %r13b
jne 0x5b3d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8d76
movswl %bp, %edx
movq %rbx, %rdi
movq %r12, %rsi
movl $0xc8, %ecx
callq 0x825b
leaq 0x28(%rsp), %rdi
callq 0x55fc
movq (%r15), %rcx
testl %eax, %eax
jne 0x5b7f
leaq 0xb7fc(%rip), %rdi      # 0x11364
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
callq 0x7ec0
xorl %eax, %eax
jmp 0x5a72
leaq 0xb7cd(%rip), %rdi      # 0x11353
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
jmp 0x5a6f
nop