// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
callq 0x31780
cmpl $0x4000, -0x14(%rbp)    # imm = 0x4000
jbe 0x31b35
movl -0x14(%rbp), %eax
imull -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x3a(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x31b6b
callq 0x31870
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31d24
movw -0x3a(%rbp), %ax
movw %ax, -0x3a(%rbp)
movq 0x1c39a6(%rip), %rdi    # 0x1f5520
movzwl -0x3a(%rbp), %eax
movslq %eax, %rsi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x31ba6
callq 0x31870
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31d24
movl $0x0, -0x34(%rbp)
movq 0x1c396c(%rip), %rdi    # 0x1f5520
movzwl -0x3a(%rbp), %esi
movq 0x1c3969(%rip), %rdx    # 0x1f5528
callq 0x318a0
movl %eax, -0x38(%rbp)
movq 0x1c395a(%rip), %rdi    # 0x1f5528
movq -0x48(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x6ef00
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movq $0x1, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
cmpq %rcx, %rax
jae 0x31d19
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jl 0x31c91
movq -0x20(%rbp), %rcx
leaq -0x3a(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x31c35
callq 0x31870
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31d24
movw -0x3a(%rbp), %ax
movw %ax, -0x3a(%rbp)
movq 0x1c38dc(%rip), %rdi    # 0x1f5520
movzwl -0x3a(%rbp), %eax
movslq %eax, %rsi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x64f0
cmpq $0x1, %rax
je 0x31c70
callq 0x31870
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31d24
movl $0x0, -0x34(%rbp)
movq 0x1c38a2(%rip), %rdi    # 0x1f5520
movzwl -0x3a(%rbp), %esi
movq 0x1c389f(%rip), %rdx    # 0x1f5528
callq 0x318a0
movl %eax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x31cef
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq 0x1c3870(%rip), %rcx    # 0x1f5528
movq -0x30(%rbp), %rdx
movslq -0x34(%rbp), %rsi
addq %rsi, %rdx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %esi
addq %rsi, %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x31c99
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x31beb
callq 0x31870
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)