// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: kdfread
unsigned kdfread(void *buffer, unsigned dasizeof, unsigned count, int fil)
{
	size_t i, j;
	int k, kgoal;
	unsigned short leng;
	unsigned char *ptr;

	lzwallocate();

	if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; }
	ptr = (unsigned char *)buffer;

	if (kread(fil,&leng,2) != 2) { lzwrelease(); return 0; }
	leng = B_LITTLE16(leng);
	if (kread(fil,lzwbuf5,(int)leng) != leng) { lzwrelease(); return 0; }
	k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4);

	copybufbyte(lzwbuf4,ptr,(int)dasizeof);
	k += (int)dasizeof;

	for(i=1;i<count;i++)
	{
		if (k >= kgoal)
		{
			if (kread(fil,&leng,2) != 2) { lzwrelease(); return -1; }
			leng = B_LITTLE16(leng);
			if (kread(fil,lzwbuf5,(int)leng) != leng) { lzwrelease(); return -1; }
			k = 0; kgoal = lzwuncompress(lzwbuf5,(int)leng,lzwbuf4);
		}
		for(j=0;j<dasizeof;j++) ptr[j+dasizeof] = ((ptr[j]+lzwbuf4[j+k])&255);
		k += dasizeof;
		ptr += dasizeof;
	}
	lzwrelease();
	return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r14
callq 0x213a6
cmpl $0x4001, %r12d          # imm = 0x4001
movl $0x1, %ebp
movl %r12d, %eax
cmovael %ebp, %eax
movl %eax, 0xc(%rsp)
cmovael %r12d, %ebp
leaq 0xa(%rsp), %rsi
movl %ebx, %edi
movl $0x2, %edx
callq 0x20684
xorl %r12d, %r12d
cmpl $0x2, %eax
jne 0x21383
movzwl 0xa(%rsp), %edx
movq 0x19776b(%rip), %rsi    # 0x1b89c0
movl %ebx, 0x14(%rsp)
movl %ebx, %edi
callq 0x20684
movzwl 0xa(%rsp), %ecx
cmpl %ecx, %eax
jne 0x21383
movl %ebp, %ebx
imull %r15d, %ebx
movq 0x197746(%rip), %rdi    # 0x1b89c0
movq 0x197747(%rip), %rdx    # 0x1b89c8
movl %eax, %esi
callq 0x21465
movl %eax, %r12d
movq 0x197736(%rip), %rdi    # 0x1b89c8
movq %r14, %rsi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
callq 0x4d437
cmpl $0x2, %ebx
jb 0x21380
movl %ebx, 0x10(%rsp)
movl %ebx, %edi
movl %ebp, %r8d
movq %r8, %r15
negq %r15
leaq (%r14,%r8), %r13
movl $0x1, %ebx
movl %ebp, %eax
movq %rdi, 0x20(%rsp)
movq %r8, 0x18(%rsp)
cmpl %r12d, %eax
jl 0x2133a
movl 0x14(%rsp), %ebp
movl %ebp, %edi
leaq 0xa(%rsp), %rsi
movl $0x2, %edx
callq 0x20684
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $0x2, %eax
jne 0x21383
movzwl 0xa(%rsp), %edx
movq 0x1976be(%rip), %rsi    # 0x1b89c0
movl %ebp, %edi
callq 0x20684
movzwl 0xa(%rsp), %ecx
cmpl %ecx, %eax
jne 0x21383
movq 0x1976a7(%rip), %rdi    # 0x1b89c0
movq 0x1976a8(%rip), %rdx    # 0x1b89c8
movl %eax, %esi
callq 0x21465
movl %eax, %r12d
xorl %eax, %eax
movl 0xc(%rsp), %ebp
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
testl %ebp, %ebp
je 0x21365
movslq %eax, %rcx
xorl %edx, %edx
movq 0x19767e(%rip), %rsi    # 0x1b89c8
addq %rcx, %rsi
movb (%rdx,%rsi), %sil
addb (%r14,%rdx), %sil
movb %sil, (%r13,%rdx)
incq %rdx
movq %r15, %rsi
addq %rdx, %rsi
jne 0x21343
addl %ebp, %eax
addq %r8, %r14
incq %rbx
addq %r8, %r13
cmpq %rdi, %rbx
jne 0x212cd
movl 0x10(%rsp), %r12d
jmp 0x21383
movl %ebx, %r12d
movb $0x1, 0x19764a(%rip)    # 0x1b89d4
movl $0x1010101, 0x19763c(%rip) # imm = 0x1010101
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq