// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/cardfile.c
// Function: do_object_rrg
static int do_object_rrg(deark *c, lctx *d, struct page_ctx *pg, i64 pos1,
	i64 *bytes_consumed)
{
	de_module_params *mparams = NULL;
	i64 pos = pos1;
	i64 n1, n2, n3, n4;
	int retval = 0;

	n1 = de_getu32le_p(&pos);
	de_dbg(c, "object ID: 0x%08x", (unsigned int)n1);

	mparams = de_malloc(c, sizeof(de_module_params));
	mparams->in_params.codes = "U";
	mparams->in_params.input_encoding = d->ole_encoding;

	// TODO: Make the output filenames contain the index text
	de_dbg(c, "OLE1 data at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	de_run_module_by_id_on_slice(c, "ole1", mparams, c->infile, pos,
		pg->data_endpos-2-14-pos);
	de_dbg_indent(c, -1);

	// Unfortunately, there is no direct way to figure out the OLE object size,
	// and we need it to find the card's text (and to know whether it has text).
	// The ole1 module will try to tell us the size, but this feature needs more
	// work, and is difficult to test.

	if(mparams->out_params.flags & 0x1) {
		pos += mparams->out_params.int64_1;
	}
	else {
		// ole1 module failed to figure out the object size
		goto done;
	}
	de_dbg(c, "[OLE object ends at %"I64_FMT"]", pos);

	n1 = de_getu16le_p(&pos);
	n2 = de_getu16le_p(&pos);
	de_dbg(c, "char width,height: %d,%d", (int)n1, (int)n2);

	n1 = de_geti16le_p(&pos);
	n2 = de_geti16le_p(&pos);
	n3 = de_getu16le_p(&pos);
	n4 = de_getu16le_p(&pos);
	de_dbg(c, "rect: %d,%d,%d,%d", (int)n1, (int)n2, (int)n3, (int)n4);

	n1 = de_getu16le_p(&pos);
	de_dbg(c, "object type: %d", (int)n1);

	*bytes_consumed = pos - pos1;
	retval = 1;
done:
	de_free(c, mparams);
	return retval;
}

// 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 $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165580
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x15484b(%rip), %rsi    # 0x1a53e4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x70, %esi
callq 0x15b780
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
leaq 0x1582e3(%rip), %rcx    # 0x1a8ea0
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x154819(%rip), %rsi    # 0x1a53f6
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x38(%rbp), %r8
movq -0x18(%rbp), %rax
movq 0x10(%rax), %r9
subq $0x2, %r9
subq $0xe, %r9
subq -0x38(%rbp), %r9
leaq 0x1547e6(%rip), %rsi    # 0x1a5407
callq 0x15c9f0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x30(%rbp), %rax
movl 0x40(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x50c55
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x50c5a
jmp 0x50d7b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x1547a3(%rip), %rsi    # 0x1a540c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x48(%rbp), %rax
movl %eax, %ecx
leaq 0x154774(%rip), %rsi    # 0x1a5425
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1653f0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1653f0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %eax, %r8d
movq -0x58(%rbp), %rax
movl %eax, %r9d
leaq 0x15470d(%rip), %rsi    # 0x1a543e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
movl %eax, %edx
leaq 0x1546f2(%rip), %rsi    # 0x1a5450
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rcx
subq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15b820
movl -0x5c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)