// File: /workspace/github_c_makefile_star2_O3/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 0x215e5
movl $0xff, %eax
movq 0x197554(%rip), %rsi    # 0x1b89e0
movw %ax, (%rsi,%rax,2)
movq 0x197551(%rip), %rsi    # 0x1b89e8
movw %ax, (%rsi,%rax,2)
addq $-0x1, %rax
jb 0x21485
movswl %cx, %eax
cmpl $0x102, %eax            # imm = 0x102
movl $0x101, %eax            # imm = 0x101
cmovgel %ecx, %eax
movzwl %ax, %eax
xorl %esi, %esi
movl $0x20, %edi
movl $0x100, %r8d            # imm = 0x100
movl $0x8, %r9d
movl $0x100, %r10d           # imm = 0x100
movl %edi, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movl (%rbx,%rcx), %r11d
movl %edi, %ecx
andb $0x7, %cl
sarl %cl, %r11d
leal -0x1(%r8), %r14d
andl %r11d, %r14d
movl %r8d, %r11d
sarl %r11d
decl %r11d
movl %r14d, %ecx
andl %r11d, %ecx
leal -0x1(%r10), %ebp
andl %r11d, %ebp
xorl %r11d, %r11d
cmpl %ebp, %ecx
setg %bpl
cmovlel %r14d, %ecx
movq 0x1974d6(%rip), %r14    # 0x1b89e8
movw %cx, (%r14,%r10,2)
movslq %esi, %rsi
cmpl $0x100, %ecx            # imm = 0x100
jl 0x2159b
movl $0x1, %r12d
xorl %r15d, %r15d
movl %r12d, %r14d
movq 0x1974ab(%rip), %r12    # 0x1b89e0
movl %ecx, %ecx
movb (%r12,%rcx,2), %r12b
movq 0x197496(%rip), %r13    # 0x1b89d8
movb %r12b, (%r13,%r15)
incq %r15
movq 0x197497(%rip), %r12    # 0x1b89e8
movswl (%r12,%rcx,2), %ecx
leal 0x1(%r14), %r12d
cmpl $0xff, %ecx
jg 0x2152b
movb %cl, (%rdx,%rsi)
incl %esi
testl %r15d, %r15d
jle 0x215a0
movslq %esi, %r15
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
incq %r14
addq %rdx, %r15
movq 0x197455(%rip), %r12    # 0x1b89d8
movb -0x2(%r12,%r14), %r12b
movb %r12b, (%r15)
decq %r14
incq %r15
incl %esi
cmpq $0x1, %r14
ja 0x2157c
jmp 0x215a0
movb %cl, (%rdx,%rsi)
incl %esi
addl %r9d, %edi
movb %bpl, %r11b
subl %r11d, %edi
movq 0x197430(%rip), %r11    # 0x1b89e0
movw %cx, -0x2(%r11,%r10,2)
movq 0x197423(%rip), %r11    # 0x1b89e0
movw %cx, (%r11,%r10,2)
movslq %r8d, %r11
xorl %ecx, %ecx
cmpq %r11, %r10
setge %cl
shll %cl, %r8d
leaq 0x1(%r10), %r11
addl %ecx, %r9d
movq %r11, %r10
cmpq %rax, %r11
jne 0x214cd
jmp 0x215fa
movl %esi, %eax
leaq 0x4(%rbx), %rdi
decl %eax
sarl $0x2, %eax
movq %rdx, %rsi
movl %eax, %edx
callq 0x4d3c2
movswl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq