// File: /workspace/github_c_makefile_star2_O3/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 0xe8a1c
movq %rbx, %rdi
callq 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
leaq 0x83aa0(%rip), %rsi     # 0x125d63
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rsp, %rsi
movq $0x4, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeeb4b
cmpb $0x8, %al
jne 0xa234c
movq %rsp, %rsi
addq $0x3, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeeb4b
movzbl %al, %r12d
cmpb $0x2, %r12b
leaq 0x906c2(%rip), %rax     # 0x1329d4
leaq 0x89e38(%rip), %rdx     # 0x12c151
cmoveq %rax, %rdx
cmpb $0x1, %r12b
leaq 0x9069b(%rip), %rcx     # 0x1329c3
cmovneq %rdx, %rcx
leaq 0x906af(%rip), %rsi     # 0x1329e2
xorl %r15d, %r15d
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
leal -0x3(%r12), %eax
cmpb $-0x2, %al
jae 0xa239a
movb $0x1, 0x14(%r14)
cmpb $0x0, 0x14(%r14)
je 0xa2369
leaq 0x9069b(%rip), %rsi     # 0x1329fa
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x4, (%rsp)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpl $0x0, 0x38(%r14)
je 0xa23b8
xorl %r15d, %r15d
jmp 0xa2351
movq (%rsp), %rsi
leaq 0x8(%rsp), %rbp
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x18(%rbx), %rdi
callq 0xeead3
cmpb $0x12, %al
jne 0xa234c
testq %r15, %r15
je 0xa23e8
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq %r12, 0x10(%rax)
movq (%rsp), %r13
movq %r13, 0x18(%rax)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe8a1c
movl 0x10(%r15), %edx
movq 0x18(%r15), %rcx
movq %rbx, %rdi
leaq 0x905fa(%rip), %rsi     # 0x132a1b
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
incq %r13
movq %r13, 0x8(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xfd57d
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed83
movq %rax, 0x98(%r15)
movq %rbx, %rdi
leaq 0x8fa15(%rip), %rsi     # 0x131e7a
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x98(%r15), %rax
testq %rax, %rax
je 0xa2493
cmpq 0x18(%r15), %rax
jle 0xa2493
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jge 0xa2493
movb $0x1, 0xa0(%r15)
movq 0x50(%r15), %rsi
addq $0x18, %rsi
movq %r14, %rdi
leaq 0x75d31(%rip), %rdx     # 0x1181d6
movl $0x3, %ecx
movq %rbp, %r8
callq 0xfd638
addq $0x2, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %r13d
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x58(%r15), %rcx
movl 0x18(%r14), %r9d
movq %r13, %rdx
movl $0x1, %r8d
callq 0xefbd7
movq 0x58(%r15), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x99854(%rip), %rsi     # 0x13bd4e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rsp), %rax
addq %r13, %rax
incq %rax
movq %rax, 0x8(%rsp)
movq %rax, 0x40(%r15)
leaq 0x3ae(%rip), %rax       # 0xa28cd
movq %rax, 0xa8(%r15)
movq %r15, %rdi
callq 0xfd85e
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
cmpb $0x0, 0xa0(%r15)
je 0xa2351
movq 0x98(%r15), %rsi
movq %rsi, (%rsp)
incq %r12
cmpl $0x0, 0x38(%r14)
je 0xa23c7
jmp 0xa2351