// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rcx, 0x10(%rsp)
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r15
callq 0x1ea64
cmpl $0x4001, %ebx           # imm = 0x4001
pushq $0x1
popq %r13
movl %ebx, %r14d
cmovael %r13d, %r14d
cmovbl %r13d, %ebx
movl %ebx, 0x8(%rsp)
movq 0x192706(%rip), %rsi    # 0x1b19c8
movq %r15, %rdi
movl %r14d, %edx
callq 0x44524
movl $0x4000, %edi           # imm = 0x4000
subl %r14d, %edi
movl %r14d, %r12d
cmpl %edi, %r14d
movl %edi, 0xc(%rsp)
jbe 0x1f347
movq 0x1926e0(%rip), %rdi    # 0x1b19c8
movq 0x1926d1(%rip), %rdx    # 0x1b19c0
movl %r14d, %esi
callq 0x1f089
movl %eax, %r12d
leaq 0x6(%rsp), %rdi
movw %r12w, (%rdi)
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x1f429
movq 0x192699(%rip), %rdi    # 0x1b19c0
movzwl %r12w, %esi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x6b90
xorl %r12d, %r12d
cmpq $0x1, %rax
movl 0xc(%rsp), %edi
jne 0x1f48f
movl 0x8(%rsp), %eax
imull %ebp, %eax
movl %eax, 0x8(%rsp)
movl %r14d, %r8d
movq %r8, %rbx
negq %rbx
leaq (%r15,%r8), %rbp
movl %r14d, 0x18(%rsp)
movq %r8, 0x20(%rsp)
cmpl 0x8(%rsp), %r13d
jae 0x1f42e
movl %r12d, %eax
xorl %ecx, %ecx
movq %rbx, %rdx
addq %rcx, %rdx
je 0x1f39b
movb (%rbp,%rcx), %dl
subb (%r15,%rcx), %dl
movq 0x192638(%rip), %rsi    # 0x1b19c8
addq %rax, %rsi
movb %dl, (%rcx,%rsi)
incq %rcx
jmp 0x1f379
addl %r14d, %r12d
cmpl %edi, %r12d
jbe 0x1f41b
movl %r13d, 0x1c(%rsp)
movq 0x192619(%rip), %rdi    # 0x1b19c8
movq 0x19260a(%rip), %rdx    # 0x1b19c0
movl %r12d, %esi
callq 0x1f089
movl %eax, %r12d
movw %r12w, 0x6(%rsp)
leaq 0x6(%rsp), %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq 0x10(%rsp), %r13
movq %r13, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x1f429
movq 0x1925d0(%rip), %rdi    # 0x1b19c0
movzwl %r12w, %esi
movq %r14, %rdx
movq %r13, %rcx
callq 0x6b90
xorl %r12d, %r12d
cmpq $0x1, %rax
movl 0x1c(%rsp), %r13d
movl 0x18(%rsp), %r14d
movl 0xc(%rsp), %edi
movq 0x20(%rsp), %r8
jne 0x1f48f
addq %r8, %r15
incl %r13d
addq %r8, %rbp
jmp 0x1f369
xorl %r12d, %r12d
jmp 0x1f48f
testl %r12d, %r12d
je 0x1f48a
movq 0x19258e(%rip), %rdi    # 0x1b19c8
movq 0x19257f(%rip), %rdx    # 0x1b19c0
movl %r12d, %esi
callq 0x1f089
movl %eax, %ebp
leaq 0x6(%rsp), %rdi
movw %bp, (%rdi)
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x6b90
xorl %r12d, %r12d
cmpq $0x1, %rax
jne 0x1f48f
movq 0x19254a(%rip), %rdi    # 0x1b19c0
movzwl %bp, %esi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x6b90
cmpq $0x1, %rax
jne 0x1f48f
movl 0x8(%rsp), %r12d
movb $0x1, 0x19253e(%rip)    # 0x1b19d4
movl $0x1010101, 0x192530(%rip) # imm = 0x1010101
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop