// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/fmtutil-lzh.c
// Function: fmtutil_distilled_codectype1
void fmtutil_distilled_codectype1(deark *c, struct de_dfilter_in_params *dcmpri,
	struct de_dfilter_out_params *dcmpro, struct de_dfilter_results *dres,
	void *codec_private_params)
{
	struct lzh_ctx *cctx = NULL;
	char pos_descr[32];

	cctx = de_malloc(c, sizeof(struct lzh_ctx));
	cctx->modname = "distilled";
	cctx->c = c;
	cctx->dcmpri = dcmpri;
	cctx->dcmpro = dcmpro;
	cctx->dres = dres;

	cctx->bitrd.bbll.is_lsb = 1;
	cctx->bitrd.f = dcmpri->f;
	cctx->bitrd.curpos = dcmpri->pos;
	cctx->bitrd.endpos = dcmpri->pos + dcmpri->len;

	cctx->ringbuf = de_lz77buffer_create(cctx->c, 8192);
	cctx->ringbuf->userdata = (void*)cctx;
	cctx->ringbuf->writebyte_cb = lzh_lz77buf_writebytecb;
	de_lz77buffer_clear(cctx->ringbuf, 0x20);

	distilled_read_nodetable(c, cctx);
	if(cctx->err_flag) goto done;

	distilled_make_offsets_tree(c, cctx);

	de_bitreader_describe_curpos(&cctx->bitrd, pos_descr, sizeof(pos_descr));
	de_dbg2(c, "cmpr data codes at %s", pos_descr);
	de_dbg_indent(c, 1);
	distilled_main(c, cctx);
	de_dbg_indent(c, -1);

	de_bitreader_skip_to_byte_boundary(&cctx->bitrd);
	cctx->dres->bytes_consumed = cctx->bitrd.curpos - cctx->dcmpri->pos;
	if(cctx->dres->bytes_consumed<0) {
		cctx->dres->bytes_consumed = 0;
	}
	cctx->dres->bytes_consumed_valid = 1;

done:
	if(cctx) {
		if(cctx->err_flag) {
			de_dfilter_set_generic_error(c, dres, cctx->modname);
		}
		destroy_lzh_ctx(cctx);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
movl $0xd0, %esi
callq 0xdecaf
movq %rax, %rbp
leaq 0x12ba6(%rip), %rax     # 0x1079cd
movq %rax, 0x20(%rbp)
movq %r15, (%rbp)
movq %r12, 0x8(%rbp)
movq %rbx, 0x10(%rbp)
movq %r14, 0x18(%rbp)
leaq 0x38(%rbp), %rbx
movb $0x1, 0x58(%rbp)
movq (%r12), %rax
movq %rax, 0x38(%rbp)
movq 0x8(%r12), %rax
movq %rax, 0x40(%rbp)
addq 0x10(%r12), %rax
movq %rax, 0x48(%rbp)
movq %r15, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0xef27c
movq %rax, 0x70(%rbp)
movq %rbp, (%rax)
leaq 0x41b(%rip), %rcx       # 0xf5293
movq %rcx, 0x8(%rax)
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0xef2e9
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0xdebae
movl $0xa30, %esi            # imm = 0xA30
movq %r15, %rdi
callq 0xdecaf
movq %rax, %r13
movq %r15, (%rax)
leaq 0x4954d(%rip), %rsi     # 0x13e3fb
movq %r15, %rdi
xorl %eax, %eax
callq 0xde9f1
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0xe6a4a
movl %eax, 0x8(%r13)
leaq 0x4952f(%rip), %rsi     # 0x13e408
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde9f1
movl 0x8(%r13), %r12d
leal -0x2(%r12), %eax
cmpl $0x273, %eax            # imm = 0x273
setb %al
testb $0x1, %r12b
sete %cl
testb %cl, %al
movq %rbx, 0x8(%rsp)
je 0xf4f37
movq %rbp, (%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0xe6a4a
movq %rax, %rbx
leaq 0x494f8(%rip), %rsi     # 0x13e417
movq %r15, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0xde9f1
leal -0xd(%rbx), %eax
cmpl $-0xd, %eax
ja 0xf4f43
movq (%rsp), %rbp
movl $0x1, 0x30(%rbp)
jmp 0xf5009
shrl %r12d
incq %r12
movq %r12, 0x10(%rsp)
leaq 0x494cf(%rip), %rsi     # 0x13e424
movq %r15, %rdi
xorl %eax, %eax
callq 0xde9f1
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
leaq 0x494c8(%rip), %r12     # 0x13e439
xorl %ebp, %ebp
movl 0x8(%r13), %eax
cmpq %rax, %rbp
movq 0x8(%rsp), %rdi
jae 0xf4fa4
movl %ebx, %esi
callq 0xe6a4a
movw %ax, 0x1a(%r13,%rbp,4)
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde9f1
incq %rbp
jmp 0xf4f73
pushq $-0x1
popq %rbx
movq %r15, %rdi
movl %ebx, %esi
callq 0xdeba7
movq %r15, %rdi
movl %ebx, %esi
callq 0xdeba7
leaq 0x49485(%rip), %rsi     # 0x13e447
movq %r15, %rdi
xorl %eax, %eax
callq 0xdea83
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
movq %r15, %rdi
movq 0x10(%rsp), %rdx
movq %rdx, %rsi
callq 0xf8601
movq (%rsp), %rbp
movq %rax, 0x98(%rbp)
movq %rax, 0x10(%r13)
movl 0x8(%r13), %esi
addl $-0x2, %esi
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf61e3
movq %r15, %rdi
movq %r13, %rsi
callq 0xded32
movl 0x30(%rsp), %esi
movq %r15, %rdi
callq 0xdebb7
cmpl $0x0, 0x30(%rbp)
movq %rbp, %r13
jne 0xf526d
movq %r14, 0x20(%rsp)
pushq $0x40
popq %rdx
movq %r15, %rdi
movq %rdx, %rsi
callq 0xf8601
leaq 0xa0(%r13), %rcx
movq %rcx, 0x10(%rsp)
movq %r13, (%rsp)
movq %rax, 0xa0(%r13)
leaq 0x49409(%rip), %rsi     # 0x13e467
movq %r15, %rdi
xorl %eax, %eax
callq 0xdea83
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
pushq $0x3
popq %r14
leaq 0x49572(%rip), %r13     # 0x13e5f0
xorl %ebx, %ebx
movl %r14d, %ebp
testq %rbx, %rbx
je 0xf50b3
cmpq $0x40, %rbx
je 0xf510a
pushq $0x4
popq %rbp
cmpq $0x4, %rbx
jb 0xf50b3
pushq $0x5
popq %rbp
cmpq $0xc, %rbx
jb 0xf50b3
pushq $0x6
popq %rbp
cmpq $0x18, %rbx
jb 0xf50b3
cmpq $0x30, %rbx
pushq $0x8
popq %rbp
sbbl $0x0, %ebp
movzbl (%rbx,%r13), %r12d
cmpl $0x2, (%r15)
jle 0xf50e6
leaq 0x30(%rsp), %rdi
pushq $0x48
popq %rsi
movq %r12, %rdx
movl %ebp, %ecx
callq 0xdfc03
movq %r15, %rdi
leaq 0x1c2b6(%rip), %rsi     # 0x111390
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0xdea83
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
movq %r12, %rdx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0xf7e56
incq %rbx
jmp 0xf5080
pushq $-0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
leaq 0x30(%rsp), %rbx
pushq $0x20
popq %rdx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xe6b25
leaq 0x1bfe7(%rip), %rsi     # 0x111118
xorl %r12d, %r12d
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xde9f1
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq (%rsp), %r13
movq %r13, %rbx
addq $0x98, %rbx
pushq $0x1
popq %r14
movq %rbx, 0x28(%rsp)
cmpb $0x0, 0x50(%r13)
jne 0xf522b
movq %r13, %rdi
callq 0xf5ddd
testl %eax, %eax
je 0xf5187
testl %r12d, %r12d
pushq $0x1
popq %r12
jne 0xf522b
movq %r13, %rdi
movq %rbx, %rsi
callq 0xf5df8
movl %eax, %ebp
cmpl $0xff, %eax
ja 0xf51aa
movq 0x70(%r13), %rdi
movzbl %bpl, %esi
callq 0xef336
jmp 0xf5163
cmpl $0x100, %ebp            # imm = 0x100
je 0xf522b
movl %r12d, 0x1c(%rsp)
addl $0xffffff02, %ebp       # imm = 0xFFFFFF02
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0xf5df8
movl %eax, %r12d
movq 0x28(%r13), %rax
addq $0x3c, %rax
pushq $0x7
popq %rcx
movl %ecx, %ebx
movq 0x8(%rsp), %rdi
leal 0x5(%rbx), %ecx
cmpl $0x6, %ecx
jb 0xf51f6
movq %r14, %rdx
shlq %cl, %rdx
cmpq %rdx, %rax
jge 0xf51f8
decl %ebx
jmp 0xf51df
xorl %ebx, %ebx
movl %ebx, %esi
callq 0xe6a4a
movl %ebx, %ecx
shll %cl, %r12d
orl %eax, %r12d
movq 0x70(%r13), %rdi
notl %r12d
addl 0x10(%rdi), %r12d
movl %r12d, %esi
movl %ebp, %edx
callq 0xef363
movl 0x1c(%rsp), %r12d
movq 0x28(%rsp), %rbx
jmp 0xf5163
pushq $-0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
movq 0x8(%rsp), %rdi
callq 0xe6abe
movq 0x40(%r13), %rax
movq 0x8(%r13), %rcx
movq 0x18(%r13), %rdx
subq 0x8(%rcx), %rax
xorl %ecx, %ecx
testq %rax, %rax
cmovgq %rax, %rcx
movq %rcx, 0x8(%rdx)
movb $0x1, 0x4(%rdx)
cmpl $0x0, 0x30(%r13)
movq 0x20(%rsp), %r14
je 0xf527c
movq 0x20(%r13), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xee91c
movq %r13, %rdi
callq 0xf3885
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq