// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/installshld.c
// Function: de_run_tscomp
static void de_run_tscomp(deark *c, de_module_params *mparams)
{
	de_arch_lctx *d = NULL;
	i64 pos;
	i64 i;
	int saved_indent_level;
	u8 b;
	const char *name;
	struct de_arch_member_data *md = NULL;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_arch_create_lctx(c);
	d->is_le = 1;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_CP437);

	pos = 0;
	de_dbg(c, "archive header at %d", (int)pos);
	de_dbg_indent(c, 1);
	pos += 4;

	b = de_getbyte_p(&pos);
	if(b!=0x08) { d->need_errmsg = 1; goto done; }
	pos += 3; // version?? (01 03 00)
	b = de_getbyte_p(&pos);
	switch(b) {
	case 1: name = "without wildcard"; break;
	case 2: name = "with wildcard"; break;
		// 0: seems to identify an "old" version (but it might be a significantly
		// different format).
	default: name = "?";
	}
	de_dbg(c, "filename style: %u (%s)", (UI)b, name);
	if(b!=1 && b!=2) { d->need_errmsg = 1; goto done; }

	pos += 4; // ??
	de_dbg_indent(c, -1);

	i = 0;
	while(1) {
		if(d->fatalerrflag) goto done;
		if(de_getbyte(pos) != 0x12) { d->need_errmsg = 1; goto done; }

		if(md) {
			de_arch_destroy_md(c, md);
			md = NULL;
		}

		md = de_arch_create_md(c, d);
		md->member_idx = i;
		md->member_hdr_pos = pos;

		tscomp_do_member(c, d, md);

		if(!md->next_member_exists) goto done;
		pos = md->next_member_pos;
		i++;
	}

done:
	if(d->need_errmsg) {
		de_err(c, "Bad or unsupported TSComp format");
	}
	de_arch_destroy_md(c, md);
	de_arch_destroy_lctx(c, d);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %rsi
callq 0xdebae
movq %rbx, %rdi
callq 0xf16ce
movq %rax, %r14
movl $0x1, 0x10(%rax)
xorl %r15d, %r15d
pushq $0xd
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x18(%r14)
leaq 0x7c667(%rip), %rsi     # 0x118b63
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq %rsp, %rsi
movq $0x4, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3f2a
cmpb $0x8, %al
jne 0x9c583
movq %rsp, %rsi
addq $0x3, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3f2a
movzbl %al, %r12d
cmpb $0x2, %r12b
leaq 0x8918b(%rip), %rax     # 0x1256d4
leaq 0x82991(%rip), %rdx     # 0x11eee1
cmoveq %rax, %rdx
cmpb $0x1, %r12b
leaq 0x89164(%rip), %rcx     # 0x1256c3
cmovneq %rdx, %rcx
leaq 0x89178(%rip), %rsi     # 0x1256e2
xorl %r15d, %r15d
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
leal -0x3(%r12), %eax
cmpb $-0x2, %al
jae 0x9c5ca
movb $0x1, 0x14(%r14)
leaq 0x8916b(%rip), %rsi     # 0x1256fa
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf16e7
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x4, (%rsp)
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x8(%rsp), %r12
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpl $0x0, 0x38(%r14)
jne 0x9c779
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
callq 0xe3eb4
cmpb $0x12, %al
jne 0x9c583
testq %r15, %r15
je 0x9c610
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1630
movq %rax, %r15
movq %rbp, 0x10(%rax)
movq (%rsp), %r13
movq %r13, 0x18(%rax)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xdebae
movl 0x10(%r15), %edx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
leaq 0x890d2(%rip), %rsi     # 0x12571b
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
incq %r13
movq %r13, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xf17ab
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe40bf
movq %rax, 0x98(%r15)
movq %rbx, %rdi
leaq 0x88503(%rip), %rsi     # 0x124b8e
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x98(%r15), %rax
testq %rax, %rax
je 0x9c6b9
cmpq 0x18(%r15), %rax
jle 0x9c6b9
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jge 0x9c6b9
movb $0x1, 0xa0(%r15)
movq 0x50(%r15), %rsi
addq $0x18, %rsi
movq %r14, %rdi
leaq 0x6ea1b(%rip), %rdx     # 0x10b0e6
pushq $0x3
popq %rcx
movq %r12, %r8
callq 0xf1866
addq $0x2, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3f2a
movzbl %al, %r13d
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x58(%r15), %rcx
movl 0x18(%r14), %r9d
movq %r13, %rdx
pushq $0x1
popq %r8
callq 0xe4c9a
movq 0x58(%r15), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x92342(%rip), %rsi     # 0x12ea5e
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %rax
addq %r13, %rax
incq %rax
movq %rax, 0x8(%rsp)
movq %rax, 0x40(%r15)
leaq 0x39b(%rip), %rax       # 0x9cadc
movq %rax, 0xa8(%r15)
movq %r15, %rdi
callq 0xf1a85
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
cmpb $0x0, 0xa0(%r15)
je 0x9c779
movq 0x98(%r15), %rax
movq %rax, (%rsp)
incq %rbp
jmp 0x9c5e4
cmpb $0x0, 0x14(%r14)
jne 0x9c588
jmp 0x9c599