// File: /workspace/github_c_makefile_star2_O1/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 0xe969b
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb7d1
movl %eax, (%r14)
xorl %edx, %edx
cmpl $0x2, 0x90(%rbx)
setge %dl
leaq 0xca439(%rip), %rsi     # 0x120fb8
movq %rbx, %rdi
callq 0xea727
movl %eax, 0x8(%r14)
leaq 0xca436(%rip), %rsi     # 0x120fc8
movq %rbx, %rdi
xorl %edx, %edx
callq 0xea727
movb %al, 0xc(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, 0xd0(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, 0xd8(%r14)
movq %rbx, %rdi
callq 0xf6870
movq %rax, 0x108(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, 0xf0(%r14)
leaq 0xcc5b0(%rip), %rsi     # 0x12319f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xef417
movq %rax, 0x10(%r14)
leaq 0xca435(%rip), %rsi     # 0x121056
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0xef417
leaq 0xca434(%rip), %rsi     # 0x121077
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xef417
leaq 0xc4a6c(%rip), %rsi     # 0x11b6d1
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x10(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x56e1b
cmpl $0x0, 0x98(%r14)
leaq 0xca365(%rip), %rax     # 0x12100d
leaq 0xc73b0(%rip), %r8      # 0x11e05f
cmoveq %rax, %r8
cmpl $0x0, 0x9c(%r14)
leaq 0xedf0e(%rip), %rax     # 0x144bd0
leaq 0xca34c(%rip), %r9      # 0x121015
cmoveq %rax, %r9
movl 0x88(%r14), %edx
cmpl $0x0, 0xa0(%r14)
leaq 0xca346(%rip), %r10     # 0x121029
cmoveq %rax, %r10
cmpl $0x0, 0xa8(%r14)
movl 0x8c(%r14), %ecx
leaq 0xca33e(%rip), %r11     # 0x12103b
cmoveq %rax, %r11
movl 0x90(%r14), %r15d
cmpl $0x0, 0xac(%r14)
leaq 0xca32d(%rip), %r12     # 0x121044
cmoveq %rax, %r12
cmpl $0x0, 0xb0(%r14)
movl 0xb8(%r14), %r13d
leaq 0xca31c(%rip), %rbp     # 0x12104d
cmoveq %rax, %rbp
leaq 0xca29f(%rip), %rsi     # 0x120fdb
movq %rbx, %rdi
xorl %eax, %eax
pushq %rbp
pushq %r12
pushq %r11
pushq %r13
pushq %r15
pushq %r10
callq 0xe9226
addq $0x30, %rsp
movq 0xd0(%r14), %rdi
callq 0xf0b13
movq 0xd8(%r14), %rdi
callq 0xf0b13
movq 0xf0(%r14), %rdi
callq 0xf0b13
movq 0x108(%r14), %rdi
callq 0xf6bb0
movq 0x110(%r14), %rdi
callq 0xf6bb0
movq 0x118(%r14), %rdi
callq 0xf6bb0
movq 0xc0(%r14), %rdi
callq 0xf0b13
movq 0x100(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9752