// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0xc764(%rip), %rsi      # 0x12048
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x5d75
movabsq $0x656e6f5f6e6962, %rax # imm = 0x656E6F5F6E6962
leaq 0x70(%rsp), %r15
movq %rax, -0x1b(%r15)
movabsq $0x6e69625f74736574, %r12 # imm = 0x6E69625F74736574
movq %r12, -0x20(%r15)
leaq 0xc748(%rip), %rsi      # 0x12061
movq %r15, %rdi
callq 0x5d75
movabsq $0x6f77745f6e6962, %rax # imm = 0x6F77745F6E6962
movq %rax, 0x25(%r15)
movq %r12, 0x20(%r15)
leaq 0xb0(%rsp), %rdi
movl $0xdeadbeef, %esi       # imm = 0xDEADBEEF
callq 0x5dbc
leaq 0x38(%rsp), %rax
movl $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
movq %r14, %rcx
movl $0x2, %r9d
pushq %rax
callq 0x7557
addq $0x10, %rsp
movq 0x1364e(%rip), %r15     # 0x18fe0
movq (%r15), %rcx
testl %eax, %eax
jne 0x5a83
leaq 0xc6fd(%rip), %rdi      # 0x120a1
movl $0x19, %esi
movl $0x1, %edx
callq 0x54e0
leaq 0x8(%rsp), %r8
movq $0x0, (%r8)
movq 0x28(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movl 0x24(%rbx), %eax
leaq 0x10(%rsp), %r10
leaq 0x18(%rsp), %rcx
leaq 0x4(%rsp), %r9
pushq %r10
pushq %rax
callq 0x7c48
addq $0x10, %rsp
movq (%r15), %rdi
testl %eax, %eax
jne 0x5aac
movl 0x4(%rsp), %edx
leaq 0xc6f7(%rip), %rsi      # 0x120f6
xorl %eax, %eax
callq 0x5350
movl 0x4(%rsp), %esi
testl %esi, %esi
jle 0x5a28
leaq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rsi
leaq 0x14(%rsp), %r14
movq %r14, %rdx
callq 0x55e5
movl (%r14), %esi
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5a41
callq 0x5e41
movq 0x8(%rsp), %rdi
callq 0x5290
movq (%r15), %rcx
leaq 0xc712(%rip), %rdi      # 0x1215d
movl $0x1c, %esi
movl $0x1, %edx
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 0x7a19
movq (%r15), %rdi
testl %eax, %eax
jne 0x5ad2
callq 0x5686
jmp 0x5a9b
leaq 0xc5f6(%rip), %rsi      # 0x12080
movq %rcx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x5350
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xc608(%rip), %rsi      # 0x120bb
movl %eax, %edx
xorl %eax, %eax
callq 0x5350
movq 0x8(%rsp), %rdi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x5a9b
callq 0x5290
jmp 0x5a9b
leaq 0xc6a1(%rip), %rsi      # 0x1217a
jmp 0x5a8d