// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/misc3.c
// Function: de_run_cmz
static void de_run_cmz(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);

	while(1) {
		if(pos+CMZ_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_cmz_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);
		md = NULL;
	}
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported CMZ 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 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rax
cmpq $0x16, 0x18(%rax)
jl 0x6f0df
leaq 0x8(%rsp), %rbp
xorl %r15d, %r15d
xorl %r13d, %r13d
testq %r15, %r15
je 0x6ef02
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq %r13, 0x18(%rax)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe8a1c
movq 0x18(%r15), %r12
movq %r12, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movl $0x4, %ecx
movq %r12, %rsi
leaq 0xb7397(%rip), %rdx     # 0x1262d4
callq 0xefc85
testl %eax, %eax
jne 0x6f093
addq $0x4, %r12
movq %r12, 0x8(%rsp)
movq 0x18(%r15), %rdx
movq %rbx, %rdi
leaq 0xccbfc(%rip), %rsi     # 0x13bb5d
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r15, %rdi
movq %rbp, %rsi
callq 0xfd57d
movq %r15, %rdi
movq %rbp, %rsi
callq 0xfd538
movq 0x50(%r15), %rsi
addq $0x18, %rsi
movq %r14, %rdi
leaq 0xa9239(%rip), %rdx     # 0x1181d6
movl $0x3, %ecx
movq %rbp, %r8
callq 0xfd638
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeebeb
cmpq $0x100, %rax            # imm = 0x100
jge 0x6f0b0
movq %rax, %r12
movq 0x8(%rsp), %rsi
addq $0x2, %rsi
movq %rsi, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq 0x58(%r15), %rcx
movl 0x18(%r14), %r9d
movq %rax, %rdx
xorl %r8d, %r8d
callq 0xefbd7
movq 0x58(%r15), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xccd51(%rip), %rsi     # 0x13bd4e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq 0x8(%rsp), %r12
movq %r12, 0x8(%rsp)
movq %r12, 0x40(%r15)
movq 0x30(%r15), %rcx
movq %rbx, %rdi
leaq 0xb7208(%rip), %rsi     # 0x12622b
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r15, %rdi
callq 0xfd7af
testl %eax, %eax
je 0x6f0c8
movq 0x30(%r15), %rax
addq 0x40(%r15), %rax
subq 0x18(%r15), %rax
movq %rax, 0x28(%r15)
leaq 0x25a1(%rip), %rax      # 0x715f5
movq %rax, 0xa8(%r15)
movq %r15, %rdi
callq 0xfd85e
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x28(%r15), %rax
testq %rax, %rax
jle 0x6f0d4
leaq (%rax,%r13), %rcx
addq $0x15, %rcx
addq %rax, %r13
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rcx
jl 0x6eef2
jmp 0x6f0d4
cmpq $0x0, 0x18(%r15)
je 0x6f0b7
leaq 0xb721d(%rip), %rsi     # 0x1262be
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0x6f0c8
movb $0x1, 0x14(%r14)
jmp 0x6f0c8
leaq 0xb71f1(%rip), %rsi     # 0x1262af
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
cmpb $0x0, 0x14(%r14)
je 0x6f0f7
leaq 0xb71a6(%rip), %rsi     # 0x126293
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq