// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/asf.c
// Function: do_object
static int do_object(deark *c, lctx *d, i64 pos1, i64 len,
	int level, i64 *pbytes_consumed)
{
	u8 id[16];
	char id_string[50];
	const char *id_name = NULL;
	int retval = 0;
	int saved_indent_level;
	struct handler_params *hp = NULL;

	de_dbg_indent_save(c, &saved_indent_level);
	*pbytes_consumed = 0;
	if(len<24) goto done;

	de_dbg(c, "object at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);

	hp = de_malloc(c, sizeof(struct handler_params));
	hp->objpos = pos1;
	hp->level = level;

	read_and_render_guid(c->infile, id, pos1, id_string, sizeof(id_string));

	hp->uui = find_object_info(id);
	if(hp->uui) id_name = hp->uui->name;
	if(!id_name) id_name = "?";

	de_dbg(c, "guid: {%s} (%s)", id_string, id_name);

	hp->objlen = de_geti64le(pos1+16);
	de_sanitize_length(&hp->objlen);
	hp->dpos = pos1 + 24;
	hp->dlen = hp->objlen - 24;
	de_dbg(c, "size: %"I64_FMT", dpos=%"I64_FMT", dlen=%"I64_FMT,
		hp->objlen, hp->dpos, hp->dlen);
	if(hp->objlen<24) goto done;

	if(hp->objlen > len) {
		// TODO: Handle this differently depending on whether the problem was
		// an unexpected end of file.
		de_warn(c, "Object at %"I64_FMT" (length %"I64_FMT") exceeds its parent's bounds",
			pos1, hp->objlen);
		goto done;
	}

	if(hp->uui && hp->uui->hfn) {
		hp->uui->hfn(c, d, hp);
	}

	*pbytes_consumed = hp->objlen;
	retval = 1;
done:
	de_dbg_indent_restore(c, saved_indent_level);
	de_free(c, hp);
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movq $0x0, -0x98(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x15b580
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x18, -0x20(%rbp)
jge 0x22b8a
jmp 0x22da3
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x17bc40(%rip), %rsi    # 0x19e7d9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movl $0x30, %esi
callq 0x15b780
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, (%rax)
movl -0x24(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x80(%rbp), %rcx
movl $0x32, %r8d
callq 0x22de0
leaq -0x40(%rbp), %rdi
callq 0x22e50
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x98(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x22c38
movq -0x98(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x22c50
leaq 0x194fe4(%rip), %rax    # 0x1b7c2d
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
leaq 0x17b596(%rip), %rsi    # 0x19e1fc
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
callq 0x1657e0
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x15f830
movq -0x18(%rbp), %rcx
addq $0x18, %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rcx
subq $0x18, %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x98(%rbp), %rax
movq 0x18(%rax), %r8
leaq 0x17b513(%rip), %rsi    # 0x19e20c
movb $0x0, %al
callq 0x15b0d0
movq -0x98(%rbp), %rax
cmpq $0x18, 0x8(%rax)
jge 0x22d13
jmp 0x22da3
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x20(%rbp), %rax
jle 0x22d47
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x17b4ec(%rip), %rsi    # 0x19e22a
movb $0x0, %al
callq 0x15bc10
jmp 0x22da3
movq -0x98(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x22d87
movq -0x98(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x20(%rax)
je 0x22d87
movq -0x98(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq *%rax
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x8c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x90(%rbp), %esi
callq 0x15b5a0
movq -0x8(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x15b820
movl -0x8c(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)