// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/../foreign/lzhuf.h
// Function: lzhuf_Decode_continue
static void lzhuf_Decode_continue(struct lzahuf_ctx *cctx, const u8 *buf, i64 buf_len, int flush)
{
	UI i, j, c;
	i64 bufpos = 0;
	char pos_descr[32];

	pos_descr[0] = '\0';
	if(cctx->dfctx->finished_flag) goto done;

	while(1) {
		if(cctx->errflag) goto done;
		if(lzah_have_enough_output(cctx)) {
			goto done;
		}

		// We're relying on the assumption that a compression instruction can
		// never be more than 57 bits in size.
		// The Huffman-encoded "character" maxes out, I think, at around 15 or
		// 16 bits -- this follows indirectly from MAX_FREQ, which reduces the
		// tree depth perdiodically.
		// For a "match" instruction, an 8-bit code is then read.
		// Then, some additional bits are read -- the most possible for the
		// supported formats is 8, for DMS-Deep.
		// So, about 16+8+8 = 32 bits should be sufficient.

		// Top off the bitbuf, if possible.
		while(bufpos<buf_len && cctx->bbll.nbits_in_bitbuf<=(64-8)) {
			de_bitbuf_lowlevel_add_byte(&cctx->bbll, buf[bufpos++]);
			cctx->total_nbytes_processed++;
		}

		if(!flush && cctx->bbll.nbits_in_bitbuf<=(64-8)) {
			// Wait for more data before trying to continue
			goto done;
		}

		if(cctx->c->debug_level>=4) {
			de_bitbuf_describe_curpos(&cctx->bbll,
				cctx->dfctx->input_file_offset+cctx->total_nbytes_processed,
				pos_descr, sizeof(pos_descr));
		}

		c = lzhuf_DecodeChar(cctx);
		if(cctx->errflag) goto done;

		if(c==256 && cctx->num_special_codes>=1) {
			if(cctx->c->debug_level>=4) {
				de_dbg(cctx->c, "special @%s =%u", pos_descr, c);
			}
			cctx->dfctx->finished_flag = 1;
			goto done;
		}
		if (c < 256) {
			if(cctx->c->debug_level>=4) {
				de_dbg(cctx->c, "lit @%s =%u", pos_descr, c);
			}
			de_lz77buffer_add_literal_byte(cctx->ringbuf, (u8)c);
		}
		else {
			// i is the distance back
			i = lzhuf_DecodePosition(cctx);
			if(cctx->errflag) goto done;

			// j is the match length
			j = c - cctx->match_length_bias;

			if(cctx->c->debug_level>=4) {
				de_dbg(cctx->c, "match @%s dist=%u len=%u", pos_descr, i+1, j);
			}

			de_lz77buffer_copy_from_hist(cctx->ringbuf,
				(UI)(cctx->ringbuf->curpos - (UI)i - 1), j);
		}
	}

done:
	if(!cctx->dfctx->finished_flag && !cctx->errflag) {
		if(bufpos<buf_len) {
			// It shouldn't be possible to get here. If we do, it means some input
			// bytes will be lost.
			de_dfilter_set_generic_error(cctx->dfctx->c, cctx->dres, cctx->modname);
			cctx->errflag = 1;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movb $0x0, 0x80(%rsp)
movq 0x18(%rdi), %rax
cmpb $0x0, 0x20(%rax)
jne 0x106caa
cmpl $0x0, 0x54(%rbx)
je 0x106ceb
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
cmpb $0x0, 0x20(%rax)
jne 0x106cd9
cmpq %r14, %r15
jge 0x106cd9
cmpl $0x0, 0x54(%rbx)
jne 0x106cd9
movq (%rax), %rdi
movq 0x8(%rbx), %rdx
movq 0x28(%rbx), %rsi
callq 0xfa311
movl $0x1, 0x54(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %ebp
movq %rsi, %r13
leaq 0x70(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0xcd6(%rbx), %rax
movq %rax, (%rsp)
leaq 0x80(%rbx), %r12
xorl %r15d, %r15d
movq %rsi, 0x40(%rsp)
movq 0x20(%rbx), %rax
cmpb $0x0, 0x8(%rax)
je 0x106d2b
movq 0x60(%rbx), %rcx
cmpq 0x10(%rax), %rcx
jge 0x1074dd
cmpq %r14, %r15
jge 0x106d55
cmpl $0x38, 0x74(%rbx)
ja 0x106d55
movzbl (%r13,%r15), %esi
incq %r15
movq 0x28(%rsp), %rdi
callq 0xf1b5e
incq 0x58(%rbx)
cmpq %r15, %r14
jne 0x106d30
movq %r14, %r15
testl %ebp, %ebp
jne 0x106d63
cmpl $0x39, 0x74(%rbx)
jb 0x106cad
movq (%rbx), %rax
cmpl $0x4, (%rax)
jl 0x106d8e
movq 0x18(%rbx), %rax
movq 0x58(%rbx), %rsi
addq 0x18(%rax), %rsi
movl $0x20, %ecx
movq 0x28(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0xf1c9e
movl 0x40(%rbx), %eax
cmpq $0x276, %rax            # imm = 0x276
ja 0x106da3
movq (%rsp), %rcx
movzwl (%rcx,%rax,2), %ecx
jmp 0x106dac
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
movl 0x3c(%rbx), %r9d
cmpl %ecx, %r9d
jbe 0x106e0e
movl %ebp, 0xc(%rsp)
cmpl $0x0, 0x74(%rbx)
je 0x10748c
movq %rcx, %rbp
movq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0xf1b93
cmpl $0x0, 0x54(%rbx)
jne 0x106cad
addl %eax, %ebp
cmpl $0x276, %ebp            # imm = 0x276
ja 0x106df5
movl %ebp, %eax
movq (%rsp), %rcx
movzwl (%rcx,%rax,2), %ecx
jmp 0x106dfe
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
movl 0x3c(%rbx), %r9d
cmpl %ecx, %r9d
ja 0x106db9
movl 0x40(%rbx), %eax
movl 0xc(%rsp), %ebp
cmpl $0x278, %eax            # imm = 0x278
jae 0x107146
movq %rcx, 0x10(%rsp)
movl %eax, %eax
movzwl (%r12,%rax,2), %eax
cmpl $0x8000, %eax           # imm = 0x8000
ja 0x10748c
negw %ax
movl %r9d, %eax
movq 0x10(%rsp), %rcx
jno 0x107150
testl %r9d, %r9d
je 0x106ef4
movl %r9d, %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x276, %rcx            # imm = 0x276
ja 0x106e64
movq (%rsp), %rsi
movzwl (%rsi,%rcx,2), %esi
jmp 0x106e6d
movl $0x1, 0x54(%rbx)
xorl %esi, %esi
cmpl %esi, %r9d
ja 0x106ee8
cmpq $0x277, %rcx            # imm = 0x277
ja 0x106e8d
movq (%rsp), %rsi
movzwl -0xc56(%rsi,%rcx,2), %esi
incl %esi
shrl %esi
jmp 0x106e96
movl $0x1, 0x54(%rbx)
xorl %esi, %esi
cmpl $0x277, %edx            # imm = 0x277
ja 0x106ea7
movl %edx, %edi
movw %si, (%r12,%rdi,2)
jmp 0x106eae
movl $0x1, 0x54(%rbx)
cmpq $0x276, %rcx            # imm = 0x276
ja 0x106ec1
movq (%rsp), %rsi
movzwl (%rsi,%rcx,2), %esi
jmp 0x106eca
movl $0x1, 0x54(%rbx)
xorl %esi, %esi
cmpl $0x276, %edx            # imm = 0x276
ja 0x106edf
movl %edx, %edi
movq (%rsp), %r8
movw %si, (%r8,%rdi,2)
jmp 0x106ee6
movl $0x1, 0x54(%rbx)
incl %edx
incq %rcx
cmpq %rcx, %rax
jne 0x106e51
movl 0x38(%rbx), %edx
movl %r9d, %eax
cmpl %r9d, %edx
jae 0x1070c2
movl %ebp, 0xc(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x50(%rsp)
movl %edx, %eax
notl %eax
movl %eax, 0x3c(%rsp)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
subl %edx, %eax
movl %eax, 0x38(%rsp)
leal -0x1(%rdx), %ebp
xorl %ecx, %ecx
movl %r9d, 0x34(%rsp)
cmpq $0x278, %rcx            # imm = 0x278
jae 0x106f44
movzwl (%r12,%rcx,2), %eax
movzwl 0x2(%r12,%rcx,2), %r15d
jmp 0x106f50
movl $0x1, 0x54(%rbx)
xorl %eax, %eax
xorl %r15d, %r15d
cmpq $0x277, %rdx            # imm = 0x277
movq %rcx, 0x58(%rsp)
ja 0x106f68
addl %eax, %r15d
movw %r15w, (%r12,%rdx,2)
jmp 0x106f72
movl $0x1, 0x54(%rbx)
xorl %r15d, %r15d
xorl %r13d, %r13d
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
leal (%rbp,%r13), %ecx
cmpl $0x277, %ecx            # imm = 0x277
ja 0x106f90
movl %ecx, %ecx
movzwl (%r12,%rcx,2), %ecx
jmp 0x106f99
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
decl %r13d
addl $0x2, %eax
cmpw %cx, %r15w
jb 0x106f7a
cmpq $0x277, %rdx            # imm = 0x277
ja 0x107498
movl %r13d, %ecx
notl %ecx
cmpl $0x278, %ecx            # imm = 0x278
ja 0x107498
movq %rdx, 0x18(%rsp)
movl %r13d, %r14d
subl 0x3c(%rsp), %r14d
movl %r13d, %ecx
subl 0x38(%rsp), %ecx
movq %rcx, 0x78(%rsp)
leaq (%r12,%rcx,2), %rdi
movl %r14d, %ecx
movq %rcx, 0x68(%rsp)
leaq (%r12,%rcx,2), %rsi
movl %eax, %edx
movq %rsi, 0x60(%rsp)
movq %rdx, 0x70(%rsp)
callq 0x18270
cmpl $0x277, %r14d           # imm = 0x277
ja 0x107011
movq 0x60(%rsp), %rax
movw %r15w, (%rax)
jmp 0x107018
movl $0x1, 0x54(%rbx)
movq 0x18(%rsp), %rax
cmpq $0x276, %rax            # imm = 0x276
ja 0x107498
cmpl $0xfffffd87, %r13d      # imm = 0xFFFFFD87
je 0x107498
movq (%rsp), %rax
movq 0x78(%rsp), %rcx
leaq (%rax,%rcx,2), %rdi
movq 0x68(%rsp), %rcx
leaq (%rax,%rcx,2), %r15
movq %r15, %rsi
movq 0x70(%rsp), %rdx
callq 0x18270
cmpl $0x276, %r14d           # imm = 0x276
ja 0x10707c
movq 0x58(%rsp), %rcx
movw %cx, (%r15)
movq 0x40(%rsp), %r13
movl 0x34(%rsp), %r9d
movq 0x18(%rsp), %rdx
jmp 0x107097
movl $0x1, 0x54(%rbx)
movq 0x40(%rsp), %r13
movl 0x34(%rsp), %r9d
movq 0x18(%rsp), %rdx
movq 0x58(%rsp), %rcx
addq $0x2, %rcx
incq %rdx
movl 0x3c(%rbx), %eax
decl 0x3c(%rsp)
decl 0x38(%rsp)
incl %ebp
cmpq %rax, %rdx
jb 0x106f2e
movq 0x50(%rsp), %r14
movq 0x20(%rsp), %r15
movl 0xc(%rsp), %ebp
testl %eax, %eax
je 0x107136
movl %eax, %ecx
xorl %edx, %edx
cmpq $0x276, %rdx            # imm = 0x276
ja 0x1070f9
movq (%rsp), %rsi
movzwl (%rsi,%rdx,2), %esi
cmpl %esi, %ecx
jbe 0x107115
cmpl $0x3b2, %esi            # imm = 0x3B2
ja 0x107127
movw %dx, 0x570(%rbx,%rsi,2)
cmpl $0x3b2, %esi            # imm = 0x3B2
jne 0x107109
jmp 0x107127
movl $0x1, 0x54(%rbx)
movw %dx, 0x570(%rbx)
xorl %esi, %esi
movl %esi, %esi
movw %dx, 0x572(%rbx,%rsi,2)
jmp 0x10712e
cmpl $0x3b2, %esi            # imm = 0x3B2
ja 0x107127
movw %dx, 0x570(%rbx,%rsi,2)
jmp 0x10712e
movl $0x1, 0x54(%rbx)
incq %rdx
cmpq %rdx, %rcx
jne 0x1070ca
cmpl $0x0, 0x54(%rbx)
movq 0x10(%rsp), %rcx
je 0x107150
jmp 0x106cad
movl $0x1, 0x54(%rbx)
movl %r9d, %eax
subl %r9d, %ecx
movq %rcx, 0x10(%rsp)
addl %eax, %ecx
cmpl $0x3b2, %ecx            # imm = 0x3B2
ja 0x10716e
movl %ecx, %ecx
movzwl 0x570(%rbx,%rcx,2), %edx
jmp 0x107177
movl $0x1, 0x54(%rbx)
xorl %edx, %edx
xorl %ecx, %ecx
cmpl $0x3b4, %ecx            # imm = 0x3B4
je 0x10748c
movzwl %dx, %esi
movzwl %si, %edi
cmpl $0x278, %edi            # imm = 0x278
jae 0x1071b9
movzwl (%r12,%rdi,2), %r8d
incl %r8d
movw %r8w, (%r12,%rdi,2)
movl $0x278, %r9d            # imm = 0x278
cmpl $0x277, %edi            # imm = 0x277
je 0x1071c0
leal 0x1(%rsi), %r9d
movzwl (%r12,%r9,2), %r10d
jmp 0x1071ca
leal 0x1(%rsi), %r9d
xorl %r8d, %r8d
movl $0x1, 0x54(%rbx)
xorl %r10d, %r10d
cmpw %r10w, %r8w
jbe 0x107322
decl %r9d
movl %r9d, %esi
leal 0x2(%rsi), %r9d
cmpl $0x277, %r9d            # imm = 0x277
ja 0x1071f1
movl %r9d, %r9d
movzwl (%r12,%r9,2), %r9d
jmp 0x1071fb
movl $0x1, 0x54(%rbx)
xorl %r9d, %r9d
incl %esi
cmpw %r9w, %r8w
ja 0x1071da
movl %esi, %r9d
cmpl $0x277, %esi            # imm = 0x277
ja 0x107215
movzwl (%r12,%r9,2), %r10d
jmp 0x10721f
movl $0x1, 0x54(%rbx)
xorl %r10d, %r10d
cmpl $0x277, %edi            # imm = 0x277
ja 0x10722e
movw %r10w, (%r12,%rdi,2)
jmp 0x107235
movl $0x1, 0x54(%rbx)
cmpl $0x277, %esi            # imm = 0x277
ja 0x107244
movw %r8w, (%r12,%r9,2)
jmp 0x10724b
movl $0x1, 0x54(%rbx)
cmpl $0x277, %edi            # imm = 0x277
jae 0x10726e
movq (%rsp), %r8
movzwl (%r8,%rdi,2), %r8d
cmpl $0x3b2, %r8d            # imm = 0x3B2
jbe 0x107278
movl $0x1, 0x54(%rbx)
jmp 0x107284
movl $0x1, 0x54(%rbx)
xorl %r8d, %r8d
movl %r8d, %r10d
movw %si, 0x570(%rbx,%r10,2)
cmpl %r8d, %eax
jbe 0x1072a7
cmpl $0x3b1, %r8d            # imm = 0x3B1
ja 0x1072a0
movl %r8d, %r10d
movw %si, 0x572(%rbx,%r10,2)
jmp 0x1072a7
movl $0x1, 0x54(%rbx)
cmpl $0x277, %esi            # imm = 0x277
jae 0x1072cf
movq (%rsp), %r11
movzwl (%r11,%r9,2), %r10d
movw %r8w, (%r11,%r9,2)
cmpl $0x3b2, %r10d           # imm = 0x3B2
jbe 0x1072d9
movl $0x1, 0x54(%rbx)
jmp 0x1072e5
movl $0x1, 0x54(%rbx)
xorl %r10d, %r10d
movl %r10d, %r8d
movw %dx, 0x570(%rbx,%r8,2)
cmpl %r10d, %eax
jbe 0x107308
cmpl $0x3b1, %r10d           # imm = 0x3B1
ja 0x107301
movl %r10d, %r8d
movw %dx, 0x572(%rbx,%r8,2)
jmp 0x107308
movl $0x1, 0x54(%rbx)
cmpl $0x276, %edi            # imm = 0x276
ja 0x10731b
movq (%rsp), %rdx
movw %r10w, (%rdx,%rdi,2)
jmp 0x107322
movl $0x1, 0x54(%rbx)
cmpl $0x3b2, %esi            # imm = 0x3B2
ja 0x10748c
incl %ecx
movl %esi, %edx
movzwl 0x570(%rbx,%rdx,2), %edx
testw %dx, %dx
jne 0x107179
cmpl $0x0, 0x54(%rbx)
jne 0x106cad
movq 0x10(%rsp), %rax
cmpl $0x100, %eax            # imm = 0x100
jne 0x107364
cmpl $0x0, 0x44(%rbx)
je 0x10739f
jmp 0x1074ba
jae 0x10739f
movq (%rbx), %rdi
cmpl $0x4, (%rdi)
jl 0x10738e
leaq 0x44f2b(%rip), %rsi     # 0x14c2a0
leaq 0x80(%rsp), %rdx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%rsp), %rax
movq 0x68(%rbx), %rdi
movzbl %al, %esi
callq 0xfae4e
jmp 0x10747d
movl %ebp, 0xc(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, %r13
cmpl $0x8, 0x74(%rbx)
jb 0x1074a6
movq 0x28(%rsp), %rdi
movl $0x8, %esi
callq 0xf1b93
cmpl $0x0, 0x54(%rbx)
jne 0x1074ad
movq %rax, %rbp
movl %ebp, %edi
leaq 0x4c(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x10674c
movl 0x48(%rsp), %r15d
subl 0x4c(%rbx), %r15d
cmpl %r15d, 0x74(%rbx)
jb 0x1074a6
movl 0x4c(%rsp), %r14d
movl 0x48(%rbx), %eax
movl %eax, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movl %r15d, %esi
callq 0xf1b93
cmpl $0x0, 0x54(%rbx)
jne 0x1074ad
movl %r15d, %ecx
shll %cl, %ebp
orl %eax, %ebp
movl 0x18(%rsp), %ecx
shll %cl, %r14d
andl 0x50(%rbx), %ebp
orl %r14d, %ebp
movq (%rbx), %rdi
movq 0x10(%rsp), %r14
subl 0x34(%rbx), %r14d
cmpl $0x4, (%rdi)
jl 0x107459
leal 0x1(%rbp), %ecx
leaq 0x44e65(%rip), %rsi     # 0x14c2ac
leaq 0x80(%rsp), %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe8617
movq 0x68(%rbx), %rdi
notl %ebp
addl 0x10(%rdi), %ebp
movl %ebp, %esi
movl %r14d, %edx
callq 0xfae7b
movq %r13, %r14
movq 0x20(%rsp), %r15
movl 0xc(%rsp), %ebp
movq 0x40(%rsp), %r13
cmpl $0x0, 0x54(%rbx)
je 0x106d13
jmp 0x106cad
movl $0x1, 0x54(%rbx)
jmp 0x106cad
movl $0x1, 0x54(%rbx)
movq 0x50(%rsp), %r14
jmp 0x1074b0
movl $0x1, 0x54(%rbx)
movq %r13, %r14
movq 0x20(%rsp), %r15
jmp 0x106cad
movq (%rbx), %rdi
cmpl $0x4, (%rdi)
jl 0x1074dd
leaq 0x44dc7(%rip), %rsi     # 0x14c290
leaq 0x80(%rsp), %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rax
movb $0x1, 0x20(%rax)
jmp 0x106cad