// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: dfread
unsigned dfread(void *buffer, unsigned dasizeof, unsigned count, BFILE *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 (Bfread(&leng,2,1,fil) != 1) { lzwrelease(); return -1; }
	leng = B_LITTLE16(leng);
	if (Bfread(lzwbuf5,(int)leng,1,fil) != 1) { lzwrelease(); return -1; }
	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 (Bfread(&leng,2,1,fil) != 1) { lzwrelease(); return -1; }
			leng = B_LITTLE16(leng);
			if (Bfread(lzwbuf5,(int)leng,1,fil) != 1) { 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
movq %rcx, %rbx
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %r14
callq 0x20fa4
cmpl $0x4001, %ebp           # imm = 0x4001
movl $0x1, %r15d
movl %ebp, %eax
cmovael %r15d, %eax
movl %eax, 0x8(%rsp)
cmovael %ebp, %r15d
leaq 0x6(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x6550
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x1, %rax
jne 0x213ac
movzwl 0x6(%rsp), %r13d
movq 0x19675c(%rip), %rdi    # 0x1b79c0
movl $0x1, %edx
movq %r13, %rsi
movq %rbx, %rcx
callq 0x6550
cmpq $0x1, %rax
jne 0x213ac
imull %r12d, %r15d
movq 0x196737(%rip), %rdi    # 0x1b79c0
movq 0x196738(%rip), %rdx    # 0x1b79c8
movl %r13d, %esi
callq 0x21063
movl %eax, %r13d
movq 0x196726(%rip), %rdi    # 0x1b79c8
movq %r14, %rsi
movl 0x8(%rsp), %ebp
movl %ebp, %edx
callq 0x4ac52
cmpl $0x2, %r15d
jb 0x213a2
movq %rbx, 0x20(%rsp)
movl %r15d, 0xc(%rsp)
movl %r15d, %r8d
movl %ebp, %r9d
movl %ebp, %edi
movq %r9, %rbp
negq %rbp
leaq (%r14,%r9), %r12
movl $0x1, %ebx
movl %edi, %eax
movq %r8, 0x18(%rsp)
movq %r9, 0x10(%rsp)
movq 0x20(%rsp), %r15
cmpl %r13d, %eax
jl 0x2135e
movl $0x2, %esi
movl $0x1, %edx
leaq 0x6(%rsp), %rdi
movq %r15, %rcx
callq 0x6550
cmpq $0x1, %rax
jne 0x213a7
movzwl 0x6(%rsp), %r13d
movq 0x1966a1(%rip), %rdi    # 0x1b79c0
movl $0x1, %edx
movq %r13, %rsi
movq %r15, %rcx
callq 0x6550
cmpq $0x1, %rax
jne 0x213a7
movq 0x196684(%rip), %rdi    # 0x1b79c0
movq 0x196685(%rip), %rdx    # 0x1b79c8
movl %r13d, %esi
callq 0x21063
movl %eax, %r13d
xorl %eax, %eax
movl 0x8(%rsp), %edi
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
testl %edi, %edi
je 0x21388
movslq %eax, %rcx
xorl %edx, %edx
movq 0x19665a(%rip), %rsi    # 0x1b79c8
addq %rcx, %rsi
movb (%rdx,%rsi), %sil
addb (%r14,%rdx), %sil
movb %sil, (%r12,%rdx)
incq %rdx
movq %rbp, %rsi
addq %rdx, %rsi
jne 0x21367
addl %edi, %eax
addq %r9, %r14
incq %rbx
addq %r9, %r12
cmpq %r8, %rbx
jne 0x212ec
movl 0xc(%rsp), %ebp
jmp 0x213ac
movl %r15d, %ebp
jmp 0x213ac
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movb $0x1, 0x196621(%rip)    # 0x1b79d4
movl $0x1010101, 0x196613(%rip) # imm = 0x1010101
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq