// File: /workspace/github_c_makefile_star2_O0/sharpyfox[P]citrusleaf-client/tests/loop_c/src/loop.c
// Function: do_loop_test
int 
do_loop_test ( )
{
	fprintf(stderr, "starting test\n");
	
	// this hash is the rendez-vous for all the worker threads, to make sure they're not working
	// on the same keys at the same time. It starts out empty. When a worker wants to use a key, it
	// drops an element in the hash unique.
	shash_create(&g_config.in_progress_hash, progress_hash_fn, sizeof(uint32_t), 0, g_config.n_threads * 2, SHASH_CR_MT_BIGLOCK);

	// Create the aerospike cluster
	g_config.asc = citrusleaf_cluster_create();
	citrusleaf_cluster_add_host(g_config.asc, g_config.host, g_config.port, 0);

	if (g_config.follow == false) 
		citrusleaf_cluster_follow(g_config.asc, false);
	
	
	// This array is the current value of a given key. Starts out as uninitialized.
	g_config.values = malloc( sizeof(uint64_t) * g_config.n_keys);
	if (g_config.values == 0) {
		fprintf(stderr, " could not malloc %d, use fewer keys",(int)(sizeof(uint64_t)*g_config.n_keys));
		return(-1);
	}
	for (uint i=0;i<g_config.n_keys;i++)
		g_config.values[i] = VALUE_UNINIT;

	g_config.read_counter = atomic_int_create(0);
	g_config.write_counter = atomic_int_create(0);
	g_config.delete_counter = atomic_int_create(0);
	g_config.key_counter = atomic_int_create(0);
	
	void *counter_control = start_counter_thread( g_config.read_counter, g_config.write_counter, g_config.delete_counter, g_config.key_counter);
	
	// Create the threads and send them on their way
	pthread_t	*thr_array = malloc(sizeof(pthread_t) * g_config.n_threads);

	fprintf(stderr, "starting threads for test\n");
	for (uint i=0;i<g_config.n_threads;i++)
		pthread_create(&thr_array[i], 0, work_fn, 0); 
	
	for (uint i=0;i<g_config.n_threads;i++) {
		void *value_ptr;
		pthread_join(thr_array[i], &value_ptr);
		if ( ((int)(ssize_t)value_ptr) )
			fprintf(stderr, "thread %d returned value %d\n",i,(int) (ssize_t) value_ptr);
	}
	
	free(g_config.values);
	free(thr_array);
	citrusleaf_cluster_destroy(g_config.asc);
	
	stop_counter_thread(counter_control);
	
	return(-1);	
}

// Assembly:
subq $0x28, %rsp
movq 0x1a3c5(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
leaq 0x14a45(%rip), %rsi     # 0x1866a
movb $0x0, %al
callq 0x23b0
leaq 0x1a6cd(%rip), %rax     # 0x1e300
movl 0x2c(%rax), %r8d
shll %r8d
leaq 0x1a6bf(%rip), %rdi     # 0x1e300
addq $0x48, %rdi
leaq -0x5c(%rip), %rsi       # 0x3bf0
movl $0x4, %r9d
xorl %ecx, %ecx
movl %r9d, %edx
callq 0x3f20
callq 0x9de0
movq %rax, %rcx
leaq 0x1a695(%rip), %rax     # 0x1e300
movq %rcx, 0x78(%rax)
leaq 0x1a68a(%rip), %rax     # 0x1e300
movq 0x78(%rax), %rdi
leaq 0x1a67f(%rip), %rax     # 0x1e300
movq (%rax), %rsi
leaq 0x1a675(%rip), %rax     # 0x1e300
movl 0x8(%rax), %eax
xorl %ecx, %ecx
movswl %ax, %edx
callq 0xa260
leaq 0x1a661(%rip), %rax     # 0x1e300
movb 0x29(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3cbe
leaq 0x1a64d(%rip), %rax     # 0x1e300
movq 0x78(%rax), %rdi
xorl %esi, %esi
callq 0xb1e0
leaq 0x1a63b(%rip), %rax     # 0x1e300
movl 0x30(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2310
movq %rax, %rcx
leaq 0x1a623(%rip), %rax     # 0x1e300
movq %rcx, 0x40(%rax)
leaq 0x1a618(%rip), %rax     # 0x1e300
cmpq $0x0, 0x40(%rax)
jne 0x3d24
movq 0x1a2ea(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
leaq 0x1a600(%rip), %rax     # 0x1e300
movl 0x30(%rax), %eax
shlq $0x3, %rax
movl %eax, %edx
leaq 0x14969(%rip), %rsi     # 0x18679
movb $0x0, %al
callq 0x23b0
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x3f0f
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
leaq 0x1a5c9(%rip), %rcx     # 0x1e300
cmpl 0x30(%rcx), %eax
jae 0x3d60
leaq 0x1a5bd(%rip), %rax     # 0x1e300
movq 0x40(%rax), %rax
movl 0x20(%rsp), %ecx
movq $-0x1, (%rax,%rcx,8)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x3d2c
xorl %eax, %eax
movl %eax, %edi
callq 0x2680
movq %rax, %rcx
leaq 0x1a58d(%rip), %rax     # 0x1e300
movq %rcx, 0x50(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x2680
movq %rax, %rcx
leaq 0x1a576(%rip), %rax     # 0x1e300
movq %rcx, 0x58(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x2680
movq %rax, %rcx
leaq 0x1a55f(%rip), %rax     # 0x1e300
movq %rcx, 0x60(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x2680
movq %rax, %rcx
leaq 0x1a548(%rip), %rax     # 0x1e300
movq %rcx, 0x68(%rax)
leaq 0x1a53d(%rip), %rax     # 0x1e300
movq 0x50(%rax), %rdi
leaq 0x1a532(%rip), %rax     # 0x1e300
movq 0x58(%rax), %rsi
leaq 0x1a527(%rip), %rax     # 0x1e300
movq 0x60(%rax), %rdx
leaq 0x1a51c(%rip), %rax     # 0x1e300
movq 0x68(%rax), %rcx
callq 0x2840
movq %rax, 0x18(%rsp)
leaq 0x1a507(%rip), %rax     # 0x1e300
movl 0x2c(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2310
movq %rax, 0x10(%rsp)
movq 0x1a1cd(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
leaq 0x14881(%rip), %rsi     # 0x1869e
movb $0x0, %al
callq 0x23b0
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
leaq 0x1a4c9(%rip), %rcx     # 0x1e300
cmpl 0x2c(%rcx), %eax
jae 0x3e6c
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %eax
shlq $0x3, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x9a7(%rip), %rdx      # 0x34b0
movq %rcx, %rsi
callq 0x2500
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x3e2c
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
leaq 0x1a481(%rip), %rcx     # 0x1e300
cmpl 0x2c(%rcx), %eax
jae 0x3ed3
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
movq %rsp, %rsi
callq 0x2250
movq (%rsp), %rax
cmpl $0x0, %eax
je 0x3ec4
movq 0x1a137(%rip), %rax     # 0x1dfe0
movq (%rax), %rdi
movl 0x8(%rsp), %edx
movq (%rsp), %rax
movl %eax, %ecx
leaq 0x147fc(%rip), %rsi     # 0x186b9
movb $0x0, %al
callq 0x23b0
jmp 0x3ec6
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x3e74
leaq 0x1a426(%rip), %rax     # 0x1e300
movq 0x40(%rax), %rdi
callq 0x22e0
movq 0x10(%rsp), %rdi
callq 0x22e0
leaq 0x1a40c(%rip), %rax     # 0x1e300
movq 0x78(%rax), %rdi
callq 0xa6d0
movq 0x18(%rsp), %rdi
callq 0x28d0
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopl (%rax,%rax)