// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ole1.c
// Function: do_ole_object
static int do_ole_object(deark *c, lctx *d, i64 pos1, i64 len, int exact_size_known,
	int is_presentation, i64 *bytes_consumed)
{
	int saved_indent_level;
	i64 pos = pos1;
	i64 nbytesleft;
	i64 bytes_consumed2;
	int ret;
	unsigned int n;
	unsigned int formatID;
	int retval = 0;

	de_dbg_indent_save(c, &saved_indent_level);
	if(len<8) goto done;
	de_dbg(c, "OLE object at %"I64_FMT", len%s%"I64_FMT, pos1,
		(exact_size_known?"=":DE_CHAR_LEQ), len);
	de_dbg_indent(c, 1);

	n = (unsigned int)de_getu32le_p(&pos);
	de_dbg(c, "OLEVersion: 0x%08x", n);

	formatID = (unsigned int)de_getu32le_p(&pos);
	de_dbg(c, "FormatID: %u (%s)", formatID, get_FormatID_name(formatID));

	nbytesleft = pos1+len-pos;
	if(formatID==1 && !is_presentation) {
		ret = do_ole_object_linked(c, d, pos, nbytesleft, exact_size_known, &bytes_consumed2);
		if(!ret) goto done;
		pos += bytes_consumed2;
	}
	else if(formatID==2 && !is_presentation) {
		ret = do_ole_object_embedded(c, d, pos, nbytesleft, exact_size_known, &bytes_consumed2);
		if(!ret) goto done;
		pos += bytes_consumed2;
	}
	else if(formatID==3) {
		ret = do_ole_object_presentation(c, d, pos, nbytesleft, formatID, &bytes_consumed2);
		if(!ret) goto done;
		pos += bytes_consumed2;
	}
	else if(formatID==5 && is_presentation) {
		ret = do_ole_object_presentation(c, d, pos, nbytesleft, formatID, &bytes_consumed2);
		if(!ret) goto done;
		pos += bytes_consumed2;
	}
	else if(formatID==0 && is_presentation) {
		;
	}
	else {
		de_dbg(c, "[unsupported OLE FormatID]");
		goto done;
	}

	*bytes_consumed = pos-pos1;
	retval = 1;

done:
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x15b580
cmpq $0x8, -0x20(%rbp)
jge 0xe771c
jmp 0xe7928
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x24(%rbp), %esi
leaq 0xd5d86(%rip), %rcx     # 0x1bd4b4
leaq 0xe3f1a(%rip), %rax     # 0x1cb64f
cmpl $0x0, %esi
cmovneq %rax, %rcx
movq -0x20(%rbp), %r8
leaq 0xd5d51(%rip), %rsi     # 0x1bd498
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165580
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %edx
leaq 0xd5d3a(%rip), %rsi     # 0x1bd4b8
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165580
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x54(%rbp), %edi
callq 0xe7b20
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %edx
movq %rax, %rcx
leaq 0xd5d0b(%rip), %rsi     # 0x1bd4cb
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x1, -0x54(%rbp)
jne 0xe781f
cmpl $0x0, -0x28(%rbp)
jne 0xe781f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x24(%rbp), %r8d
leaq -0x48(%rbp), %r9
callq 0xe7ba0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xe780e
jmp 0xe7928
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xe7912
cmpl $0x2, -0x54(%rbp)
jne 0xe7867
cmpl $0x0, -0x28(%rbp)
jne 0xe7867
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x24(%rbp), %r8d
leaq -0x48(%rbp), %r9
callq 0xe7ea0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xe7856
jmp 0xe7928
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xe7910
cmpl $0x3, -0x54(%rbp)
jne 0xe78a6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x54(%rbp), %r8d
leaq -0x48(%rbp), %r9
callq 0xe8480
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xe7898
jmp 0xe7928
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xe790e
cmpl $0x5, -0x54(%rbp)
jne 0xe78e8
cmpl $0x0, -0x28(%rbp)
je 0xe78e8
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl -0x54(%rbp), %r8d
leaq -0x48(%rbp), %r9
callq 0xe8480
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0xe78da
jmp 0xe7928
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xe790c
cmpl $0x0, -0x54(%rbp)
jne 0xe78f6
cmpl $0x0, -0x28(%rbp)
je 0xe78f6
jmp 0xe790a
movq -0x8(%rbp), %rdi
leaq 0xd5bdc(%rip), %rsi     # 0x1bd4dd
movb $0x0, %al
callq 0x15b0d0
jmp 0xe7928
jmp 0xe790c
jmp 0xe790e
jmp 0xe7910
jmp 0xe7912
movq -0x38(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x15b5a0
movl -0x58(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)