// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_get_hashed_code
static DELZW_CODE delzw_get_hashed_code(delzwctx *dc, DELZW_CODE code,
	u8 value)
{
	DELZW_CODE h;
	DELZW_CODE saved_h;
	u32 count;

	h = ((code+(DELZW_CODE)value) | 0x0800) & 0xffff;
	h = ((h*h) >> 6) % dc->ct_capacity;

	if(dc->ct[h].codetype==DELZW_CODETYPE_DYN_UNUSED) {
		return h;
	}

	// Collision - First, walk to the end of the duplicates list
	count = 0;
	while(dc->ct2[h].next != DELZW_NEXTPTR_NONE) {
		h = dc->ct2[h].next;

		count++;
		if(count > dc->ct_capacity) {
			delzw_set_error(dc, DELZW_ERRCODE_GENERIC_ERROR, NULL);
			return 0;
		}
	}

	saved_h = h;

	// Then search for an open slot
	count = 0;
	while(1) {
		if(count==0)
			h += 101;
		else
			h += 1;
		h %= dc->ct_capacity;

		if(dc->ct[h].codetype==DELZW_CODETYPE_DYN_UNUSED)
			break;

		count++;
		if(count > dc->ct_capacity) {
			delzw_set_error(dc, DELZW_ERRCODE_GENERIC_ERROR, NULL);
			return 0;
		}
	}

	dc->ct2[saved_h].next = h;
	return h;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb %al, -0x15(%rbp)
movl -0x14(%rbp), %eax
movzbl -0x15(%rbp), %ecx
addl %ecx, %eax
orl $0x800, %eax            # imm = 0x800
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
imull -0x1c(%rbp), %eax
shrl $0x6, %eax
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divl 0xc8(%rcx)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0xd0(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x6, %rcx, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x185d2c
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x185e4a
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x1c(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x185d99
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x1c(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc8(%rcx), %eax
jbe 0x185d97
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x185850
movl $0x0, -0x4(%rbp)
jmp 0x185e4a
jmp 0x185d33
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x185db7
movl -0x1c(%rbp), %eax
addl $0x65, %eax
movl %eax, -0x1c(%rbp)
jmp 0x185dc0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0xc8(%rax), %ecx
movl -0x1c(%rbp), %eax
xorl %edx, %edx
divl %ecx
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0xd0(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x6, %rcx, %rcx
addq %rcx, %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x185df4
jmp 0x185e2c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc8(%rcx), %eax
jbe 0x185e27
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x185850
movl $0x0, -0x4(%rbp)
jmp 0x185e4a
jmp 0x185da6
movl -0x1c(%rbp), %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x20(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)