// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/hlp.c
// Function: de_run_hlp
static void de_run_hlp(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;

	d = de_malloc(c, sizeof(lctx));

	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);
	d->extract_text = de_get_ext_option_bool(c, "hlp:extracttext",
		((c->extract_level>=2)?1:0));
	d->extract_raw_streams = (u8)de_get_ext_option_bool(c, "hlp:extractstreams", 0);
	d->tmpdbuf1 = dbuf_create_membuf(c, 0, 0);
	d->unc_linkdata2_dbuf = dbuf_create_membuf(c, 0, 0);
	d->tmpucstring1 = ucstring_create(c);
	d->phrases_data = dbuf_create_membuf(c, 0, 0);

	pos = 0;
	do_header(c, d, pos);

	do_file(c, d, d->internal_dir_FILEHEADER_offs, FILETYPE_INTERNALDIR, 0, NULL);

	de_dbg(c, "summary: v%d.%d %s%s%s blksize=%d levels=%d%s%s%s",
		d->ver_major, d->ver_minor,
		d->is_lz77_compressed?"lz77":"no_lz77",
		d->uses_old_phrase_compression?" phrase_compression":"",
		d->uses_hall_compression?" Hall_compression":"",
		(int)d->topic_block_size,
		(int)d->internal_dir_num_levels,
		d->has_shg?" has-shg":"",
		d->has_ico?" has-ico":"",
		d->has_bmp?" has-bmp":"");

	if(d) {
		dbuf_close(d->tmpdbuf1);
		dbuf_close(d->unc_linkdata2_dbuf);
		dbuf_close(d->phrases_data);
		ucstring_destroy(d->tmpucstring1);
		ucstring_destroy(d->help_file_title);
		ucstring_destroy(d->help_file_copyright);
		dbuf_close(d->outf_text);
		de_free(c, d->phrase_info);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x130, %esi            # imm = 0x130
callq 0xe8b2b
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, (%r14)
xorl %edx, %edx
cmpl $0x2, 0x90(%rbx)
setge %dl
leaq 0xca639(%rip), %rsi     # 0x1210c8
movq %rbx, %rdi
callq 0xe9bd0
movl %eax, 0x8(%r14)
leaq 0xca636(%rip), %rsi     # 0x1210d8
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9bd0
movb %al, 0xc(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, 0xd0(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, 0xd8(%r14)
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x108(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, 0xf0(%r14)
leaq 0xcc880(%rip), %rsi     # 0x12337f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xeedfa
movq %rax, 0x10(%r14)
leaq 0xca635(%rip), %rsi     # 0x121166
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0xeedfa
leaq 0xca634(%rip), %rsi     # 0x121187
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xeedfa
leaq 0xc4c84(%rip), %rsi     # 0x11b7f9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x10(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x56d2b
cmpl $0x0, 0x98(%r14)
leaq 0xca565(%rip), %rax     # 0x12111d
leaq 0xc75b0(%rip), %r8      # 0x11e16f
cmoveq %rax, %r8
cmpl $0x0, 0x9c(%r14)
leaq 0xee4de(%rip), %rax     # 0x1450b0
leaq 0xca54c(%rip), %r9      # 0x121125
cmoveq %rax, %r9
movl 0x88(%r14), %edx
cmpl $0x0, 0xa0(%r14)
leaq 0xca546(%rip), %r10     # 0x121139
cmoveq %rax, %r10
cmpl $0x0, 0xa8(%r14)
movl 0x8c(%r14), %ecx
leaq 0xca53e(%rip), %r11     # 0x12114b
cmoveq %rax, %r11
movl 0x90(%r14), %r15d
cmpl $0x0, 0xac(%r14)
leaq 0xca52d(%rip), %r12     # 0x121154
cmoveq %rax, %r12
cmpl $0x0, 0xb0(%r14)
movl 0xb8(%r14), %r13d
leaq 0xca51c(%rip), %rbp     # 0x12115d
cmoveq %rax, %rbp
leaq 0xca49f(%rip), %rsi     # 0x1210eb
movq %rbx, %rdi
xorl %eax, %eax
pushq %rbp
pushq %r12
pushq %r11
pushq %r13
pushq %r15
pushq %r10
callq 0xe8617
addq $0x30, %rsp
movq 0xd0(%r14), %rdi
callq 0xf052b
movq 0xd8(%r14), %rdi
callq 0xf052b
movq 0xf0(%r14), %rdi
callq 0xf052b
movq 0x108(%r14), %rdi
callq 0xf6753
movq 0x110(%r14), %rdi
callq 0xf6753
movq 0x118(%r14), %rdi
callq 0xf6753
movq 0xc0(%r14), %rdi
callq 0xf052b
movq 0x100(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8be2