// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/example/main.c
// Function: do_example
int
do_example(config *c)
{
	int rv;
	
	// Put some test values
	cl_object o_key;
	citrusleaf_object_init_str(&o_key, "example_key");
	cl_bin values[2];
	strcpy(values[0].bin_name, "test_bin_one");
	citrusleaf_object_init_str(&values[0].object, "example_value_one");
	strcpy(values[1].bin_name, "test_bin_two");
	citrusleaf_object_init_int(&values[1].object, 0xDEADBEEF);
	
	// set a non-default write parameter
	cl_write_parameters cl_wp;
	cl_write_parameters_set_default(&cl_wp);
	cl_wp.timeout_ms = 1000;
	
	if (0 != (rv = citrusleaf_put(c->asc, c->ns, c->set, &o_key, values, 2, &cl_wp))) {
		fprintf(stderr, "citrusleaf put failed: error %d\n",rv);
		return(-1);
	}
	fprintf(stderr, "citrusleaf put succeeded\n");
	
	// Get all the values in this key (enjoy the fine c99 standard)
	cl_bin *cl_v = 0;
	uint32_t generation;
	int 	cl_v_len;
	if (0 != (rv = citrusleaf_get_all(c->asc, c->ns, c->set, &o_key, &cl_v, &cl_v_len, c->timeout_ms, &generation))) {
		fprintf(stderr, "get after put failed, but there should be a key here - %d\n",rv);
		if (cl_v)	free(cl_v);
		return(-1);
	}
	fprintf(stderr, "get all returned %d bins\n",cl_v_len);
	for (int i=0;i<cl_v_len;i++) {
		fprintf(stderr, "%d:  bin %s ",i,cl_v[i].bin_name);
		switch (cl_v[i].object.type) {
			case CL_STR:
				fprintf(stderr, "type string: value %s\n", cl_v[i].object.u.str);
				break;
			case CL_INT:
				fprintf(stderr, "type int: value %"PRId64"\n",cl_v[i].object.u.i64);
				break;
			default:
				fprintf(stderr, "type unknown! (%d)\n",(int)cl_v[i].object.type);
				break;
		}
		// could have done this -- but let's free the objects in the bins later
		// citrusleaf_object_free(&cl_v[i].object);
	}
	if (cl_v)	{
		citrusleaf_bins_free(cl_v, cl_v_len);
		free(cl_v); // only one free for all bins
	}
	fprintf(stderr,"citrusleaf getall succeeded\n");
	
	// Delete the key you just set
	if (0 != (rv = citrusleaf_delete(c->asc, c->ns, c->set, &o_key, 0/*default write params*/))) {
		fprintf(stderr, "citrusleaf delete failed: error %d\n",rv);
		return(-1);
	}
	fprintf(stderr, "citrusleaf delete succeeded\n");
	
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0xba31(%rip), %rsi      # 0x11048
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x5ba6
movabsq $0x656e6f5f6e6962, %rax # imm = 0x656E6F5F6E6962
leaq 0x70(%rsp), %r15
movq %rax, -0x1b(%r15)
movabsq $0x6e69625f74736574, %r12 # imm = 0x6E69625F74736574
movq %r12, -0x20(%r15)
leaq 0xba15(%rip), %rsi      # 0x11061
movq %r15, %rdi
callq 0x5ba6
movabsq $0x6f77745f6e6962, %rax # imm = 0x6F77745F6E6962
movq %rax, 0x25(%r15)
movq %r12, 0x20(%r15)
leaq 0xb0(%rsp), %rdi
movl $0xdeadbeef, %esi       # imm = 0xDEADBEEF
callq 0x5be7
leaq 0x38(%rsp), %rax
andl $0x0, (%rax)
movb $0x0, 0x4(%rax)
movl $0x2, 0x14(%rax)
movq $0x3e8, 0xc(%rax)       # imm = 0x3E8
movq 0x28(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
subq $0x8, %rsp
leaq 0x58(%rsp), %r8
pushq $0x2
popq %r9
movq %r14, %rcx
pushq %rax
callq 0x7147
addq $0x10, %rsp
movq 0x12920(%rip), %r15     # 0x17fe0
movq (%r15), %rcx
testl %eax, %eax
jne 0x57b2
leaq 0xb9cf(%rip), %rdi      # 0x110a1
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
leaq 0x8(%rsp), %r8
andq $0x0, (%r8)
movq 0x28(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movl 0x24(%rbx), %eax
leaq 0x14(%rsp), %r10
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r9
pushq %r10
pushq %rax
callq 0x78f3
addq $0x10, %rsp
movq (%r15), %rdi
testl %eax, %eax
jne 0x57c7
movl 0x10(%rsp), %edx
leaq 0xb9d0(%rip), %rsi      # 0x110f6
xorl %eax, %eax
callq 0x5350
leaq 0xb9dc(%rip), %r14      # 0x11110
leaq 0xba0e(%rip), %r13      # 0x11149
xorl %r12d, %r12d
xorl %ebp, %ebp
movslq 0x10(%rsp), %rsi
cmpq %rsi, %rbp
jge 0x57f8
movq (%r15), %rdi
movq 0x8(%rsp), %rcx
addq %r12, %rcx
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x5350
movq 0x8(%rsp), %rax
movl 0x20(%rax,%r12), %edx
movq (%r15), %rdi
cmpl $0x1, %edx
je 0x578a
cmpl $0x3, %edx
jne 0x579f
movq 0x30(%rax,%r12), %rdx
leaq 0xb995(%rip), %rsi      # 0x1111d
jmp 0x5796
movq 0x30(%rax,%r12), %rdx
leaq 0xb99e(%rip), %rsi      # 0x11134
xorl %eax, %eax
callq 0x5350
jmp 0x57a9
movq %r13, %rsi
xorl %eax, %eax
callq 0x5350
incq %rbp
addq $0x40, %r12
jmp 0x5740
leaq 0xb8c7(%rip), %rsi      # 0x11080
movq %rcx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x5350
jmp 0x57e1
leaq 0xb8ed(%rip), %rsi      # 0x110bb
movl %eax, %edx
xorl %eax, %eax
callq 0x5350
movq 0x8(%rsp), %rdi
callq 0x5290
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5811
callq 0x5c5a
movq 0x8(%rsp), %rdi
callq 0x5290
movq (%r15), %rcx
leaq 0xb942(%rip), %rdi      # 0x1115d
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
movq 0x28(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
xorl %ebx, %ebx
leaq 0x18(%rsp), %rcx
xorl %r8d, %r8d
callq 0x764c
movq (%r15), %rcx
testl %eax, %eax
jne 0x585c
leaq 0xb94f(%rip), %rdi      # 0x1119e
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x54e0
jmp 0x57e4
leaq 0xb917(%rip), %rsi      # 0x1117a
jmp 0x57b9