// File: /workspace/github_c_makefile_star2_O2/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 0xdecaf
movq %rax, %r14
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r14)
xorl %edx, %edx
cmpl $0x2, 0x90(%rbx)
setge %dl
leaq 0xc023b(%rip), %rsi     # 0x113fd8
movq %rbx, %rdi
callq 0xdfae5
movl %eax, 0x8(%r14)
leaq 0xc0238(%rip), %rsi     # 0x113fe8
movq %rbx, %rdi
xorl %edx, %edx
callq 0xdfae5
movb %al, 0xc(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0xd0(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0xd8(%r14)
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x108(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0xf0(%r14)
leaq 0xc23b2(%rip), %rsi     # 0x1161bf
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
pushq $0x4
popq %rsi
callq 0xe40f2
movq %rax, 0x10(%r14)
leaq 0xc023b(%rip), %rsi     # 0x114076
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0xe40f2
leaq 0xc023c(%rip), %rsi     # 0x114097
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0xc
popq %rsi
callq 0xe40f2
leaq 0xba88e(%rip), %rsi     # 0x10e709
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x10(%r14), %rdx
pushq $0x3
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x54029
cmpl $0x0, 0x98(%r14)
leaq 0xc0173(%rip), %rax     # 0x11402d
leaq 0xbd1da(%rip), %r8      # 0x11109b
cmoveq %rax, %r8
cmpl $0x0, 0x9c(%r14)
leaq 0xe3d8c(%rip), %rax     # 0x137c60
leaq 0xc015a(%rip), %r9      # 0x114035
cmoveq %rax, %r9
movl 0x88(%r14), %edx
cmpl $0x0, 0xa0(%r14)
leaq 0xc0154(%rip), %r10     # 0x114049
cmoveq %rax, %r10
cmpl $0x0, 0xa8(%r14)
movl 0x8c(%r14), %ecx
leaq 0xc014c(%rip), %r11     # 0x11405b
cmoveq %rax, %r11
movl 0x90(%r14), %r15d
cmpl $0x0, 0xac(%r14)
leaq 0xc013b(%rip), %r12     # 0x114064
cmoveq %rax, %r12
cmpl $0x0, 0xb0(%r14)
movl 0xb8(%r14), %r13d
leaq 0xc012a(%rip), %rbp     # 0x11406d
cmoveq %rax, %rbp
leaq 0xc00ad(%rip), %rsi     # 0x113ffb
movq %rbx, %rdi
xorl %eax, %eax
pushq %rbp
pushq %r12
pushq %r11
pushq %r13
pushq %r15
pushq %r10
callq 0xde896
addq $0x30, %rsp
movq 0xd0(%r14), %rdi
callq 0xe5591
movq 0xd8(%r14), %rdi
callq 0xe5591
movq 0xf0(%r14), %rdi
callq 0xe5591
movq 0x108(%r14), %rdi
callq 0xeaf3c
movq 0x110(%r14), %rdi
callq 0xeaf3c
movq 0x118(%r14), %rdi
callq 0xeaf3c
movq 0xc0(%r14), %rdi
callq 0xe5591
movq 0x100(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xded32