// File: /workspace/github_c_makefile_star2_O3/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 0x213a6
cmpl $0x4001, %r15d          # imm = 0x4001
movl $0x1, %ebx
movl %r15d, %ebp
cmovael %ebx, %ebp
cmovael %r15d, %ebx
movq 0x196d8f(%rip), %rsi    # 0x1b89c8
movq %r14, %rdi
movl %ebp, %edx
callq 0x4d437
movl $0x4000, %r12d          # imm = 0x4000
subl %ebp, %r12d
movl %ebp, %r15d
cmpl %r12d, %ebp
jbe 0x21cc5
movl %r13d, 0x4(%rsp)
movq 0x196d68(%rip), %rdi    # 0x1b89c8
movq 0x196d59(%rip), %rdx    # 0x1b89c0
movl %ebp, %esi
callq 0x219eb
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 0x21dff
movq 0x196d1e(%rip), %rdi    # 0x1b89c0
movzwl %r15w, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x6b90
xorl %r15d, %r15d
cmpq $0x1, %rax
movl 0x4(%rsp), %r13d
jne 0x21e02
imull %r13d, %ebx
movl %ebx, 0x4(%rsp)
cmpl $0x2, %ebx
jb 0x21d96
movl %ebp, %ebx
movl $0x1, %r13d
movl %ebp, 0x14(%rsp)
testl %ebp, %ebp
je 0x21d0d
movl %r15d, %eax
leaq (%r14,%rbx), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
subb (%r14,%rdx), %sil
movq 0x196cca(%rip), %rdi    # 0x1b89c8
addq %rax, %rdi
movb %sil, (%rdx,%rdi)
incq %rdx
cmpq %rdx, %rbx
jne 0x21cef
addl %ebp, %r15d
cmpl %r12d, %r15d
jbe 0x21d85
movl %r12d, %ebp
movq 0x196ca9(%rip), %rdi    # 0x1b89c8
movq 0x196c9a(%rip), %rdx    # 0x1b89c0
movl %r15d, %esi
callq 0x219eb
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 0x21dff
movq 0x196c5c(%rip), %rdi    # 0x1b89c0
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 0x21e02
addq %rbx, %r14
incl %r13d
cmpl 0x4(%rsp), %r13d
jne 0x21ce2
testl %r15d, %r15d
je 0x21df8
movq 0x196c26(%rip), %rdi    # 0x1b89c8
movq 0x196c17(%rip), %rdx    # 0x1b89c0
movl %r15d, %esi
callq 0x219eb
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 0x21e02
movq 0x196bde(%rip), %rdi    # 0x1b89c0
movzwl %bp, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x21e02
movl 0x4(%rsp), %r15d
jmp 0x21e02
xorl %r15d, %r15d
movb $0x1, 0x196bcb(%rip)    # 0x1b89d4
movl $0x1010101, 0x196bbd(%rip) # imm = 0x1010101
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)