// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/misc3.c
// Function: de_run_tc_trs80
static void de_run_tc_trs80(deark *c, de_module_params *mparams)
{
	de_arch_lctx *d = NULL;
	struct de_arch_member_data *md = NULL;
	i64 pos = 0;
	i64 seq_num = 0;

	d = de_arch_create_lctx(c);
	d->is_le = 0;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_ASCII);

	while(1) {
		if(pos >= c->infile->len) {
			d->fatalerrflag = 1;
			d->need_errmsg = 1;
			goto done;
		}

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

		seq_num++; // 1-based
		md = de_arch_create_md(c, d);
		md->member_hdr_pos = pos;
		md->member_idx = seq_num;
		do_tc_member(c, d, md);
		if(d->stop_flag || d->fatalerrflag || md->member_total_size<1) {
			goto done;
		}
		pos += md->member_total_size;
	}

done:

	if(md) {
		de_arch_destroy_md(c, md);
	}
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported TC file");
		}
		de_arch_destroy_lctx(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0xfdb0a
movq %rax, %r13
movl $0x0, 0x10(%rax)
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xeb7d1
movl %eax, 0x18(%r13)
movq 0x18(%rbx), %rax
cmpq $0x0, 0x18(%rax)
jle 0x7147e
movl $0x1, %r12d
movq %rsp, %r14
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %r13, 0x8(%rsp)
testq %r15, %r15
je 0x711b6
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfda6c
movq %rax, %r15
movq %rbp, 0x18(%rax)
movq %r12, 0x10(%rax)
movq %rbp, (%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe958c
movq 0x18(%r15), %rdx
movq %rbx, %rdi
leaq 0xca5f8(%rip), %rsi     # 0x13b7e3
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
movq %r13, %r14
movzbl %al, %r13d
movq %rbx, %rdi
leaq 0xad790(%rip), %rsi     # 0x11e9ac
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
testb %r13b, %r13b
je 0x713e7
cmpq %r13, 0x10(%r15)
jne 0x713f1
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movq 0x58(%r15), %rcx
movq 0x8(%rsp), %r14
movl 0x18(%r14), %r9d
movl $0x8, %edx
movl $0x1, %r8d
callq 0xf01b0
addq $0x8, (%rsp)
movq 0x58(%r15), %rdi
callq 0xf6900
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movl 0x18(%r14), %r9d
movl $0x3, %edx
movq %rax, %rcx
movl $0x1, %r8d
callq 0xf01b0
addq $0x3, (%rsp)
movq %r13, %rdi
callq 0xf6900
movq %r13, %rdi
callq 0xf6c00
testl %eax, %eax
je 0x712c9
movq 0x58(%r15), %rdi
movl $0x2e, %esi
callq 0xf69a2
movq 0x58(%r15), %rdi
movq %r13, %rsi
callq 0xf6969
movq 0x58(%r15), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xca6f8(%rip), %rsi     # 0x13b9d4
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0xef14d
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xa6d52(%rip), %rsi     # 0x118054
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xb5201(%rip), %rsi     # 0x126523
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
cmpb $0x1, %al
jne 0x7144d
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xef6f2
movq %rax, 0x30(%r15)
addq $0x3, (%rsp)
movq (%r15), %rdi
leaq 0xacf24(%rip), %rsi     # 0x11e28b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
movzbl %al, %edx
movl %edx, 0x90(%r15)
movq %rbx, %rdi
leaq 0xb48eb(%rip), %rsi     # 0x125c7c
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %rdx
movq %rdx, 0x40(%r15)
movq %rbx, %rdi
leaq 0xb5188(%rip), %rsi     # 0x126532
xorl %eax, %eax
callq 0xe9226
movq 0x30(%r15), %rax
addq 0x40(%r15), %rax
subq 0x18(%r15), %rax
movq %rax, 0x28(%r15)
movl 0x90(%r15), %edx
cmpl $0x2, %edx
jb 0x71461
movq %rbx, %rdi
leaq 0xa23c7(%rip), %rsi     # 0x1137a2
xorl %eax, %eax
callq 0xe9df7
jmp 0x71477
movl $0x1, 0x50(%r14)
jmp 0x71403
movq 0x8(%rsp), %r14
movl $0x1, 0x38(%r14)
movb $0x1, 0x14(%r14)
xorl %r13d, %r13d
movq %r13, %rdi
callq 0xf6bb0
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
cmpl $0x0, 0x50(%r14)
movq %r14, %r13
jne 0x7148b
cmpl $0x0, 0x38(%r13)
jne 0x7148b
movq 0x28(%r15), %rax
testq %rax, %rax
jle 0x7148b
addq %rax, %rbp
movq 0x18(%rbx), %rax
incq %r12
cmpq 0x18(%rax), %rbp
movq %rsp, %r14
jl 0x711a6
jmp 0x7147e
movq 0x8(%rsp), %r14
movl $0x1, 0x38(%r14)
movb $0x1, 0x14(%r14)
jmp 0x71406
leaq 0xcc1(%rip), %rax       # 0x72129
movq %rax, 0xa8(%r15)
movq %r15, %rdi
callq 0xfdec1
movq 0x8(%rsp), %r14
jmp 0x71406
movl $0x1, 0x38(%r13)
movb $0x1, 0x14(%r13)
testq %r15, %r15
je 0x7149b
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
testq %r13, %r13
je 0x714c3
cmpb $0x0, 0x14(%r13)
je 0x714b8
leaq 0xb505a(%rip), %rsi     # 0x126508
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfdb25
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq