// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fli.c
// Function: identify_chunk
static void identify_chunk(deark *c, lctx *d, struct chunk_info_type *ci)
{
	enum mapped_chunktype_enum parent_mct;
	UI ct = ci->chunktype;

	parent_mct = ci->parent ? ci->parent->mct : MCT_NONE;
	ci->mct = MCT_NONE;
	ci->handler_fn = NULL;
	ci->chunk_type_name = "?";

	if(parent_mct==MCT_NONE) {
		if(ct==CHUNKTYPE_FLI) {
			ci->chunk_type_name = "FLI";
		}
		else if(ct==CHUNKTYPE_FLC) {
			ci->chunk_type_name = "FLC";
		}
		ci->mct = MCT_FLI_OR_FLC;
		ci->handler_fn = do_chunk_FLI_FLC;
		goto done;
	}

	if(parent_mct==MCT_FLI_OR_FLC) {
		if(ct==CHUNKTYPE_FRAME) {
			ci->mct = MCT_FRAME;
			ci->chunk_type_name = "frame";
			ci->handler_fn = do_chunk_frame;
			goto done;
		}
		else if(ct==0xf5fa) {
			ci->mct = MCT_FRAME;
			ci->chunk_type_name = "frame-variant";
			ci->handler_fn = do_chunk_frame;
			goto done;
		}
		else if(ct==CHUNKTYPE_PREFIX) {
			ci->mct = MCT_PREFIX;
			ci->chunk_type_name = "prefix";
			ci->handler_fn = do_chunk_prefix;
			goto done;
		}
	}

	if(parent_mct==MCT_FRAME || parent_mct==MCT_THUMBNAIL) {
		if(ct==CHUNKTYPE_COLORMAP64) {
			ci->mct = MCT_COLORMAP;
			ci->chunk_type_name = "color map 64";
			ci->handler_fn = do_chunk_colormap;
			goto done;
		}
		else if(ct==CHUNKTYPE_COLORMAP256) {
			ci->mct = MCT_COLORMAP;
			ci->chunk_type_name = "color map 256";
			ci->handler_fn = do_chunk_colormap;
			goto done;
		}
		else if(ct==CHUNKTYPE_RLE) {
			ci->mct = MCT_RLE;
			ci->chunk_type_name = "RLE compressed data";
			ci->handler_fn = do_chunk_rle;
			goto done;
		}
		else if(ct==CHUNKTYPE_DELTA_FLI) {
			ci->mct = MCT_DELTA_FLI;
			ci->chunk_type_name = "delta compressed data (old)";
			ci->handler_fn = do_chunk_delta_fli;
			goto done;
		}
		else if(ct==CHUNKTYPE_DELTA_FLC) {
			ci->mct = MCT_DELTA_FLC;
			ci->chunk_type_name = "delta compressed data (new)";
			ci->handler_fn = do_chunk_delta_flc;
			goto done;
		}
		else if(ct==CHUNKTYPE_COPY) {
			ci->mct = MCT_COPY;
			ci->chunk_type_name = "uncompressed data";
			ci->handler_fn = do_chunk_copy;
			goto done;
		}
		else if(ct==CHUNKTYPE_BLACK) {
			ci->mct = MCT_BLACK;
			ci->chunk_type_name = "clear screen";
			ci->handler_fn = do_chunk_black;
			goto done;
		}
	}

	if(parent_mct==MCT_FRAME) {
		if(ct==CHUNKTYPE_THUMBNAIL) {
			ci->mct = MCT_THUMBNAIL;
			ci->chunk_type_name = "thumbnail image";
			ci->handler_fn = do_chunk_thumbnail;
			goto done;
		}
	}

	if(parent_mct==MCT_PREFIX) {
		if(ct==0x0002) {
			ci->mct = MCT_SETTINGS;
			ci->chunk_type_name = "settings";
			ci->handler_fn = do_chunk_settings;
			goto done;
		}
		else if(ct==0x0003) {
			ci->mct = MCT_CELDATA;
			ci->chunk_type_name = "CEL data";
			ci->handler_fn = do_chunk_hexdump;
			goto done;
		}
	}

	if(parent_mct==MCT_SETTINGS) {
		ci->mct = MCT_ONESETTING;
		ci->handler_fn = do_chunk_hexdump;
		goto done;
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x80c04
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0x80c0e
movl $0x10002, %eax          # imm = 0x10002
movl %eax, -0x24(%rbp)
jmp 0x80c0e
movl -0x24(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl $0x10002, 0x8(%rax)     # imm = 0x10002
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
leaq 0x136ff7(%rip), %rcx    # 0x1b7c2d
movq %rcx, 0x40(%rax)
cmpl $0x10002, -0x1c(%rbp)   # imm = 0x10002
jne 0x80c96
cmpl $0xaf11, -0x20(%rbp)    # imm = 0xAF11
jne 0x80c5d
movq -0x18(%rbp), %rax
leaq 0x12cf22(%rip), %rcx    # 0x1adb79
movq %rcx, 0x40(%rax)
jmp 0x80c77
cmpl $0xaf12, -0x20(%rbp)    # imm = 0xAF12
jne 0x80c75
movq -0x18(%rbp), %rax
leaq 0x12cf0c(%rip), %rcx    # 0x1adb7d
movq %rcx, 0x40(%rax)
jmp 0x80c77
movq -0x18(%rbp), %rax
movl $0x10003, 0x8(%rax)     # imm = 0x10003
movq -0x18(%rbp), %rax
leaq 0x333(%rip), %rcx       # 0x80fc0
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0x10003, -0x1c(%rbp)   # imm = 0x10003
jne 0x80d4e
cmpl $0xf1fa, -0x20(%rbp)    # imm = 0xF1FA
jne 0x80cda
movq -0x18(%rbp), %rax
movl $0x10004, 0x8(%rax)     # imm = 0x10004
movq -0x18(%rbp), %rax
leaq 0x132890(%rip), %rcx    # 0x1b3552
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x74f(%rip), %rcx       # 0x81420
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0xf5fa, -0x20(%rbp)    # imm = 0xF5FA
jne 0x80d11
movq -0x18(%rbp), %rax
movl $0x10004, 0x8(%rax)     # imm = 0x10004
movq -0x18(%rbp), %rax
leaq 0x12ce88(%rip), %rcx    # 0x1adb81
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x718(%rip), %rcx       # 0x81420
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0xf100, -0x20(%rbp)    # imm = 0xF100
jne 0x80d48
movq -0x18(%rbp), %rax
movl $0x10005, 0x8(%rax)     # imm = 0x10005
movq -0x18(%rbp), %rax
leaq 0x14cb6b(%rip), %rcx    # 0x1cd89b
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x8a1(%rip), %rcx       # 0x815e0
movq %rcx, 0x38(%rax)
jmp 0x80fb3
jmp 0x80d4a
jmp 0x80d4c
jmp 0x80d4e
cmpl $0x10004, -0x1c(%rbp)   # imm = 0x10004
je 0x80d64
cmpl $0x1000c, -0x1c(%rbp)   # imm = 0x1000C
jne 0x80ede
cmpl $0xb, -0x20(%rbp)
jne 0x80d98
movq -0x18(%rbp), %rax
movl $0x10006, 0x8(%rax)     # imm = 0x10006
movq -0x18(%rbp), %rax
leaq 0x12ce0f(%rip), %rcx    # 0x1adb8f
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x891(%rip), %rcx       # 0x81620
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0x4, -0x20(%rbp)
jne 0x80dcc
movq -0x18(%rbp), %rax
movl $0x10006, 0x8(%rax)     # imm = 0x10006
movq -0x18(%rbp), %rax
leaq 0x12cde8(%rip), %rcx    # 0x1adb9c
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x85d(%rip), %rcx       # 0x81620
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0xf, -0x20(%rbp)
jne 0x80e00
movq -0x18(%rbp), %rax
movl $0x10009, 0x8(%rax)     # imm = 0x10009
movq -0x18(%rbp), %rax
leaq 0x12cdc2(%rip), %rcx    # 0x1adbaa
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0xa19(%rip), %rcx       # 0x81810
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0xc, -0x20(%rbp)
jne 0x80e34
movq -0x18(%rbp), %rax
movl $0x1000a, 0x8(%rax)     # imm = 0x1000A
movq -0x18(%rbp), %rax
leaq 0x12cda2(%rip), %rcx    # 0x1adbbe
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0xbd5(%rip), %rcx       # 0x81a00
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0x7, -0x20(%rbp)
jne 0x80e68
movq -0x18(%rbp), %rax
movl $0x1000b, 0x8(%rax)     # imm = 0x1000B
movq -0x18(%rbp), %rax
leaq 0x12cd8a(%rip), %rcx    # 0x1adbda
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0xe11(%rip), %rcx       # 0x81c70
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0x10, -0x20(%rbp)
jne 0x80e9c
movq -0x18(%rbp), %rax
movl $0x10007, 0x8(%rax)     # imm = 0x10007
movq -0x18(%rbp), %rax
leaq 0x12cd72(%rip), %rcx    # 0x1adbf6
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x10fd(%rip), %rcx      # 0x81f90
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0xd, -0x20(%rbp)
jne 0x80ed0
movq -0x18(%rbp), %rax
movl $0x10008, 0x8(%rax)     # imm = 0x10008
movq -0x18(%rbp), %rax
leaq 0x12cd50(%rip), %rcx    # 0x1adc08
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x1149(%rip), %rcx      # 0x82010
movq %rcx, 0x38(%rax)
jmp 0x80fb3
jmp 0x80ed2
jmp 0x80ed4
jmp 0x80ed6
jmp 0x80ed8
jmp 0x80eda
jmp 0x80edc
jmp 0x80ede
cmpl $0x10004, -0x1c(%rbp)   # imm = 0x10004
jne 0x80f1d
cmpl $0x12, -0x20(%rbp)
jne 0x80f1b
movq -0x18(%rbp), %rax
movl $0x1000c, 0x8(%rax)     # imm = 0x1000C
movq -0x18(%rbp), %rax
leaq 0x12cd12(%rip), %rcx    # 0x1adc15
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x116e(%rip), %rcx      # 0x82080
movq %rcx, 0x38(%rax)
jmp 0x80fb3
jmp 0x80f1d
cmpl $0x10005, -0x1c(%rbp)   # imm = 0x10005
jne 0x80f8c
cmpl $0x2, -0x20(%rbp)
jne 0x80f57
movq -0x18(%rbp), %rax
movl $0x1000d, 0x8(%rax)     # imm = 0x1000D
movq -0x18(%rbp), %rax
leaq 0x120503(%rip), %rcx    # 0x1a1445
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x130f(%rip), %rcx      # 0x82260
movq %rcx, 0x38(%rax)
jmp 0x80fb3
cmpl $0x3, -0x20(%rbp)
jne 0x80f88
movq -0x18(%rbp), %rax
movl $0x1000f, 0x8(%rax)     # imm = 0x1000F
movq -0x18(%rbp), %rax
leaq 0x12ccb2(%rip), %rcx    # 0x1adc25
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
leaq 0x131e(%rip), %rcx      # 0x822a0
movq %rcx, 0x38(%rax)
jmp 0x80fb3
jmp 0x80f8a
jmp 0x80f8c
cmpl $0x1000d, -0x1c(%rbp)   # imm = 0x1000D
jne 0x80fb1
movq -0x18(%rbp), %rax
movl $0x1000e, 0x8(%rax)     # imm = 0x1000E
movq -0x18(%rbp), %rax
leaq 0x12f5(%rip), %rcx      # 0x822a0
movq %rcx, 0x38(%rax)
jmp 0x80fb3
jmp 0x80fb3
popq %rbp
retq
nopw %cs:(%rax,%rax)