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

	d = de_arch_create_lctx(c);
	d->is_le = 1;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_CP437);
	d->crco = de_crcobj_create(c, DE_CRCOBJ_CRC16_XMODEM);

	while(1) {
		if(pos+MDCD_MINHEADERLEN >= c->infile->len) goto done;

		if(md) {
			de_arch_destroy_md(c, md);
			md = NULL;
		}
		md = de_arch_create_md(c, d);
		md->member_hdr_pos = pos;
		if(!do_mdcd_member(c, d, md)) goto done;
		if(md->member_total_size<=0) 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 MDCD file");
		}
		de_arch_destroy_lctx(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
movq %rbx, %rdi
movl $0x20, %esi
callq 0xeb499
movq %rax, 0x30(%r14)
movq 0x18(%rbx), %rax
cmpq $0x37, 0x18(%rax)
jl 0x6ec8d
leaq 0x14(%rsp), %r13
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %r14, 0x18(%rsp)
testq %r15, %r15
je 0x6e8cd
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq %rbp, 0x18(%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe8a1c
movq 0x18(%r15), %r12
movq %r12, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movl $0x4, %ecx
movq %r12, %rsi
leaq 0xb7945(%rip), %rdx     # 0x12624b
callq 0xefc85
movq 0x18(%r15), %rdx
testl %eax, %eax
jne 0x6ec45
movq %rbp, 0x20(%rsp)
movq %r13, %rbp
movq %rbx, %rdi
leaq 0xcd234(%rip), %rsi     # 0x13bb5d
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
addq $0x5, %r12
movq %r12, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0xeeb4b
movzbl %al, %r12d
movq %rbx, %rdi
leaq 0xb78b6(%rip), %rsi     # 0x12621b
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
cmpb $0x1, %r12b
jne 0x6ec3a
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r12
movq %rbx, %rdi
leaq 0xb79e6(%rip), %rsi     # 0x126378
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpq $0x35, %r12
jle 0x6ec3a
addq $0x10, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeeb4b
movzbl %al, %edx
movl %edx, 0x90(%r15)
movq %rbx, %rdi
leaq 0xb74e0(%rip), %rsi     # 0x125eac
xorl %eax, %eax
callq 0xe8617
movq %r15, %rdi
movq %r13, %rsi
callq 0xfd538
movq %r15, %rdi
movq %r13, %rsi
callq 0xfd57d
movq 0x18(%r15), %rax
addq %r12, %rax
movq %rax, 0x40(%r15)
movq %r15, %rdi
callq 0xfd7af
testl %eax, %eax
je 0x6ec71
movq 0x30(%r15), %rax
addq %r12, %rax
movq %rax, 0x28(%r15)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %r15, %rdi
movl %eax, %esi
callq 0xfd5bd
movq 0x50(%r15), %rsi
addq $0x18, %rsi
movq 0x18(%rsp), %r14
movq %r14, %rdi
leaq 0xa979a(%rip), %rdx     # 0x1181d6
movl $0x4, %ecx
movq %r13, %r8
callq 0xfd638
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movl %eax, 0x48(%r15)
movq %rbx, %rdi
leaq 0xd63c9(%rip), %rsi     # 0x144e2c
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeeb4b
cmpb $0xd, %al
jb 0x6ea8e
movb $0x1, 0x14(%r14)
movq %rbp, %r13
movq 0x20(%rsp), %rbp
jmp 0x6ec0a
movzbl %al, %r13d
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x68(%r15)
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%r14), %r9d
movq %r13, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xefbd7
movq 0x68(%r15), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xcd282(%rip), %rsi     # 0x13bd4e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0xc, 0x8(%rsp)
cmpq $0x36, %r12
jne 0x6eae7
xorl %r12d, %r12d
jmp 0x6eaf9
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xeeb4b
movzbl %al, %r12d
movq 0x20(%rsp), %rbp
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x70(%r15)
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%r14), %r9d
movq %r12, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xefbd7
movq 0x70(%r15), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xd57f1(%rip), %rsi     # 0x144329
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%r15), %rdi
callq 0xf67a3
testl %eax, %eax
leaq 0x14(%rsp), %r13
je 0x6eb99
movq 0x70(%r15), %rdi
movq 0x10(%rdi), %rax
testq %rax, %rax
jle 0x6eb7d
movq 0x8(%rdi), %rcx
movl (%rcx), %edx
cmpl $0x2f, %edx
je 0x6eb99
cmpl $0x5c, %edx
je 0x6eb99
cmpq $0x1, %rax
je 0x6eb7d
cmpl $0x3a, 0x4(%rcx)
je 0x6eb99
movl $0x1, %esi
callq 0xfd4f8
movq 0x58(%r15), %rdi
movq 0x70(%r15), %rsi
callq 0xf6509
orb $0x1, 0x78(%r15)
movq 0x58(%r15), %rdi
movq 0x68(%r15), %rsi
callq 0xf6509
movq 0x30(%r15), %rcx
movq 0x40(%r15), %rdx
movq %rbx, %rdi
leaq 0xb7673(%rip), %rsi     # 0x12622b
xorl %eax, %eax
callq 0xe8617
movl 0x90(%r15), %edx
cmpl $0x2, %edx
jb 0x6ebde
movq %rbx, %rdi
leaq 0xa4c7d(%rip), %rsi     # 0x113852
xorl %eax, %eax
callq 0xe9295
jmp 0x6ec0a
leaq 0x2e33(%rip), %rax      # 0x71a18
movq %rax, 0xa8(%r15)
movb $0x1, 0xa1(%r15)
orl 0x48(%r15), %edx
jne 0x6ec02
movb $0x1, 0xa2(%r15)
movq %r15, %rdi
callq 0xfd85e
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x28(%r15), %rax
testq %rax, %rax
jle 0x6ec82
leaq (%rax,%rbp), %rcx
addq $0x36, %rcx
addq %rax, %rbp
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rcx
jl 0x6e8bd
jmp 0x6ec82
movq 0x18(%rsp), %rax
movb $0x1, 0x14(%rax)
jmp 0x6ec71
testq %rdx, %rdx
je 0x6ec60
leaq 0xb75b0(%rip), %rsi     # 0x126201
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
jmp 0x6ec71
leaq 0xb7589(%rip), %rsi     # 0x1261f0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x18(%rsp), %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
cmpb $0x0, 0x14(%r14)
je 0x6eca5
leaq 0xb7538(%rip), %rsi     # 0x1261d3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq