// File: /workspace/github_c_makefile_star2_O0/sharpyfox[P]citrusleaf-client/tests/key_c/src/key.c
// Function: ops_fn
void *
ops_fn(void *udata)
{
	op_work *work = (op_work *) udata;
	write_work *workw = (write_work * )malloc(sizeof(write_work));
	read_work *workr = (read_work * )malloc(sizeof(read_work));

	int iteration = (int)((work->n_ops)/100);
	int residue = (work->n_ops)%100;
	uint read_start_key =  work->start_key;
	uint write_start_key = work->start_key;
	work->writeratio = my_min(100, work->writeratio);

	//writing snd reading n_ops times in a ratio writeratio : (100-writepesr100)
	for (uint i=0;i<iteration;i++) {
		for(int j=0; j<work->writeratio; j++) {
        		write_start_key = (rand_64()%work->n_keys) + work->start_key;
			//writing
			workw->completed = work->wcompleted;
			workw->gen_errs = work->gen_errs;
			workw->key_len = work->key_len;
			workw->value_len = work->value_len;
			workw->start_key = write_start_key;
			workw->value_len = work->value_len;
			workw->asc = work->asc;
			workw->id = 0;
			workw->n_writes = 1;
			write_fn(workw);
		}

		for(int j=0; j<100-work->writeratio; j++) {	
			//reading
			workr->completed = work->rcompleted;
			workr->key_len = work->key_len;
			workr->value_len = work->value_len;
			workr->start_key = read_start_key;
			workr->value_len = work->value_len;
			workr->asc = work->asc;
			workr->n_keys = work->n_keys;
			workr->id = 0;
			workr->n_reads = 1;
			read_fn(workr);
		}
	}
	//Residue
	int work_residue = (int)(residue*work->writeratio/100);

	for(int j=0; j<work_residue; j++) {
		write_start_key = (rand_64()%work->n_keys) + work->start_key;
		//working
		workw->completed = work->wcompleted;
		workw->gen_errs = work->gen_errs;
		workw->key_len = work->key_len;
		workw->value_len = work->value_len;
		workw->start_key = write_start_key;
		workw->value_len = work->value_len;
		workw->asc = work->asc;
		workw->id = 0;
		workw->n_writes = 1;
		write_fn(workw);
	}
	
	for(int j=0; j<(residue-work_residue); j++) {
		//reading
		workr->completed = work->rcompleted;
		workr->key_len = work->key_len;
		workr->value_len = work->value_len;
		workr->start_key = work->start_key;
		workr->value_len = work->value_len;
		workr->asc = work->asc;
		workr->n_keys = work->n_keys;
		workr->id = 0;
		workr->n_reads = 1;
		read_fn(workr);
	}
	free(workw);
	free(workr);
	return (0);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x30, %edi
callq 0x2310
movq %rax, 0x30(%rsp)
movl $0x28, %edi
callq 0x2310
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, 0x24(%rsp)
movq 0x38(%rsp), %rax
movl 0x4(%rax), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, 0x20(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movl 0x28(%rax), %esi
movl $0x64, %edi
callq 0x4510
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x28(%rax)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x24(%rsp), %eax
jae 0x5ed8
movl $0x0, 0x10(%rsp)
movl 0x10(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x5e04
movb $0x0, %al
callq 0x2960
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq 0x38(%rsp), %rax
movl (%rax), %eax
addq %rax, %rdx
movl %edx, %eax
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0x18(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movl $0x1, 0x4(%rax)
movq 0x30(%rsp), %rdi
callq 0x5180
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x5d2b
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x38(%rsp), %rdx
movl $0x64, %ecx
subl 0x28(%rdx), %ecx
cmpl %ecx, %eax
jge 0x5ec6
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movl 0x1c(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x38(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x28(%rsp), %rax
movl $0x0, 0x14(%rax)
movq 0x28(%rsp), %rax
movl $0x1, (%rax)
movq 0x28(%rsp), %rdi
callq 0x3560
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x5e0c
jmp 0x5ec8
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x5d15
movl 0x20(%rsp), %eax
movq 0x38(%rsp), %rcx
imull 0x28(%rcx), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
cmpl 0x8(%rsp), %eax
jge 0x5fce
movb $0x0, %al
callq 0x2960
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq 0x38(%rsp), %rax
movl (%rax), %eax
addq %rax, %rdx
movl %edx, %eax
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0x18(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x30(%rsp), %rax
movl $0x0, 0x10(%rax)
movq 0x30(%rsp), %rax
movl $0x1, 0x4(%rax)
movq 0x30(%rsp), %rdi
callq 0x5180
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x5ef9
movl $0x0, (%rsp)
movl (%rsp), %eax
movl 0x20(%rsp), %ecx
subl 0x8(%rsp), %ecx
cmpl %ecx, %eax
jge 0x608a
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x38(%rsp), %rax
movl (%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x38(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x28(%rsp), %rax
movl $0x0, 0x14(%rax)
movq 0x28(%rsp), %rax
movl $0x1, (%rax)
movq 0x28(%rsp), %rdi
callq 0x3560
movl (%rsp), %eax
addl $0x1, %eax
movl %eax, (%rsp)
jmp 0x5fd5
movq 0x30(%rsp), %rdi
callq 0x22c0
movq 0x28(%rsp), %rdi
callq 0x22c0
xorl %eax, %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
nop