// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: lzwcompress
static int lzwcompress(unsigned char *lzwinbuf, int uncompleng, unsigned char *lzwoutbuf)
{
	int i, addr, newaddr, addrcnt, zx;
	int *intptr;
	int bytecnt1, bitcnt, numbits, oneupnumbits;
	short *shortptr;

	for(i=255;i>=0;i--) { lzwbuf1[i] = i; lzwbuf3[i] = (i+1)&255; }
	clearbuf(lzwbuf2,256>>1,0xffffffff);
	clearbuf(lzwoutbuf,((uncompleng+15)+3)>>2,0L);

	addrcnt = 256; bytecnt1 = 0; bitcnt = (4<<3);
	numbits = 8; oneupnumbits = (1<<8);
	do
	{
		addr = lzwinbuf[bytecnt1];
		do
		{
			bytecnt1++;
			if (bytecnt1 == uncompleng) break;
			if (lzwbuf2[addr] < 0) {lzwbuf2[addr] = addrcnt; break;}
			newaddr = lzwbuf2[addr];
			while (lzwbuf1[newaddr] != lzwinbuf[bytecnt1])
			{
				zx = lzwbuf3[newaddr];
				if (zx < 0) {lzwbuf3[newaddr] = addrcnt; break;}
				newaddr = zx;
			}
			if (lzwbuf3[newaddr] == addrcnt) break;
			addr = newaddr;
		} while (addr >= 0);
		lzwbuf1[addrcnt] = lzwinbuf[bytecnt1];
		lzwbuf2[addrcnt] = -1;
		lzwbuf3[addrcnt] = -1;

		intptr = (int *)&lzwoutbuf[bitcnt>>3];
		intptr[0] |= B_LITTLE32(addr<<(bitcnt&7));
		bitcnt += numbits;
		if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
			bitcnt--;

		addrcnt++;
		if (addrcnt > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
	} while ((bytecnt1 < uncompleng) && (bitcnt < (uncompleng<<3)));

	intptr = (int *)&lzwoutbuf[bitcnt>>3];
	intptr[0] |= B_LITTLE32(addr<<(bitcnt&7));
	bitcnt += numbits;
	if ((addr&((oneupnumbits>>1)-1)) > ((addrcnt-1)&((oneupnumbits>>1)-1)))
		bitcnt--;

	shortptr = (short *)lzwoutbuf;
	shortptr[0] = B_LITTLE16((short)uncompleng);
	if (((bitcnt+7)>>3) < uncompleng)
	{
		shortptr[1] = B_LITTLE16((short)addrcnt);
		return((bitcnt+7)>>3);
	}
	shortptr[1] = 0;
	for(i=0;i<uncompleng;i++) lzwoutbuf[i+4] = lzwinbuf[i];
	return(uncompleng+4);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movl $0xff, %eax
testl %eax, %eax
js 0x1f0c7
movq 0x19292b(%rip), %rcx    # 0x1b19d8
movl %eax, %edx
movb %al, (%rcx,%rdx)
leal 0x1(%rax), %ecx
movzbl %cl, %ecx
movq 0x192929(%rip), %rsi    # 0x1b19e8
movw %cx, (%rsi,%rdx,2)
decl %eax
jmp 0x1f0a2
movq 0x192912(%rip), %rdi    # 0x1b19e0
pushq $-0x1
popq %rdx
movl $0x80, %esi
callq 0x444af
leal 0x12(%r14), %esi
shrl $0x2, %esi
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
callq 0x444af
leal (,%r14,8), %eax
movl %eax, 0x4(%rsp)
movslq %r14d, %r10
movl $0x100, %esi            # imm = 0x100
pushq $0x8
popq %rax
pushq $0x20
popq %rdx
movl $0x100, %r11d           # imm = 0x100
movq %r11, %rdi
movslq %r12d, %r12
movzbl (%r15,%r12), %ecx
movl %ecx, %r9d
incq %r12
cmpq %r10, %r12
je 0x1f17a
movq 0x1928b4(%rip), %rcx    # 0x1b19e0
movl %r9d, %r8d
movzwl (%rcx,%r8,2), %ebp
testw %bp, %bp
js 0x1f17f
movq 0x192898(%rip), %r13    # 0x1b19d8
movb (%r15,%r12), %r8b
movq 0x19289d(%rip), %r11    # 0x1b19e8
movzwl %bp, %ecx
cmpb %r8b, (%r13,%rcx)
je 0x1f16b
movzwl (%r11,%rcx,2), %ebp
testw %bp, %bp
jns 0x1f14b
movw %di, (%r11,%rcx,2)
movq 0x19287d(%rip), %r11    # 0x1b19e8
movswq (%r11,%rcx,2), %r8
movl %r8d, %r8d
cmpq %r8, %rdi
jne 0x1f11a
jmp 0x1f184
movl %r14d, %r12d
jmp 0x1f184
movw %di, (%rcx,%r8,2)
movslq %r12d, %r13
movb (%r15,%r13), %cl
movq 0x192846(%rip), %r8     # 0x1b19d8
movb %cl, (%r8,%rdi)
movq 0x192843(%rip), %rcx    # 0x1b19e0
orw $-0x1, (%rcx,%rdi,2)
movq 0x19283f(%rip), %rcx    # 0x1b19e8
orw $-0x1, (%rcx,%rdi,2)
movl %edx, %r8d
sarl $0x3, %r8d
movl %edx, %ecx
andb $0x7, %cl
movl %r9d, %r11d
shll %cl, %r11d
movslq %r8d, %rcx
orl %r11d, (%rbx,%rcx)
addl %eax, %edx
movl %esi, %ecx
sarl %ecx
decl %ecx
movl %r9d, %r8d
andl %ecx, %r8d
leal -0x1(%rdi), %r11d
andl %ecx, %r11d
xorl %ecx, %ecx
cmpl %r11d, %r8d
setg %cl
subl %ecx, %edx
leaq 0x1(%rdi), %r11
movslq %esi, %rsi
xorl %ecx, %ecx
cmpq %rsi, %rdi
setge %cl
addl %ecx, %eax
shll %cl, %esi
cmpl %r14d, %r13d
jge 0x1f208
cmpl 0x4(%rsp), %edx
jl 0x1f10f
movl %edx, %r8d
sarl $0x3, %r8d
movl %edx, %ecx
andb $0x7, %cl
movl %r9d, %r10d
shll %cl, %r10d
movslq %r8d, %rcx
orl %r10d, (%rbx,%rcx)
sarl %esi
decl %esi
andl %esi, %r9d
andl %edi, %esi
cmpl %r9d, %esi
sbbl $0x0, %eax
movw %r14w, (%rbx)
addl %edx, %eax
addl $0x7, %eax
sarl $0x3, %eax
cmpl %r14d, %eax
jge 0x1f248
movw %r11w, 0x2(%rbx)
jmp 0x1f274
andw $0x0, 0x2(%rbx)
xorl %eax, %eax
testl %r14d, %r14d
movl $0x0, %ecx
cmovgl %r14d, %ecx
cmpq %rax, %rcx
je 0x1f26d
movb (%r15,%rax), %dl
movb %dl, 0x4(%rbx,%rax)
incq %rax
jmp 0x1f25b
addl $0x4, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq