// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/misc3.c
// Function: de_run_hta
static void de_run_hta(deark *c, de_module_params *mparams)
{
	struct de_arch_member_data *md = NULL;
	i64 pos;
	i64 num_members;
	UI fmtver;
	i64 idx;
	de_arch_lctx *d = NULL;
	int saved_indent_level;
	i64 tracking_dpos = 0;
	struct fmtutil_fmtid_ctx *idctx = NULL;

	de_dbg_indent_save(c, &saved_indent_level);

	d = de_arch_create_lctx(c);
	d->is_le = 1;
	idctx = de_malloc(c, sizeof(struct fmtutil_fmtid_ctx));

	pos = 8;
	fmtver = (UI)de_getu32le_p(&pos);
	de_dbg(c, "format version: %u", fmtver);
	if(fmtver!=100) { d->need_errmsg = 1; goto done; }
	num_members = de_getu32le_p(&pos);
	de_dbg(c, "number of members: %"I64_FMT, num_members);
	if(pos+num_members*8 > c->infile->len) { d->need_errmsg = 1; goto done; }

	for(idx=0; idx<num_members; idx++) {
		i64 endpos;

		if(md) {
			de_arch_destroy_md(c, md);
			md = NULL;
		}
		md = de_arch_create_md(c, d);
		de_dbg(c, "member[%"I64_FMT"]", idx);
		de_dbg_indent(c, 1);

		md->cmpr_pos = de_getu32le_p(&pos);
		de_dbg(c, "data pos: %"I64_FMT, md->cmpr_pos);
		de_arch_read_field_orig_len_p(md, &pos);
		md->cmpr_len = md->orig_len;

		if(md->cmpr_pos < tracking_dpos) { d->need_errmsg = 1; goto done; }
		endpos = md->cmpr_pos + md->cmpr_len;
		if(endpos > c->infile->len) { d->need_errmsg = 1; goto done; }
		tracking_dpos = endpos;

		de_zeromem(idctx, sizeof(struct fmtutil_fmtid_ctx));
		idctx->inf = c->infile;
		idctx->inf_pos = md->cmpr_pos;
		idctx->inf_len = md->cmpr_len;
		idctx->mode = FMTUTIL_FMTIDMODE_ALL_IMG;
		fmtutil_fmtid(c, idctx);

		de_finfo_set_name_from_sz(c, md->fi, idctx->ext_sz, 0, DE_ENCODING_LATIN1);
		md->dfn = noncompressed_decompressor_fn;
		de_arch_extract_member_file(md);

		de_dbg_indent(c, -1);
	}

done:
	if(md) {
		de_arch_destroy_md(c, md);
		md = NULL;
	}
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported HTA file");
		}
		de_arch_destroy_lctx(c, d);
	}
	de_free(c, idctx);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movq %rbx, %rdi
callq 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movl $0x78, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
leaq 0x10(%rsp), %rsi
movq $0x8, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeed83
movq %rax, %r12
leaq 0xa3e09(%rip), %rsi     # 0x114117
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x64, %r12d
jne 0x7035f
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0xeed83
movq %rax, %r12
leaq 0xa43fb(%rip), %rsi     # 0x114737
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq (,%r12,8), %rax
addq (%r13), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x703a6
movb $0x1, 0x14(%r14)
leaq 0xb6254(%rip), %rsi     # 0x1265bf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
jle 0x70537
movq %r14, (%rsp)
movq %r15, %rax
addq $0x6c, %rax
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %r12, 0x20(%rsp)
testq %rbp, %rbp
je 0x703dc
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xfd460
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0xfd414
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xb61be(%rip), %rsi     # 0x1265b3
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xeed83
movq %rax, 0x40(%rbp)
movq %rbx, %rdi
leaq 0xb5c0a(%rip), %rsi     # 0x126035
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbp, %rdi
movq %r12, %rsi
callq 0xfd538
movq 0x38(%rbp), %rax
movq 0x40(%rbp), %r12
movq %rax, 0x30(%rbp)
cmpq %r14, %r12
jl 0x70523
addq %rax, %r12
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jg 0x70523
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%r15)
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
movq $0x0, 0x70(%r15)
movq 0x18(%rbx), %rax
movq %rax, 0x10(%r15)
movq 0x40(%rbp), %rax
movq %rax, 0x18(%r15)
movq 0x30(%rbp), %rax
movq %rax, 0x20(%r15)
movb $0x1, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf9e98
movq 0x50(%rbp), %rsi
movq %rbx, %rdi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0xea78f
leaq 0x151b(%rip), %rax      # 0x719f5
movq %rax, 0xa8(%rbp)
movq %rbp, %rdi
callq 0xfd85e
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %r13
movq %r12, %r14
movq 0x20(%rsp), %r12
cmpq %r13, %r12
jne 0x703cc
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xfd460
movq (%rsp), %r14
testq %r14, %r14
jne 0x70537
jmp 0x70380
movq (%rsp), %r14
movb $0x1, 0x14(%r14)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xfd460
cmpb $0x0, 0x14(%r14)
jne 0x70364
jmp 0x70375