// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
callq 0x17c220
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xd, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0xc29b7(%rip), %rsi     # 0x1b15a0
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165170
movb %al, -0x2d(%rbp)
movzbl -0x2d(%rbp), %eax
cmpl $0x8, %eax
je 0xeec34
movq -0x18(%rbp), %rax
movb $0x1, 0x14(%rax)
jmp 0xeeda6
movq -0x20(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165170
movb %al, -0x2d(%rbp)
movzbl -0x2d(%rbp), %eax
movl %eax, -0x44(%rbp)
subl $0x1, %eax
je 0xeec6c
jmp 0xeec62
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0xeec79
jmp 0xeec86
leaq 0xcf6f8(%rip), %rax     # 0x1be36b
movq %rax, -0x38(%rbp)
jmp 0xeec91
leaq 0xcf6fc(%rip), %rax     # 0x1be37c
movq %rax, -0x38(%rbp)
jmp 0xeec91
leaq 0xc8fa0(%rip), %rax     # 0x1b7c2d
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x2d(%rbp), %edx
movq -0x38(%rbp), %rcx
leaq 0xcf6e6(%rip), %rsi     # 0x1be38a
movb $0x0, %al
callq 0x15b0d0
movzbl -0x2d(%rbp), %eax
cmpl $0x1, %eax
je 0xeecca
movzbl -0x2d(%rbp), %eax
cmpl $0x2, %eax
je 0xeecca
movq -0x18(%rbp), %rax
movb $0x1, 0x14(%rax)
jmp 0xeeda6
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0xeecfb
jmp 0xeeda6
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x165060
movzbl %al, %eax
cmpl $0x12, %eax
je 0xeed21
movq -0x18(%rbp), %rax
movb $0x1, 0x14(%rax)
jmp 0xeeda6
cmpq $0x0, -0x40(%rbp)
je 0xeed3d
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x17c1a0
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x17c120
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xef9e0
movq -0x40(%rbp), %rax
cmpb $0x0, 0xa0(%rax)
jne 0xeed86
jmp 0xeeda6
movq -0x40(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xeecec
movq -0x18(%rbp), %rax
cmpb $0x0, 0x14(%rax)
je 0xeedc2
movq -0x8(%rbp), %rdi
leaq 0xcf5e7(%rip), %rsi     # 0x1be3a2
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x17c1a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x17c270
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x15b5a0
addq $0x50, %rsp
popq %rbp
retq
nop