// File: /workspace/github_c_makefile_star2_O1/ranbenbasat[P]RHHH/ulossycount.c
// Function: LCU_Init
LCU_type * LCU_Init(float fPhi)
{
	int i;
	int k = 1 + (int) 1.0/fPhi;

	LCU_type* result = (LCU_type*) calloc(1,sizeof(LCU_type));

	result->a= (long long) 698124007;
	result->b= (long long) 5125833;
	if (k<1) k=1;
	result->k=k;
	result->n=0;  

	result->tblsz=LCU_HASHMULT*k;  
	result->hashtable=(LCUITEM**) calloc(result->tblsz,sizeof(LCUITEM *));
	result->groups=(LCUGROUP *)calloc(k,sizeof(LCUGROUP));
	result->items=(LCUITEM *) calloc(k,sizeof(LCUITEM));
	result->freegroups=(LCUGROUP **) calloc(k,sizeof(LCUGROUP*));

	for (i=0; i<result->tblsz;i++) 
		result->hashtable[i]=NULL;

	result->root=result->groups;
	result->groups->count=0;
	result->groups->nextg=NULL;
	result->groups->previousg=NULL;

	result->groups->items=result->items;
	for (i=0; i<k;i++)
		result->freegroups[i]=&result->groups[i];
	result->gpt=1; // initialize list of free groups

	for (i=0;i<k;i++) 
	{
		result->items[i].item=LCL_NULLITEM;
		result->items[i].delta=0;
		result->items[i].hash=-1;
		result->items[i].nexti=NULL;
		result->items[i].previousi=NULL;  // initialize values

		result->items[i].parentg=result->groups;
		result->items[i].nexting=&(result->items[i+1]);
		result->items[i].previousing=&(result->items[i-1]); 
		// create doubly linked list
	}
	result->items[0].previousing=&(result->items[k-1]);
	result->items[k-1].nexting=&(result->items[0]);
	// fix start and end of linked list

	return(result);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movss 0x2499(%rip), %xmm1     # 0x4174
movaps %xmm1, %xmm2
divss %xmm0, %xmm2
addss %xmm1, %xmm2
cvttss2si %xmm2, %ebp
movl $0x1, %edi
movl $0x48, %esi
callq 0x1120
movq %rax, %rbx
movq $0x299c86e7, 0x10(%rax) # imm = 0x299C86E7
movq $0x4e36c9, 0x18(%rax)   # imm = 0x4E36C9
cmpl $0x2, %ebp
movl $0x1, %r14d
cmovgel %ebp, %r14d
movl %r14d, 0x8(%rax)
xorl %r12d, %r12d
movl %r12d, (%rax)
leal (%r14,%r14,2), %edi
movl %edi, 0xc(%rax)
movl $0x8, %esi
callq 0x1120
movq %rax, (%rsp)
movq %rax, 0x40(%rbx)
movl $0x20, %esi
movq %r14, %rdi
callq 0x1120
movq %rax, %r15
movq %rax, 0x30(%rbx)
movl $0x38, %esi
movq %r14, %rdi
callq 0x1120
movq %rax, %rbp
movq %rax, 0x28(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x1120
movq %rax, %r13
movq %rax, 0x38(%rbx)
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rdx
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x10d0
movq %r15, 0x20(%rbx)
movl %r12d, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movq %rbp, 0x8(%r15)
leal 0x1(%r14), %eax
leaq -0x1(%r14), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
andl $-0x2, %eax
shlq $0x3, %rax
movdqa 0x23bd(%rip), %xmm1     # 0x4180
movdqa 0x23c5(%rip), %xmm2     # 0x4190
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x23c5(%rip), %xmm4     # 0x41a0
movq %r15, %rcx
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edx
notl %edx
testb $0x1, %dl
je 0x1e14
movq %rcx, (%r13,%r12)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x1e2b
leaq 0x20(%rcx), %rdx
movq %rdx, 0x8(%r13,%r12)
paddq %xmm4, %xmm1
addq $0x10, %r12
addq $0x40, %rcx
cmpq %r12, %rax
jne 0x1dde
movl $0x1, 0x4(%rbx)
movl %r14d, %eax
leaq 0x38(%rbp), %rcx
movabsq $-0x80000001, %rdx      # imm = 0xFFFFFFFF7FFFFFFF
pxor %xmm0, %xmm0
movq %rdx, -0x38(%rcx)
movl $0x0, -0x30(%rcx)
movdqu %xmm0, -0x20(%rcx)
movq %r15, -0x28(%rcx)
movq %rcx, -0x10(%rcx)
leaq -0x70(%rcx), %rsi
movq %rsi, -0x8(%rcx)
addq $0x38, %rcx
decq %rax
jne 0x1e58
decl %r14d
imulq $0x38, %r14, %rax
movq %rbp, %rcx
addq %rax, %rcx
movq %rcx, 0x30(%rbp)
movq %rbp, 0x28(%rbp,%rax)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq