// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ole1.c
// Function: calc_ole_obj_size
static void calc_ole_obj_size(deark *c, lctx *d)
{
	UI format;
	i64 pos1 = 0;
	i64 n;

	d->calculated_size = 0;
	d->pos_for_calc_size = pos1;

	if(!calc_chkver(c, d)) goto done;

	format = (UI)de_getu32le_p(&d->pos_for_calc_size);
	if(format<1 || format>3) goto done;

	n = de_getu32le_p(&d->pos_for_calc_size);
	d->pos_for_calc_size += n; // Class string

	if(format==3) { // Static
		d->pos_for_calc_size += 8; // width & height
		n = de_getu32le_p(&d->pos_for_calc_size);
		d->pos_for_calc_size += n; // Presentation data
	}
	else {
		n = de_getu32le_p(&d->pos_for_calc_size);
		d->pos_for_calc_size += n; // Topic string
		n = de_getu32le_p(&d->pos_for_calc_size);
		d->pos_for_calc_size += n; // Item string
		if(format==2) { // Embedded object
			n = de_getu32le_p(&d->pos_for_calc_size);
			d->pos_for_calc_size += n; // Native data
			if(!calc_skip_presentation_obj(c, d)) goto done;
		}
		else { // format==1
			n = de_getu32le_p(&d->pos_for_calc_size);
			d->pos_for_calc_size += n; // Network name
			d->pos_for_calc_size += 8; // Network type/version, link update options
			if(!calc_skip_presentation_obj(c, d)) goto done;
		}
	}

	d->calculated_size = d->pos_for_calc_size - pos1;

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xe8f00
cmpl $0x0, %eax
jne 0xe7987
jmp 0xe7b19
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jb 0xe79ab
cmpl $0x3, -0x14(%rbp)
jbe 0xe79b0
jmp 0xe7b19
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
cmpl $0x3, -0x14(%rbp)
jne 0xe7a1d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0xe7b05
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
cmpl $0x2, -0x14(%rbp)
jne 0xe7ab4
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xe8f50
cmpl $0x0, %eax
jne 0xe7ab2
jmp 0xe7b19
jmp 0xe7b03
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
callq 0x165580
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xe8f50
cmpl $0x0, %eax
jne 0xe7b01
jmp 0xe7b19
jmp 0xe7b03
jmp 0xe7b05
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
subq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
addq $0x30, %rsp
popq %rbp
retq
nop