// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movl $0xff, %eax
movq 0x1963dd(%rip), %rcx    # 0x1b79d8
movb %al, (%rcx,%rax)
leal 0x1(%rax), %ecx
movzbl %cl, %ecx
movq 0x1963dd(%rip), %rdx    # 0x1b79e8
movw %cx, (%rdx,%rax,2)
addq $-0x1, %rax
jb 0x215f4
movq 0x1963c4(%rip), %rdi    # 0x1b79e0
movl $0x80, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x4abc9
leal 0x12(%r14), %esi
shrl $0x2, %esi
xorl %r12d, %r12d
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4abc9
leal (,%r14,8), %eax
movl %eax, 0xc(%rsp)
movslq %r14d, %r9
movl $0x100, %esi            # imm = 0x100
movl $0x8, %eax
movl $0x20, %edx
movl $0x100, %r13d           # imm = 0x100
movw $0xffff, %r11w          # imm = 0xFFFF
movq %r13, %rdi
movslq %r12d, %r12
movzbl (%r15,%r12), %ecx
movl %ecx, %r10d
incq %r12
cmpq %r9, %r12
je 0x216dc
movq 0x196356(%rip), %rcx    # 0x1b79e0
movl %r10d, %ebx
movzwl (%rcx,%rbx,2), %r8d
testw %r8w, %r8w
js 0x216e1
movq 0x196339(%rip), %r13    # 0x1b79d8
movb (%r15,%r12), %bl
movq 0x19633e(%rip), %rbp    # 0x1b79e8
movzwl %r8w, %ecx
cmpb %bl, (%r13,%rcx)
je 0x216c6
movzwl (%rbp,%rcx,2), %r8d
testw %r8w, %r8w
jns 0x216aa
movw %di, (%rbp,%rcx,2)
movq 0x19631b(%rip), %r8     # 0x1b79e8
movswq (%r8,%rcx,2), %r8
movl %r8d, %r8d
cmpq %r8, %rdi
jne 0x21678
jmp 0x216e5
movl %r14d, %r12d
jmp 0x216e5
movw %di, (%rcx,%rbx,2)
movslq %r12d, %rbp
movb (%r15,%rbp), %cl
movq 0x1962e5(%rip), %r8     # 0x1b79d8
movb %cl, (%r8,%rdi)
movq 0x1962e2(%rip), %rcx    # 0x1b79e0
movw %r11w, (%rcx,%rdi,2)
movq 0x1962de(%rip), %rcx    # 0x1b79e8
movw %r11w, (%rcx,%rdi,2)
movl %edx, %r8d
sarl $0x3, %r8d
movl %edx, %ecx
andb $0x7, %cl
movl %r10d, %ebx
shll %cl, %ebx
movslq %r8d, %rcx
movq 0x10(%rsp), %r8
orl %ebx, (%r8,%rcx)
addl %eax, %edx
movl %esi, %ecx
sarl %ecx
decl %ecx
movl %r10d, %r8d
andl %ecx, %r8d
leal -0x1(%rdi), %ebx
andl %ecx, %ebx
xorl %ecx, %ecx
cmpl %ebx, %r8d
setg %cl
subl %ecx, %edx
leaq 0x1(%rdi), %r13
movslq %esi, %rsi
xorl %ecx, %ecx
cmpq %rsi, %rdi
setge %cl
addl %ecx, %eax
shll %cl, %esi
cmpl %r14d, %ebp
jge 0x2176b
cmpl 0xc(%rsp), %edx
jl 0x2166d
movl %edx, %r8d
sarl $0x3, %r8d
movl %edx, %ecx
andb $0x7, %cl
movl %r10d, %r9d
shll %cl, %r9d
movslq %r8d, %rcx
movq 0x10(%rsp), %r8
orl %r9d, (%r8,%rcx)
sarl %esi
decl %esi
andl %esi, %r10d
andl %edi, %esi
cmpl %r10d, %esi
sbbl $0x0, %eax
movw %r14w, (%r8)
addl %edx, %eax
addl $0x7, %eax
sarl $0x3, %eax
cmpl %r14d, %eax
jge 0x217b0
movw %r13w, 0x2(%r8)
jmp 0x217d9
movw $0x0, 0x2(%r8)
testl %r14d, %r14d
jle 0x217d2
movl %r14d, %eax
xorl %ecx, %ecx
movb (%r15,%rcx), %dl
movb %dl, 0x4(%r8,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x217c1
addl $0x4, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq