// File: /workspace/github_c_makefile_star2_O0/sharpyfox[P]citrusleaf-client/tests/key_c/src/key.c
// Function: make_key_value
static key_value *make_key_value(uint seed, uint key_len, uint value_len)
{
	int i;
	size_t	sz = sizeof(key_value) + key_len + value_len + 2 + value_len;
	key_value *kv = malloc(sz);
	if (!kv)	return(0);

	// save before molesting
	kv->key_int = kv->value_int = seed * g_config.value_factor;
	
	// a little hinky, pointing internally to local memory, but so much more efficient
	kv->key_str = ((char *)kv)+ sizeof(key_value);
	kv->value_str = ((char *)kv)+ sizeof(key_value) + key_len + 1;
	kv->value_blob = kv->value_str + value_len + 1;
	kv->value_blob_len = value_len;
	
	// generate the string key
	kv->key_str[key_len] = 0;
	for (i = key_len-1; i >= 0; i--) {
		kv->key_str[i] = (seed % 10) + '0';
		seed = seed / 10;
	}
	
	// build a string out of the value, might be different from key
	// (optimization: don't build if integer test, or if value_factor == 1
	char value_str_short[key_len];
	seed = kv->value_int;
	value_str_short[key_len] = 0;
	for (i = key_len-1; i >= 0; i--) {
		value_str_short[i] = (seed % 10) + '0';
		seed = seed / 10;
	}
	
	
	// longer value likely required: multiple copies of value_str_short
	i=0;
	while (i < value_len) {
		if (value_len - i > key_len) {
			memcpy(&kv->value_str[i], value_str_short, key_len);
			i += key_len;
		}
		else {
			memcpy(&kv->value_str[i], value_str_short, value_len - i);
			i += (value_len - i);
		}
	}	
	kv->value_str[value_len] = 0;

	// And how's about a fine blob!
	uint64_t t = kv->value_int;
	memcpy(kv->value_blob, &t, sizeof(t)); // this will make sure some nulls, always a good idea
	memcpy(kv->value_blob + sizeof(t), kv->value_str,kv->value_blob_len - sizeof(t));

	
#ifdef DEBUG_VERBOSE
	fprintf(stderr, "make key value: key_len %d key %s value_len %d value_str %s value_int %"PRIu64"\n",key_len,kv->key,value_len,kv->value_str,kv->value_int);
#endif
	
	return(kv);	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl -0x10(%rbp), %eax
addq $0x30, %rax
movl -0x14(%rbp), %ecx
addq %rcx, %rax
addq $0x2, %rax
movl -0x14(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2310
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x418d
movq $0x0, -0x8(%rbp)
jmp 0x439f
movl -0xc(%rbp), %eax
leaq 0x21199(%rip), %rcx     # 0x25330
imull 0x44(%rcx), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
addq $0x30, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
addq $0x30, %rcx
movl -0x10(%rbp), %eax
addq %rax, %rcx
addq $0x1, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x14(%rbp), %eax
addq %rax, %rcx
addq $0x1, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x10(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x4252
movl -0xc(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
addl $0x30, %edx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0xc(%rbp)
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4214
movl -0x10(%rbp), %eax
movl %eax, %ecx
movq %rsp, %rax
movq %rax, -0x30(%rbp)
movq %rcx, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x48(%rbp)
movq %rax, %rsp
movq %rcx, -0x38(%rbp)
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl %ecx, -0xc(%rbp)
movl -0x10(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x42cf
movl -0xc(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movq -0x48(%rbp), %rax
addl $0x30, %edx
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0xc(%rbp)
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4295
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x4341
movl -0x14(%rbp), %eax
subl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jbe 0x4311
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x18(%rbp), %rax
addq %rax, %rdi
movl -0x10(%rbp), %eax
movl %eax, %edx
callq 0x21b0
movl -0x10(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x433f
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x18(%rbp), %rax
addq %rax, %rdi
movl -0x14(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x21b0
movl -0x14(%rbp), %eax
subl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x42d6
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x8, %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x28(%rbp), %rax
movslq 0x18(%rax), %rdx
subq $0x8, %rdx
callq 0x21b0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rsp
movq -0x8(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax,%rax)