// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/tiff.c
// Function: try_to_extract_mpf_image
static void try_to_extract_mpf_image(deark *c, lctx *d, struct page_ctx *pg,
	struct mpfctx_struct *mpfctx)
{
	dbuf *inf;

	de_dbg2(c, "[trying to extract image at %d, size=%d]", (int)mpfctx->imgoffs_abs,
		(int)mpfctx->imgsize);
	if(!d->in_params) goto done;
	if(!(d->in_params->flags&0x01)) goto done;
	if(!d->in_params->parent_dbuf) goto done;
	if(mpfctx->imgoffs_abs<1) goto done;
	inf = d->in_params->parent_dbuf;

	if(mpfctx->imgoffs_abs + mpfctx->imgsize > inf->len) {
		if(mpfctx->warned) goto done;
		mpfctx->warned = 1;
		detiff_warn(c, d, pg, "Invalid MPF multi-picture data. File size should be at "
			"least %"I64_FMT", is %"I64_FMT".",
			mpfctx->imgoffs_abs+mpfctx->imgsize, inf->len);
		goto done;
	}

	if(dbuf_memcmp(inf, mpfctx->imgoffs_abs, "\xff\xd8\xff", 3)) {
		detiff_warn(c, d, pg, "Invalid or unsupported MPF multi-picture data. Expected image at "
			"%"I64_FMT" not found.", mpfctx->imgoffs_abs);
		goto done;
	}

	dbuf_create_file_from_slice(inf, mpfctx->imgoffs_abs, mpfctx->imgsize,
		mpfctx->is_thumb?"mpfthumb.jpg":"mpf.jpg",
		NULL, DE_CREATEFLAG_IS_AUX);

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
leaq 0x96ee6(%rip), %rsi     # 0x1cb4dd
movb $0x0, %al
callq 0x15b350
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
jne 0x13460e
jmp 0x13474b
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl 0x8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x134626
jmp 0x13474b
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x13463a
jmp 0x13474b
movq -0x20(%rbp), %rax
cmpq $0x1, 0x8(%rax)
jge 0x13464a
jmp 0x13474b
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x10(%rcx), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x1346c3
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x134682
jmp 0x13474b
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x20(%rbp), %rax
addq 0x10(%rax), %r8
movq -0x28(%rbp), %rax
movq 0x18(%rax), %r9
leaq 0x96e4f(%rip), %rcx     # 0x1cb506
movb $0x0, %al
callq 0x12dfd0
jmp 0x13474b
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x6bcb8(%rip), %rdx     # 0x1a038e
movl $0x3, %ecx
callq 0x166ab0
cmpl $0x0, %eax
je 0x134709
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
leaq 0x96e50(%rip), %rcx     # 0x1cb550
movb $0x0, %al
callq 0x12dfd0
jmp 0x13474b
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0x96e81(%rip), %rcx     # 0x1cb5ad
leaq 0x96e6d(%rip), %rax     # 0x1cb5a0
cmpl $0x0, %r8d
cmovneq %rax, %rcx
xorl %eax, %eax
movl %eax, %r8d
movl $0x1, %r9d
callq 0x166be0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)