// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, %rbx
movq 0x128(%rdi), %rcx
movl 0x4(%rcx), %r14d
cmpl $0x4c495354, %r14d      # imm = 0x4C495354
je 0xc1d86
cmpl $0x52494658, %r14d      # imm = 0x52494658
je 0xc1d86
cmpl $0x52494646, %r14d      # imm = 0x52494646
jne 0xc1d95
movl $0x1, 0x134(%rbx)
jmp 0xc1f94
movq (%rbx), %r12
movq 0x10(%rbx), %rsi
movl 0xfc(%rbx), %eax
movq 0x40(%rcx), %r13
movq 0x48(%rcx), %r15
cmpl $0x494e464f, %eax       # imm = 0x494E464F
jne 0xc1e29
movq %rsi, 0x10(%rsp)
movq %r12, %rdi
callq 0xf6410
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movl 0x60(%rbx), %eax
movl %eax, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %r8
movl $0x1, %r9d
callq 0xefc2a
movq %rbp, %rdi
callq 0xf70f6
leaq 0x50978(%rip), %rsi     # 0x11276b
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpl $0x494e414d, %r14d      # imm = 0x494E414D
jne 0xc1f82
movq 0x10(%rsp), %r14
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xc1f56
callq 0xf6423
jmp 0xc1f62
cmpl $0x626d701f, %r14d      # imm = 0x626D701F
jg 0xc1e72
cmpl $0x584d501f, %r14d      # imm = 0x584D501F
jle 0xc1ecc
cmpl $0x61766967, %r14d      # imm = 0x61766967
jg 0xc1fa8
cmpl $0x584d5020, %r14d      # imm = 0x584D5020
je 0xc1e62
cmpl $0x5f504d58, %r14d      # imm = 0x5F504D58
jne 0xc1f94
movq 0x18(%rbx), %rdi
leaq 0x75c71(%rip), %rcx     # 0x137ade
jmp 0xc1efe
cmpl $0x666d741f, %r14d      # imm = 0x666D741F
jle 0xc1f14
cmpl $0x73747265, %r14d      # imm = 0x73747265
jg 0xc1fd0
cmpl $0x666d7420, %r14d      # imm = 0x666D7420
je 0xc2001
cmpl $0x69636f6e, %r14d      # imm = 0x69636F6E
jne 0xc1f94
cmpl $0x41434f4e, 0x9c(%rbx) # imm = 0x41434F4E
jne 0xc1f94
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xc2487
jmp 0xc1f8a
cmpl $0x44495350, %r14d      # imm = 0x44495350
je 0xc206f
cmpl $0x45584946, %r14d      # imm = 0x45584946
je 0xc20bd
cmpl $0x49434350, %r14d      # imm = 0x49434350
jne 0xc1f94
movq 0x18(%rbx), %rdi
leaq 0x53c9f(%rip), %rcx     # 0x115b9d
movq %r13, %rsi
movq %r15, %rdx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xefd48
jmp 0xc1f8a
cmpl $0x626d7020, %r14d      # imm = 0x626D7020
je 0xc2085
cmpl $0x64617461, %r14d      # imm = 0x64617461
je 0xc20d0
cmpl $0x66616374, %r14d      # imm = 0x66616374
jne 0xc1f94
cmpl $0x57415645, 0x9c(%rbx) # imm = 0x57415645
jne 0xc1f94
movl 0x58(%rbx), %esi
movq %r12, %rdi
movq %r13, %rdx
movq %r15, %rcx
callq 0xc273f
jmp 0xc1f8a
movq %r12, %rdi
callq 0xf6410
movq %rax, 0x18(%r14)
cmpq $0x41, 0x10(%rbp)
jl 0xc1f76
movl $0x40, %esi
movq %rbp, %rdi
callq 0xf642a
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0xf6509
movq %rbp, %rdi
callq 0xf6753
movl $0x1, 0x130(%rbx)
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x61766968, %r14d      # imm = 0x61766968
je 0xc2023
cmpl $0x626d6864, %r14d      # imm = 0x626D6864
jne 0xc1f94
cmpl $0x52444942, %eax       # imm = 0x52444942
jne 0xc1f94
movq 0x50(%rcx), %rax
testq %rax, %rax
je 0xc1f8a
orb $0x1, 0x60(%rax)
jmp 0xc1f8a
cmpl $0x73747266, %r14d      # imm = 0x73747266
je 0xc2046
cmpl $0x73747268, %r14d      # imm = 0x73747268
jne 0xc1f94
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xc1f94
movq %r12, %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0xc2835
jmp 0xc1f8a
cmpl $0x57415645, 0x9c(%rbx) # imm = 0x57415645
jne 0xc1f94
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xc2910
jmp 0xc1f8a
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xc1f94
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xc2774
jmp 0xc1f8a
cmpl $0x41564920, 0x9c(%rbx) # imm = 0x41564920
jne 0xc1f94
movl 0x8(%rsi), %esi
movq %r12, %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0xc28d2
jmp 0xc1f8a
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0xc233b
jmp 0xc1f8a
cmpl $0x0, 0x4(%rsi)
setne %cl
cmpl $0x626d7074, %eax       # imm = 0x626D7074
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0xc1f94
cmpq $0x14, %r15
jl 0xc1f8a
movq 0x18(%rbx), %rdi
addq $0x2, %r13
addq $-0x2, %r15
leaq 0x5f0a7(%rip), %rcx     # 0x121162
jmp 0xc20f4
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xf7a67
jmp 0xc1f8a
cmpl $0x50414c20, %eax       # imm = 0x50414C20
je 0xc211b
cmpl $0x52444942, %eax       # imm = 0x52444942
je 0xc2105
cmpl $0x524d4944, %eax       # imm = 0x524D4944
jne 0xc1f94
movq 0x18(%rbx), %rdi
leaq 0x7836a(%rip), %rcx     # 0x13a45e
movq %r13, %rsi
movq %r15, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
jmp 0xc1f0d
movq %r12, %rdi
movq %rbx, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0xc269b
jmp 0xc1f8a
movl 0x58(%rbx), %esi
movq %r12, %rdi
movq %r13, %rdx
movq %r15, %rcx
callq 0xc2511
jmp 0xc1f8a