// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pack.c
// Function: decode_file_data
static void decode_file_data(deark *c, lctx *d, i64 pos1, dbuf *outf)
{
	i64 ncodes_expected;
	i64 i;

	de_dbg(c, "compressed data at %"I64_FMT, pos1);

	d->bitrd.f = c->infile;
	d->bitrd.curpos = pos1;
	d->bitrd.endpos = c->infile->len;
	d->bitrd.bbll.is_lsb = 0;
	de_bitbuf_lowlevel_empty(&d->bitrd.bbll);

	ncodes_expected = d->unc_size + 1;

	for(i=0; i<ncodes_expected; i++) {
		int ret;
		fmtutil_huffman_valtype val = 0;

		ret = fmtutil_huffman_read_next_value(d->ht->bk, &d->bitrd, &val, NULL);
		if(ret && c->debug_level>=3) {
			de_dbg3(c, "val: %d", (int)val);
		}

		if(i==ncodes_expected-1) { // Expecting the EOF code at this position
			if(!ret || val!=PCK_EOF_CODE) {
				de_warn(c, "EOF code not found. Decompression might have failed.");
			}
			goto done;
		}

		if(!ret) {
			if(d->bitrd.eof_flag) {
				de_err(c, "Unexpected end of file");
			}
			else {
				de_err(c, "Huffman decode error");
			}
			goto done;
		}

		if(val==PCK_EOF_CODE) {
			de_err(c, "Unexpected EOF code");
			goto done;
		}

		dbuf_writebyte(outf, (u8)val);
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0xac60c(%rip), %rsi     # 0x1bdbe3
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
addq $0x20, %rdi
callq 0x16a360
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0x11173e
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x187bc0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x11169b
movq -0x8(%rbp), %rax
cmpl $0x3, (%rax)
jl 0x11169b
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %edx
leaq 0xa518a(%rip), %rsi     # 0x1b681e
movb $0x0, %al
callq 0x15b400
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x1116cc
cmpl $0x0, -0x34(%rbp)
je 0x1116b8
cmpl $-0x1, -0x38(%rbp)
je 0x1116ca
movq -0x8(%rbp), %rdi
leaq 0xb24c0(%rip), %rsi     # 0x1c3b83
movb $0x0, %al
callq 0x15bc10
jmp 0x111740
cmpl $0x0, -0x34(%rbp)
jne 0x111704
movq -0x10(%rbp), %rax
cmpb $0x0, 0x30(%rax)
je 0x1116f0
movq -0x8(%rbp), %rdi
leaq 0x8d6d8(%rip), %rsi     # 0x19edbf
movb $0x0, %al
callq 0x15bfb0
jmp 0x111702
movq -0x8(%rbp), %rdi
leaq 0xb24bd(%rip), %rsi     # 0x1c3bb8
movb $0x0, %al
callq 0x15bfb0
jmp 0x111740
cmpl $-0x1, -0x38(%rbp)
jne 0x11171e
movq -0x8(%rbp), %rdi
leaq 0xb24b8(%rip), %rsi     # 0x1c3bcd
movb $0x0, %al
callq 0x15bfb0
jmp 0x111740
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %eax
movzbl %al, %esi
callq 0x168380
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x11163e
jmp 0x111740
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)