// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/mmm.c
// Function: my_mmm_chunk_handler
static int my_mmm_chunk_handler(struct de_iffctx *ictx)
{
	deark *c = ictx->c;
	struct mmm_ctx *d = (struct mmm_ctx*)ictx->userdata;
	i64 dpos, dlen;

	dpos = ictx->chunkctx->dpos;
	dlen = ictx->chunkctx->dlen;

	switch(ictx->chunkctx->chunk4cc.id) {
	case CODE_RIFF:
		ictx->is_std_container = 1;
		goto done;
	}

	if(ictx->level != 1) goto done;

	ictx->handled = 1;

	switch(ictx->chunkctx->chunk4cc.id) {
	case CODE_Ver_:
	case CODE_ver:
		if(d->pass==1) {
			do_mmm_ver(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_CFTC:
	case CODE_cftc:
		if(d->pass==1) {
			do_mmm_cftc(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_CLUT:
	case CODE_clut:
		if(d->pass==1 || d->pass==100) {
			do_mmm_clut(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_DIB:
	case CODE_dib:
		if(d->pass==1) {
			d->dib_count++;
		}
		else if(d->pass==2 && !d->suppress_dib_pass2) {
			do_mmm_dib(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_snd:
		if(d->pass==2) {
			do_mmm_snd(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_CURS:
		if(d->pass==2) {
			do_mmm_CURS(c, d, ictx, dpos, dlen);
		}
		break;
	case CODE_McNm:
	case CODE_mcnm:
		if(d->pass==1) {
			do_mmm_mcnm(c, d, ictx, dpos, dlen);
		}
		break;
	default:
		if(d->pass==1) {
			// Make sure the default behavior only happens in one of the passes
			// (e.g. hexdump if the debug level is set high enough).
			ictx->handled = 0;
		}
	}

done:
	if(d->errflag) return 0;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
movq 0x10(%rdi), %r15
movq 0x128(%rdi), %rcx
movl 0x4(%rcx), %eax
cmpl $0x52494646, %eax       # imm = 0x52494646
jne 0x970d4
movl $0x1, 0x134(%r14)
jmp 0x97488
cmpl $0x1, 0x64(%r14)
jne 0x97488
movq (%r14), %rdx
movq %rdx, 0x8(%rsp)
movq 0x40(%rcx), %r13
movq 0x48(%rcx), %r12
movl $0x1, 0x130(%r14)
cmpl $0x63667462, %eax       # imm = 0x63667462
jg 0x9714a
cmpl $0x4449421f, %eax       # imm = 0x4449421F
jg 0x97174
cmpl $0x43465443, %eax       # imm = 0x43465443
je 0x97212
cmpl $0x434c5554, %eax       # imm = 0x434C5554
je 0x97266
cmpl $0x43555253, %eax       # imm = 0x43555253
jne 0x9718d
cmpl $0x2, (%r15)
jne 0x97488
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x97dc9
jmp 0x97488
cmpl $0x6d636e6c, %eax       # imm = 0x6D636E6C
jg 0x971a7
cmpl $0x63667463, %eax       # imm = 0x63667463
je 0x97212
cmpl $0x636c7574, %eax       # imm = 0x636C7574
je 0x97266
cmpl $0x64696220, %eax       # imm = 0x64696220
je 0x971f4
jmp 0x9718d
cmpl $0x44494220, %eax       # imm = 0x44494220
je 0x971f4
cmpl $0x4d634e6d, %eax       # imm = 0x4D634E6D
je 0x97234
cmpl $0x5665722e, %eax       # imm = 0x5665722E
je 0x971c4
cmpl $0x1, (%r15)
jne 0x97488
movl $0x0, 0x130(%r14)
jmp 0x97488
cmpl $0x6d636e6d, %eax       # imm = 0x6D636E6D
je 0x97234
cmpl $0x736e6420, %eax       # imm = 0x736E6420
je 0x97339
cmpl $0x76657220, %eax       # imm = 0x76657220
jne 0x9718d
cmpl $0x1, (%r15)
jne 0x97488
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xeed61
leaq 0x9fba3(%rip), %rsi     # 0x136d84
movq 0x8(%rsp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
jmp 0x97488
movl (%r15), %eax
cmpl $0x2, %eax
je 0x9735e
cmpl $0x1, %eax
jne 0x97488
incl 0x18(%r15)
jmp 0x97488
cmpl $0x1, (%r15)
jne 0x97488
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x97579
jmp 0x97488
cmpl $0x1, (%r15)
jne 0x97488
addq $0x4, %r13
leaq 0x20(%rsp), %rcx
movq %r13, (%rcx)
leaq 0x996b1(%rip), %r8      # 0x130902
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x97fd7
jmp 0x97488
movl (%r15), %eax
cmpl $0x64, %eax
je 0x97277
cmpl $0x1, %eax
jne 0x97488
leaq 0x30(%rsp), %rbp
movq %r13, (%rbp)
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0xeee2f
movl %eax, 0x1c(%r15)
leaq 0xa7e4c(%rip), %rsi     # 0x13f0e3
leaq 0x99567(%rip), %rdx     # 0x130805
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movl 0x1c(%r15), %eax
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x97fd7
addq %r13, %r12
movq (%rbp), %rcx
subq %rcx, %r12
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
movq %r12, %rax
imulq %rdx
movq %rdx, %r13
shrq $0x3f, %r13
addq %rdx, %r13
leaq 0x99516(%rip), %rsi     # 0x13080c
movq %rbx, %rdi
movq %rcx, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe8617
leaq -0x60(%r12), %rax
cmpq $0x6, %rax
jb 0x97322
addq $-0x600, %r12           # imm = 0xFA00
cmpq $0x6, %r12
jae 0x974a1
movl (%r15), %eax
cmpl $0x64, %eax
je 0x97384
cmpl $0x1, %eax
jne 0x9738e
cmpb $0x0, 0x5(%r15)
sete %al
jmp 0x97390
cmpl $0x2, (%r15)
jne 0x97488
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x97b50
jmp 0x97488
cmpb $0x0, 0x11(%r15)
jne 0x97488
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x97655
jmp 0x97488
cmpb $0x0, 0x5(%r15)
setne %al
jmp 0x97390
xorl %eax, %eax
cmpb $0x0, 0x6(%r15)
movq %r15, 0x18(%rsp)
je 0x973a6
movl 0x14(%rsp), %ecx
cmpl 0x8(%r15), %ecx
jmp 0x973ab
cmpb $0x0, 0x20(%r15)
sete %cl
andb %al, %cl
movb %cl, 0x14(%rsp)
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xe8a15
xorl %ebx, %ebx
leaq 0x30(%rsp), %r12
xorl %r15d, %r15d
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xeeb91
movl $0x10, %edi
movl %eax, %esi
callq 0xec741
movzbl %al, %eax
movl %eax, 0x20(%rsp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x973cd
movq %rbx, %rbp
notq %rbp
addq %r13, %rbp
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %r15d
shll $0x10, %eax
shll $0x8, %r15d
orl %eax, %r15d
orl 0x28(%rsp), %r15d
orl $0xff000000, %r15d      # imm = 0xFF000000
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0xe91fc
cmpb $0x0, 0x14(%rsp)
je 0x97449
movq 0x18(%rsp), %rax
movl %r15d, 0x38(%rax,%rbp,4)
incq %rbx
cmpq %r13, %rbx
jne 0x973ca
jmp 0x9746b
incq %rbx
cmpq %r13, %rbx
jne 0x973ca
movq 0x8(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%rsp), %r15
jmp 0x97484
movq 0x8(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%rsp), %r15
movb $0x1, 0x20(%r15)
incl 0x14(%r15)
xorl %eax, %eax
cmpb $0x0, 0x10(%r15)
sete %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9937f(%rip), %rsi     # 0x130827
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0xe8faa
jmp 0x97484