// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/wri.c
// Function: do_picture
static void do_picture(deark *c, lctx *d, struct para_info *pinfo)
{
	int orig_file_count, curr_file_count;
	struct picctx_struct *picctx = NULL;
	i64 pos = pinfo->thisparapos;

	picctx = de_malloc(c, sizeof(struct picctx_struct));
	if(pinfo->thisparalen<2) goto done;
	picctx->mm = (unsigned int)de_getu16le(pos);
	de_dbg(c, "picture storage type: 0x%04x (%s)", picctx->mm,
		get_picture_storage_type_name(picctx->mm));

	orig_file_count = get_next_output_file_id(c);

	do_picture_header(c, d, pinfo, picctx);

	switch(picctx->mm) {
	case WRI_STG_METAFILE:
		do_picture_metafile(c, d, pinfo, picctx);
		break;
	case WRI_STG_BITMAP:
		do_picture_bitmap(c, d, pinfo, picctx);
		break;
	case WRI_STG_OLE:
		do_picture_ole(c, d, pinfo, picctx);
		break;
	default:
		de_err(c, "Picture storage type 0x%04x not supported", picctx->mm);
	}

	if(d->html_outf) {
		// We want to include the image file ID numbers in the HTML document,
		// so that the user can figure out which image goes where.
		// To deduce the ID number, we watch the global file ID counter.
		// It's totally a hack, but unfortunately our high level functions that
		// create an output file (e.g. de_convert_and_write_image_bilevel) do
		// not have a way return the ID number of the file they created. It
		// would be a lot of trouble to create such a mechanism.

		do_emit_raw_sz(c, d, pinfo, "<p class=r>");
		pinfo->in_para = 1;
		ucstring_empty(d->tmpstr);
		ucstring_append_sz(d->tmpstr, "object", DE_ENCODING_LATIN1);

		curr_file_count = get_next_output_file_id(c);
		if(curr_file_count == orig_file_count+1) {
			ucstring_printf(d->tmpstr, DE_ENCODING_LATIN1, " %d", orig_file_count);
		}
		else if(curr_file_count == orig_file_count) {
			ucstring_append_sz(d->tmpstr, " (not extracted)", DE_ENCODING_LATIN1);
		}
		else {
			ucstring_printf(d->tmpstr, DE_ENCODING_UTF8, "s %d" "\xe2\x80\x93" "%d",
				orig_file_count, curr_file_count-1);
		}
		do_emit_ucstring(c, d, pinfo, d->tmpstr);
		end_para(c, d, pinfo);
	}

done:
	de_free(c, picctx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl $0x28, %esi
callq 0x15b780
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x2, 0x8(%rax)
jge 0x13c9c9
jmp 0x13cbc0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x165280
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %edi
movl %edi, -0x38(%rbp)
callq 0x13cfb0
movq -0x40(%rbp), %rdi
movl -0x38(%rbp), %edx
movq %rax, %rcx
leaq 0x90bfd(%rip), %rsi     # 0x1cd606
xorl %eax, %eax
callq 0x15b0d0
movq -0x8(%rbp), %rdi
callq 0x13d020
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x13d040
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
subl $0x88, %eax
je 0x13ca5b
jmp 0x13ca43
movl -0x34(%rbp), %eax
subl $0xe3, %eax
je 0x13ca72
jmp 0x13ca4f
movl -0x34(%rbp), %eax
subl $0xe4, %eax
je 0x13ca89
jmp 0x13caa0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x13d340
jmp 0x13cab8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x13d3e0
jmp 0x13cab8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x13d510
jmp 0x13cab8
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %edx
leaq 0x90b77(%rip), %rsi     # 0x1cd628
movb $0x0, %al
callq 0x15bfb0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x13cbbe
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x90b78(%rip), %rcx     # 0x1cd652
callq 0x13d600
movq -0x18(%rbp), %rax
movl $0x1, 0x1c(%rax)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x171210
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
leaq 0x90b77(%rip), %rsi     # 0x1cd67d
movl $0x5, %edx
callq 0x1715e0
movq -0x8(%rbp), %rdi
callq 0x13d020
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13cb49
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x1c(%rbp), %ecx
movl $0x5, %esi
leaq 0x850dd(%rip), %rdx     # 0x1c1c1d
movb $0x0, %al
callq 0x171660
jmp 0x13cb94
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x13cb6c
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
leaq 0x90afe(%rip), %rsi     # 0x1cd65e
movl $0x5, %edx
callq 0x1715e0
jmp 0x13cb92
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
subl $0x1, %r8d
movl $0x2, %esi
leaq 0x90ae4(%rip), %rdx     # 0x1cd66f
movb $0x0, %al
callq 0x171660
jmp 0x13cb94
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
callq 0x13d680
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x13d6f0
jmp 0x13cbc0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x15b820
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)