// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x318f8
movq -0x10(%rbp), %rdi
addq $0x4, %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
subl $0x4, %edx
addl $0x3, %edx
sarl $0x2, %edx
callq 0x6ed90
movq -0x58(%rbp), %rax
movswl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x31aec
movl $0xff, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x3193a
movl -0x34(%rbp), %eax
movw %ax, %dx
movq 0x1c3c2e(%rip), %rax    # 0x1f5540
movslq -0x34(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x34(%rbp), %eax
movw %ax, %dx
movq 0x1c3c21(%rip), %rax    # 0x1f5548
movslq -0x34(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x318ff
movl $0x100, -0x28(%rbp)     # imm = 0x100
movl $0x20, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x8, -0x2c(%rbp)
movl $0x100, -0x30(%rbp)     # imm = 0x100
movq -0x10(%rbp), %rax
movl -0x40(%rbp), %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl -0x40(%rbp), %ecx
andl $0x7, %ecx
sarl %cl, %eax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
movl -0x30(%rbp), %ecx
sarl %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movl -0x30(%rbp), %edx
sarl %edx
subl $0x1, %edx
andl %edx, %ecx
cmpl %ecx, %eax
jle 0x319cb
movl -0x30(%rbp), %eax
sarl %eax
subl $0x1, %eax
andl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
movw %ax, %dx
movq 0x1c3b70(%rip), %rax    # 0x1f5548
movslq -0x28(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl $0x0, -0x3c(%rbp)
cmpl $0x100, -0x38(%rbp)     # imm = 0x100
jl 0x31a2c
movq 0x1c3b49(%rip), %rax    # 0x1f5540
movslq -0x38(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movb %al, %dl
movq 0x1c3b30(%rip), %rax    # 0x1f5538
movslq -0x3c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq 0x1c3b29(%rip), %rax    # 0x1f5548
movslq -0x38(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x38(%rbp)
jmp 0x319e7
movl -0x38(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x44(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x31a83
movq 0x1c3adc(%rip), %rax    # 0x1f5538
movslq -0x34(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x20(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x44(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x31a4f
movl -0x38(%rbp), %eax
movw %ax, %dx
movq 0x1c3ab0(%rip), %rax    # 0x1f5540
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
movl -0x38(%rbp), %eax
movw %ax, %dx
movq 0x1c3a96(%rip), %rax    # 0x1f5540
movslq -0x28(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jle 0x31ad4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
shll %eax
movl %eax, -0x30(%rbp)
jmp 0x31ad6
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jl 0x3195d
movq -0x58(%rbp), %rax
movswl (%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)