// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fli.c
// Function: do_chunk_thumbnail
static void do_chunk_thumbnail(deark *c, lctx *d, struct chunk_info_type *ci)
{
	UI colortype;
	i64 w, h;
	struct image_ctx_type *ictx = NULL;
	i64 pos = ci->dpos;
	de_finfo *fi = NULL;

	h = de_getu16le_p(&pos);
	w = de_getu16le_p(&pos);
	de_dbg_dimensions(c, w, h);
	colortype = (UI)de_getu16le_p(&pos);
	de_dbg(c, "color type: %u", colortype);
	if(colortype!=1) goto done;

	ictx = create_image_ctx(c, d, w, h);
	ci->ictx = ictx;
	make_6cube_pal(ictx->pal);
	do_sequence_of_chunks(c, d, ci, pos, -1);

	fi = de_finfo_create(c);
	fi->internal_mod_time = d->mod_timestamp;
	if(d->aspect_x && d->aspect_y) {
		// Evidence suggests the thumbnail has the same aspect ratio as the animation,
		// at least approximately.
		fi->density.code = DE_DENSITY_UNK_UNITS;
		fi->density.xdens = (double)d->aspect_x;
		fi->density.ydens = (double)d->aspect_y;
	}
	de_finfo_set_name_from_sz(c, fi, "thumb", 0, DE_ENCODING_LATIN1);

	if(ictx->use_count>0 && !ictx->error_flag) {
		de_bitmap_write_to_file_finfo(ictx->img, fi, DE_CREATEFLAG_IS_AUX);
	}

done:
	destroy_image_ctx(c, ictx);
	ci->ictx = NULL;
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x15bba0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x12bd05(%rip), %rsi    # 0x1ade12
movb $0x0, %al
callq 0x15b0d0
cmpl $0x1, -0x1c(%rbp)
je 0x8211f
jmp 0x82227
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x824d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
callq 0x826d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq $-0x1, %r8
callq 0x82540
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
movq %rdx, 0x68(%rax)
movq 0x30(%rcx), %rcx
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x821df
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x821df
movq -0x48(%rbp), %rax
movl $0x1, 0x78(%rax)
movq -0x10(%rbp), %rax
cvtsi2sdq 0x40(%rax), %xmm0
movq -0x48(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movq -0x10(%rbp), %rax
cvtsi2sdq 0x48(%rax), %xmm0
movq -0x48(%rbp), %rax
movsd %xmm0, 0x88(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq 0x13494d(%rip), %rdx    # 0x1b6b3b
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0x15d4c0
movq -0x38(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x82225
movq -0x38(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x82225
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x48(%rbp), %rsi
movl $0x1, %edx
callq 0x16afa0
jmp 0x82227
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x82680
movq -0x18(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x15d260
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)