// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/corel.c
// Function: de_run_corel_ccx
static void de_run_corel_ccx(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	struct de_iffctx *ictx = NULL;

	d = de_malloc(c, sizeof(lctx));

	ictx = fmtutil_create_iff_decoder(c);
	ictx->is_le = 1;
	ictx->reversed_4cc = 0;
	ictx->userdata = (void*)d;
	ictx->handle_chunk_fn = my_ccx_chunk_handler;
	ictx->f = c->infile;

	fmtutil_read_iff_format(ictx, 0, c->infile->len);
	if(d->pack_pos) {
		de_dbg(c, "pack chunk found at %"I64_FMT, d->pack_pos);
		de_dbg_indent(c, 1);
		do_decompress(c, d);
		de_dbg_indent(c, -1);
	}

	fmtutil_destroy_iff_decoder(ictx);
	if(d) {
		if(!d->wrote_cmx_file) {
			de_err(c, "Cannot convert this CCX file. Try \"-m riff\" to decode.");
		}
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
pushq $0x20
popq %rsi
callq 0xdecaf
movq %rax, %r14
movq %rbx, %rdi
callq 0xfacc0
movq %rax, %r15
movl $0x1, 0x58(%rax)
movb $0x0, 0x5c(%rax)
movq %r14, 0x10(%rax)
leaq 0x323(%rip), %rax       # 0x527d1
movq %rax, 0x20(%r15)
movq 0x18(%rbx), %rax
movq %rax, 0x18(%r15)
movq 0x18(%rax), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0xface4
movq (%r14), %rdx
testq %rdx, %rdx
je 0x52658
leaq 0xc14c9(%rip), %rsi     # 0x1139a4
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
cmpq $0xc, 0x10(%r14)
jl 0x5263a
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe40bf
movq %rax, %rbp
leaq 0xc14cc(%rip), %rsi     # 0x1139f3
xorl %r13d, %r13d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpq $0x5f5e100, %rbp        # imm = 0x5F5E100
jg 0x5263a
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe4071
cmpl $0x43506e67, %eax       # imm = 0x43506E67
jne 0x52621
addq $0x4, 0x8(%rsp)
movq %rbp, %rdi
callq 0xdfb87
movq 0x8(%rsp), %rcx
movq 0x8(%r14), %r13
subq %rcx, %r13
addq 0x10(%r14), %r13
testq %r13, %r13
jle 0x52637
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
callq 0xe59cd
movq %rax, %r12
leaq 0x48(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x68(%rsp), %rcx
movq %rbx, %rdi
callq 0xee7ee
movq 0x18(%rbx), %rax
leaq 0x48(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsi)
movq %r13, 0x10(%rsi)
leaq 0x30(%rsp), %rdx
movq %r12, (%rdx)
movb $0x1, 0x8(%rdx)
movq %rbp, 0x10(%rdx)
leaq 0x20(%rsp), %r8
movl $0x1, (%r8)
movq %rbx, %rdi
leaq 0x68(%rsp), %r13
movq %r13, %rcx
callq 0xf4633
cmpl $0x0, (%r13)
je 0x52695
leaq 0x78(%rsp), %rdx
leaq 0xb56ed(%rip), %rsi     # 0x107cff
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x5263d
leaq 0xc13ec(%rip), %rsi     # 0x113a14
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x5263a
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %r12, %rdi
callq 0xe5591
movq %r13, %rdi
callq 0xe5591
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq %r15, %rdi
callq 0xfacd3
cmpl $0x0, 0x18(%r14)
jne 0x52678
leaq 0xc134e(%rip), %rsi     # 0x1139bc
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %r13
movq 0x18(%r12), %rcx
cmpq %rbp, %rcx
jge 0x526b8
leaq 0xc1388(%rip), %rsi     # 0x113a33
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xdf05a
movq %r12, %rdi
movq %r13, %rsi
callq 0xe5eb2
movq 0x8(%r14), %rbp
movq 0x10(%r14), %rdi
callq 0xdfb87
addq %rax, %rbp
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rdi
subq %rbp, %rdi
callq 0xdfb87
movq %rax, 0x18(%rsp)
movq 0x18(%r12), %rdx
movq (%r14), %rcx
addq %rax, %rcx
leaq (%rdx,%rcx), %rax
addq $-0x8, %rax
movq %rax, 0x10(%rsp)
leaq 0xc1368(%rip), %rsi     # 0x113a6f
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r13
movl $0x1, 0x18(%r14)
movl $0x52494646, %esi       # imm = 0x52494646
movq %rax, %rdi
callq 0xe5f65
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0xe5f7f
movl $0x434d5831, %esi       # imm = 0x434D5831
movq %r13, %rdi
callq 0xe5f65
movq 0x18(%rbx), %rdi
movq (%r14), %rdx
addq $-0xc, %rdx
pushq $0xc
popq %rsi
movq %r13, %rcx
callq 0xe45f4
movq 0x18(%r12), %rdx
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rcx
callq 0xe45f4
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rcx
callq 0xe45f4
jmp 0x5263d