// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: kdfwrite
unsigned kdfwrite(void *buffer, unsigned dasizeof, unsigned count, int 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 (Bwrite(fil,&swleng,2) != 2) { lzwrelease(); return 0; }
		if (Bwrite(fil,lzwbuf5,(int)leng) != leng) { 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 (Bwrite(fil,&swleng,2) != 2) { lzwrelease(); return 0; }
			if (Bwrite(fil,lzwbuf5,(int)leng) != leng) { lzwrelease(); return 0; }
		}
		ptr += dasizeof;
	}
	if (k > 0)
	{
		leng = (short)lzwcompress(lzwbuf4,k,lzwbuf5); swleng = B_LITTLE16(leng);
		if (Bwrite(fil,&swleng,2) != 2) { lzwrelease(); return 0; }
		if (Bwrite(fil,lzwbuf5,(int)leng) != leng) { lzwrelease(); return 0; }
	}
	lzwrelease();
	return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
callq 0x31780
cmpl $0x4000, -0x14(%rbp)    # imm = 0x4000
jbe 0x31d64
movl -0x14(%rbp), %eax
imull -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq 0x1c37b1(%rip), %rsi    # 0x1f5528
movl -0x14(%rbp), %edx
callq 0x6ef00
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl $0x4000, %ecx           # imm = 0x4000
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x31e1b
movq 0x1c3789(%rip), %rdi    # 0x1f5528
movl -0x28(%rbp), %esi
movq 0x1c3777(%rip), %rdx    # 0x1f5520
callq 0x31fd0
movw %ax, -0x2a(%rbp)
movl $0x0, -0x28(%rbp)
movw -0x2a(%rbp), %ax
movw %ax, -0x2c(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x6a20
cmpq $0x2, %rax
je 0x31de9
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
movl -0x1c(%rbp), %edi
movq 0x1c372d(%rip), %rsi    # 0x1f5520
movzwl -0x2a(%rbp), %eax
movslq %eax, %rdx
callq 0x6a20
movzwl -0x2a(%rbp), %ecx
cmpq %rcx, %rax
je 0x31e19
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
jmp 0x31e1b
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x31f3b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x31e7e
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
addl -0x14(%rbp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x38(%rbp), %rcx
movl -0x24(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
andl $0xff, %eax
movb %al, %dl
movq 0x1c36c0(%rip), %rax    # 0x1f5528
movl -0x24(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x31e35
movl -0x14(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl $0x4000, %ecx           # imm = 0x4000
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x31f1d
movq 0x1c3687(%rip), %rdi    # 0x1f5528
movl -0x28(%rbp), %esi
movq 0x1c3675(%rip), %rdx    # 0x1f5520
callq 0x31fd0
movw %ax, -0x2a(%rbp)
movl $0x0, -0x28(%rbp)
movw -0x2a(%rbp), %ax
movw %ax, -0x2c(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x6a20
cmpq $0x2, %rax
je 0x31eeb
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
movl -0x1c(%rbp), %edi
movq 0x1c362b(%rip), %rsi    # 0x1f5520
movzwl -0x2a(%rbp), %eax
movslq %eax, %rdx
callq 0x6a20
movzwl -0x2a(%rbp), %ecx
cmpq %rcx, %rax
je 0x31f1b
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
jmp 0x31f1d
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x31e22
cmpl $0x0, -0x28(%rbp)
jbe 0x31fb7
movq 0x1c35e0(%rip), %rdi    # 0x1f5528
movl -0x28(%rbp), %esi
movq 0x1c35ce(%rip), %rdx    # 0x1f5520
callq 0x31fd0
movw %ax, -0x2a(%rbp)
movw -0x2a(%rbp), %ax
movw %ax, -0x2c(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x6a20
cmpq $0x2, %rax
je 0x31f88
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
movl -0x1c(%rbp), %edi
movq 0x1c358e(%rip), %rsi    # 0x1f5520
movzwl -0x2a(%rbp), %eax
movslq %eax, %rdx
callq 0x6a20
movzwl -0x2a(%rbp), %ecx
cmpq %rcx, %rax
je 0x31fb5
callq 0x31870
movl $0x0, -0x4(%rbp)
jmp 0x31fc2
jmp 0x31fb7
callq 0x31870
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)