// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/riff.c
// Function: my_riff_chunk_handler
static int my_riff_chunk_handler(struct de_iffctx *ictx)
{
	i64 dpos, dlen;
	u32 list_type;
	deark *c = ictx->c;
	lctx *d = (lctx*)ictx->userdata;

	list_type = ictx->curr_container_contentstype4cc.id;
	dpos = ictx->chunkctx->dpos;
	dlen = ictx->chunkctx->dlen;

	switch(ictx->chunkctx->chunk4cc.id) {
	case CHUNK_RIFF:
	case CHUNK_RIFX:
	case CHUNK_LIST:
		ictx->is_std_container = 1;
		return 1;
	}

	if(list_type==CODE_INFO) {
		do_INFO_item(c, d, ictx, dpos, dlen, ictx->chunkctx->chunk4cc.id);
		ictx->handled = 1;
		goto done;
	}

	switch(ictx->chunkctx->chunk4cc.id) {

	case CHUNK_DISP:
		do_DISP(c, d, ictx, dpos, dlen);
		ictx->handled = 1;
		break;

	case CHUNK_ICCP: // Used by WebP
		do_ICCP(c, d, ictx, dpos, dlen);
		ictx->handled = 1;
		break;

	case CHUNK_EXIF: // Used by WebP
		do_EXIF(c, d, ictx, dpos, dlen);
		ictx->handled = 1;
		break;

	case CHUNK_XMP: // Used by WebP
	case CHUNK__PMX: // Used by WAVE, AVI
		do_XMP(c, d, ictx, dpos, dlen);
		ictx->handled = 1;
		break;

	case CHUNK_bmhd:
		if(list_type==CODE_RDIB) {
			do_RDIB_bmhd(c, d, ictx);
			ictx->handled = 1;
		}
		break;

	case CHUNK_icon:
		if(ictx->main_contentstype4cc.id==CODE_ACON) {
			extract_ani_frame(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_data:
		if(list_type==CODE_RMID) {
			do_extract_raw(c, d, ictx, dpos, dlen, "mid", NULL, 0);
			ictx->handled = 1;
		}
		else if(list_type==CODE_PAL) {
			do_palette(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		else if(list_type==CODE_RDIB) {
			do_RDIB_data(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_fmt:
		if(ictx->main_contentstype4cc.id==CODE_WAVE) {
			do_wav_fmt(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_fact:
		if(ictx->main_contentstype4cc.id==CODE_WAVE) {
			do_wav_fact(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_avih:
		if(ictx->main_contentstype4cc.id==CODE_AVI) {
			do_avi_avih(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_strh:
		if(ictx->main_contentstype4cc.id==CODE_AVI) {
			do_avi_strh(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_strf:
		if(ictx->main_contentstype4cc.id==CODE_AVI) {
			do_avi_strf(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;

	case CHUNK_bmp:
		if(d->is_cdr && ictx->curr_container_contentstype4cc.id==CODE_bmpt) {
			do_cdr_bmp(c, d, ictx, dpos, dlen);
			ictx->handled = 1;
		}
		break;
	}

done:
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rbx
movq 0x128(%rdi), %rax
movl 0x4(%rax), %r14d
cmpl $0x4c495354, %r14d      # imm = 0x4C495354
je 0xba35d
cmpl $0x52494658, %r14d      # imm = 0x52494658
je 0xba35d
cmpl $0x52494646, %r14d      # imm = 0x52494646
jne 0xba36c
movl $0x1, 0x134(%rbx)
jmp 0xbab3a
movq (%rbx), %r15
movq 0x10(%rbx), %rbp
movl 0xfc(%rbx), %ecx
movq 0x40(%rax), %r13
movq 0x48(%rax), %r12
cmpl $0x494e464f, %ecx       # imm = 0x494E464F
jne 0xba3f5
movq %r15, %rdi
callq 0xeac74
movq %r13, %rsi
movq %rax, %r13
movq 0x18(%rbx), %rdi
movl 0x60(%rbx), %eax
movl %eax, (%rsp)
pushq $0x1
popq %r9
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r12, %rdx
movq %r13, %r8
callq 0xe4ced
movq %r13, %rdi
callq 0xeb877
leaq 0x4b387(%rip), %rsi     # 0x10574b
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpl $0x494e414d, %r14d      # imm = 0x494E414D
jne 0xba5a3
movq 0x18(%rbp), %rdi
testq %rdi, %rdi
je 0xba579
callq 0xeac85
jmp 0xba585
cmpl $0x73747268, %r14d      # imm = 0x73747268
je 0xba77d
cmpl $0x45584946, %r14d      # imm = 0x45584946
je 0xba5e2
cmpl $0x49434350, %r14d      # imm = 0x49434350
je 0xba8cb
cmpl $0x584d5020, %r14d      # imm = 0x584D5020
je 0xba5b0
cmpl $0x5f504d58, %r14d      # imm = 0x5F504D58
je 0xba5b0
cmpl $0x61766968, %r14d      # imm = 0x61766968
je 0xba632
cmpl $0x626d6864, %r14d      # imm = 0x626D6864
je 0xba5c0
cmpl $0x626d7020, %r14d      # imm = 0x626D7020
je 0xba5f5
cmpl $0x64617461, %r14d      # imm = 0x64617461
je 0xba89b
cmpl $0x66616374, %r14d      # imm = 0x66616374
je 0xba80e
cmpl $0x666d7420, %r14d      # imm = 0x666D7420
je 0xba768
cmpl $0x69636f6e, %r14d      # imm = 0x69636F6E
je 0xba6fe
cmpl $0x73747266, %r14d      # imm = 0x73747266
je 0xba856
cmpl $0x44495350, %r14d      # imm = 0x44495350
jne 0xbab3a
cmpq $0x4, %r12
jl 0xbab30
cmpl $0x0, 0x58(%rbx)
je 0xbab30
movq 0x18(%r15), %rdi
movq %r13, %r14
movq %r13, %rsi
callq 0xe409f
movq %rax, %r13
movl %r13d, %edi
callq 0xed57e
leaq 0x4b22d(%rip), %rsi     # 0x10570d
movq %r15, %rdi
movl %r13d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
addq $0x4, %r14
addq $-0x4, %r12
cmpl $0x1, %r13d
je 0xba51c
cmpl $0x11, %r13d
je 0xbaac4
cmpl $0x8, %r13d
je 0xbaac4
cmpl $0x7, %r13d
jne 0xbab30
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r13
xorl %esi, %esi
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0xe4b21
movq (%r13), %r13
subq %r14, %r13
testl %eax, %eax
cmoveq %r12, %r13
leaq 0x520f5(%rip), %rsi     # 0x10c63e
movq %r15, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
testq %r13, %r13
jle 0xbab30
movq 0x18(%rbx), %rdi
leaq 0x72c04(%rip), %rcx     # 0x12d16e
pushq $0x1
popq %r9
movq %r14, %rsi
movq %r13, %rdx
jmp 0xba8e0
movq %r15, %rdi
callq 0xeac74
movq %rax, 0x18(%rbp)
cmpq $0x41, 0x10(%r13)
jl 0xba597
pushq $0x40
popq %rsi
movq %r13, %rdi
callq 0xeac8c
movq 0x18(%rbp), %rdi
movq %r13, %rsi
callq 0xead71
movq %r13, %rdi
callq 0xeaf3c
jmp 0xbab30
movq 0x18(%rbx), %rdi
leaq 0x70243(%rip), %rcx     # 0x12a7fe
jmp 0xba8d6
cmpl $0x52444942, %ecx       # imm = 0x52444942
jne 0xbab3a
movq 0x50(%rax), %rax
testq %rax, %rax
je 0xbab30
orb $0x1, 0x60(%rax)
jmp 0xbab30
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xec1b2
jmp 0xbab30
cmpl $0x0, 0x4(%rbp)
setne %al
cmpl $0x626d7074, %ecx       # imm = 0x626D7074
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xbab3a
cmpq $0x14, %r12
jl 0xbab30
movq 0x18(%rbx), %rdi
addq $0x2, %r13
addq $-0x2, %r12
leaq 0x59a45(%rip), %rcx     # 0x114072
jmp 0xbab1f
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xbab3a
cmpq $0x28, %r12
jl 0xbab30
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xe409f
leaq 0x72be9(%rip), %rsi     # 0x12d248
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0xc(%r13), %rsi
callq 0xe409f
leaq 0x5efaf(%rip), %rsi     # 0x11962e
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0x10(%r13), %rsi
callq 0xe409f
leaq 0x72bc0(%rip), %rsi     # 0x12d25f
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0x18(%r13), %rsi
callq 0xe409f
leaq 0x72bb5(%rip), %rsi     # 0x12d274
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0x20(%r13), %rsi
callq 0xe409f
movq %rax, %r14
movq 0x18(%r15), %rdi
addq $0x24, %r13
movq %r13, %rsi
callq 0xe409f
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xdf038
jmp 0xbab30
cmpl $0x41434f4e, 0x9c(%rbx) # imm = 0x41434F4E
jne 0xbab3a
leaq 0x72a62(%rip), %rsi     # 0x12d177
movq %r15, %rdi
movl %r13d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
leaq 0x20(%rsp), %r15
pushq $0x4
popq %rcx
movq %r15, %rsi
movq %r13, %rdx
callq 0xe3cb7
cmpl $0x10000, (%r15)        # imm = 0x10000
je 0xbab14
cmpl $0x20000, 0x20(%rsp)    # imm = 0x20000
leaq 0x55b4b(%rip), %rax     # 0x1102a3
leaq 0x6dd7e(%rip), %rcx     # 0x1284dd
cmoveq %rax, %rcx
jmp 0xbab1b
cmpl $0x57415645, 0x9c(%rbx) # imm = 0x57415645
jne 0xbab3a
jmp 0xba8e8
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xbab3a
cmpq $0x8, %r12
jl 0xbab30
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %rdx
pushq $0x4
popq %r12
movq %r13, %rsi
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0xe657c
leaq 0x30(%rsp), %r14
leaq 0x72acc(%rip), %rsi     # 0x12d28a
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movl -0xc(%r14), %eax
movl %eax, 0x8(%rbp)
movq 0x18(%rbx), %rdi
addq $0x4, %r13
leaq 0xc8(%rsp), %rdx
movq %r13, %rsi
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0xe657c
leaq 0xd8(%rsp), %rdx
leaq 0x72a9d(%rip), %rsi     # 0x12d29c
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
jmp 0xbab30
cmpl $0x57415645, 0x9c(%rbx) # imm = 0x57415645
jne 0xbab3a
cmpq $0x4, %r12
jl 0xbab30
cmpl $0x0, 0x58(%rbx)
je 0xbab30
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xe409f
leaq 0x729ed(%rip), %rsi     # 0x12d232
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
jmp 0xbab30
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xbab3a
movl 0x8(%rbp), %eax
cmpl $0x61756473, %eax       # imm = 0x61756473
je 0xba8e8
cmpl $0x76696473, %eax       # imm = 0x76696473
jne 0xbab30
movq 0x18(%rbx), %rsi
leaq 0x20(%rsp), %rdx
pushq $0x18
popq %r9
movq %r15, %rdi
movq %r13, %rcx
movq %r12, %r8
callq 0xebba5
jmp 0xbab30
cmpl $0x50414c20, %ecx       # imm = 0x50414C20
je 0xba973
cmpl $0x52444942, %ecx       # imm = 0x52444942
je 0xba8fe
cmpl $0x524d4944, %ecx       # imm = 0x524D4944
jne 0xbab3a
movq 0x18(%rbx), %rdi
leaq 0x728a4(%rip), %rcx     # 0x12d16a
jmp 0xbab1f
movq 0x18(%rbx), %rdi
leaq 0x4e237(%rip), %rcx     # 0x108b0d
pushq $0x1
popq %r9
movq %r13, %rsi
movq %r12, %rdx
xorl %r8d, %r8d
jmp 0xbab2b
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xbad76
jmp 0xbab30
movq 0x50(%rax), %rax
testq %rax, %rax
je 0xbab4f
movl 0x60(%rax), %ecx
testb $0x1, %cl
jne 0xbab4f
movq %r13, %r14
orl $0x1, %ecx
movl %ecx, 0x60(%rax)
movq %r15, %rdi
callq 0xdfd1a
movq %rax, %r13
movq 0x18(%rbp), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0xba952
movq 0x18(%rbp), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0xdfd55
movq 0x18(%rbp), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
leaq 0x59715(%rip), %rcx     # 0x114072
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %r8
xorl %r9d, %r9d
callq 0xe4e0b
jmp 0xbab52
cmpl $0x0, 0x58(%rbx)
je 0xbab30
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xe3fa3
leaq 0x6d789(%rip), %rsi     # 0x128119
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x2(%r13), %rsi
movq 0x18(%r15), %rdi
callq 0xe3fa3
movq %r13, %r14
movq %rax, %r13
leaq 0x4f038(%rip), %rsi     # 0x1099ee
movq %r15, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
addq $-0x4, %r12
pushq $0x4
popq %rcx
movq %r12, %rax
cqto
idivq %rcx
cmpq %rax, %r13
cmovlq %r13, %rax
movl $0x400, %ecx            # imm = 0x400
cmpq %rcx, %rax
cmovlq %rax, %rcx
movq %rcx, 0x18(%rsp)
testq %rax, %rax
jle 0xbab30
movq %r14, %r13
addq $0x4, %r13
leaq 0x7278a(%rip), %rsi     # 0x12d18b
movq %r15, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
xorl %r12d, %r12d
cmpq %r12, 0x18(%rsp)
je 0xbab5f
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xe3eb4
movb %al, 0x17(%rsp)
movq 0x18(%r15), %rdi
leaq 0x1(%r13), %rsi
callq 0xe3eb4
movq %r12, %rbp
movl %eax, %r12d
movq 0x18(%r15), %rdi
leaq 0x2(%r13), %rsi
callq 0xe3eb4
movl %eax, %r14d
movq 0x18(%r15), %rdi
leaq 0x3(%r13), %rsi
callq 0xe3eb4
movzbl 0x17(%rsp), %ecx
shll $0x10, %ecx
movzbl %r12b, %edx
movq %rbp, %r12
shll $0x8, %edx
orl %ecx, %edx
movzbl %r14b, %ebp
orl %edx, %ebp
orl $0xff000000, %ebp       # imm = 0xFF000000
movzbl %al, %ecx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
pushq $0x20
popq %rsi
leaq 0x563fd(%rip), %rdx     # 0x110e99
xorl %eax, %eax
callq 0xde40c
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r14, %r9
callq 0xdf153
incq %r12
addq $0x4, %r13
jmp 0xbaa1c
cmpq $0xc, %r12
jb 0xbab30
pushq $0x70
popq %rsi
movq %r15, %rdi
callq 0xdecaf
movq %rax, %r13
leaq 0x7bb0d(%rip), %rax     # 0x1365ec
movq %rax, (%r13)
movl $0x80, 0x8(%r13)
movq 0x18(%rbx), %rcx
leaq 0x5b759(%rip), %rsi     # 0x11624f
movq %r15, %rdi
movq %r13, %rdx
movq %r14, %r8
movq %r12, %r9
callq 0xdf9b8
movq %r15, %rdi
movq %r13, %rsi
callq 0xded32
jmp 0xbab30
leaq 0x5954e(%rip), %rcx     # 0x114069
movq 0x18(%rbx), %rdi
movq %r13, %rsi
movq %r12, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xe4e0b
movl $0x1, 0x130(%rbx)
pushq $0x1
popq %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
movq %r15, %rdi
movq %r13, %rsi
callq 0xdfd24
jmp 0xbab30
pushq $-0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
jmp 0xbab30