// File: /workspace/github_c_makefile_star2_O3/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 %rsi, %r12
movl %edi, %r14d
movq %rdx, -0x30(%rbp)
xorl %eax, %eax
callq 0x2f19
cmpq $-0x3, %rax
ja 0x3289
leaq 0x13053(%rip), %rbx     # 0x162f0
movq %rax, %rcx
movl %r14d, %edx
movq %rsp, %r14
movq 0x40(%rbx), %rax
movq %rcx, (%rax,%rdx,8)
movl 0x38(%rbx), %eax
leal 0x1(%rax), %edx
addq $0xf, %rdx
andq $-0x10, %rdx
subq %rdx, %r14
movq %r14, %rsp
movb $0x0, (%rax,%r14)
decl %eax
js 0x32f9
movl %eax, %esi
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, (%r14,%rsi)
addq $-0x1, %rsi
movq %rdx, %rcx
jb 0x32d7
movq 0x20(%rbx), %rsi
leaq -0x70(%rbp), %r13
movq %r13, %rdi
callq 0x2240
leaq -0x50(%rbp), %r15
movq %r14, %rsi
movq %r15, %rdi
callq 0x4629
movabsq $0x200000000, %rax      # imm = 0x200000000
leaq -0x88(%rbp), %r10
movq 0x78(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rax, 0x10(%r10)
movl 0x74(%rbx), %eax
movl $0x0, (%r10)
movb $0x0, 0x4(%r10)
movl %eax, 0xc(%r10)
subq $0x8, %rsp
movq %r12, %rcx
movq %r13, %r8
movl $0x1, %r9d
pushq %r10
callq 0x5d7c
addq $0x10, %rsp
testl %eax, %eax
jne 0x33fc
movq %r15, %rdi
callq 0x4618
movl 0x74(%rbx), %eax
movq 0x78(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
leaq -0x70(%rbp), %r8
movq %r12, %rcx
movl $0x1, %r9d
pushq $0x0
pushq %rax
callq 0x6666
addq $0x10, %rsp
testl %eax, %eax
jne 0x342e
movl -0x50(%rbp), %edx
cmpl $0x3, %edx
jne 0x3460
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x2350
testl %eax, %eax
jne 0x3493
movq %r15, %rdi
callq 0x46d9
movq 0x50(%rbx), %rdi
movl $0x1, %esi
callq 0x2e2f
movq 0x58(%rbx), %rdi
movl $0x1, %esi
callq 0x2e2f
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x12bdd(%rip), %rcx     # 0x15fe0
movq -0x30(%rbp), %rsi
movl %eax, %edx
xorl %eax, %eax
movq (%rcx), %rdi
movq (%rsi), %rcx
leaq 0xbfa8(%rip), %rsi      # 0xf3c0
callq 0x2380
cmpb $0x0, 0x2a(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x336f
jmp 0x33ed
movq 0x12bab(%rip), %rcx     # 0x15fe0
movq -0x30(%rbp), %rsi
movl %eax, %edx
xorl %eax, %eax
movq (%rcx), %rdi
movq (%rsi), %rcx
leaq 0xbfa8(%rip), %rsi      # 0xf3f2
callq 0x2380
cmpb $0x0, 0x2a(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x33a7
jmp 0x33ed
movq 0x12b79(%rip), %rax     # 0x15fe0
leaq 0xbfb0(%rip), %rsi      # 0xf41e
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movq (%rax), %rcx
xorl %eax, %eax
callq 0x2380
cmpb $0x0, 0x2a(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
je 0x33b3
jmp 0x33ed
movq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rdx
movq %r14, %rsi
callq 0x2b59
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, %cl
je 0x33c7
jmp 0x33ed