// File: /workspace/github_c_makefile_star2_O2/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 %rdx, %r8
movq %rdi, %rbx
movswq 0x2(%rdi), %rcx
movq %rcx, (%rsp)
testq %rcx, %rcx
je 0x1ec8e
movl $0xff, %eax
testl %eax, %eax
js 0x1eb6b
movq 0x192e8a(%rip), %rcx    # 0x1b19e0
movl %eax, %edi
movw %ax, (%rcx,%rdi,2)
movq 0x192e85(%rip), %rcx    # 0x1b19e8
movw %ax, (%rcx,%rdi,2)
decl %eax
jmp 0x1eb4b
movq %r8, %rdx
leaq 0x1(%r8), %rax
xorl %edi, %edi
pushq $0x20
popq %r8
movl $0x100, %r9d            # imm = 0x100
pushq $0x8
popq %r10
movl $0x100, %r11d           # imm = 0x100
movl %r8d, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movl (%rbx,%rcx), %ebp
movl %r8d, %ecx
andb $0x7, %cl
sarl %cl, %ebp
leal -0x1(%r9), %r14d
andl %ebp, %r14d
movl %r9d, %ebp
sarl %ebp
decl %ebp
movl %r14d, %ecx
andl %ebp, %ecx
leal -0x1(%r11), %r15d
andl %ebp, %r15d
xorl %ebp, %ebp
cmpl %r15d, %ecx
setg %bpl
cmovlel %r14d, %ecx
negl %ebp
movq 0x192e1c(%rip), %r14    # 0x1b19e8
movw %cx, (%r14,%r11,2)
movl %edi, %r15d
xorl %r14d, %r14d
cmpl $0x100, %ecx            # imm = 0x100
jl 0x1ec0c
movq 0x192dfa(%rip), %r12    # 0x1b19e0
movl %ecx, %ecx
movb (%r12,%rcx,2), %r12b
movq 0x192de5(%rip), %r13    # 0x1b19d8
movb %r12b, (%r13,%r14)
incq %r14
movq 0x192de6(%rip), %r12    # 0x1b19e8
movswl (%r12,%rcx,2), %ecx
incl %r15d
jmp 0x1ebd7
movq %rbx, %rsi
addl %r10d, %r8d
movslq %edi, %r12
movb %cl, (%rdx,%r12)
movslq %r15d, %r15
leaq (%rax,%r12), %r13
subq %r15, %r12
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x1ec46
movq 0x192da6(%rip), %rbx    # 0x1b19d8
addq %r14, %rbx
movb -0x1(%r15,%rbx), %bl
movb %bl, (%r13)
decq %r15
incq %r13
jmp 0x1ec26
addl %ebp, %r8d
subl %r15d, %edi
incl %edi
movq 0x192d8b(%rip), %rbx    # 0x1b19e0
movw %cx, -0x2(%rbx,%r11,2)
movq 0x192d7e(%rip), %rbx    # 0x1b19e0
movw %cx, (%rbx,%r11,2)
movslq %r9d, %rbx
xorl %ecx, %ecx
cmpq %rbx, %r11
setge %cl
shll %cl, %r9d
leaq 0x1(%r11), %rbx
addl %ecx, %r10d
movq %rbx, %r11
cmpq (%rsp), %rbx
movq %rsi, %rbx
jl 0x1eb88
jmp 0x1eca3
movl %esi, %eax
leaq 0x4(%rbx), %rdi
decl %eax
sarl $0x2, %eax
movq %r8, %rsi
movl %eax, %edx
callq 0x444be
movswl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq