// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rdi, %rbx
movb $0x0, 0x80(%rsp)
movq 0x18(%rdi), %rax
cmpb $0x0, 0x20(%rax)
jne 0x107171
cmpl $0x0, 0x54(%rbx)
je 0x1071b2
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
cmpb $0x0, 0x20(%rax)
jne 0x1071a0
cmpq %r13, %r14
jge 0x1071a0
cmpl $0x0, 0x54(%rbx)
jne 0x1071a0
movq (%rax), %rdi
movq 0x8(%rbx), %rdx
movq 0x28(%rbx), %rsi
callq 0xfa815
movl $0x1, 0x54(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r15
movl %ecx, 0x44(%rsp)
leaq 0x70(%rbx), %r12
leaq 0x80(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0xcd6(%rbx), %rax
movq %rax, 0x60(%rsp)
xorl %r14d, %r14d
movq %rsi, 0x30(%rsp)
movq %r12, 0x18(%rsp)
movq 0x20(%rbx), %rax
cmpb $0x0, 0x8(%rax)
je 0x1071fa
movq 0x60(%rbx), %rcx
cmpq 0x10(%rax), %rcx
jge 0x107a23
cmpq %r13, %r14
jge 0x107221
cmpl $0x38, 0x74(%rbx)
ja 0x107221
movzbl (%r15,%r14), %esi
incq %r14
movq %r12, %rdi
callq 0xf21e9
incq 0x58(%rbx)
cmpq %r14, %r13
jne 0x1071ff
movq %r13, %r14
cmpl $0x0, 0x44(%rsp)
jne 0x107232
cmpl $0x39, 0x74(%rbx)
jb 0x107174
movq (%rbx), %rax
cmpl $0x4, (%rax)
jl 0x10725b
movq 0x18(%rbx), %rax
movq 0x58(%rbx), %rsi
addq 0x18(%rax), %rsi
movl $0x20, %ecx
movq %r12, %rdi
leaq 0x80(%rsp), %rdx
callq 0xf230b
movl 0x40(%rbx), %eax
cmpq $0x276, %rax            # imm = 0x276
ja 0x107270
movzwl 0xcd6(%rbx,%rax,2), %ebp
jmp 0x107279
movl $0x1, 0x54(%rbx)
xorl %ebp, %ebp
movl 0x3c(%rbx), %eax
cmpl %ebp, %eax
movq %r14, 0x28(%rsp)
jbe 0x1072d2
cmpl $0x0, 0x74(%rbx)
je 0x10729a
movq %r12, %rdi
movl $0x1, %esi
callq 0xf221e
jmp 0x1072a3
movl $0x1, 0x54(%rbx)
xorl %eax, %eax
cmpl $0x0, 0x54(%rbx)
jne 0x107629
addl %ebp, %eax
cmpl $0x276, %eax            # imm = 0x276
ja 0x1072c2
movl %eax, %eax
movzwl 0xcd6(%rbx,%rax,2), %ebp
jmp 0x1072cb
movl $0x1, 0x54(%rbx)
xorl %ebp, %ebp
movl 0x3c(%rbx), %eax
cmpl %ebp, %eax
ja 0x107285
movl 0x40(%rbx), %ecx
cmpq $0x277, %rcx            # imm = 0x277
ja 0x1072e8
movzwl 0x80(%rbx,%rcx,2), %ecx
jmp 0x1072f1
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
subl %eax, %ebp
movzwl %cx, %edx
cmpl $0x8000, %edx           # imm = 0x8000
jbe 0x10730a
movl $0x1, 0x54(%rbx)
jmp 0x1078af
negw %cx
jno 0x10765a
testl %eax, %eax
je 0x1073c7
movl %eax, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpq $0x276, %rdx            # imm = 0x276
ja 0x107334
movzwl 0xcd6(%rbx,%rdx,2), %edi
jmp 0x10733d
movl $0x1, 0x54(%rbx)
xorl %edi, %edi
cmpl %edi, %eax
ja 0x1073bb
cmpq $0x277, %rdx            # imm = 0x277
ja 0x10735b
movzwl 0x80(%rbx,%rdx,2), %r8d
incl %r8d
shrl %r8d
jmp 0x107365
movl $0x1, 0x54(%rbx)
xorl %r8d, %r8d
movl %esi, %edi
cmpl $0x277, %esi            # imm = 0x277
ja 0x10737a
movw %r8w, 0x80(%rbx,%rdi,2)
jmp 0x107381
movl $0x1, 0x54(%rbx)
cmpq $0x276, %rdx            # imm = 0x276
ja 0x107395
movzwl 0xcd6(%rbx,%rdx,2), %r8d
jmp 0x10739f
movl $0x1, 0x54(%rbx)
xorl %r8d, %r8d
cmpl $0x276, %esi            # imm = 0x276
ja 0x1073b2
movw %r8w, 0xcd6(%rbx,%rdi,2)
jmp 0x1073b9
movl $0x1, 0x54(%rbx)
incl %esi
incq %rdx
cmpq %rdx, %rcx
jne 0x107321
movl 0x38(%rbx), %esi
cmpl %eax, %esi
jae 0x1075a9
movq %r13, 0x50(%rsp)
movl %esi, %eax
notl %eax
movl %eax, 0x14(%rsp)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
subl %esi, %eax
movl %eax, 0x10(%rsp)
leal -0x1(%rsi), %r13d
xorl %ecx, %ecx
movq %rbp, 0x20(%rsp)
cmpq $0x277, %rcx            # imm = 0x277
ja 0x107409
movq 0x38(%rsp), %rdx
movzwl (%rdx,%rcx,2), %eax
jmp 0x107417
movl $0x1, 0x54(%rbx)
xorl %eax, %eax
movq 0x38(%rsp), %rdx
cmpq $0x277, %rcx            # imm = 0x277
movq %rcx, 0x58(%rsp)
ja 0x10742f
orq $0x1, %rcx
movzwl (%rdx,%rcx,2), %ecx
jmp 0x107438
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
cmpq $0x277, %rsi            # imm = 0x277
ja 0x107449
addl %eax, %ecx
movw %cx, (%rdx,%rsi,2)
jmp 0x107450
movl $0x1, 0x54(%rbx)
cmpq $0x277, %rsi            # imm = 0x277
ja 0x10745f
movzwl (%rdx,%rsi,2), %ebp
jmp 0x107468
movl $0x1, 0x54(%rbx)
xorl %ebp, %ebp
xorl %r15d, %r15d
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
leal (%r15,%r13), %ecx
cmpl $0x277, %ecx            # imm = 0x277
ja 0x107484
movl %ecx, %ecx
movzwl (%rdx,%rcx,2), %ecx
jmp 0x10748d
movl $0x1, 0x54(%rbx)
xorl %ecx, %ecx
decl %r15d
addl $0x2, %eax
cmpw %cx, %bp
jb 0x107470
cmpq $0x277, %rsi            # imm = 0x277
ja 0x107630
movl %r15d, %ecx
notl %ecx
cmpl $0x278, %ecx            # imm = 0x278
ja 0x107630
movq %rsi, 0x8(%rsp)
movl %r15d, %r12d
subl 0x14(%rsp), %r12d
movl %r15d, %r14d
subl 0x10(%rsp), %r14d
movq 0x38(%rsp), %rcx
leaq (%rcx,%r14,2), %rdi
movl %r12d, %edx
movq %rdx, 0x70(%rsp)
leaq (%rcx,%rdx,2), %rsi
movl %eax, %edx
movq %rsi, 0x68(%rsp)
movq %rdx, 0x78(%rsp)
callq 0x18270
cmpl $0x277, %r12d           # imm = 0x277
ja 0x107504
movq 0x68(%rsp), %rax
movw %bp, (%rax)
jmp 0x10750b
movl $0x1, 0x54(%rbx)
movq 0x8(%rsp), %rax
cmpq $0x276, %rax            # imm = 0x276
ja 0x107630
cmpl $0xfffffd87, %r15d      # imm = 0xFFFFFD87
je 0x107630
movq 0x60(%rsp), %rax
leaq (%rax,%r14,2), %rdi
movq 0x70(%rsp), %rcx
leaq (%rax,%rcx,2), %r14
movq %r14, %rsi
movq 0x78(%rsp), %rdx
callq 0x18270
cmpl $0x276, %r12d           # imm = 0x276
ja 0x107561
movq 0x58(%rsp), %rcx
movw %cx, (%r14)
movq 0x8(%rsp), %rsi
jmp 0x107572
movl $0x1, 0x54(%rbx)
movq 0x8(%rsp), %rsi
movq 0x58(%rsp), %rcx
addq $0x2, %rcx
incq %rsi
movl 0x3c(%rbx), %eax
decl 0x14(%rsp)
decl 0x10(%rsp)
incl %r13d
cmpq %rax, %rsi
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rbp
jb 0x1073f5
movq 0x50(%rsp), %r13
testl %eax, %eax
je 0x107650
movl %eax, %eax
xorl %ecx, %ecx
cmpq $0x276, %rcx            # imm = 0x276
ja 0x1075c8
movzwl 0xcd6(%rbx,%rcx,2), %edx
jmp 0x1075d1
movl $0x1, 0x54(%rbx)
xorl %edx, %edx
cmpl %edx, %eax
jbe 0x1075e9
cmpl $0x3b2, %edx            # imm = 0x3B2
ja 0x1075fd
movl %edx, %esi
movw %cx, 0x570(%rbx,%rsi,2)
jmp 0x107604
cmpl $0x3b2, %edx            # imm = 0x3B2
ja 0x107618
movl %edx, %edx
movw %cx, 0x570(%rbx,%rdx,2)
jmp 0x10761f
movl $0x1, 0x54(%rbx)
cmpl $0x3b1, %edx            # imm = 0x3B1
ja 0x107618
movl %edx, %edx
movw %cx, 0x572(%rbx,%rdx,2)
jmp 0x10761f
movl $0x1, 0x54(%rbx)
incq %rcx
cmpq %rcx, %rax
jne 0x1075b5
jmp 0x107650
xorl %ebp, %ebp
jmp 0x1078af
movl $0x1, 0x54(%rbx)
movq 0x50(%rsp), %r13
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rbp
cmpl $0x0, 0x54(%rbx)
jne 0x1078af
movl 0x3c(%rbx), %eax
leal (%rax,%rbp), %ecx
cmpl $0x3b2, %ecx            # imm = 0x3B2
ja 0x107674
movl %ecx, %ecx
movzwl 0x570(%rbx,%rcx,2), %edx
jmp 0x10767d
movl $0x1, 0x54(%rbx)
xorl %edx, %edx
xorl %ecx, %ecx
cmpl $0x3b4, %ecx            # imm = 0x3B4
je 0x1072fe
movzwl %dx, %esi
cmpl $0x277, %esi            # imm = 0x277
ja 0x1076a2
movzwl 0x80(%rbx,%rsi,2), %edi
incl %edi
jmp 0x1076ad
movl $0x1, 0x54(%rbx)
movw $0x1, %di
cmpl $0x277, %esi            # imm = 0x277
ja 0x1076bf
movw %di, 0x80(%rbx,%rsi,2)
jmp 0x1076c6
movl $0x1, 0x54(%rbx)
cmpl $0x277, %esi            # imm = 0x277
ja 0x1076d9
movzwl 0x80(%rbx,%rsi,2), %r9d
jmp 0x1076e3
movl $0x1, 0x54(%rbx)
xorl %r9d, %r9d
movzwl %si, %edi
cmpl $0x276, %esi            # imm = 0x276
ja 0x107700
leal 0x1(%rdi), %r8d
movl %r8d, %r8d
movzwl 0x80(%rbx,%r8,2), %r8d
jmp 0x10770a
movl $0x1, 0x54(%rbx)
xorl %r8d, %r8d
cmpw %r8w, %r9w
jbe 0x107887
leal 0x2(%rdi), %r8d
cmpl $0x277, %r8d            # imm = 0x277
ja 0x10772f
movl %r8d, %r8d
movzwl 0x80(%rbx,%r8,2), %r8d
jmp 0x107739
movl $0x1, 0x54(%rbx)
xorl %r8d, %r8d
incl %edi
cmpw %r8w, %r9w
ja 0x107714
movl %edi, %r8d
cmpl $0x277, %edi            # imm = 0x277
ja 0x107757
movzwl 0x80(%rbx,%r8,2), %r10d
jmp 0x107761
movl $0x1, 0x54(%rbx)
xorl %r10d, %r10d
cmpl $0x277, %esi            # imm = 0x277
ja 0x107774
movw %r10w, 0x80(%rbx,%rsi,2)
jmp 0x10777b
movl $0x1, 0x54(%rbx)
cmpl $0x277, %edi            # imm = 0x277
ja 0x10778e
movw %r9w, 0x80(%rbx,%r8,2)
jmp 0x107795
movl $0x1, 0x54(%rbx)
cmpl $0x276, %esi            # imm = 0x276
ja 0x1077a8
movzwl 0xcd6(%rbx,%rsi,2), %r9d
jmp 0x1077b2
movl $0x1, 0x54(%rbx)
xorl %r9d, %r9d
movzwl %r9w, %r10d
cmpl $0x3b2, %r10d           # imm = 0x3B2
ja 0x1077ca
movw %di, 0x570(%rbx,%r10,2)
jmp 0x1077d1
movl $0x1, 0x54(%rbx)
cmpl %r10d, %eax
jbe 0x1077f4
cmpl $0x3b1, %r10d           # imm = 0x3B1
ja 0x1077ed
movl %r10d, %r10d
movw %di, 0x572(%rbx,%r10,2)
jmp 0x1077f4
movl $0x1, 0x54(%rbx)
cmpl $0x276, %edi            # imm = 0x276
ja 0x107807
movzwl 0xcd6(%rbx,%r8,2), %r10d
jmp 0x107811
movl $0x1, 0x54(%rbx)
xorl %r10d, %r10d
cmpl $0x276, %edi            # imm = 0x276
ja 0x107824
movw %r9w, 0xcd6(%rbx,%r8,2)
jmp 0x10782b
movl $0x1, 0x54(%rbx)
movzwl %r10w, %r8d
cmpl $0x3b2, %r8d            # imm = 0x3B2
ja 0x107843
movw %dx, 0x570(%rbx,%r8,2)
jmp 0x10784a
movl $0x1, 0x54(%rbx)
cmpl %r8d, %eax
jbe 0x10786d
cmpl $0x3b1, %r8d            # imm = 0x3B1
ja 0x107866
movl %r8d, %r8d
movw %dx, 0x572(%rbx,%r8,2)
jmp 0x10786d
movl $0x1, 0x54(%rbx)
cmpl $0x276, %esi            # imm = 0x276
ja 0x107880
movw %r10w, 0xcd6(%rbx,%rsi,2)
jmp 0x107887
movl $0x1, 0x54(%rbx)
cmpl $0x3b2, %edi            # imm = 0x3B2
ja 0x10789b
movl %edi, %edx
movzwl 0x570(%rbx,%rdx,2), %edx
jmp 0x1078a4
movl $0x1, 0x54(%rbx)
xorl %edx, %edx
incl %ecx
testw %dx, %dx
jne 0x10767f
cmpl $0x0, 0x54(%rbx)
jne 0x107174
cmpl $0x100, %ebp            # imm = 0x100
jne 0x1078cb
cmpl $0x0, 0x44(%rbx)
jne 0x107a00
cmpl $0xff, %ebp
ja 0x107905
movq (%rbx), %rdi
cmpl $0x4, (%rdi)
jl 0x1078f3
leaq 0x4439e(%rip), %rsi     # 0x14bc80
leaq 0x80(%rsp), %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x68(%rbx), %rdi
movzbl %bpl, %esi
callq 0xfb382
jmp 0x1079f1
cmpl $0x7, 0x74(%rbx)
movq %rbp, 0x20(%rsp)
ja 0x10791c
movl $0x1, 0x54(%rbx)
xorl %r15d, %r15d
jmp 0x10792c
movq %r12, %rdi
movl $0x8, %esi
callq 0xf221e
movq %rax, %r15
xorl %ebp, %ebp
cmpl $0x0, 0x54(%rbx)
jne 0x107998
movl %r15d, %edi
leaq 0x4c(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x106bfc
movl 0x4c(%rsp), %esi
movl 0x48(%rbx), %r12d
movl 0x48(%rsp), %r14d
subl 0x4c(%rbx), %r14d
cmpl %r14d, 0x74(%rbx)
jae 0x107968
movl $0x1, 0x54(%rbx)
xorl %eax, %eax
jmp 0x10797d
movq 0x18(%rsp), %rdi
movl %esi, 0x8(%rsp)
movl %r14d, %esi
callq 0xf221e
movl 0x8(%rsp), %esi
cmpl $0x0, 0x54(%rbx)
jne 0x107998
movl %r14d, %ecx
shll %cl, %r15d
orl %r15d, %eax
movl %r12d, %ecx
shll %cl, %esi
andl 0x50(%rbx), %eax
orl %esi, %eax
movl %eax, %ebp
cmpl $0x0, 0x54(%rbx)
jne 0x107a30
movq (%rbx), %rdi
movq 0x20(%rsp), %r15
subl 0x34(%rbx), %r15d
cmpl $0x4, (%rdi)
movq 0x28(%rsp), %r14
movq 0x18(%rsp), %r12
jl 0x1079d9
leal 0x1(%rbp), %ecx
leaq 0x442c5(%rip), %rsi     # 0x14bc8c
leaq 0x80(%rsp), %rdx
movl %r15d, %r8d
xorl %eax, %eax
callq 0xe9226
movq 0x68(%rbx), %rdi
notl %ebp
addl 0x10(%rdi), %ebp
movl %ebp, %esi
movl %r15d, %edx
callq 0xfb3af
movq 0x30(%rsp), %r15
cmpl $0x0, 0x54(%rbx)
je 0x1071e2
jmp 0x107174
movq (%rbx), %rdi
cmpl $0x4, (%rdi)
jl 0x107a23
leaq 0x44261(%rip), %rsi     # 0x14bc70
leaq 0x80(%rsp), %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rax
movb $0x1, 0x20(%rax)
jmp 0x107174
movq 0x28(%rsp), %r14
jmp 0x107174