// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/olepropset.c
// Function: do_prop_clipboard
static void do_prop_clipboard(deark *c, lctx *d, struct propset_struct *si,
	struct prop_info_struct *pinfo,
	i64 pos1, i64 *bytes_consumed)
{
	u32 cbtype;
	i64 cbsize_reported;
	i64 cbsize_payload;
	i64 cbdatapos;
	const char *cbtype_name;

	cbsize_reported = dbuf_getu32le(d->f, pos1);
	de_dbg(c, "clipboard data size: %d", (int)cbsize_reported);

	cbtype = (u32)dbuf_getu32le(d->f, pos1+8);
	if(cbtype==0x54434950U) {
		cbtype_name="PICT";
	}
	else {
		cbtype_name = fmtutil_get_windows_cb_data_type_name((unsigned int)cbtype);
	}
	de_dbg(c, "clipboard data type: 0x%08x (%s)", (unsigned int)cbtype, cbtype_name);

	cbdatapos = pos1+12;
	cbsize_payload = cbsize_reported-8;
	if(cbdatapos + cbsize_payload > d->f->len) goto done;

	*bytes_consumed = de_pad_to_4(cbsize_reported);

	if(cbtype==3) { // CF_METAFILEPICT
		dbuf_create_file_from_slice(d->f, cbdatapos+8, cbsize_payload-8,
			"wmf", NULL, DE_CREATEFLAG_IS_AUX);
	}
	else if(cbtype==8) { // CF_DIB
		de_run_module_by_id_on_slice2(c, "dib", "X", d->f,
			cbdatapos, cbsize_payload);
	}
	else if(cbtype==0x54434950U) { // "PICT"
		dbuf *outf = NULL;
		outf = dbuf_create_output_file(c, "pict", NULL, DE_CREATEFLAG_IS_AUX);
		dbuf_write_zeroes(outf, 512);
		dbuf_copy(d->f, cbdatapos, cbsize_payload, outf);
		dbuf_close(outf);
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165540
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0xed6cc(%rip), %rsi     # 0x1b94a1
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x165540
movl %eax, -0x34(%rbp)
cmpl $0x54434950, -0x34(%rbp) # imm = 0x54434950
jne 0xcbe09
leaq 0xf63c9(%rip), %rax     # 0x1c21cc
movq %rax, -0x58(%rbp)
jmp 0xcbe15
movl -0x34(%rbp), %edi
callq 0x174fd0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x58(%rbp), %rcx
leaq 0xed692(%rip), %rsi     # 0x1b94b9
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
subq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
addq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xcbe60
jmp 0xcbf3d
movq -0x40(%rbp), %rdi
callq 0x15ce30
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x3, -0x34(%rbp)
jne 0xcbeac
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x50(%rbp), %rsi
addq $0x8, %rsi
movq -0x48(%rbp), %rdx
subq $0x8, %rdx
leaq 0xdc2bc(%rip), %rcx     # 0x1a8153
xorl %eax, %eax
movl %eax, %r8d
movl $0x1, %r9d
callq 0x166be0
jmp 0xcbf3b
cmpl $0x8, -0x34(%rbp)
jne 0xcbeda
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x50(%rbp), %r8
movq -0x48(%rbp), %r9
leaq 0xe2f27(%rip), %rsi     # 0x1aedf3
leaq 0x10369c(%rip), %rdx    # 0x1cf56f
callq 0x15cab0
jmp 0xcbf39
cmpl $0x54434950, -0x34(%rbp) # imm = 0x54434950
jne 0xcbf37
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xd5e32(%rip), %rsi     # 0x1a1d28
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0x166c60
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x1685f0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x166070
movq -0x60(%rbp), %rdi
callq 0x1676a0
jmp 0xcbf39
jmp 0xcbf3b
jmp 0xcbf3d
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)