// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/jfbuild/src/cache1d.c
// Function: lzwuncompress
static int lzwuncompress(unsigned char *lzwinbuf, int compleng, unsigned char *lzwoutbuf)
{
	int strtot, currstr, numbits, oneupnumbits;
	int i, dat, leng, bitcnt, outbytecnt;
	int *intptr;
	short *shortptr;

	shortptr = (short *)lzwinbuf;
	strtot = (int)B_LITTLE16(shortptr[1]);
	if (strtot == 0)
	{
		copybuf(lzwinbuf+4,lzwoutbuf,((compleng-4)+3)>>2);
		return((int)B_LITTLE16(shortptr[0])); //uncompleng
	}
	for(i=255;i>=0;i--) { lzwbuf2[i] = i; lzwbuf3[i] = i; }
	currstr = 256; bitcnt = (4<<3); outbytecnt = 0;
	numbits = 8; oneupnumbits = (1<<8);
	do
	{
		intptr = (int *)&lzwinbuf[bitcnt>>3];
		dat = ((B_LITTLE32(intptr[0])>>(bitcnt&7)) & (oneupnumbits-1));
		bitcnt += numbits;
		if ((dat&((oneupnumbits>>1)-1)) > ((currstr-1)&((oneupnumbits>>1)-1)))
			{ dat &= ((oneupnumbits>>1)-1); bitcnt--; }

		lzwbuf3[currstr] = dat;

		for(leng=0;dat>=256;leng++,dat=lzwbuf3[dat])
			lzwbuf1[leng] = lzwbuf2[dat];

		lzwoutbuf[outbytecnt++] = dat;
		for(i=leng-1;i>=0;i--) lzwoutbuf[outbytecnt++] = lzwbuf1[i];

		lzwbuf2[currstr-1] = dat; lzwbuf2[currstr] = dat;
		currstr++;
		if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
	} while (currstr < strtot);
	return((int)B_LITTLE16(shortptr[0])); //uncompleng
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0x2(%rdi), %ecx
testw %cx, %cx
je 0x211d2
movl $0xff, %eax
movq 0x196956(%rip), %rsi    # 0x1b79e0
movw %ax, (%rsi,%rax,2)
movq 0x196953(%rip), %rsi    # 0x1b79e8
movw %ax, (%rsi,%rax,2)
addq $-0x1, %rax
jb 0x21083
movswl %cx, %eax
cmpl $0x102, %eax            # imm = 0x102
movl $0x101, %eax            # imm = 0x101
cmovgel %ecx, %eax
movzwl %ax, %eax
xorl %r10d, %r10d
movl $0x20, %esi
movl $0x100, %edi            # imm = 0x100
movl $0x8, %r8d
movl $0x100, %r9d            # imm = 0x100
movl %esi, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movl (%rbx,%rcx), %r11d
movl %esi, %ecx
andb $0x7, %cl
sarl %cl, %r11d
leal -0x1(%rdi), %ebp
andl %r11d, %ebp
movl %edi, %r11d
sarl %r11d
decl %r11d
movl %ebp, %ecx
andl %r11d, %ecx
leal -0x1(%r9), %r14d
andl %r11d, %r14d
xorl %r11d, %r11d
cmpl %r14d, %ecx
cmovlel %ebp, %ecx
setg %bpl
movq 0x1968da(%rip), %r14    # 0x1b79e8
movw %cx, (%r14,%r9,2)
xorl %r15d, %r15d
cmpl $0x100, %ecx            # imm = 0x100
jl 0x2114d
movq 0x1968bb(%rip), %r14    # 0x1b79e0
movl %ecx, %ecx
movb (%r14,%rcx,2), %r14b
movq 0x1968a6(%rip), %r12    # 0x1b79d8
movb %r14b, (%r12,%r15)
incq %r15
movq 0x1968a8(%rip), %r14    # 0x1b79e8
movswl (%r14,%rcx,2), %ecx
cmpl $0xff, %ecx
jg 0x2111e
movslq %r10d, %r14
movb %cl, (%rdx,%r14)
incl %r14d
testl %r15d, %r15d
jle 0x2118b
movslq %r14d, %r12
movl %r15d, %r13d
incq %r13
addq %rdx, %r12
leal (%r10,%r15), %r14d
incl %r14d
movq 0x196862(%rip), %r10    # 0x1b79d8
movb -0x2(%r10,%r13), %r10b
movb %r10b, (%r12)
decq %r13
incq %r12
cmpq $0x1, %r13
jg 0x2116f
addl %r8d, %esi
movb %bpl, %r11b
subl %r11d, %esi
movq 0x196845(%rip), %r10    # 0x1b79e0
movw %cx, -0x2(%r10,%r9,2)
movq 0x196838(%rip), %r10    # 0x1b79e0
movw %cx, (%r10,%r9,2)
movslq %edi, %r10
xorl %ecx, %ecx
cmpq %r10, %r9
leaq 0x1(%r9), %r11
setge %cl
shll %cl, %edi
addl %ecx, %r8d
movq %r11, %r9
movl %r14d, %r10d
cmpq %rax, %r11
jne 0x210cb
jmp 0x211e7
movl %esi, %eax
leaq 0x4(%rbx), %rdi
decl %eax
sarl $0x2, %eax
movq %rdx, %rsi
movl %eax, %edx
callq 0x4abdd
movswl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq