// File: /workspace/github_c_makefile_star2_O2/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 0xf16ce
movq %rax, %rbp
movl $0x1, 0x10(%rax)
pushq $0xd
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x18(%rbp)
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0xe0ae9
movq %rax, 0x30(%rbp)
leaq 0x14(%rsp), %r13
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbp, 0x20(%rsp)
leaq 0x36(%r14), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jge 0x6aea5
testq %r15, %r15
je 0x6ab56
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf1630
movq %rax, %r15
movq %r14, 0x18(%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xdebae
movq 0x18(%r15), %r12
movq %r12, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6db2e
movq 0x18(%r15), %rdx
testl %eax, %eax
je 0x6aeac
movq %r14, 0x18(%rsp)
movq %r13, %r14
movq %rbx, %rdi
leaq 0xc3cc8(%rip), %rsi     # 0x12e86d
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
addq $0x5, %r12
movq %r12, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %r12d
movq %rbx, %rdi
leaq 0xae43c(%rip), %rsi     # 0x11901b
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
cmpb $0x1, %r12b
jne 0x6ae9f
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rax, %r12
movq %rbx, %rdi
leaq 0xae56c(%rip), %rsi     # 0x119178
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpq $0x35, %r12
jle 0x6ae9f
addq $0x10, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movzbl %al, %edx
movl %edx, 0x90(%r15)
movq %rbx, %rdi
leaq 0xae066(%rip), %rsi     # 0x118cac
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movq %r13, %rsi
callq 0xf1766
movq %r15, %rdi
movq %r13, %rsi
callq 0xf17ab
movq 0x18(%r15), %rax
addq %r12, %rax
movq %rax, 0x40(%r15)
movq %r15, %rdi
callq 0xf19d5
testl %eax, %eax
je 0x6aed8
movq 0x30(%r15), %rax
addq %r12, %rax
movq %rax, 0x28(%r15)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %r15, %rdi
movl %eax, %esi
callq 0xf17eb
movq 0x50(%r15), %rsi
addq $0x18, %rsi
movq %rbp, %rdi
leaq 0xa0435(%rip), %rdx     # 0x10b0e6
pushq $0x4
popq %rcx
movq %r13, %r8
callq 0xf1866
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movl %eax, 0x48(%r15)
movq %rbx, %rdi
leaq 0xccd06(%rip), %rsi     # 0x1379dc
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
cmpb $0xd, %al
jb 0x6ad00
movb $0x1, 0x14(%rbp)
movq %r14, %r13
movq 0x18(%rsp), %r14
jmp 0x6ae81
movq %rbp, %r13
movzbl %al, %ebp
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x68(%r15)
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movl 0x18(%r13), %r9d
movq %rbp, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xe4c9a
movq 0x68(%r15), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xc3d1e(%rip), %rsi     # 0x12ea5e
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0xc, 0x8(%rsp)
cmpq $0x36, %r12
jne 0x6ad5b
xorl %r12d, %r12d
jmp 0x6ad6d
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe3f2a
movzbl %al, %r12d
movq 0x18(%rsp), %r14
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x70(%r15)
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rbp
movl 0x18(%rbp), %r9d
movq %r12, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0xe4c9a
movq 0x70(%r15), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xcc128(%rip), %rsi     # 0x136ed9
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x70(%r15), %rdi
callq 0xeaf8a
testl %eax, %eax
leaq 0x14(%rsp), %r13
je 0x6ae10
movq 0x70(%r15), %rdi
movq 0x10(%rdi), %rax
testq %rax, %rax
jle 0x6adf6
movq 0x8(%rdi), %rcx
movl (%rcx), %edx
cmpl $0x2f, %edx
je 0x6ae10
cmpl $0x5c, %edx
je 0x6ae10
cmpq $0x1, %rax
je 0x6adf6
cmpl $0x3a, 0x4(%rcx)
je 0x6ae10
pushq $0x1
popq %rsi
callq 0xf1712
movq 0x58(%r15), %rdi
movq 0x70(%r15), %rsi
callq 0xead71
orb $0x1, 0x78(%r15)
movq 0x58(%r15), %rdi
movq 0x68(%r15), %rsi
callq 0xead71
movq 0x30(%r15), %rcx
movq 0x40(%r15), %rdx
movq %rbx, %rdi
leaq 0xae1fc(%rip), %rsi     # 0x11902b
xorl %eax, %eax
callq 0xde896
movl 0x90(%r15), %edx
cmpl $0x2, %edx
jb 0x6ae55
movq %rbx, %rdi
leaq 0x9b9a6(%rip), %rsi     # 0x1067f2
xorl %eax, %eax
callq 0xdf2a5
jmp 0x6ae81
leaq 0x2cf1(%rip), %rax      # 0x6db4d
movq %rax, 0xa8(%r15)
movb $0x1, 0xa1(%r15)
orl 0x48(%r15), %edx
jne 0x6ae79
movb $0x1, 0xa2(%r15)
movq %r15, %rdi
callq 0xf1a85
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x28(%r15), %rax
addq %rax, %r14
testq %rax, %rax
jg 0x6ab34
jmp 0x6aee4
movb $0x1, 0x14(%rbp)
jmp 0x6aed8
testq %r15, %r15
jne 0x6aee4
jmp 0x6aeef
testq %rdx, %rdx
je 0x6aec7
leaq 0xae149(%rip), %rsi     # 0x119001
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
jmp 0x6aed8
leaq 0xae122(%rip), %rsi     # 0x118ff0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
testq %rbp, %rbp
je 0x6af16
cmpb $0x0, 0x14(%rbp)
je 0x6af0b
leaq 0xae0d2(%rip), %rsi     # 0x118fd3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf16e7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq