// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
callq 0xe958c
movq %rbx, %rdi
callq 0xfdb0a
movq %rax, %r14
movl $0x1, 0x10(%rax)
movl $0x78, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq $0x8, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xef3a0
movq %rax, %r12
leaq 0xa3af6(%rip), %rsi     # 0x114067
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x64, %r12d
jne 0x705c2
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r13
movq %r13, %rsi
callq 0xef3a0
movq %rax, %r12
leaq 0xa40bd(%rip), %rsi     # 0x11465c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
leaq (,%r12,8), %rax
addq (%r13), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x70628
movb $0x1, 0x14(%r14)
xorl %r13d, %r13d
testq %r13, %r13
je 0x705da
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfdab8
testq %r14, %r14
je 0x70602
cmpb $0x0, 0x14(%r14)
je 0x705f7
leaq 0xb5da2(%rip), %rsi     # 0x12638f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfdb25
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
jle 0x705c7
movq %r15, %rax
addq $0x6c, %rax
movq %rax, 0x28(%rsp)
decq %r12
movq %r12, 0x30(%rsp)
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
xorl %ebp, %ebp
movq %r14, 0x10(%rsp)
testq %r13, %r13
je 0x70664
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfda6c
movq %rax, %r13
movq %rbx, %rdi
leaq 0xb5d07(%rip), %rsi     # 0x126383
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
callq 0xef3a0
movq %rax, 0x40(%r13)
movq %rbx, %rdi
leaq 0xb5753(%rip), %rsi     # 0x125e05
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movq %r12, %rsi
callq 0xfdb9b
movq 0x38(%r13), %rax
movq 0x40(%r13), %r12
movq %rax, 0x30(%r13)
cmpq 0x18(%rsp), %r12
jl 0x706e7
addq %rax, %r12
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jle 0x706f4
movb $0x1, 0x14(%r14)
movb $0x1, %r14b
jmp 0x7078c
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(%r13), %rax
movq %rax, 0x18(%r15)
movq 0x30(%r13), %rax
movq %rax, 0x20(%r15)
movb $0x1, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfa395
movq 0x50(%r13), %rsi
xorl %r14d, %r14d
movq %rbx, %rdi
movq 0x28(%rsp), %rdx
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0xeac7c
leaq 0x1524(%rip), %rax      # 0x71c8f
movq %rax, 0xa8(%r13)
movq %r13, %rdi
callq 0xfdec1
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %r12, 0x18(%rsp)
testb %r14b, %r14b
jne 0x707ad
leaq 0x1(%rbp), %rax
cmpq %rbp, 0x30(%rsp)
movq %rax, %rbp
movq 0x10(%rsp), %r14
jne 0x70654
jmp 0x705ca
movq 0x10(%rsp), %r14
jmp 0x705ca