// File: /workspace/github_c_makefile_star2_O0/sharpyfox[P]citrusleaf-client/tests/loop_c/src/shash.c
// Function: shash_create
int
shash_create(shash **h_r, shash_hash_fn h_fn, uint32_t key_len, uint32_t value_len, uint32_t sz, uint flags)
{
	shash *h;

	h = malloc(sizeof(shash));
	if (!h)	return(SHASH_ERR);

	h->elements = 0;
	h->table_len = sz;
	h->key_len = key_len;
	h->value_len = value_len;
	h->flags = flags;
	h->h_fn = h_fn;

	if ((flags & SHASH_CR_MT_BIGLOCK) && (flags & SHASH_CR_MT_MANYLOCK)) {
		*h_r = 0;
		return(SHASH_ERR);
	}
	
	h->table = malloc(sz * SHASH_ELEM_SZ(h));
	if (!h->table) {
		free(h);
		*h_r = 0;
		return(SHASH_ERR);
	}
	
	shash_elem *table = h->table;
	for (uint i=0;i<sz;i++) {
		table->in_use = false;
		table->next = 0;
		// next element in head table
		table = (shash_elem *) (((uint8_t *)table) + SHASH_ELEM_SZ(h));
	}
	
	if (flags & SHASH_CR_MT_BIGLOCK) {
		if (0 != pthread_mutex_init ( &h->biglock, 0) ) {
			free(h->table); free(h);
			return(SHASH_ERR);
		}
	}
	else
		memset( &h->biglock, 0, sizeof( h->biglock ) );
	
	if (flags & SHASH_CR_MT_MANYLOCK) {
		h->lock_table = malloc( sizeof(pthread_mutex_t) * sz);
		if (! h->lock_table) {
			free(h);
			*h_r = 0;
			return(SHASH_ERR);
		}
		for (uint i=0;i<sz;i++) {
			pthread_mutex_init( &(h->lock_table[i]), 0 );
		}
	}
	else
		h->lock_table = 0;
	

	*h_r = h;

	return(SHASH_OK);
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movl %ecx, 0x28(%rsp)
movl %r8d, 0x24(%rsp)
movl %r9d, 0x20(%rsp)
movl $0x58, %edi
callq 0x2310
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x3f64
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x41bc
movq 0x18(%rsp), %rax
movl $0x0, (%rax)
movl 0x24(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x18(%rax)
movl 0x2c(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x4(%rax)
movl 0x28(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0x20(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x30(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movl 0x20(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3fde
movl 0x20(%rsp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x3fde
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x41bc
movl 0x24(%rsp), %eax
movl %eax, %edi
movq 0x18(%rsp), %rax
movl 0x4(%rax), %eax
addq $0x10, %rax
movq 0x18(%rsp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
imulq %rax, %rdi
callq 0x2310
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x403f
movq 0x18(%rsp), %rdi
callq 0x22e0
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x41bc
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x24(%rsp), %eax
jae 0x40a5
movq 0x10(%rsp), %rax
movb $0x0, 0x8(%rax)
movq 0x10(%rsp), %rax
movq $0x0, (%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movl 0x4(%rcx), %ecx
addq $0x10, %rcx
movq 0x18(%rsp), %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x4055
movl 0x20(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x40f2
movq 0x18(%rsp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2430
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x40f0
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x22e0
movq 0x18(%rsp), %rdi
callq 0x22e0
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x41bc
jmp 0x4107
movq 0x18(%rsp), %rdi
addq $0x28, %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x2170
movl 0x20(%rsp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x419a
movl 0x24(%rsp), %eax
imulq $0x28, %rax, %rdi
callq 0x2310
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x415c
movq 0x18(%rsp), %rdi
callq 0x22e0
movq 0x38(%rsp), %rax
movq $0x0, (%rax)
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x41bc
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
cmpl 0x24(%rsp), %eax
jae 0x4198
movq 0x18(%rsp), %rax
movq 0x50(%rax), %rdi
movl 0x8(%rsp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2430
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x4164
jmp 0x41a7
movq 0x18(%rsp), %rax
movq $0x0, 0x50(%rax)
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)
nop