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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x8(%rsp)
movl %edx, %r13d
movl %esi, %r15d
movq %rdi, %r14
callq 0x20fa4
cmpl $0x4001, %r15d          # imm = 0x4001
movl $0x1, %ebx
movl %r15d, %ebp
cmovael %ebx, %ebp
cmovael %r15d, %ebx
movq 0x1961a2(%rip), %rsi    # 0x1b79c8
movq %r14, %rdi
movl %ebp, %edx
callq 0x4ac52
movl $0x4000, %r12d          # imm = 0x4000
subl %ebp, %r12d
movl %ebp, %r15d
cmpl %r12d, %ebp
jbe 0x218b2
movl %r13d, 0x4(%rsp)
movq 0x19617b(%rip), %rdi    # 0x1b79c8
movq 0x19616c(%rip), %rdx    # 0x1b79c0
movl %ebp, %esi
callq 0x215d8
movl %eax, %r15d
leaq 0x2(%rsp), %rdi
movw %r15w, (%rdi)
movl $0x2, %esi
movl $0x1, %edx
movq 0x8(%rsp), %r13
movq %r13, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x219ec
movq 0x196131(%rip), %rdi    # 0x1b79c0
movzwl %r15w, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x6b90
xorl %r15d, %r15d
cmpq $0x1, %rax
movl 0x4(%rsp), %r13d
jne 0x219ef
imull %r13d, %ebx
movl %ebx, 0x4(%rsp)
cmpl $0x2, %ebx
jb 0x21983
movl %ebp, %ebx
movl $0x1, %r13d
movl %ebp, 0x14(%rsp)
testl %ebp, %ebp
je 0x218fa
movl %r15d, %eax
leaq (%r14,%rbx), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
subb (%r14,%rdx), %sil
movq 0x1960dd(%rip), %rdi    # 0x1b79c8
addq %rax, %rdi
movb %sil, (%rdx,%rdi)
incq %rdx
cmpq %rdx, %rbx
jne 0x218dc
addl %ebp, %r15d
cmpl %r12d, %r15d
jbe 0x21972
movl %r12d, %ebp
movq 0x1960bc(%rip), %rdi    # 0x1b79c8
movq 0x1960ad(%rip), %rdx    # 0x1b79c0
movl %r15d, %esi
callq 0x215d8
movl %eax, %r15d
movw %r15w, 0x2(%rsp)
movl $0x2, %esi
movl $0x1, %edx
leaq 0x2(%rsp), %rdi
movq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x219ec
movq 0x19606f(%rip), %rdi    # 0x1b79c0
movzwl %r15w, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x6b90
xorl %r15d, %r15d
cmpq $0x1, %rax
movl %ebp, %r12d
movl 0x14(%rsp), %ebp
jne 0x219ef
addq %rbx, %r14
incl %r13d
cmpl 0x4(%rsp), %r13d
jne 0x218cf
testl %r15d, %r15d
je 0x219e5
movq 0x196039(%rip), %rdi    # 0x1b79c8
movq 0x19602a(%rip), %rdx    # 0x1b79c0
movl %r15d, %esi
callq 0x215d8
movl %eax, %ebp
leaq 0x2(%rsp), %rdi
movw %bp, (%rdi)
movl $0x2, %esi
movl $0x1, %edx
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
callq 0x6b90
xorl %r15d, %r15d
cmpq $0x1, %rax
jne 0x219ef
movq 0x195ff1(%rip), %rdi    # 0x1b79c0
movzwl %bp, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x219ef
movl 0x4(%rsp), %r15d
jmp 0x219ef
xorl %r15d, %r15d
movb $0x1, 0x195fde(%rip)    # 0x1b79d4
movl $0x1010101, 0x195fd0(%rip) # imm = 0x1010101
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop