// File: /workspace/github_c_makefile_star2_O0/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
subq $0xa0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, %al
callq 0x2910
movq %rax, -0x20(%rbp)
movb $0x1, %al
cmpq $-0x1, -0x20(%rbp)
movb %al, -0x91(%rbp)
je 0x311e
cmpq $-0x2, -0x20(%rbp)
sete %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x30f6
movq -0x20(%rbp), %rsi
leaq 0x1b1cd(%rip), %rax     # 0x1e300
movq 0x40(%rax), %rcx
movl -0x8(%rbp), %edx
movq %rsi, (%rcx,%rdx,8)
movl 0x38(%rax), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0xa0(%rbp)
movq %rdi, %rsp
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x1b18c(%rip), %rax     # 0x1e300
movl 0x38(%rax), %edx
callq 0x3060
leaq -0x70(%rbp), %rdi
leaq 0x1b179(%rip), %rax     # 0x1e300
movq 0x20(%rax), %rsi
callq 0x2270
movq -0xa0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
callq 0x54a0
leaq -0x88(%rbp), %rdi
callq 0x3450
leaq 0x1b149(%rip), %rax     # 0x1e300
movl 0x74(%rax), %eax
movl %eax, -0x7c(%rbp)
leaq 0x1b13c(%rip), %rax     # 0x1e300
movq 0x78(%rax), %rdi
leaq 0x1b131(%rip), %rax     # 0x1e300
movq 0x10(%rax), %rsi
leaq 0x1b126(%rip), %rax     # 0x1e300
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rcx
leaq -0x70(%rbp), %r8
movl $0x1, %r9d
leaq -0x88(%rbp), %rax
subq $0x10, %rsp
movq %rax, (%rsp)
callq 0x80f0
addq $0x10, %rsp
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
je 0x325d
movq 0x1adc6(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movl -0x8c(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
leaq 0x151dc(%rip), %rsi     # 0x1840d
movb $0x0, %al
callq 0x23b0
leaq 0x1b0c1(%rip), %rax     # 0x1e300
testb $0x1, 0x2a(%rax)
je 0x325b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x90(%rbp)
jmp 0x343e
jmp 0x325d
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
callq 0x5470
leaq 0x1b08f(%rip), %rax     # 0x1e300
movq 0x78(%rax), %rdi
leaq 0x1b084(%rip), %rax     # 0x1e300
movq 0x10(%rax), %rsi
leaq 0x1b079(%rip), %rax     # 0x1e300
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rcx
leaq -0x70(%rbp), %r8
leaq 0x1b066(%rip), %rax     # 0x1e300
movl 0x74(%rax), %eax
movl $0x1, %r9d
xorl %r10d, %r10d
subq $0x10, %rsp
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x9340
addq $0x10, %rsp
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
je 0x3318
movq 0x1ad0b(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movl -0x8c(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
leaq 0x15153(%rip), %rsi     # 0x1843f
movb $0x0, %al
callq 0x23b0
leaq 0x1b006(%rip), %rax     # 0x1e300
testb $0x1, 0x2a(%rax)
je 0x3316
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x90(%rbp)
jmp 0x343e
jmp 0x3318
cmpl $0x3, -0x50(%rbp)
je 0x3365
movq 0x1acbb(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movl -0x50(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
leaq 0x15132(%rip), %rsi     # 0x1846b
movb $0x0, %al
callq 0x23b0
leaq 0x1afb9(%rip), %rax     # 0x1e300
testb $0x1, 0x2a(%rax)
je 0x3363
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x90(%rbp)
jmp 0x343e
jmp 0x3365
movq -0xa0(%rbp), %rsi
movq -0x40(%rbp), %rdi
callq 0x2380
cmpl $0x0, %eax
je 0x33f6
movq 0x1ac5f(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
leaq 0x1511f(%rip), %rsi     # 0x184b1
movb $0x0, %al
callq 0x23b0
movq -0xa0(%rbp), %rdx
movq 0x1ac39(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
leaq 0x15131(%rip), %rsi     # 0x184e2
movb $0x0, %al
callq 0x23b0
movq 0x1ac21(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x15126(%rip), %rsi     # 0x184f3
movb $0x0, %al
callq 0x23b0
leaq 0x1af25(%rip), %rax     # 0x1e300
testb $0x1, 0x2a(%rax)
je 0x33f4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x90(%rbp)
jmp 0x343e
jmp 0x33f6
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
callq 0x56a0
leaq 0x1aef6(%rip), %rax     # 0x1e300
movq 0x50(%rax), %rdi
movl $0x1, %esi
callq 0x26f0
leaq 0x1aee1(%rip), %rax     # 0x1e300
movq 0x58(%rax), %rdi
movl $0x1, %esi
callq 0x26f0
movl $0x0, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)