// File: /workspace/github_c_makefile_star2_O1/sharpyfox[P]citrusleaf-client/tests/loop_c/src/loop.c
// Function: write_new_value
int
write_new_value(uint32_t key, cl_object *key_o, cf_digest *d)
{
	uint64_t new_value_int;
	do {
		new_value_int = rand_64();
	} while (new_value_int == VALUE_UNINIT || new_value_int == VALUE_DELETED);
	
	g_config.values[key] = new_value_int;
	char new_value_str[g_config.value_len+1];
	my_itoa(new_value_str, new_value_int, g_config.value_len); 
	
	cl_bin values[1];
	strcpy(values[0].bin_name, g_config.bin);
	citrusleaf_object_init_str(&values[0].object, new_value_str);

	cl_write_parameters cl_w_p;	
	cl_write_parameters_set_default(&cl_w_p);
	cl_w_p.timeout_ms = g_config.timeout_ms;
	
	int rv;
	rv = citrusleaf_put(g_config.asc, g_config.ns, g_config.set, key_o, values, 1, &cl_w_p);
	if (rv != 0) {
		fprintf(stderr, "aerospike put returned error %d, fail digest %"PRIx64"\n",rv, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}
	
	citrusleaf_object_init(&values[0].object);
	
	rv = citrusleaf_verify(g_config.asc, g_config.ns, g_config.set, key_o, values, 1, g_config.timeout_ms, NULL);
	if (rv != 0) {
		fprintf(stderr, "aerospike get returned error %d digest %"PRIx64"\n",rv, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}

	// test!
	if (values[0].object.type != CL_STR) {
		fprintf(stderr, "read value has wrong type: expect string (3) got %d, fail digest %"PRIx64"\n",(int)values[0].object.type, *(uint64_t *)d);
		if (g_config.strict)
			return(-1);
	}
	if (strcmp(values[0].object.u.str, new_value_str) != 0) {
		fprintf(stderr, "read value does not match set value. digest %"PRIx64"\n", *(uint64_t *)d);
		fprintf(stderr, "  expecting: %s\n",new_value_str);
		fprintf(stderr, "  got: %s\n",values[0].object.u.str);
		if (g_config.strict)
			return( -1);
	}
	
	citrusleaf_object_free(&values[0].object);
	
	atomic_int_add(g_config.read_counter, 1);
	atomic_int_add(g_config.write_counter, 1);

	
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, -0x30(%rbp)
movq %rsi, %r15
movl %edi, %r14d
xorl %eax, %eax
callq 0x2f09
cmpq $-0x3, %rax
ja 0x3298
movq %rax, %rcx
leaq 0x14041(%rip), %rbx     # 0x172f0
movq 0x40(%rbx), %rax
movl %r14d, %edx
movq %rcx, (%rax,%rdx,8)
movl 0x38(%rbx), %eax
leal 0x1(%rax), %edx
movq %rsp, %r14
addq $0xf, %rdx
andq $-0x10, %rdx
subq %rdx, %r14
movq %r14, %rsp
movb $0x0, (%rax,%r14)
decl %eax
js 0x330b
movl %eax, %esi
incq %rsi
movabsq $-0x3333333333333333, %rdi # imm = 0xCCCCCCCCCCCCCCCD
movq %rcx, %rax
mulq %rdi
shrq $0x3, %rdx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
subl %eax, %ecx
orb $0x30, %cl
movb %cl, -0x1(%r14,%rsi)
decq %rsi
movq %rdx, %rcx
jg 0x32e9
movq 0x20(%rbx), %rsi
leaq -0x70(%rbp), %r13
movq %r13, %rdi
callq 0x2240
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4689
movabsq $0x200000000, %rax      # imm = 0x200000000
leaq -0x88(%rbp), %r10
movq %rax, 0x10(%r10)
movl $0x0, (%r10)
movb $0x0, 0x4(%r10)
movl 0x74(%rbx), %eax
movl %eax, 0xc(%r10)
movq 0x78(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
subq $0x8, %rsp
movq %r15, %rcx
movq %r13, %r8
movl $0x1, %r9d
pushq %r10
callq 0x5e6b
addq $0x10, %rsp
testl %eax, %eax
jne 0x340e
movq %r12, %rdi
callq 0x4678
movq 0x78(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movl 0x74(%rbx), %eax
leaq -0x70(%rbp), %r8
movq %r15, %rcx
movl $0x1, %r9d
pushq $0x0
pushq %rax
callq 0x6722
addq $0x10, %rsp
testl %eax, %eax
jne 0x3440
movl -0x50(%rbp), %edx
cmpl $0x3, %edx
jne 0x3472
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2350
testl %eax, %eax
jne 0x34a5
movq %r12, %rdi
callq 0x4739
movq 0x50(%rbx), %rdi
movl $0x1, %esi
callq 0x2e1f
movq 0x58(%rbx), %rdi
movl $0x1, %esi
callq 0x2e1f
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13bcb(%rip), %rcx     # 0x16fe0
movq (%rcx), %rdi
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0xcf9a(%rip), %rsi      # 0x103c0
movl %eax, %edx
xorl %eax, %eax
callq 0x2380
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x0, 0x2a(%rbx)
je 0x3381
jmp 0x33ff
movq 0x13b99(%rip), %rcx     # 0x16fe0
movq (%rcx), %rdi
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
leaq 0xcf9a(%rip), %rsi      # 0x103f2
movl %eax, %edx
xorl %eax, %eax
callq 0x2380
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x0, 0x2a(%rbx)
je 0x33b9
jmp 0x33ff
movq 0x13b67(%rip), %rax     # 0x16fe0
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rcx
leaq 0xcf94(%rip), %rsi      # 0x1041e
xorl %eax, %eax
callq 0x2380
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x0, 0x2a(%rbx)
je 0x33c5
jmp 0x33ff
leaq -0x40(%rbp), %rdx
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x2b53
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, %cl
je 0x33d9
jmp 0x33ff