// File: /workspace/github_c_makefile_star2_O1/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), %rbx
movq 0x128(%rdi), %rcx
movl 0x4(%rcx), %eax
cmpl $0x52494646, %eax       # imm = 0x52494646
jne 0x979d5
movl $0x1, 0x134(%r14)
jmp 0x97d62
cmpl $0x1, 0x64(%r14)
jne 0x97d62
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 0x97a4a
cmpl $0x4449421f, %eax       # imm = 0x4449421F
jg 0x97a70
cmpl $0x43465443, %eax       # imm = 0x43465443
je 0x97b06
cmpl $0x434c5554, %eax       # imm = 0x434C5554
je 0x97b58
cmpl $0x43555253, %eax       # imm = 0x43555253
jne 0x97a89
cmpl $0x2, (%rbx)
jne 0x97d62
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x98658
jmp 0x97d62
cmpl $0x6d636e6c, %eax       # imm = 0x6D636E6C
jg 0x97aa2
cmpl $0x63667463, %eax       # imm = 0x63667463
je 0x97b06
cmpl $0x636c7574, %eax       # imm = 0x636C7574
je 0x97b58
cmpl $0x64696220, %eax       # imm = 0x64696220
je 0x97aea
jmp 0x97a89
cmpl $0x44494220, %eax       # imm = 0x44494220
je 0x97aea
cmpl $0x4d634e6d, %eax       # imm = 0x4D634E6D
je 0x97b27
cmpl $0x5665722e, %eax       # imm = 0x5665722E
je 0x97abb
cmpl $0x1, (%rbx)
jne 0x97d62
movl $0x0, 0x130(%r14)
jmp 0x97d62
cmpl $0x6d636e6d, %eax       # imm = 0x6D636E6D
je 0x97b27
cmpl $0x736e6420, %eax       # imm = 0x736E6420
je 0x97c34
cmpl $0x76657220, %eax       # imm = 0x76657220
jne 0x97a89
cmpl $0x1, (%rbx)
jne 0x97d62
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xef37e
leaq 0x9eee3(%rip), %rsi     # 0x1369ba
movq 0x8(%rsp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
jmp 0x97d62
movl (%rbx), %eax
cmpl $0x2, %eax
je 0x97c58
cmpl $0x1, %eax
jne 0x97d62
incl 0x18(%rbx)
jmp 0x97d62
cmpl $0x1, (%rbx)
jne 0x97d62
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x97e5d
jmp 0x97d62
cmpl $0x1, (%rbx)
jne 0x97d62
addq $0x4, %r13
leaq 0x18(%rsp), %rcx
movq %r13, (%rcx)
leaq 0x98a84(%rip), %r8      # 0x1305c7
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x98866
jmp 0x97d62
movl (%rbx), %eax
cmpl $0x64, %eax
je 0x97b68
cmpl $0x1, %eax
jne 0x97d62
leaq 0x30(%rsp), %rbp
movq %r13, (%rbp)
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0xef475
movl %eax, 0x1c(%rbx)
leaq 0xa715c(%rip), %rsi     # 0x13ece3
leaq 0x9893c(%rip), %rdx     # 0x1304ca
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movl 0x1c(%rbx), %eax
movl %eax, 0x14(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x98866
addq %r13, %r12
movq (%rbp), %r8
subq %r8, %r12
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
movq %r12, %rax
imulq %rdx
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rdx, %rcx
leaq 0x988ec(%rip), %rsi     # 0x1304d1
movq %r15, %rdi
movq %r8, %rdx
movq %rcx, 0x28(%rsp)
xorl %eax, %eax
callq 0xe9226
leaq -0x60(%r12), %rax
cmpq $0x6, %rax
jb 0x97c14
leaq -0x600(%r12), %rax
cmpq $0x6, %rax
jae 0x97d7a
movl (%rbx), %eax
cmpl $0x64, %eax
je 0x97c2b
cmpl $0x1, %eax
jne 0x97c7d
cmpb $0x0, 0x5(%rbx)
je 0x97c81
cmpl $0x64, %eax
jne 0x97c7d
cmpb $0x0, 0x5(%rbx)
setne %al
jmp 0x97c83
cmpl $0x2, (%rbx)
jne 0x97d62
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x983e2
jmp 0x97d62
cmpb $0x0, 0x11(%rbx)
jne 0x97d62
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r13, %rcx
movq %r12, %r8
callq 0x97f41
jmp 0x97d62
xorl %eax, %eax
jmp 0x97c83
movb $0x1, %al
cmpb $0x0, 0x6(%rbx)
je 0x97c92
movl 0x14(%rsp), %ecx
cmpl 0x8(%rbx), %ecx
jmp 0x97c96
cmpb $0x0, 0x20(%rbx)
sete %cl
andb %al, %cl
movb %cl, 0x14(%rsp)
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xe9585
cmpq $0x6, %r12
jl 0x97d45
xorl %r13d, %r13d
leaq 0x30(%rsp), %r12
xorl %r15d, %r15d
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xef193
movl %eax, 0x18(%rsp,%r15,4)
movl $0x10, %edi
movl %eax, %esi
callq 0xecd9a
movzbl %al, %eax
movl %eax, 0x18(%rsp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x97cc3
movq %r13, %rbp
notq %rbp
addq 0x28(%rsp), %rbp
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %r15d
shll $0x10, %eax
shll $0x8, %r15d
orl %eax, %r15d
orl 0x20(%rsp), %r15d
orl $0xff000000, %r15d      # imm = 0xFF000000
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0xe9d68
cmpb $0x0, 0x14(%rsp)
je 0x97d37
movl %r15d, 0x38(%rbx,%rbp,4)
incq %r13
cmpq 0x28(%rsp), %r13
jne 0x97cc0
movq 0x8(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x0, 0x14(%rsp)
je 0x97d5f
movb $0x1, 0x20(%rbx)
incl 0x14(%rbx)
xorl %eax, %eax
cmpb $0x0, 0x10(%rbx)
sete %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9876b(%rip), %rsi     # 0x1304ec
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0x97d5f